On Ubuntu 10.04 with latest libm and on older FreeBSD 6.2, gamma() returns bad values. I see references to this by other people; it has not been addressed. How serious it is is demonstrated by relating that libm says gamma(2.0) = 0.0 and that gamma(3.0) - 0.39, when both answers should be 1.0. Mathematically 1/gamma(2) is legal but not with this bug. Most statistical modeling is screwed. I had to migrate to the GSL library to get correct results. OUCH!
gamma is a non-standard function that returns $log_e |Γ(x)|$. Use tgamma for the gramma function. And Γ(3) ≠ 1.
Sorry about the 2/3, I meant 1/2. I tried tgamma but it does not exist in the library on Ubuntu (meaning the latest.) lgamma() of course returns the error I mention. Therefore there is still no working gamma. If in libm "gamma" is the function that ought to be named "lngamma" or "loggamma", then that's an error that should be corrected despite any "historical precendent" in my opinion. schwab@linux-m68k.org wrote: > http://sourceware.org/bugzilla/show_bug.cgi?id=12144 > > Andreas Schwab <schwab@linux-m68k.org> changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > Status|NEW |RESOLVED > Resolution| |INVALID > > --- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> 2010-10-21 08:40:00 UTC --- > gamma is a non-standard function that returns $log_e |Γ(x)|$. Use tgamma for > the gramma function. And Γ(3) ≠ 1. > >
If tgamma() truly is not present in Ubuntu's libm (it sure is in Debian's at least), report that to your distributor. The gamma() function naming is unfortunate, sadly we cannot reshape the word to be pretty without any regard to compatibility. I suggest you at least read through the related Linux manpages which explain the gamma() family of functions and historical story behind.