Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You should tell us how you construct your polynomial and what its parent is if you want meaningful advice. Basically, if the polynomial is over an exact ring like the rationals then the roots will be exact (if they are rational). If the polynomial is over real floating-point ring the real roots will be numerically computed. If the polynomial is over a complex floating-point ring the roots will be numerically computed and complex.

sage: R.<x> = QQ[]
sage: (x^3-8).roots()
[(2, 1)]
sage: (x^3-2).roots()   # one real root but not rational
[]
sage: (x^3-2).roots(ring=CDF)
[(1.25992104989, 1), (-0.629960524947 - 1.09112363597*I, 1), (-0.629960524947 + 1.09112363597*I, 1)]

sage: R.<x> = CDF[]
sage: (x^3-8).roots()
[(2.0, 1), (-1.0 - 1.73205080757*I, 1), (-1.0 + 1.73205080757*I, 1)]
sage: (x^3-2).roots()
[(1.25992104989, 1), (-0.629960524947 - 1.09112363597*I, 1), (-0.629960524947 + 1.09112363597*I, 1)]

Its unavoidable that numerical root solvers sometimes return a tiny imaginary part.