GAMMA(S) UNIX System V GAMMA(S)
Name
gamma - log gamma function
Syntax
#include <math.h>
double gamma (x)
double x;
extern int signgam;
Description
The gamma function returns ln(|gamma(x)|), where gamma(x) is
defined as the integral from zero to infinity of
-t x-1
e t dt. The sign of gamma(x) is returned in the external
integer signgam. The argument x may not be a non-positive
integer.
The following C program fragment might be used to calculate
gamma:
if ((y = gamma(x)) > LN_MAXDOUBLE)
error();
y = signgam * exp(y);
where LN_MAXDOUBLE is the least value that causes exp(S) to
return a range error, and is defined in the <values.h>
header file.
See Also
exp(S), matherr(S), values(M)
Diagnostics
For non-negative integer arguments HUGE is returned, and
errno is set to EDOM. A message indicating SING error is
printed on the standard error output [for example, gamma (-
5.0)].
If the correct value would overflow, gamma returns HUGE and
sets errno to ERANGE.
These error-handling procedures may be changed with the
function matherr(S).
Standards Conformance
gamma is conformant with:
AT&T SVID Issue 2, Select Code 307-127;
and The X/Open Portability Guide II of January 1987.
(printed 6/20/89)