LGAMMA(3)

NAME
lgamma, lgammaf, gamma, gammaf - log gamma functions, gamma functions

SYNOPSIS
#include <math.h>
extern int
signgam;

double
lgamma(double x);
float
lgammaf(float x);
double
gamma(double x);
float
gamma(float x);

DESCRIPTION
lgamma(x) and lgammaf(x) returns ln|Γ(x)|.

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

gamma(x) and gammaf(x) return Γ(x), with no effect on signgam.

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() or lgammaf() has returned can signgam be correct.

For arguments in its range, gamma() and gammaf() is preferred, as for positive arguments it is accurate to within one unit in the last place. Exponentiation of lgamma() will lose up to 10 significant bits.

RETURN VALUES
gamma(), gammaf(), lgamma(), and lgammaf() return appropriate values unless an argument is out of range. Overflow will occur for sufficiently large positive values, and non-positive integers. On the VAX, the reserved operator is returned, and errno is set to ERANGE For large non-integer negative values, gamma() will underflow.

SEE ALSO
math(3), infnan(3)

HISTORY
The lgamma function appeared in 4.3BSD. The gamma function appeared in 4.4BSD. The name gamma() was originally dedicated to the lgamma() function, so some old code may no longer be compatible.