Name
lgamma, lgamma_r, lgammaf, lgammal, lgammaf_r
gamma, gamma_r, gammaf, gammal, gammaf_r
- log gamma function
Library
libm.lib
Synopsis
|
double
lgamma (double x);
|
|
double
lgamma_r (double x, int *signgamp);
|
|
long double
lgammal (long double x);
|
|
float
lgammaf_r (float x, int *signgamp);
|
|
double
gamma_r (double x, int *signgamp);
|
|
long double
gammal (long double x);
|
|
float
gammaf_r (float x, int *signgamp);
|
Return values
gamma,
gamma_r,
gammaf,
gammaf_r,
lgamma,
lgamma_r,
lgammaf,
and
lgammaf_r
return appropriate values unless an argument is out of range.
Overflow will occur for sufficiently large positive values, and
non-positive integers.
For large non-integer negative values,
tgamma
will underflow.
Detailed description
lgamma (x);
and
lgammaf (x);
return ln||_(x)| where
|_(x) = I00oo0 tx-10 e-t0 dt for x > 0 and
|_(x) = pi/(|_(1-x)sin(pix)) for x < 1.
return ln||_(x)|.
The external integer
signgam
returns the sign of |_(x).
lgamma_r (x, signgamp);
and
lgammaf_r (x, signgamp);
provide the same functionality as
lgamma (x);
and
lgammaf (x);
but the caller must provide an integer to store the sign of |_(x).
gamma,
gammaf,
gamma_r,
and
gammaf_r
are deprecated aliases for
lgamma,
lgammaf,
lgamma_r,
and
lgammaf_r,
respectively.
lgammal (and);
gammal (are, just, alias, to, the, functions);
lgamma (and);
gamma
respectively.
Idiosyncrasies
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.
Examples
#include <math.h>
int main( void )
{
double x1 = 0.0, y;
y = lgamma( 0.0 );
printf( "lgamma(%f) = %f and signgam = %d\n", x1, signgam, y );
y = lgammaf( 0.0 );
printf( "lgammaf(%f) = %f and signgam = %d\n", x1, signgam, y );
y = lgammal( 0.0 );
printf( "lgammal(%f) = %f and signgam = %d\n", x1, signgam, y );
y = gamma( 0.0 );
printf( "gamma(%f) = %f and signgam = %d\n", x1, signgam, y );
y = gammaf( 0.0 );
printf( "gammaf(%f) = %f and signgam = %d\n", x1, signgam, y );
y = gammal( 0.0 );
printf( "gammal(%f) = %f and signgam = %d\n", x1, signgam, y );
}
Output
lgamma ( 0.0) = Inf and signgam = 1
lgammaf( 0.0 ) = Inf and signgam = 1
lgammal( 0.0 ) = Inf and signgam = 1
gamma ( 0.0 ) = Inf and signgam = 1
gammaf( 0.0 ) = Inf and signgam = 1
gammal( 0.0 ) = Inf and signgam = 1
See also
math
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia
|
|