GAMMA(3M) SysV GAMMA(3M)
NAME
gamma, lgamma - log gamma function
SYNOPSIS
#include <math.h>
double gamma (x)
double x;
double lgamma (x)
double x;
extern int signgam;
DESCRIPTION
The gamma and lgamma functions return the logarithm of the absolute value
of the gamma of x, where the gamma of x is defined as:
$int from 0 to inf e sup { - t } t sup { x - 1 } dt$
The names lgamma and gamma are different names for the same function. The
sign of the gamma of x is stored in the external integer variable
signgam. The x argument cannot be a nonpositive integer. The gamma of x
is defined over the reals, except the nonpositive integers. Do not use
the expression
g = signgam * exp (lgamma (x))
to compute
g = gamma (x)
Instead, use the following sequence:
lg = lgamma (x);
g = signgam * exp (lg);
This is because the C language does not specify evaluation order, and
signgam is modified by the call to the lgamma function.
DIAGNOSTICS
For non-negative integer arguments HUGE_VAL is returned, and errno is set
to EDOM. If x is NaN, NaN is returned. A message indicating SING error
is printed on the standard error output.
If the correct value would overflow, HUGE_VAL is returned and errno is
set to ERANGE.
These error-handling procedures may be changed with the function
matherr(3M).
SEE ALSO
exp(3M isnan(3C) matherr(3M)