Ask Your Question
0

solve maxima need to prechew equ to succeed (solve sympy ok)

asked 2020-08-19 01:29:03 -0500

ortollj gravatar image

HI

Ubuntu 18.04 , Jupyter notebook SageMath 9.1

vL=['x','y','x_o','y_o','a','b']
varL=var(vL)

for v in varL :
    assume(v,'real')

eq02=y - y_o == -b^2*(x - x_o)*x/(a^2*y)
eq2=x^2/a^2 + y^2/b^2 == 1
# here I need to prechew
eq03=eq02.multiply_both_sides(y/b^2).expand()

SmaximaPrechewed=solve([eq03,eq2],x,y)
show("solution maxima ok prechewed : ",SmaximaPrechewed)


SsympyNotPrechewed=solve([eq02,eq2],x,y,algorithm='sympy')
show("solution sympy ok : ",SsympyNotPrechewed)

SmaximaNotPrechewedKO=solve([eq02,eq2],x,y,algorithm='maxima')
show("solution maxima not preChewed KO  : ",SmaximaNotPrechewedKO)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-08-19 05:01:51 -0500

Emmanuel Charpentier gravatar image

The problem lies in the Maxima to Sage backtranslation :

sage: var('x','y','x_o','y_o','a','b', domain="real")
(x, y, x_o, y_o, a, b)
sage: eq02=y - y_o == -b^2*(x - x_o)*x/(a^2*y)
sage: eq2=x^2/a^2 + y^2/b^2 == 1
sage: solve([eq2,eq02],[x,y])

[ Snip.. ]

TypeError: unable to make sense of Maxima expression '[if((_SAGE_VAR_a^2*_SAGE_VAR_b^2!=0)and(-(_SAGE_VAR_a^2*(_SAGE_VAR_b^2*_SAGE_VAR_x_o*sqrt(_SAGE_VAR_a^2*_SAGE_VAR_y_o^2+_SAGE_VAR_b^2*_SAGE_VAR_x_o^2-_SAGE_VAR_a^2*_SAGE_VAR_b^2)-_SAGE_VAR_a^2*_SAGE_VAR_b^2*_SAGE_VAR_y_o))/(_SAGE_VAR_a^2*_SAGE_VAR_y_o^2+_SAGE_VAR_b^2*_SAGE_VAR_x_o^2)!=0),[_SAGE_VAR_x==(_SAGE_VAR_a^2*_SAGE_VAR_y_o*sqrt(_SAGE_VAR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GE_VAR_b^2*_SAGE_VAR_x_o^2-_SAGE_VAR_a^2*_SAGE_VAR_b^2)+_SAGE_VAR_a^2*_SAGE_VAR_b^2*_SAGE_VAR_y_o)/(_SAGE_VAR_a^2*_SAGE_VAR_y_o^2+_SAGE_VAR_b^2*_SAGE_VAR_x_o^2)],union())]' in Sage

and indeed :

sage: SolM=solve([eq2,(eq02*y/b^2).expand()],[x,y],solution_dict=True) ; SolM
[{x: (a^2*b^2*x_o - sqrt(-a^2*b^2 + b^2*x_o^2 + a^2*y_o^2)*a^2*y_o)/(b^2*x_o^2 + a^2*y_o^2),
  y: (a^2*b^2*y_o + sqrt(-a^2*b^2 + b^2*x_o^2 + a^2*y_o^2)*b^2*x_o)/(b^2*x_o^2 + a^2*y_o^2)},
 {x: (a^2*b^2*x_o + sqrt(-a^2*b^2 + b^2*x_o^2 + a^2*y_o^2)*a^2*y_o)/(b^2*x_o^2 + a^2*y_o^2),
  y: (a^2*b^2*y_o - sqrt(-a^2*b^2 + b^2*x_o^2 + a^2*y_o^2)*b^2*x_o)/(b^2*x_o^2 + a^2*y_o^2)}]
sage: SolP=solve([eq2,(eq02*y/b^2).expand()],[x,y],algorithme="sympy",solution_dict=True) ; SolP
[{x: (a^2*b^2*x_o - sqrt(-a^2*b^2 + b^2*x_o^2 + a^2*y_o^2)*a^2*y_o)/(b^2*x_o^2 + a^2*y_o^2),
  y: (a^2*b^2*y_o + sqrt(-a^2*b^2 + b^2*x_o^2 + a^2*y_o^2)*b^2*x_o)/(b^2*x_o^2 + a^2*y_o^2)},
 {x: (a^2*b^2*x_o + sqrt(-a^2*b^2 + b^2*x_o^2 + a^2*y_o^2)*a^2*y_o)/(b^2*x_o^2 + a^2*y_o^2),
  y: (a^2*b^2*y_o - sqrt(-a^2*b^2 + b^2*x_o^2 + a^2*y_o^2)*b^2*x_o)/(b^2*x_o^2 + a^2*y_o^2)}]
sage: bool(Set(SolM)==Set(SolP))
True

That's probably Trac#13773.

Shit happens. Complain fiercely...

HTH,

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-08-19 01:29:03 -0500

Seen: 60 times

Last updated: Aug 19