Bug 31764

Summary: gamma(3) man page incorrect
Product: Base System Reporter: peter.jeremy <peter.jeremy>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.4-STABLE   
Hardware: Any   
OS: Any   

Description peter.jeremy 2001-11-05 05:20:00 UTC
	The gamma(3) man page states that gamma(x) is gamma(x), whilst
	lgamma(x) returns ln(gamma(x)).  gamma(x) actually returns
	the log of gamma(x).

Fix: 

The standard seems to be that gamma() actually return log gamma(),
	therefore the implementation is correct, it's just the man page
	that is wrong.  That said, there are two implementations of gamma
	provided: src/lib/libm/common_source/gamma.c appears to match the
	man page, whilst src/lib/msun/src/w_gamma.c is the one in libm.
How-To-Repeat: #include <math.h>
#include <stdio.h>

int main()
{
    double d;

    for (d = 1; d < 10; d++) {
	printf("gamma(%f) = %f\n", d, gamma(d));
    }
}

	If the man page was correct, this program would return:
gamma(1.000000) = 1.000000
gamma(2.000000) = 1.000000
gamma(3.000000) = 2.000000
gamma(4.000000) = 6.000000
gamma(5.000000) = 24.000000
gamma(6.000000) = 120.000000
gamma(7.000000) = 720.000000
gamma(8.000000) = 40320.000000
gamma(9.000000) = 362880.000000

	It actually returns:
gamma(1.000000) = 0.000000
gamma(2.000000) = 0.000000
gamma(3.000000) = 0.693147
gamma(4.000000) = 1.791759
gamma(5.000000) = 3.178054
gamma(6.000000) = 4.787492
gamma(7.000000) = 6.579251
gamma(8.000000) = 8.525161
gamma(9.000000) = 10.604603
Comment 1 dwmalone freebsd_committer freebsd_triage 2001-11-05 09:27:27 UTC
State Changed
From-To: open->closed

Duplicate of PR 28972, which contains a patch.