Ticket #5378 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

[with patch, positive review] Sage 3.3: numerical noise in rings/polynomial/complex_roots.py on cicero & fulvia

Reported by: mabshoff Owned by: mabshoff
Priority: blocker Milestone: sage-3.4.1
Component: doctest coverage Keywords:
Cc: cwitty Work issues:
Report Upstream: Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

sage -t  "devel/sage/sage/rings/polynomial/complex_roots.py"
**********************************************************************
File "/home/mariah/sage/sage-3.3-x86-Linux-fc-test/devel/sage/sage/rings/polynom
ial/complex_roots.py", line 271:
   sage: complex_roots(x^2 + 27*x + 181)
Expected:
   [(-14.61803398874990?..., 1), (-12.3819660112501...? + 0.?e-27*I, 1)]
Got:
   [(-12.3819660112501?, 1), (-14.61803398874990? + 0.?e-27*I, 1)]

Attachments

trac_5378.patch Download (1.6 KB) - added by mabshoff 4 years ago.

Change History

comment:1 Changed 4 years ago by mabshoff

  • Cc cwitty added
  • Milestone changed from sage-3.4 to sage-3.4.1

Hmm, the numerical noise of the imaginary part of the root causes the order of the roots for printing to be flipped. I am not sure what to do here except for picking another polynomial, but I have not looked into this in any detail since we might have this particular root for a good reason.

Cheers,

Michael

comment:2 Changed 4 years ago by cwitty

I don't remember anything special about that polynomial, so I'm fine with changing it.

Other possibilities would include changing the sorting. One possibility would be to remove the code that puts real roots first; another possibility would be to special-case complex interval roots in the sorting, and say that if the imaginary part of a root is an interval that contains 0 then it should sort with the real roots.

comment:3 Changed 4 years ago by mabshoff

  • Milestone changed from sage-3.4.2 to sage-3.4.1

Move this to 3.4.1 since I am closing this as dupe of #5559.

Cheers,

Michael

comment:4 Changed 4 years ago by mabshoff

The following illustrates the problem and a potential solution:

----------------------------------------------------------------------
| Sage Version 3.4.1.rc3, Release Date: 2009-04-16                   |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
Loading Sage library. Current Mercurial branch is: review
sage: from sage.rings.polynomial.complex_roots import complex_roots
sage: x = polygen(ZZ) 
sage: complex_roots(x^2 + 27*x + 181)
[(-12.3819660112501?, 1), (-14.61803398874990? + 0.?e-27*I, 1)]
sage: v=complex_roots(x^2 + 27*x + 181)
sage: sorted((v[0][0].real(),v[1][0].real()))
[-14.61803398874990?, -12.3819660112501?]

On another machine we get:

sage: from sage.rings.polynomial.complex_roots import complex_roots
sage:  x = polygen(ZZ)  
sage: complex_roots(x^2 + 27*x + 181)
[(-14.61803398874990? + 0.?e-27*I, 1), (-12.38196601125010? + 0.?e-27*I, 1)]
sage: v=complex_roots(x^2 + 27*x + 181)
sage: sorted((v[0][0].real(),v[1][0].real()))
[-14.61803398874990?, -12.38196601125010?]

Patch coming up.

Cheers,

Michael

Changed 4 years ago by mabshoff

comment:5 Changed 4 years ago by mabshoff

  • Status changed from new to assigned
  • Summary changed from Sage 3.3: numerical noise in rings/polynomial/complex_roots.py on cicero & fulvia to [with patch, needs review] Sage 3.3: numerical noise in rings/polynomial/complex_roots.py on cicero & fulvia

comment:6 Changed 4 years ago by rbeezer

  • Summary changed from [with patch, needs review] Sage 3.3: numerical noise in rings/polynomial/complex_roots.py on cicero & fulvia to [with patch, positive review] Sage 3.3: numerical noise in rings/polynomial/complex_roots.py on cicero & fulvia

Builds and tests just fine. Positive review.

comment:7 Changed 4 years ago by mabshoff

  • Status changed from assigned to closed
  • Resolution set to fixed

Merged in Sage 3.4.1.rc4.

Cheers,

Michael

Note: See TracTickets for help on using tickets.