rtoy / maxima

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

limits of some gamma_incomplete expressions #3900

Open rtoy opened 1 month ago

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-08 21:12:22 Created by willisbl on 2022-06-23 10:12:20 Original: https://sourceforge.net/p/maxima/bugs/3994


I think the true value of this limit is zero:

(%i1) limit(x*gamma_incomplete(1/2,x^2+%i*x),x, inf);

limit: variable must be a symbol or subscripted symbol; found: sin(x)

This similar limit is OK, I think:

(%i14) limit(x*gamma_incomplete(1,x^2+%i*x),x, inf);
(%o14)                                 0
rtoy commented 1 month ago

Imported from SourceForge on 2024-07-08 21:12:23 Created by willisbl on 2022-06-23 12:16:31 Original: https://sourceforge.net/p/maxima/bugs/3994/#06c3


We can make this bug "go away" by changing the call to $limit in gamma-upper-trans to a call to limit-catch

Calling limit-catch is some what different than calling $limit. And maybe the true bug is somewhere else--that is, gamma-upper-trans never should have been called with the arguments that give rise to this bug.

But I think this fix is likely harmless?

(defun gamma-upper-trans (arg func)
  (let ((s (car arg))
    (z (cadr arg)))
    (if (and
     (eq ($sign s) '$pos)
     (zerop1 (limit-catch z (caar tlist) (exp-pt (car tlist)))))
    (taylor2 `((mplus) ((%gamma) ,s)
           ((mtimes) -1 ((%gamma_incomplete_lower) ,s ,z))))
    (taylor2 (diff-expand `((,func) . ,arg)
                  tlist)))))
rtoy commented 1 month ago

Imported from SourceForge on 2024-07-08 21:12:26 Created by willisbl on 2022-06-23 13:29:42 Original: https://sourceforge.net/p/maxima/bugs/3994/#2055


Better patch is to use the errcatch macro:

(defun gamma-upper-trans (arg func)
  (let ((s (car arg))
    (z (cadr arg)))
    (if (and
     (eq ($sign s) '$pos)
     (zerop1 (car (errcatch ($limit z (caar tlist) (exp-pt (car tlist)))))))
    (taylor2 `((mplus) ((%gamma) ,s)
           ((mtimes) -1 ((%gamma_incomplete_lower) ,s ,z))))
    (taylor2 (diff-expand `((,func) . ,arg)
                  tlist)))))

Thanks to Kris Katterjohn for reminding me about this macro.

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-08 21:12:30 Created by robert_dodier on 2022-06-23 18:47:28 Original: https://sourceforge.net/p/maxima/bugs/3994/#7a90


Thanks for working on it, I agree ERRCATCH is a good solution.