Hi all-
I'm trying to understand why factor() and Poly.all_roots() behave
differently when trying to find simple complex roots. I suspect there is
something to do with exact values vs. numerical approximations, but I want
something that "just works". I'm doing work with transfer functions, and
I'd really like to be able to manipulate the numerator and denominator
forms and get back an expression of the form (x + a)*(x + b) rather than a
list of the roots [-a, -b].
Here's an example:
from sympy import *
x = Symbol('x')
factor(x**2 + 4, x, extension=[I])
Poly(x**2 + 4).all_roots()
factor(x**2 + 3, x, extension=[I])
Poly(x**2 + 3).all_roots()
With sympy 0.7.4.1 the output is:
In [3]: factor(x**2 + 4, x, extension=[I])
Out[3]: (x - 2*I)*(x + 2*I)
In [4]: Poly(x**2 + 4).all_roots()
Out[4]: [-2*I, 2*I]
In [5]: factor(x**2 + 3, x, extension=[I])
Out[5]: x**2 + 3
In [6]: Poly(x**2 + 3).all_roots()
Out[6]: [-sqrt(3)*I, sqrt(3)*I]
As you can see, Out[3] and Out[4] both "work".
But, Out[5] doesn't work (it's just the same as the input), while Out[6] is
correct (but not in the form I want it).
Any help is much appreciated :)
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/2ef035c5-e6cf-4573-99ee-c30d72f86e1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.