Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You just need to convert the sympy solution back to a Sage expression:

sage: sol=solve(eq1, h)
sage: sol1=sol[0]._sage_()
sage: sol1
s*sin(phi + theta) - sqrt(2*s^2*cos(phi + theta)*sin(phi)*sin(theta) + s^2*sin(phi)^2 + s^2*sin(theta)^2 + 2*r*s*cos(phi + theta) - r^2 - s^2)
click to hide/show revision 2
No.2 Revision

You just need to convert the sympy solution back to a Sage expression:

sage: sol=solve(eq1, h)
sage: sol1=sol[0]._sage_()
sage: sol1
s*sin(phi + theta) - sqrt(2*s^2*cos(phi + theta)*sin(phi)*sin(theta) + s^2*sin(phi)^2 + s^2*sin(theta)^2 + 2*r*s*cos(phi + theta) - r^2 - s^2)

For converting a Sage expresson to sympy use sympify:

sage: from sympy import sympify
sage: from sympy.solvers import solve
sage: solve(sympify(x^2-1),x)
[-1, 1]
click to hide/show revision 3
No.3 Revision

You just need to convert the sympy solution back to a Sage expression:

sage: sol=solve(eq1, h)
sage: sol1=sol[0]._sage_()
sage: sol1
s*sin(phi + theta) - sqrt(2*s^2*cos(phi + theta)*sin(phi)*sin(theta) + s^2*sin(phi)^2 + s^2*sin(theta)^2 + 2*r*s*cos(phi + theta) - r^2 - s^2)

For converting a Sage expresson expression to sympy use sympify:

sage: from sympy import sympify
sage: from sympy.solvers import solve
sage: solve(sympify(x^2-1),x)
[-1, 1]