rtoy / maxima

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

limit fails with domain complex #91

Open rtoy opened 3 weeks ago

rtoy commented 3 weeks ago

Imported from SourceForge on 2024-07-01 18:06:53 Created by kcrisman on 2017-06-26 15:45:54 Original: https://sourceforge.net/p/maxima/bugs/3313


Apparently domain:complex doesn't play well with this limit.

Maxima 5.39.0 http://maxima.sourceforge.net
using Lisp ECL 16.1.2
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) limit((x*(4/log(x))^(2*log(x)/log(log(x)))),x,inf);
(%o1)                                  0
(%i2) domain:complex;
(%o2)                               complex
(%i3) limit((x*(4/log(x))^(2*log(x)/log(log(x)))),x,inf);

Condition of type: SIMPLE-CONDITION
Undefined limit product $INF * $ZEROB in lim-times

Available restarts:

1. (CONTINUE) Return from BREAK.
2. (MACSYMA-QUIT) Maxima top-level

Top level.
> ^D

Originally reported at https://trac.sagemath.org/ticket/23328

rtoy commented 3 weeks ago

Imported from SourceForge on 2024-07-01 18:06:54 Created by willisbl on 2024-01-07 18:11:33 Original: https://sourceforge.net/p/maxima/bugs/3313/#60bb


The function lim-times, defined in hayat does a "break" when it should, I think call tay-error. I've experimented with this and a few other changes and now I get a limit nounform--that's not ideal, but it's an improvement

(%i8) block([domain : 'complex], limit((x*(4/log(x))^(2*log(x)/log(log(x)))),x,inf));

(%o8) 'limit(x*(4/log(x))^((2*log(x))/log(log(x))),x,inf)

I don't entirely understand lim-times,, and my impression is that it has other bugs; for example I'd say %o1 is OK, but %o2 should be $inf, not $minf

(%i1)   :lisp(defun \$larry (a b) (lim-times a b));
$LARRY
(%i1)   larry(inf,minf);
(%o1)   -inf
(%i2)   larry(minf,minf);
(%o2)   -inf
rtoy commented 3 weeks ago

Imported from SourceForge on 2024-07-01 18:06:56 Created by willisbl on 2024-01-07 22:32:17 Original: https://sourceforge.net/p/maxima/bugs/3313/#83f3


Here is a change that allow this limit to return a limit nounform--I changed the break to a call to tay-error

(defun lim-times (lim1 lim2)
  (let (lim)
   (cond ((or (eq lim1 '$zero) (eq lim2 '$zero)) (setq lim '$zero))
     ((and (lim-infp lim1) (lim-infp lim2)) (setq lim '$inf))
     ((and (lim-zerop lim1) (lim-zerop lim2)) (setq lim '$pos))
     ((or (when (lim-finitep lim2) (rotatef lim1 lim2) 't)
          (lim-finitep lim1))
      (when (and (eq lim1 '$finite) (lim-infp lim1))
         (tay-error "Undefined finite*inf in lim-times" lim2))
      (setq lim (lim-abs lim2)))
     (t (tay-error "Undefined limit product in lim-times" (list (list 'mtimes) lim1 lim2))))
   (if (or (lim-imagp lim1) (lim-imagp lim2))
       (if (lim-infp lim) '$infinity '$im)
      (if (and (lim-plusp lim1) (lim-plusp lim2)) lim (lim-minus lim)))))
rtoy commented 3 weeks ago

Imported from SourceForge on 2024-07-01 18:06:58 Created by willisbl on 2024-01-10 17:38:55 Original: https://sourceforge.net/p/maxima/bugs/3313/#cd9d


Second thought: I think it's better to put an errcatch on the call to $taylor in the function calculate-series (defined in limit.lisp). Unlike only changing lim-times, this change will catch all errors from$taylor,not just the error from . Again, this proposed change doesn't fix the bug, but it allows the limit to return a nounform. And that's an improvement.