Post Reply 
WP34s: Gamma function for x very close to zero
10-04-2015, 12:52 PM (This post was last modified: 10-04-2015 01:49 PM by Dieter.)
Post: #1
WP34s: Gamma function for x very close to zero
I just found what I think is a glitch in the WP34s Gamma function: arguments very close to zero can cause the calculator to hang and/or throw an error.

Code:
 1E-10     Γ     OK
 1E-20     Γ     OK
 1E-37     Γ     OK
 1E-38     Γ     +∞ Error
 1E-39     Γ     +∞ Error
 1E-40     Γ     calculator hangs and may eventually reset
 below     Γ     calculator hangs and may eventually reset
-1E-30     Γ     OK
-1E-38     Γ     OK
-1E-39     Γ     Domain Error
 below     Γ     Domain Error

I assume this is because somewhere in the code (using 39 digit precision) 1+some_small_value rounds to 1.

But there is a simple fix: If |x|<1E–20 simply evaluate \(\Gamma(x) \approx \frac{1}{x}-\gamma_{EM}\).
The absolute value of the relative error here is < 1E–40, so the result is as least as accurate as the internal 39 digit routine.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
WP34s: Gamma function for x very close to zero - Dieter - 10-04-2015 12:52 PM



User(s) browsing this thread: 1 Guest(s)