[Maxima] Bug in mring.lisp? was: Need help with Maxima (please help)

Leo Butler l.butler at ed.ac.uk
Tue Apr 27 09:50:33 CDT 2010

On Tue, 27 Apr 2010, Sheldon Newhouse wrote:

 I tried to do the problem
< "diff(arccos(x^2+8.363+267)/(sqrt(x^2-4.29x+1042)(x^2+12.8102x+1177))), x);"
< in Maple with the correct version of parentheses, etc. It computed the
< derivative fine (as maxima does), but it failed to find the zero.
I believe that there is a bug in the present mring.lisp which prevents
this probblem, and similar ones, from being solved by mnewton. The basic
problem is that in trying to create CL complex numbers from a Maxima
expression, float is being called too late. I include the patch below.

(%i1) load(mnewton)$
(%i2) f:diff(acos(x^2+8.363+267)/(sqrt(x^2-4.29*x+1042)*(x^2+12.8102*x+1177)),x)$
(%i3) mnewton(f,x,-5.0);

Unable to convert
%to a complex long fl\
line 1\
 -- an error. To debug this try: debugmode(true);
(%i4) load("/home/work/maxima/sandbox/maxima/share/linearalgebra/mring.lisp")$
(%i5) mnewton(f,x,-5.0);
(%o5) [[x = 2.013631497110261e-16*%i-5.626466372928149]]

Here is the patch which does the trick

Index: mring.lisp
RCS file: /cvsroot/maxima/maxima/share/linearalgebra/mring.lisp,v
retrieving revision 1.24
diff -u -r1.24 mring.lisp
--- mring.lisp  14 Feb 2008 01:31:37 -0000      1.24
+++ mring.lisp  27 Apr 2010 14:44:58 -0000
@@ -114,10 +114,10 @@
    :mring-to-maxima #'(lambda (s) (add (realpart s) (mult '$%i (imagpart s)))) ;; was complexify
    :maxima-to-mring #'(lambda (s)
-                         (setq s ($rectform (meval s)))
+                         (setq s ($float ($rectform (meval s))))
                          (if (complex-number-p s 'float-or-rational-p)
-                             (complex ($float ($realpart s)) ($float
                              ($imagpart s)))
-                           (merror "Unable to convert ~:M to a complex
                            long float" s))))))
+                             (complex ($realpart s) ($imagpart s))
+                             (merror "Unable to convert ~:M to a complex long float" s))))))

The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

More information about the Maxima mailing list