GAMMA(3M)
NAME
gamma, lgamma, signgam − log gamma function
SYNOPSIS
#include <math.h>
double gamma (x)
double x;
double lgamma (x)
double x;
extern int signgam;
DESCRIPTION
Gamma returns ln(|Γ( x)|), whereΓ( x) is defined as ∞∫0e−ttx−1dt. The sign of Γ( x)is returned in the external integer signgam. The argument x must not be a non-positive integer. (Gamma is defined over the reals excluding the non-positive integers).
The following C program fragment can be used to calculate Γ:
if ((y = gamma(x)) > LN_MAXDOUBLE)
error();
y = signgam ∗ exp(y);
where if y is greater than LN_MAXDOUBLE, as defined in the <values.h> header file, exp(3M) will return a range error.
ERRORS
Series 300
For non-positive integer arguments gamma returns HUGE_VAL and sets errno to EDOM. A message indicating SING error is printed on the standard error output.
If the correct value would overflow, gamma returns HUGE_VAL and sets errno to ERANGE.
Series 800 (/lib/libm.a)
For non-positive integer arguments, gamma returns HUGE_VAL and sets errno to EDOM. A message indicating SING error is printed on the standard error output.
If the correct value would overflow, gamma returns HUGE_VAL and sets errno to ERANGE.
Gamma returns NaN and sets errno to EDOM when x is NaN, or returns +INFINITY and sets errno to EDOM when x is ±INFINITY . A message indicating DOMAIN error is printed on the standard error output.
Series 800 (ANSI C /lib/libM.a)
No error messages are printed on the standard error output.
For non-positive integer arguments gamma returns HUGE_VAL and sets errno to EDOM. A message indicating SING error is printed on the standard error output.
If the correct value would overflow, gamma returns HUGE_VAL and sets errno to ERANGE.
Gamma returns NaN and sets errno to EDOM when x is NaN, or returns +INFINITY and sets errno to EDOM when x is ±INFINITY .
These error-handling procedures may be changed with the function matherr(3M).
SEE ALSO
exp(3M), isinf(3M), isnan(3M), matherr(3M), values(5).
STANDARDS CONFORMANCE
gamma: SVID2, XPG2, XPG3
signgam: SVID2, XPG2, XPG3
Hewlett-Packard Company — HP-UX Release 7.0: Sept 1989