Next: Factorials, Up: Gamma and Beta Functions
The Gamma function is defined by the following integral,
\Gamma(x) = \int_0^\infty dt t^{x-1} \exp(-t)
It is related to the factorial function by \Gamma(n)=(n-1)! for positive integer n. Further information on the Gamma function can be found in Abramowitz & Stegun, Chapter 6. The functions described in this section are declared in the header file gsl_sf_gamma.h.
These routines compute the Gamma function \Gamma(x), subject to x not being a negative integer. The function is computed using the real Lanczos method. The maximum value of x such that \Gamma(x) is not considered an overflow is given by the macro
GSL_SF_GAMMA_XMAX
and is 171.0.
These routines compute the logarithm of the Gamma function, \log(\Gamma(x)), subject to x not a being negative integer. For x<0 the real part of \log(\Gamma(x)) is returned, which is equivalent to \log(|\Gamma(x)|). The function is computed using the real Lanczos method.
This routine computes the sign of the gamma function and the logarithm of its magnitude, subject to x not being a negative integer. The function is computed using the real Lanczos method. The value of the gamma function can be reconstructed using the relation \Gamma(x) = sgn * \exp(resultlg).
These routines compute the regulated Gamma Function \Gamma^*(x) for x > 0. The regulated gamma function is given by,
\Gamma^*(x) = \Gamma(x)/(\sqrt{2\pi} x^{(x-1/2)} \exp(-x)) = (1 + (1/12x) + ...) for x \to \inftyand is a useful suggestion of Temme.
These routines compute the reciprocal of the gamma function, 1/\Gamma(x) using the real Lanczos method.
This routine computes \log(\Gamma(z)) for complex z=z_r+i z_i and z not a negative integer, using the complex Lanczos method. The returned parameters are lnr = \log|\Gamma(z)| and arg = \arg(\Gamma(z)) in (-\pi,\pi]. Note that the phase part (arg) is not well-determined when |z| is very large, due to inevitable roundoff in restricting to (-\pi,\pi]. This will result in a
GSL_ELOSS
error when it occurs. The absolute value part (lnr), however, never suffers from loss of precision.