IMSL C# Numerical Library

Sfun.Gamma Method 

Returns the Gamma function of a double.

public static double Gamma(
   double x
);

Parameters

x
A double value.

Return Value

A double value specifying the Gamma function of x. If x is a negative integer, the result is NaN.

Remarks

The Gamma function, \Gamma (x), is defined to be

\Gamma \left( x \right) = \int_0^\infty 
            {t^{x - 1} } e^{ - t} dt \,\,\,\, for \, x \gt 0

For x \lt 0, the above definition is extended by analytic continuation.

The Gamma function is not defined for integers less than or equal to zero. Also, the argument x must be greater than -170.56 so that \Gamma (x) does not underflow, and x must be less than 171.64 so that \Gamma (x) does not overflow. The underflow limit occurs first for arguments that are close to large negative half integers. Even though other arguments away from these half integers may yield machine-representable values of \Gamma (x), such arguments are considered illegal. Users who need such values should use the Log Gamma. Finally, the argument should not be so close to a negative integer that the result is less accurate than half precision.

Plot of Gamma(x)

See Also

Sfun Class | Imsl.Math Namespace | Example