[math-fun] Gamma function (formulas collection)
many formulas about gamma function are in my paper: http://rangevoting.org/WarrenSmithPages/homepage/gammprox.pdf
This is great, thank you. I couldn't find Lanczos in your paper. There is a good thesis on his method, which also had a good tutorial on the Gamma function, including Stirling and Spouge, at [1]. I also didn't see concrete algorithms pseudo-code or real source code. There is source code for Lanczos at [2]. It is very compact and the web page explains how he determined the right coefficients and parameters. He evaluated Gamma[102] to 165 digit precision as an example. There is also source code for PARI's version of gamma (with some variable, function, etc. names in French) at [3] in the file "src/basemath/trans2.c", functions mpgamma and mplngamma. Newer versions of PARI seem to have renamed it or moved it to another file, and I haven't bothered to track down the details. - Robert [1] http://laplace.phas.ubc.ca/ThesesOthers/Phd/pugh.pdf [2] http://www.vttoth.com/CMS/projects/41-the-lanczos-approximation [3] http://pari.sourcearchive.com/documentation/2.1.6/files.html On Fri, Dec 30, 2011 at 12:39, Warren Smith <warren.wds@gmail.com> wrote:
many formulas about gamma function are in my paper: http://rangevoting.org/WarrenSmithPages/homepage/gammprox.pdf
-- Robert Munafo -- mrob.com Follow me at: gplus.to/mrob - fb.com/mrob27 - twitter.com/mrob_27 - mrob27.wordpress.com - youtube.com/user/mrob143 - rilybot.blogspot.com
In case it isn't obvious I'm pretty sure the table of values used in the implementation in Ultra Fractal that I posted is from the Lanczos approximation, which at one point I was meaning to implement myself to get the table but that was before I found the one that I used (which saved a lot of time). I would have posted the links to all the relevant sources I used but I've moved 3 computers on since then and the old Windows PC with the links on is now in storage ;) On 31 Dec 2011, at 03:06, Robert Munafo wrote:
This is great, thank you.
I couldn't find Lanczos in your paper. There is a good thesis on his method, which also had a good tutorial on the Gamma function, including Stirling and Spouge, at [1].
I also didn't see concrete algorithms pseudo-code or real source code. There is source code for Lanczos at [2]. It is very compact and the web page explains how he determined the right coefficients and parameters. He evaluated Gamma[102] to 165 digit precision as an example.
There is also source code for PARI's version of gamma (with some variable, function, etc. names in French) at [3] in the file "src/basemath/trans2.c", functions mpgamma and mplngamma. Newer versions of PARI seem to have renamed it or moved it to another file, and I haven't bothered to track down the details.
- Robert
[1] http://laplace.phas.ubc.ca/ThesesOthers/Phd/pugh.pdf
[2] http://www.vttoth.com/CMS/projects/41-the-lanczos-approximation
[3] http://pari.sourcearchive.com/documentation/2.1.6/files.html
On Fri, Dec 30, 2011 at 12:39, Warren Smith <warren.wds@gmail.com> wrote:
many formulas about gamma function are in my paper: http://rangevoting.org/WarrenSmithPages/homepage/gammprox.pdf
-- Robert Munafo -- mrob.com Follow me at: gplus.to/mrob - fb.com/mrob27 - twitter.com/mrob_27 - mrob27.wordpress.com - youtube.com/user/mrob143 - rilybot.blogspot.com _______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
David, Google search for "0.49191381609762019978" yields [2] and many other pages like it, thus your terms are indeed a Lanczos approximation as in [1], with n=15, g=607/128=4.7421875. - Robert [1] http://www.vttoth.com/CMS/projects/41-the-lanczos-approximation [2] http://blog.javia.org/implementing-the-lgamma-function-in-java/ On Sat, Dec 31, 2011 at 06:57, David Makin <makinmagic@tiscali.co.uk> wrote:
In case it isn't obvious I'm pretty sure the table of values used in the implementation in Ultra Fractal that I posted is from the Lanczos approximation, which at one point I was meaning to implement myself to get the table but that was before I found the one that I used (which saved a lot of time).
I would have posted the links to all the relevant sources I used but I've
moved 3 computers on since then and the old Windows PC with the links on is now in storage ;)
On 2011-12-28, Dave Makin <dave_makin@lineone.net> wrote:
On the subject of the gamma function, I'd be interested to know if I got this correct for complex gamma - it's the func I wrote for the Ultra Fractal math library = obviously it's not the most accurate implementation but I was balancing speed with accuracy and in adition it was taking too long to hunt down a better table of values to use ;) *************** ; Complex Gamma() David Makin June 2008 ; @param pz complex argument ; @return Gamma function of argument static complex func ComplexGamma(complex pz) complex w = pz if pz==0.0 w = recip(0) else if real(pz)<0.0 w = -pz if imag(pz)==0.0 if (real(pz)%1)==0.0 w = recip(0) endif endif endif if real(w)<1e300 w = (sqrt(2.0*#pi)* \ (0.99999999999999709182 \ + 57.156235665862923517/(w+1.0) \ - 59.597960355475491248/(w+2.0) \ + 14.136097974741747174/(w+3.0) \ - 0.49191381609762019978/(w+4.0) \ + .33994649984811888699E-4/(w+5.0) \ + .46523628927048575665E-4/(w+6.0) \ - .98374475304879564677e-4/(w+7.0) \ + .15808870322491248884E-3/(w+8.0) \ - .21026444172410488319e-3/(w+9.0) \ + .21743961811521264320e-3/(w+10.0) \ - .16431810653676389022e-3/(w+11.0) \ + .84418223983852743293e-4/(w+12.0) \ - .26190838401581408670e-4/(w+13.0) \ + .36899182659531622704e-5/(w+14.0)) \ /w) * exp(-w-5.2421875)*(w+5.2421875)^(w+0.5) if real(pz)<0.0 w = pz*w*sin(#pi*pz) if (w==0.0) w = recip(0) else w = -#pi/w endif endif endif endif return w endfunc **************
-- Robert Munafo -- mrob.com Follow me at: gplus.to/mrob - fb.com/mrob27 - twitter.com/mrob_27 - mrob27.wordpress.com - youtube.com/user/mrob143 - rilybot.blogspot.com
participants (3)
-
David Makin -
Robert Munafo -
Warren Smith