rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

Very long calculation time, normal ? #3083

Closed rtoy closed 1 week ago

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 13:38:18 Created by thbesson on 2008-08-03 06:34:36 Original: https://sourceforge.net/p/maxima/bugs/1468


wxMaxima 0.7.5 http://wxmaxima.sourceforge.net Maxima 5.15.0 http://maxima.sourceforge.net Using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (aka GCL) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. The function bug_report() provides bug reporting information. (%i1) kill(all); (%o0) done (%i1) declare(a,constant); (%o1) done (%i2) declare(b,constant); (%o2) done (%i3) declare(c,constant); (%o3) done (%i4) solve(a*x^4/4!+a*x^2/2!+b*x-%pi*b+a+c);

running since 12 hours on a dualcore

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 13:38:19 Created by robert_dodier on 2008-08-03 16:58:57 Original: https://sourceforge.net/p/maxima/bugs/1468/#adc7


Logged In: YES user_id=501686 Originator: NO

Well, this is a bug.

Here is a workaround: omit the declare(..., constant) and tell solve to solve for x specifically.

solve(a*x^4/4!+a*x^2/2!+b*x-%pi*b+a+c, x); => (quickly returns a long expression)

I can't tell what is the problem here; simpler examples seem to get solved right away.

I've moved this to the bug tracker in hope of eventually resolving it.

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 13:38:23 Created by robert_dodier on 2008-08-03 18:24:24 Original: https://sourceforge.net/p/maxima/bugs/1468/#d924


rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 13:38:26 Created by jnevins32 on 2008-09-01 20:32:29 Original: https://sourceforge.net/p/maxima/bugs/1468/#4a54


Logged In: YES user_id=2201177 Originator: NO

Hi

I'm Having exact same problem (see: 2087495).

Also when doing exactly the above the problem is reproduced.

Maxima 5.16.2 http://maxima.sourceforge.net Using Lisp CLISP 2.43 (2007-11-18) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. The function bug_report() provides bug reporting information. (%i1) declare(a,constant); (%o1) done (%i2) declare(b,constant); (%o2) done (%i3) declare(c,constant); (%o3) done (%i4) solve(a*x^4/4!+a*x^2/2!+b*x-%pi*b+a+c); <<<<<<<<<<<<<<<<<<<< HANGS HERE.

Regards Jason Nevins

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 13:38:30 Created by jnevins32 on 2008-09-01 20:52:07 Original: https://sourceforge.net/p/maxima/bugs/1468/#4d78


Logged In: YES user_id=2201177 Originator: NO

Hi, thanks, workaround helped.

Also, I have realized that I had support compiled for multiple Common Lisp interpreters. Will try to reduce this to only one and see if it makes a difference.

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 13:38:33 Created by crategus on 2010-06-13 19:26:00 Original: https://sourceforge.net/p/maxima/bugs/1468/#14fa


When we declare the symbols a, b, and c as a constant for the reported example, the algorithm of solvequartic in psolve.lisp hangs. In the routine solvequartic the routine simpnrt in called directly to calculate the square root of an expression. But simpnrt never returns.

If we cut out the direct call of simpnrt and replace the code with calls to the main simplifier we no longer get the error:

(%i1) declare([a,b,c],constant);

(%o1) done (%i2) solve(a*x^4/4!+a*x^2/2!+b*x-%pi*b+a+c);

(%o2) [x = -sqrt(48*b/(a*sqrt((a*(32*sqrt( -32*a*c^3+96*%pi*a*b*c^2 -((96*%pi^2+216)*a*b^2-24*a^3)*c +81*b^4 -(-32*%pi^3-216*%pi)*a*b^3 -180*a^2*b^2-24*%pi*a^3*b-8*a^4) /a^2 .... and lot of more terms.

This is the piece of code in solvequartic. The calls to simpnrt have been replaced with calls to the function power:

lb1 ; (setq d (simpnrt (simplify (list '(mplus) tr1 tr2)) 2)) (setq d (power (add tr1 tr2) '((rat simp) 1 2))) ; (setq e ; (simpnrt (simplify (list '(mplus) ; (list '(mtimes) -1 tr2))) ; 2)) (setq e (power (add tr1 (mul -1 tr2)) '((rat simp) 1 2)))

We have no problems with the testsuite. In the share_testsuite we have only one example which gives the same solutions, but in a different order:

********************** Problem 116 *************** Input: nicedummies(%solve(cos(x)-2*cos(2*x)+cos(3*x) = 1/2,x,simpfuncs = ['expand]))

Result: %union([x = 2*%pi*%z0-atan(sqrt(sqrt(13)/2+1/2)/(1/2-sqrt(13)/2))-%pi], [x = 2*%pi*%z1+atan(sqrt(sqrt(13)/2+1/2)/(1/2-sqrt(13)/2))+%pi], [x = 2*%pi*%z2-%i*log(sqrt(13)/4-sqrt(sqrt(13)/2-1/2)/2+1/4)], [x = 2*%pi*%z3-%i*log(sqrt(13)/4+sqrt(sqrt(13)/2-1/2)/2+1/4)], [x = 2*%pi*%z4-%pi/3],[x = 2*%pi*%z5+%pi/3])

This differed from the expected result: %union([x = 2*%pi*%z0-%i*log(1/4-sqrt(sqrt(13)-1)/2^(3/2)+sqrt(13)/4)], [x = 2*%pi*%z1-%i*log(1/4+sqrt(sqrt(13)-1)/2^(3/2)+sqrt(13)/4)], [x = 2*%pi*%z2-%pi/3],[x = %pi/3+2*%pi*%z3], [x = -%pi-atan(sqrt(1+sqrt(13))/(1/sqrt(2)-sqrt(13)/sqrt(2))) +2*%pi*%z4], [x = %pi+atan(sqrt(1+sqrt(13))/(1/sqrt(2)-sqrt(13)/sqrt(2))) +2*%pi*%z5])

I think there is no reason to call simpnrt directly and we should replace these calls.

Dieter Kaiser

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 13:38:37 Created by crategus on 2010-06-19 12:08:55 Original: https://sourceforge.net/p/maxima/bugs/1468/#a910


Fixed in psolve.lisp revision 1.8. simpnrt is no longer called directly to calculate the variables d and e in solvequartic. Closing this bug report as fixed. Dieter Kaiser

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 13:38:40 Created by crategus on 2010-06-19 12:08:55 Original: https://sourceforge.net/p/maxima/bugs/1468/#ba0b