Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here is another hack. You can use the solver in sympy. For example:

from sympy.solvers import solve
ans=solve(x^3+8, x)
print ans
[a for a in ans if imag(a)==0]

gives the result

[1 + 3**(1/2)*I, -2, 1 - 3**(1/2)*I]

This works fine when you have actual values in the equations. There are issues, though, when working completely symbolically. Unfortunately, it won't work with the assume command in Sage. There is an Assume command in sympy, but I seem to be unable to get it to work in Sage.