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

Table of contents


NAME

gamibf, gamib, gamibl, gamibw, gamibq, gamibll, gamibdf, gamibd, gamibdl, gamibdll - ordinary and complementary incomplete gamma functions

SYNOPSIS

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

#include <mathcw.h>

extern void gamibf (float result[2], float a, float x);

extern void gamib (double result[2], double a, double x);

extern void gamibl (long double result[2], long double a, long double x);

extern void gamibw (__float80 result[2], __float80 a, __float80 x);

extern void gamibq (__float128 result[2], __float128 a, __float128 x);

extern void gamibll (long_long_double result[2], long_long_double a, long_long_double x);

extern void gamibdf (decimal_float result[2], decimal_float a, decimal_float x);

extern void gamibd (decimal_double result[2], decimal_double a, decimal_double x);

extern void gamibdl (decimal_long_double result[2], decimal_long_double a, decimal_long_double x);

extern void gamibdll (decimal_long_long_double result[2], decimal_long_long_double a,
                      decimal_long_long_double x);

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


DESCRIPTION

Compute auxiliary functions related to the ordinary and complementary incomplete gamma functions of the arguments.

The ordinary and complementary incomplete gamma functions are defined by

gamma(a,x) = integral(t = 0 to x) t**(a-1) exp(-t) dt,
GAMMA(a,x) = integral(t = x to Infinity) t**(a-1) exp(-t) dt,
where x is in [0, +Infinity], a is in [-Infinity, +Infinity]. They are related to the generalization of the factorial function, the complete gamma function
GAMMA(a) = integral(t = 0 to Infinity) t**(a-1) exp(-t) dt,
like this:
gamma(a,x) + GAMMA(a,x) = GAMMA(a).

Mathematical notation conventionally uses a lowercase Greek letter for the ordinary incomplete function, and an uppercase Greek letter for both the complementary incomplete function, and the complete function. The number of arguments distinguishes between the two.

The C programming language family uses tgamma(a) (true gamma) for the complete function, and lgamma(a) for the logarithm of the absolute value of the complete function.

For arguments of large magnitude, and for a near zero, the gamma functions are subject to floating-point overflow and underflow, so it is conventional to work with scaled functions defined by

g(a,x) = gamma(a,x) / GAMMA(a),
G(a,x) = GAMMA(a,x) / GAMMA(a)    (a > 0)
G(a,x) = x**(-a) * exp(x) * GAMMA(a,x) / GAMMA(a)    (a <= 0)
For a > 0, but not for zero or negative a, these functions are positive and satisfy
g(a,x) + G(a,x) = 1,
so both lie in [0,1].

gami(a,x) computes g(a,x), gamic(a,x) computes G(a,x), and gamib(result,a,x) computes both the ordinary and complementary incomplete gamma functions, since the two are often needed together. Computationally, the single-result functions are just convenient wrappers around calls to gamib().


SPECIAL VALUES

The following limits of the scaled functions hold:
G(a, 0) = 1    g(a, 0) = 0    if a > 0,
G(a, 0) = Infinity    g(a, 0) = 1    if a = 0,
G(a, 0) = 1/a    g(a, 0) = Infinity    if a < 0,
The case where both arguments are zero is indeterminate, and the stated values are what the code produces. In addition, since the complete gamma function is infinite at negative integer arguments, the ordinary incomplete gamma function and the scaled function g(a, x), are as well. However, G(a, x) is well-defined when its first argument is a negative integer.

RELATION TO OTHER FUNCTIONS

The gamma functions have these relationships to the chi-square probability distribution function, the ordinary and complementary error functions, and the exponential integral, when x >= 0:
chisq(nu,x) = gamma(nu/2, x/2) / GAMMA(nu/2),
erf(x) = g(0.5, x),
erfc(x) = G(0.5, x),
Ei(a,x) = x**(a - 1) * GAMMA(1 - a) * G(1 - a, x)    (a < 1),
Ei(a,x) = x**(1 - a) * exp(-&x) * G(1 - a, x)    (a >= 1).
The error functions are likely to be computed more accurately with their own code than via the incomplete gamma functions.

RETURN VALUES

If either a or x is a NaN, return that NaN in both components of the result vector. If x is negative, return a quiet NaN in both components. If x is Infinity, return 1 and 0 in the result vector. Otherwise, return the value of g(a,x) in result[0] and the value of G(a,x) in result[1].

ERRORS

If x is negative, set errno to EDOM. If either argument is a NaN, set errno to EDOM. \"=====================================================================

SEE ALSO

chisq(3CW), erf(3CW), erfc(3CW), exp(3CW), gami(3CW), gamic(3CW), ichisq(3CW), lgamma(3CW), pow(3CW), tgamma(3CW).