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.
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.Gamma(x) = integral(t = 0:infinity) t**(x-1) exp(-t) dt
The Gamma function satisfies this simple recursion relation:
For positive integral arguments, the Gamma function is related to the factorial function byGamma(x + 1) = x Gamma(x)
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).