Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

intro(3M)

LGAMMA(3M)  —  MATHEMATICAL FUNCTIONS

NAME

lgamma, gamma − log gamma function

SYNOPSIS

#include <math.h>

double lgamma(x)
double x;
double gamma(x)
double x;

DESCRIPTION

Lgamma

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

The external integer signgam returns the sign of Γ(x) . 

Gamma

Gamma returns ln |Γ(|x|)|. The sign of Γ(|x|) is returned in the external integer signgam. The following C program might be used to calculate Γ:

y = gamma(x);
#ifdef vax
if (y > 88.0)
#endif
#ifdef sun
if (y > 706.0)
#endif
error();
y = exp(y);
if(signgam)
y = −y;

IDIOSYNCRASIES

Do not use the expression signgam∗exp(lgamma(x)) to compute g := Γ(x).  Instead use a program like this (in C):

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

Only after lgamma has returned can signgam be correct.  Note too that Γ(x) must overflow when x is large enough, underflow when −x is large enough, and spawn a division by zero when x is a nonpositive integer. 

DIAGNOSTICS

For very large arguments over/underflows will occur inside the lgamma routine. 

gamma returns a huge value for negative integer arguments. 

SEE ALSO

intro(3M)

BUGS

gamma should return a positive indication of error. 

Only in the UNIX math library for C was the name gamma ever attached to lnΓ.  Elsewhere, for instance in IBM’s FORTRAN library, the name GAMMA belongs to Γ and the name ALGAMA to lnΓ in single precision; in double the names are DGAMMA and DLGAMA.  Why should C be different? 

Sun Release 3.2  —  Last change: 14 March 1986

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