Post Reply 
Gamma Function Using Spouge's Method
09-15-2015, 06:43 PM (This post was last modified: 09-19-2015 05:34 AM by Dieter.)
Post: #34
RE: Gamma Function Using Spouge's Methjod
(08-27-2015 11:21 PM)Dieter Wrote:  OK, this is what I got until now for the n=4. I think this should be close to the optimum. If evaluated exactly, the maximum relative error for x = 0...70 is 1,599 E–11.

So that's 1...71 for the Gamma function.

Since at least negative arguments require the reflection formula, the approximation should handle values down to 0.5, i.e. where x = 1–x. So I set up another approximation which was optimized for 0.5≤x≤71. Here are the new coefficients. 10 to 13 digits are enough to keep the error within ±3.2 E–11.

Code:
 c =  3,838
a0 =  3,27431510667 E-02
a1 =  1,188242945545
a2 = -1,0667849602
a3 =  1,87974297577 E-01
a4 = -2,712278856 E-03

This way arguments below 0.5 can be handled by the reflection formula.

And, for the record, here are the coefficients of a n=5 approximation for the same domain (0,5≤x≤71). Evaluated exactly, the relative error is within ±4,2 E–13. At x=0,5 the error is close to zero. Within the mentioned error bounds the approximation may be used down to x=0,057.

Code:
 c =  5,081
a0 =  9,4469677044570384442 E-03
a1 =  1,3671852254158201121
a2 = -1,8395354829397881396
a3 =  6,8385345981848506558 E-01
a4 = -6,5429030358398827535 E-02
a5 =  6,5720584070280550576 E-04

These are 20 digits, but a few less should do either. ;-)

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


Messages In This Thread
RE: Gamma Function Using Spouge's Methjod - Dieter - 09-15-2015 06:43 PM



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