rtoy / maxima

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

gamma(negative integer) undefined, but with numer flag gives some bogus(?) value #1358

Open rtoy opened 1 week ago

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-04 09:57:11 Created by tomasriker on 2021-09-02 09:18:07 Original: https://sourceforge.net/p/maxima/bugs/3845


The Gamma function is undefined for negative integers, and Maxima knows this:

(%i1)   gamma(-5);
gamma: gamma(-5) is undefined.
 -- an error. To debug this try: debugmode(true);

But when we add the numer flag, we get some bogus(?) numerical answer:

(%i2)   gamma(-5), numer;
(%o2)   -4.275508464667924*10^13
rtoy commented 1 week ago

Imported from SourceForge on 2024-07-04 09:57:12 Created by macrakis on 2021-09-02 21:45:26 Original: https://sourceforge.net/p/maxima/bugs/3845/#25a0


The fix is to change floatp to numberp in line 5 of simpgamma and add an errorsw clause there.

The problem is that float-numerical-eval-p accepts not just floats, but also rationals.

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-04 09:57:16 Created by robert_dodier on 2021-09-02 22:04:44 Original: https://sourceforge.net/p/maxima/bugs/3845/#19ed


I see that gamma(-5.0) triggers the message "undefined", as expected, likewise gamma(-5), float. So far it seems only gamma(-5), numer returns the spurious numerical value.