Main index | Section 3 | Options |

Math Library (libm, -lm)

#include <math.h>

` double`
`lgamma(double x)`;

` double`
`lgamma_r(double x, int *signgamp)`;

` float`
`lgammaf(float x)`;

` float`
`lgammaf_r(float x, int *signgamp)`;

` long double`
`lgammal(long double x)`;

` long double`
`lgammal_r(long double x, int *signgamp)`;

` double`
`gamma(double x)`;

` double`
`gamma_r(double x, int *signgamp)`;

` float`
`gammaf(float x)`;

` float`
`gammaf_r(float x, int *signgamp)`;

` long double`
`tgamma(double x)`;

` float`
`tgammaf(float x)`;

` long double`
`tgammal(long double x)`;

Γ(x) = ∫return ln|Γ(x)|. The external integer signgam returns the sign of Γ(x)._{}_{0}_{}^{}^{∞}^{}t^{}^{x-1}^{}e^{}^{-t}^{}dt for x > 0 and Γ(x) = π/(Γ(1-x)sin(πx)) for x < 1.

`lgamma_r(x, signgamp)`,
`lgammaf_r(x, signgamp)`,
and
`lgammal_r(x, signgamp)`
provide the same functionality as
`lgamma(x)`,
`lgammaf(x)`,
and
`lgammal(x)`,
but the caller must provide an integer to store the sign of Γ(x).

The
`tgamma(x)`,
`tgammaf(x)`,
and
`tgammal(x)`
functions return Γ(x), with no effect on
signgam.

`gamma()`,
`gammaf()`,
`gamma_r()`,
and
`gammaf_r()`
are deprecated aliases for
`lgamma()`,
`lgammaf()`,
`lgamma_r()`,
and
`lgammaf_r()`,
respectively.

Do not use the expression
"`signgam*exp(lgamma(x))`"
to compute g := Γ(x).
Instead use a program like this (in C):

lg = lgamma(x); g = signgam*exp(lg);

Only after
`lgamma()`
or
`lgammaf()`
has returned can signgam be correct.

For arguments in its range,
`tgamma()`
is preferred, as for positive arguments
it is accurate to within one unit in the last place.
Exponentiation of
`lgamma()`
will lose up to 10 significant bits.

To conform with newer C/C++ standards, a stub implementation for
**tgammal**
was committed to the math library, where
**tgammal**
is mapped to
**tgamma**.
Thus, the numerical accuracy is at most that of the 53-bit double
precision implementation.

The
`lgamma()`,
`lgammaf()`,
`lgammal()`,
`tgamma()`,
`tgammaf()`,
and
`tgammal()`
functions are expected to conform to
ISO/IEC 9899:1999 ("ISO C99").

The
`lgamma()`
function appeared in
*BSD 4.3 .*
The
`gamma()`
function appeared in
*BSD 4.4*
as a function which computed Γ(x).
This version was used in
FreeBSD 1.1 .
The name
`gamma()`
was originally dedicated to the
`lgamma()`
function,
and that usage was restored by switching to Sun's fdlibm in
FreeBSD 1.1.5 .
The
`tgamma()`
function appeared in
FreeBSD 5.0 .

LGAMMA (3) | December 8, 2017 |

Main index | Section 3 | Options |

Please direct any comments about this manual page service to Ben Bullock. Privacy policy.

“ | Today, the Unix equivalent of a power drill would have 20 dials and switches, come with a nonstandard plug, require the user to hand-wind the motor coil, and not accept 3/8" or 7/8" drill bits (though this would be documented in the BUGS section of its instruction manual). | ” |

— The Unix Haters' handbook |