Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lgamma(3M) — AOS 4.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

math(3M)

LGAMMA(3M)  —  

NAME

lgamma − log gamma function

SYNOPSIS

#include <math.h>

double lgamma(x)
double x;

DESCRIPTION

Lgamma returns ln|Γ(x)| whereΓ(x) = ∫0s10∞ tx−1 e−t dtfor x > 0 and
Γ(x) = π/(Γ(1−x)sin(πx))for x < 1.

The sign of Γ(x) is returned in the external integer signgam. Do not use the expression

     g=exp(lgamma(x))∗signgam

to compute g = Γ(x).  Instead, use a sequence of statements such as

     lg = lgamma(x);
     g = exp(lg)∗signgam;
     g = (g=exp(lgamma(x)),g∗signgam);

because only after lgamma has returned can the value of signgam be relied on.  Note, too, that evaluation of Γ(x)  must overflow when x is large enough, underflow when −x is large enough, and divide by zero when x is a nonpositive integer. 

NOTES

In 4.2BSD and earlier systems, the log gamma function is named gamma. The name has been changed to lgamma to correspond to mathematical reality. 

The original C’s gamma probably delivered ln(Γ(|x|)).  Later, the program gamma was changed to cope with negative arguments x in a more conventional way, but the documentation did not reflect that change correctly.  The most recent change corrects inaccurate values when x is almost a negative integer, and lets Γ(x) be computed without conditional expressions.  Programmers should not assume that lgamma has settled down. 

Programmers who have to use the name gamma in its former sense, for what is now lgamma, can add the following program to their others:

#include <math.h>
double gamma(x)
double x;
{

return (lgamma(x));

}

DIAGNOSTICS

For nonpositive integral arguments, lgamma returns ∞ and errno is set to EDOM.  For huge arguments, underflow or overflow may be signaled. 

SEE ALSO

math(3M)

PRPQs 5799-WZQ/5799-PFF: IBM/4.3  —  July 1987

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026