![]() | 1 | initial version |
Possible one-liners :
sage: Sys=[sin(theta), cos(theta)-x]
sage: Vars=var("x, theta")
sage: solve(t:=Sys[1].subs(solve(Sys[0], Sys[0].variables(), to_poly_solve="force")), t.variables())
[[x == cos(pi*r7), z309005 == r7]]
sage: solve(t:=Sys[1].subs(solve(Sys[0], Sys[0].variables(), to_poly_solve="force", solution_dict=True)), t.variables(), solution_dict=True)
[{x: cos(pi*r8), z309048: r8}]
Mathematica does it cleanly, but uses boolean functions not (yet) in Sage :
sage: mathematica.Solve([u==0 for u in Sys], Vars)
{{x -> -1, theta -> ConditionalExpression[Pi + 2*Pi*C[1],
Element[C[1], Integers]]},
{x -> 1, theta -> ConditionalExpression[2*Pi*C[1], Element[C[1], Integers]]}}
Sympy misses the multiplicities of solutions :
sage: solve(Sys, Vars, algorithm="sympy")
[{theta: 0, x: 1}, {theta: pi, x: -1}]
sage: solve(Sys, Vars, algorithm="sympy", solution_dict=True)
[{theta: 0, x: 1}, {theta: pi, x: -1}]
HTH,
![]() | 2 | No.2 Revision |
Possible one-liners :
sage: Sys=[sin(theta), cos(theta)-x]
sage: Vars=var("x, theta")
sage: solve(t:=Sys[1].subs(solve(Sys[0], Sys[0].variables(), to_poly_solve="force")), t.variables())
[[x == cos(pi*r7), z309005 == r7]]
sage: solve(t:=Sys[1].subs(solve(Sys[0], Sys[0].variables(), to_poly_solve="force", solution_dict=True)), t.variables(), solution_dict=True)
[{x: cos(pi*r8), z309048: r8}]
Mathematica does it cleanly, but uses boolean functions not (yet) in Sage :
sage: mathematica.Solve([u==0 for u in Sys], Vars)
{{x -> -1, theta -> ConditionalExpression[Pi + 2*Pi*C[1],
Element[C[1], Integers]]},
{x -> 1, theta -> ConditionalExpression[2*Pi*C[1], Element[C[1], Integers]]}}
Sympy misses the multiplicities of solutions :
sage: solve(Sys, Vars, algorithm="sympy")
[{theta: 0, x: 1}, {theta: pi, x: -1}]
sage: solve(Sys, Vars, algorithm="sympy", solution_dict=True)
[{theta: 0, x: 1}, {theta: pi, x: -1}]
HTH,
EDIT : See this question which reports a (more spectacuiar) problem with identical roots and a lengthy explanation...).