Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 05 Nov 2001 16:17:19 +1100
From:      peter.jeremy@alcatel.com.au
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/31764: gamma(3) man page incorrect
Message-ID:  <20011105161719.B94635@gsmx07.alcatel.com.au>

next in thread | raw e-mail | index | archive | help

>Number:         31764
>Category:       bin
>Synopsis:       gamma(3) man page incorrect
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 04 21:20:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Peter Jeremy
>Release:        FreeBSD 4.4-STABLE i386
>Organization:
Alcatel Australia Limited
>Environment:
System: FreeBSD cirb503493.alcatel.com.au 4.4-STABLE FreeBSD 4.4-STABLE #10: Sat Oct 20 18:35:46 EST 2001 root@cirb503493.alcatel.com.au:/usr/obj/usr/src/sys/pj1592 i386

>Description:
	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).

>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

>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.
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011105161719.B94635>