1 | initial version |
You have to eliminate the radicals by squaring the equation (thus possibly introducing non-solutions) and separating the terms containing and not containing a radical; since there are more than one of them, you have to repeat... In your case :
sage: (((eqSagittalH^2).expand()*2-4*r^2+Da+Di)^2).solve(Da)
[Da == -2*SagittalH^2 - 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di, Da == -2*SagittalH^2 + 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di]
FWIW, ISTR that Sympy has an adequate function for this operation, but, my head on the executioner's bill, I can't remember its name at the moment. Aging is descending...
HTH,
2 | No.2 Revision |
You have to eliminate the radicals by squaring the equation (thus possibly introducing non-solutions) and separating the terms containing and not containing a radical; since there are more than one of them, you have to repeat... In your case :
sage: (((eqSagittalH^2).expand()*2-4*r^2+Da+Di)^2).solve(Da)
[Da == -2*SagittalH^2 - 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di, Da == -2*SagittalH^2 + 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di]
FWIW, ISTR that Sympy has an adequate function for this operation, but, my head on the executioner's bill, I can't remember its name at the moment. Aging is descending...
HTH,
EDIT : It's sympy.solvers.solvers.unrad
, documeted here :
sage: from sympy.solvers.solvers import unrad
sage: unrad(eqSagittalH._sympy_())[0]._sage_().solve(Da)
[Da == -2*SagittalH^2 - 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di, Da == -2*SagittalH^2 + 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di]
3 | No.3 Revision |
You have to eliminate the radicals by squaring the equation (thus possibly introducing non-solutions) and separating the terms containing and not containing a radical; since there are more than one of them, you have to repeat... In your case :
sage: (((eqSagittalH^2).expand()*2-4*r^2+Da+Di)^2).solve(Da)
[Da == -2*SagittalH^2 - 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di, Da == -2*SagittalH^2 + 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di]
FWIW, ISTR that Sympy has an adequate function for this operation, but, my head on the executioner's bill, I can't remember its name at the moment. Aging is descending...
HTH,
EDIT : It's sympy.solvers.solvers.unrad
, documeted here :
sage: from sympy.solvers.solvers import unrad
sage: unrad(eqSagittalH._sympy_())[0]._sage_().solve(Da)
[Da == -2*SagittalH^2 - 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di, Da == -2*SagittalH^2 + 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di]
EDIT2 : Alternate solutions :
sage: var('SagittalH r Da Di')
(SagittalH, r, Da, Di)
sage: eqSagittalH = SagittalH == sqrt(r^2-(Di/2))-sqrt(r^2-(Da/2))
Sympy :
sage: import sympy sage: [{Da:s._sage_()} for s in sympy.solve(map(sympy.sympify, (eqSagittalH, Da)), dict=False)] [{Da: -(sqrt(2)SagittalH - sqrt(2r^2 - Di))^2 + 2r^2}]
Giac :
sage: [{Da:s.sage()} for s in giac.solve(map(giac, (eqSagittalH.rhs()-eqSagittalH.lhs(), Da)))] [{Da: -1/2(sqrt(2)sqrt(2r^2 - Di) - 2SagittalH)^2 + 2r^2}]
Fricas :
sage: [{Da:s.rhs().sage()} for s in fricas.solve(map(fricas, (eqSagittalH, Da)))] [{Da: 2sqrt(2)sqrt(2r^2 - Di)SagittalH - 2SagittalH^2 + Di}]
The problem is therefore a weakness of Sage's default solver (i. e. Maxima's).
4 | No.4 Revision |
You have to eliminate the radicals by squaring the equation (thus possibly introducing non-solutions) and separating the terms containing and not containing a radical; since there are more than one of them, you have to repeat... In your case :
sage: (((eqSagittalH^2).expand()*2-4*r^2+Da+Di)^2).solve(Da)
[Da == -2*SagittalH^2 - 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di, Da == -2*SagittalH^2 + 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di]
FWIW, ISTR that Sympy has an adequate function for this operation, but, my head on the executioner's bill, I can't remember its name at the moment. Aging is descending...
HTH,
EDIT : It's sympy.solvers.solvers.unrad
, documeted here :
sage: from sympy.solvers.solvers import unrad
sage: unrad(eqSagittalH._sympy_())[0]._sage_().solve(Da)
[Da == -2*SagittalH^2 - 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di, Da == -2*SagittalH^2 + 2*sqrt(4*r^2 - 2*Di)*SagittalH + Di]
EDIT2 : Alternate solutions :
sage: var('SagittalH r Da Di')
(SagittalH, r, Da, Di)
sage: eqSagittalH = SagittalH == sqrt(r^2-(Di/2))-sqrt(r^2-(Da/2))
Sympy :
sage: import sympy
sage: [{Da:s._sage_()} for s in Giac :
sage: [{Da:s.sage()} for s in Fricas :
sage: [{Da:s.rhs().sage()} for s in The problem is therefore a weakness of Sage's default solver (i. e. Maxima's).