New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
math: Gamma(x) special cases are wrong #2977
Labels
Comments
From C99 rationale: 7.12.8.4 The tgamma functions. New feature for C99. In many other standards, the meaning of gamma has changed over the years. Originally, it computed the logarithm of the absolute value of the mathematical gamma function, with an external int, signgam, being set to the sign of the gamma function. Then gamma was replaced with lgamma, and gamma was slated to be withdrawn. About that time, NCEG changed gamma to compute the mathematical gamma function, and that is what was adopted into C99 CD1; but it appears that the old meaning of gamma has not yet been withdrawn, so there would have been a conflict between C99 and current industry practice. C99 therefore changed the name in the FCD to tgamma, meaning “true gamma,” to avoid this conflict. C99 originally had tgamma(0) = NaN, but by TC2 (probably also TC1) they had changed it to tgamma(+0) = +Inf, tgamma(-0) = -Inf. Other non-positive integers do not have "sides", so they are NaN instead. http://std.dkuug.dk/jtc1/sc22/wg14/www/docs/dr_244.htm looks to be the defect report that led to the change. I believe we should match (the new) C99 in the absence of expert arguments to the contrary, meaning: Special cases are: Gamma(+Inf) = +Inf Gamma(+0) = +Inf Gamma(-0) = -Inf Gamma(x) = NaN for integer x < 0 Gamma(-Inf) = NaN Gamma(NaN) = NaN The attached program prints: netlib gamma lgamma tgamma inf inf inf inf inf -inf nan nan inf nan 0 nan inf inf inf -0 nan -inf inf -inf -1 nan nan inf nan -2 nan nan inf nan -3 nan nan inf nan -4 nan nan inf nan -5 nan nan inf nan -6 nan nan inf nan -7 nan nan inf nan -8 nan nan inf nan -9 nan nan inf nan The netlib column is the netlib source that the Go file claims to have started with, although it in a different place on netlib now and I cut out all the #ifdefs and ran it through cb. Attachments:
|
This issue was closed by revision 5496e94. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: