From cc2ac0e504a1078ac5c0ceeec890331a1465239f Mon Sep 17 00:00:00 2001 From: Kris Katterjohn Date: Mon, 31 Oct 2022 14:51:45 -0400 Subject: [PATCH] Fix bug #4036: prederror affects bigfloat calculations MEVALP has been used for evaluations in some of the numerical functions in the BIGFLOAT package. This is wrong because MEVALP is for evaluating predicates, and so prederror affects its behavior: (%i1) inverse_jacobi_cn (1.0b0 * %i, 2); (%o1) 2.037975073056735b0-3.933086691879947b0*%i (%i2) prederror : true$ (%i3) inverse_jacobi_cn (1.0b0 * %i, 2); Unable to evaluate predicate (-1.722546424198833b-16*%i)-1.414213562373095b0 -- an error. To debug this try: debugmode(true); Now MEVAL is used instead of MEVALP. When prederror was false, MEVALP was (eventually) just returning the result of MEVAL in these cases anyway. src/numeric.lisp was introduced in commit 99efec20 in 2009, and it included most of the existing calls to MEVALP at that time. No problems with the test suite or share test suite. --- ChangeLog | 1 + src/numeric.lisp | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0695da2dc..df3acc214 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,7 @@ Changes in the Windows installer: Bug fixes for numbered bugs: ---------------------------- + * \#4036: prederror affects bigfloat calculations Unnumbered bugs fixed: --------------------- diff --git a/src/numeric.lisp b/src/numeric.lisp index c2a5b680a..babc46409 100644 --- a/src/numeric.lisp +++ b/src/numeric.lisp @@ -1120,8 +1120,7 @@ (defmethod acosh ((x bigfloat)) (let* ((r (real-value x)) - (value (maxima::mevalp `((maxima::%acosh maxima::simp) - ,r)))) + (value (maxima::meval `((maxima::%acosh maxima::simp) ,r)))) (if (maxima::bigfloatp value) (make-instance 'bigfloat :real value) (make-instance 'complex-bigfloat @@ -1144,10 +1143,10 @@ (to res)))) (let ((max-op (intern (concatenate 'string "$" (string name)) '#:maxima))) `(defmethod ,name ((a complex-bigfloat)) - ;; We should do something better than calling mevalp + ;; We should do something better than calling meval (let* ((arg (maxima::add (real-value a) (maxima::mul 'maxima::$%i (imag-value a)))) - (result (maxima::mevalp `((,',max-op maxima::simp) ,arg)))) + (result (maxima::meval `((,',max-op maxima::simp) ,arg)))) (to result))))))) (frob exp) (frob sin) @@ -1170,10 +1169,10 @@ :real (maxima::bcons (maxima::fpatan (cdr (real-value a)))))) (defmethod one-arg-atan ((a complex-bigfloat)) - ;; We should do something better than calling mevalp + ;; We should do something better than calling meval (let* ((arg (maxima::add (real-value a) (maxima::mul 'maxima::$%i (imag-value a)))) - (result (maxima::mevalp `((maxima::%atan maxima::simp) ,arg)))) + (result (maxima::meval `((maxima::%atan maxima::simp) ,arg)))) (make-instance 'complex-bigfloat :real (maxima::$realpart result) :imag (maxima::$imagpart result)))) -- 2.11.4.GIT