TGAMMA 3CW "09 March 2006" "mathcw-1.00"

Table of contents


NAME

tgammaf, tgamma, tgammal, tgammaw, tgammaq, tgammall, tgammadf, tgammad, tgammadl, tgammadll - true Gamma function

SYNOPSIS

cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ]

#include <mathcw.h>

extern float tgammaf (float x);

extern double tgamma (double x);

extern long double tgammal (long double x);

extern __float80 tgammaw (__float80 x);

extern __float128 tgammaq (__float128 x);

extern long_long_double tgammall (long_long_double x);

extern decimal_float tgammadf (decimal_float x);

extern decimal_double tgammad (decimal_double x);

extern decimal_long_double tgammadl (decimal_long_double x);

extern decimal_long_long_double tgammadll (decimal_long_long_double x);

NB: Functions with prototypes containing underscores in type names may be available only with certain extended compilers.


DESCRIPTION

Compute the Gamma function, the generalized factorial function, defined by the integral
Gamma(x) = integral(t = 0:infinity) t**(x-1) exp(-t) dt
In traditional mathematical notation, Gamma is spelled as the uppercase Greek letter, and the lowercase Greek letter gamma refers either to the Euler constant, gamma = 0.57721566489... or when followed by two arguments, as in gamma(a,x), to the incomplete Gamma function, a function not currently provided by this library.

The Gamma function satisfies this simple recursion relation:

Gamma(x + 1) = x Gamma(x)
For positive integral arguments, the Gamma function is related to the factorial function by
Gamma(n + 1) = n! = n * (n - 1) * (n - 2) * ... * 1,

and

Gamma(1) = 0! = 1 (by definition).

This function was not standardized in the C language until the 1999 ISO C Standard, and because some historical implementations of the language had unfortunately used gamma(x) for the logarithm of the Gamma function, the C99 function was named tgamma(x) (for true Gamma), rather than Gamma(x), because Standard C library functions must be defined with only lowercase names.

Because tgamma(x) grows so rapidly with increasing x that it soon reaches the overflow limit, the log of its absolute value is representable for arguments almost up to the overflow limit, and is available as the companion functions lgamma(x) and lgamma_r(x,&sign). However, there is mathematically-unavoidable accuracy loss when tgamma(x) is computed from exp(lgamma(x)), so you should avoid the logarithmic form unless you really need large arguments that would cause overflow in tgamma(x).


RETURN VALUES

Return the true Gamma function of the argument.

ERRORS

If the argument is a NaN, return that argument and set errno to EDOM. If the argument is negative integer, return +Infinity and set errno to EDOM. If the argument is +Infinity or -Infinity, return that argument and set errno to ERANGE. If the argument is zero, return an infinity of the same sign as the zero, and set errno to EDOM.

SEE ALSO

lgamma(3CW), lgamma_r(3CW), psi(3CW), psiln(3CW).