Ask Your Question

Revision history [back]

For polynomial equations with rational or algebraic coefficients, the best is to use the roots method applied to a proper polynomial in a polynomial ring, instead of using symbolic expressions and solve.

Here is an example.

Define a polynomial ring and a polynomial:

sage: R.<x> = QQ[]
sage: p = x^3 + 8

Compute the roots in AA (the field of real algebraic numbers):

sage: rr = p.roots(AA, multiplicities=False)
sage: rr

So there is exactly one root, which seems to be minus two.

Use the exactify method to make Sage decide if it is actually that (it is!).

sage: _ = [r.exactify() for r in rr]
sage: rr