GAMMA(3m,L) AIX Technical Reference GAMMA(3m,L) ------------------------------------------------------------------------------- gamma, lgamma PURPOSE Computes the logarithm of the gamma function. LIBRARY Math Library (libm.a) SYNTAX #include extern int signgam; double gamma (x) double x; double lgamma (x) double x; DESCRIPTION The gamma subroutine returns ln(|Gamma(x)|) and lgamma returns lnGamma(x), where Gamma(x) is defined as: +-----------------------------------------------------------------------------+ | This figure cannot be displayed properly on the screen. | | Please refer to the printed book. | +-----------------------------------------------------------------------------+ The sign of Gamma(x) is stored in the external integer variable signgam. The x parameter cannot be a nonpositive integer. If the x parameter is a nonpositive integer, gamma and lgamma return HUGE, sets errno to EDOM, and writes a DOMAIN error message to standard error. If the correct value overflows, gamma and lgamma return HUGE and sets errno to ERANGE. You can change the error handling procedures with the matherr subroutine. EXAMPLES The following C program fragment calculates Gamma("x") and stores the result in "y": Processed November 7, 1990 GAMMA(3m,L) 1 GAMMA(3m,L) AIX Technical Reference GAMMA(3m,L) errno = 0; y = gamma(x); if (errno == 0) y = signgam * exp(y); else perror("Error in gamma function"); ERROR CONDITIONS The gamma and lgamma subroutines fail if one or more of the following is true: EDOM The value of x is a non-positive integer or NaN. ERANGE The value to be returned would have caused overflow. RELATED INFORMATION In this book: "matherr" and "cbrt, exp, expm1, log, log10, log1p, pow, sqrt." Processed November 7, 1990 GAMMA(3m,L) 2