NAME
lgamma
, lgammaf
,
lgammal
, lgamma_r
,
lgammaf_r
, lgammal_r
,
tgamma
, tgammaf
,
tgammal
, gamma
,
gammaf
—
log gamma functions
SYNOPSIS
#include
<math.h>
extern int signgam;
double
lgamma
(double
x);
float
lgammaf
(float
x);
long double
lgammal
(long
double x);
double
lgamma_r
(double
x, int
*signgamp);
float
lgammaf_r
(float
x, int
*signgamp);
long double
lgammal_r
(long
double x, int
*signgamp);
double
tgamma
(double
x);
float
tgammaf
(float
x);
long double
tgammal
(long
double x);
DESCRIPTION
lgamma
(x)
returns ln|Γ(x)| where
for x < 1.
The external integer signgam
returns the sign of Γ(x). The
lgammaf
()
function is a single precision version of lgamma
().
The
lgammal
()
function is an extended precision version of
lgamma
().
The
lgamma_r
(),
lgammaf_r
(),
and
lgammal_r
()
functions are thread-safe versions of lgamma
(),
lgammaf
(), and lgammal
()
that return the sign via the signgamp pointer instead
of modifying signgam.
The
tgamma
(x),
tgammaf
(x)
and
tgammal
(x)
functions 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
()
has returned can signgam be correct.
For arguments in its range,
tgamma
()
is preferred, as for positive arguments it is accurate to within one unit in
the last place.
RETURN VALUES
lgamma
() returns appropriate values unless
an argument is out of range. Overflow will occur for sufficiently large
positive values, and non-positive integers. For large non-integer negative
values, tgamma
() will underflow.
STANDARDS
The lgamma
(),
lgammaf
(), lgammal
(),
tgamma
(), tgammaf
(), and
tgammal
() functions are expected to conform to
ISO/IEC 9899:1999
(“ISO C99”).
The lgamma_r
(),
lgammaf_r
(), and lgammal_r
()
functions are BSD extensions.
gamma
() and
gammaf
() are deprecated aliases for
lgamma
() and lgammaf
(),
respectively.
HISTORY
A gamma
() function first appeared in
Version 5 AT&T UNIX. The
lgamma
() function first appeared in
4.3BSD. The tgamma
()
function first appeared in OpenBSD 4.4, and is based
on the gamma
() function that appeared in
4.4BSD as a function to compute Γ(x).