HP C/iX Library Reference Manual (30026-90004)

190 Chapter5
HP C/iX Library Function Descriptions
gamma
gamma
Returns the log gamma of the input value.
Syntax
#include <math.h>
double gamma (double
x
);
extern int signgam;
Parameters
x
A real number.
Return Values
n A real number giving the natural log of the absolute value of the gamma of
x
.
HUGE Indicates one of the following:
The parameter
x
is a non-positive integer, and errno is set to EDOM. A
message indicating SING error is printed on the standard error output.
An overflow condition has occurred, and errno is set to ERANGE.
Description
gamma returns:
ln( | gamma(
x
)|)
where:
gamma(
x
)
is defined as:
Figure 5-2.
The sign of gamma(
x
) is returned in the external integer signgam.
The argument
x
must be greater than or equal to zero. (The gamma function is defined over
the reals excluding the non-positive integers.)
The following C program fragment can be used to calculate gamma:
if ((
y
= gamma(
x
)) > LN_MAXDOUBLE)
error();
e
-t
t
x-1
dt
o