Somethog in rotten is the state of Maxima...

84 views
Skip to first unread message

Emmanuel Charpentier

unread,
Oct 9, 2022, 11:45:36 AM10/9/22
to sage-support
... and all is not fresh in Sympy's realm either.


TL;DR : a linear system, perfectly solved by Sage's default solver (i. e. Maxima's), gets a wrong answer when one of its variables is replaced by the `I` (*i*, imaginary unit) constant.

The problem can be reproduced in `maxima` used standalone. (see referenced post).

Furthermore, the same system (with *i*) seems to confuse `sympy` to no extend : `solve(Sys, IVars), algorithm="sympy")`doesn't return after more than 15 minutes, whereas the solution of the system with a variable instead of *i* is solved in a matter of milliseconds...

Giac doesn't give an answer, and Fricas seems to return the same thing as Sage...

Advoce requested on how to file tickets/bug reports efficiently.

Nils Bruin

unread,
Oct 9, 2022, 12:27:54 PM10/9/22
to sage-support
On Sunday, 9 October 2022 at 08:45:36 UTC-7 Emmanuel Charpentier wrote:
...
Advoce requested on how to file tickets/bug reports efficiently.
For now, it's still through trac, I believe, but in a few weeks it would but a through github issues. With the reproduction in maxima standalone, especially because the erroneously solved system is obtained by specialization from a system that is solved correctly, this can be reported "upstream" to maxima and I'm sure it will get due attention eventually.

Their bug reporting hasn't changed, I think: https://sourceforge.net/p/maxima/bugs/

Emmanuel Charpentier

unread,
Oct 9, 2022, 12:43:03 PM10/9/22
to sage-support

It turns out that the original author has also posted this problem in sage-devel, wher we should continue…

Martin R

unread,
Nov 3, 2022, 7:59:48 AM11/3/22
to sage-support
@Emmanuel, why are you saying that FriCAS returns the same as sage?  For me, fricas.solve works as expected.

Martin

Emmanuel Charpentier

unread,
Nov 3, 2022, 11:51:31 AM11/3/22
to sage-support

Le jeudi 3 novembre 2022 à 12:59:48 UTC+1, axio…@yahoo.de a écrit :

@Emmanuel, why are you saying that FriCAS returns the same as sage?

I tried solve(Sys0, IVars) and got the same result as the one given by the default solver…

For me, fricas.solve works as expected.

Could you give us your execution especially how to convert the result back to Sage ?

Emmanuel Charpentier

unread,
Nov 3, 2022, 2:08:44 PM11/3/22
to sage-support

Never mind : I reconstituted something similar :

# ****************** General system ******************
Vars = var('L1 L2 L3 L4 C1 C2 C3 C4 M23 I1 I2 I3 I4 U w p RL J')
IVars = [I1, I2, I3, I4]
Sys = [I1*(w*J*L1 + 1/(w*J*C1)) + I2*(-1/(w*J*C1) ) == U,
       I2*(w*J*L2 + 1/(w*J*C1) + 1/(w*J*C2)) + I3*(w*J*M23 - 1/(w*I*C2)) + I1*(- 1/(w*J*C1)) == 0,
       I3*(1/(w*J*C3) + w*J*L3 + 1/(w*J*C2)) + I2*(w*J*M23 - 1/(w*J*C2)) - I4/(w*J*C3) == 0,
       I4/(w*J*C3) + I4*RL - I3/(w*J*C3) == 0]
Sol = solve(Sys, IVars, solution_dict=True)
Chk = all([u.subs(Sol).simplify_full() for u in Sys])
# ****************** Specialization to J=I ******************
Sys0 = [u.subs(J=I) for u in Sys]
Sol0 = solve(Sys0, IVars, solution_dict=True)
Chk0 = all([u.subs(Sol0).simplify_full() for u in Sys0])
# ****************** Fricas ******************
Sys0f = fricas(Sys0)
Sol0ff = fricas.solve(Sys0f, fricas(IVars))
# Here, no automatic backconversion to Sage : manual conversion necessary...
Sol0f = [{fricas.lhs(u).sage():fricas.rhs(u).sage() for u in v}
          for v in Sol0ff]
Chk0f = all([u.subs(Sol0f[0]).simplify_full() for u in Sys0])

And, of course :

sage: Chk
True
sage: Chk0
False
sage: Chk0f
True

You are right….

Reply all
Reply to author
Forward
0 new messages