Bug 12144 - gamma function still returns absurd values
Summary: gamma function still returns absurd values
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: unspecified
: P2 critical
Target Milestone: ---
Assignee: Andreas Jaeger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-21 03:58 UTC by Eric Dynamic
Modified: 2014-06-30 07:24 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Dynamic 2010-10-21 03:58:46 UTC
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!
Comment 1 Andreas Schwab 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.
Comment 2 Eric Dynamic 2010-10-21 19:16:51 UTC
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.
>
>
Comment 3 Petr Baudis 2010-10-27 02:49:42 UTC
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.