Amiga Unix — 68040 · 68060

Manual pages › Math library (3M)

gamma(3M)

log gamma function

From the original Amiga UNIX 2.1 manual. Some things it mentions may not be in this release.

NAME

gamma, lgamma - log gamma function

SYNOPSIS

cc [flag ...] file ...  -lm [library ...]

#include <math.h>

double gamma (double x);

double lgamma (double x);

extern int signgam;

DESCRIPTION

gamma and lgamma return

     ln(|G(x)|)

wherooG(x)       is defined as

     ^e-ttx-1dt

     0
The sign  of  G(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 G:

if ((y = gamma(x)) > LN_MAXDOUBLE)
     error();
y = signgam * exp(y);

where LN_MAXDOUBLE is the least value that causes exp to return a range error, and is defined in the values.h header file.

SEE ALSO

exp(3M), matherr(3M), values(5).

DIAGNOSTICS

For non-positive integer  arguments  HUGE  is  returned  and
errno  is  set  to EDOM.  A message indicating SING error is
printed on the standard error output.

If the correct value would overflow, gamma and lgamma return HUGE and set errno to ERANGE.

Except when the -Xc compilation option is used, these error-handling procedures may be changed with the function matherr. When the -Xa or -Xc compilation options are used, HUGE_VAL is returned instead of HUGE and no error messages are printed.