AdvancedMathLogGamma Method

Computes the natural logarithm of the Gamma function.

Definition

Namespace: Meta.Numerics.Functions
Assembly: Meta.Numerics (in Meta.Numerics.dll) Version: 4.2.0+6d77d64445f7d5d91b12e331399c4362ecb25333
C#
public static double LogGamma(
	double x
)

Parameters

x  Double
The argument, which must be positive.

Return Value

Double
The log Gamma function ln(Γ(x)).

Remarks

Mathematically, this this just the natural logarithm of the value of Γ(x), the function that is computed by Gamma(Double).

Because Γ(x) grows rapidly for increasing positive x, the function Gamma(Double) overflows even for moderatlely large arguments. This function provides accurate values of ln(Γ(x)) even for values for which Γ(x) would overflow. Additionally, Γ(x) ~ 1 near x ~ 1 and x ~ 2. This function provides fully accurate values of ln(Γ(x)) even for those values of x for which Γ(x) is indistinguishable from one or only distinguished by the last few digits.

If you need to compute a product or quotient of several Gamma functions, computing it by exponentiating a sum or difference of evaluations of this function will allow computation of the ratio even in cases for which an individual Gamma function overflows. However, if the value you want is either a Pochhammer(Double, Double) function (the ratio of two Gamma functions) or a Beta(Double, Double) function, it will be more efficient and more accurate to use those specific functions.

Exceptions

See Also