Comment #3 on issue 3295 by [email protected]: nroots and RootOf.evalf duplicate code
http://code.google.com/p/sympy/issues/detail?id=3295

Mateusz will have to confirm, but I believe so. polyroots is a numerical algorithm. It keeps track of errors, but at the end of the day it requires floating point precision and suffers from the usual problems of floating point numbers.

The RootOf interval isolation algorithm is a rational algorithm, meaning it only uses operations like polynomial division and multiplication, and is thus infallible. See for example, http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.51.5163 (note: I do not know if this is the exact algorithm implemented, but the principle is the same).

And anyway, it's not too hard to find an example where nroots gives wrong answers, simply because it uses floating point numbers always, even when the coefficients are rational:

In [47]: nroots(expand((x - S(1000000000000)/1000000000001)*(x - 1)))
Out[47]: [0.9999999999995 - 1.05345638729316e-8⋅ⅈ, 0.9999999999995 + 1.05351934154826e-8⋅ⅈ]

In [48]: roots(expand((x - S(1000000000000)/1000000000001)*(x - 1)))
Out[48]:
⎧1000000000000         ⎫
⎨─────────────: 1, 1: 1⎬
⎩1000000000001         ⎭

In [49]: RootOf(expand((x - S(1000000000000)/1000000000001)*(x - 1)), 0)
Out[49]:
1000000000000
─────────────
1000000000001

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to