Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There's a good reason for sage to return a list of equations as it does, because that clearly labels for which variable the equations were solved. When you're solving equations in multiple variables, this labelling is even more important.

It's easy to process the return value of solve (and indeed you should not do that with regexes!):

[s.rhs() for s in solve(x^3+x+1,x)]

or

[x.subs(s) for s in solve(x^3+x+1,x)]

Alternatively, if you're actually interested in, say, float approximations to the roots perhaps you should define your polynomials in terms of a polynomial ring. If you're interested in the real roots:

sage: P.<x>=RR[]
sage: f=x^3-2*x+1
sage: f.roots(RR)
[(-1.61803398874989, 1), (0.618033988749895, 1), (1.00000000000000, 1)]
sage: f.roots(RR,multiplicities=false)
[-1.61803398874989, 0.618033988749895, 1.00000000000000]