lnGamma

Computes the natural logarithm of the gamma function at x.

The gamma function generalizes the factorial to real numbers: for positive integers, gamma(n) equals (n-1)!. The logarithmic form is used to avoid overflow for large arguments. Uses the Lanczos approximation with a reflection formula for values less than 0.5.

Example:

lnGamma(5.0) // 3.1780... (ln(24), since Gamma(5) = 4! = 24)
lnGamma(0.5) // 0.5723... (ln(sqrt(pi)))

Return

the natural logarithm of gamma(x).

Parameters

x

the point at which to evaluate. Must be positive.