Lanczos approximation is a method for computing the gamma function numerically, published by Cornelius Lanczos in 1964. It is a practical alternative to the more popular Stirling's approximation for calculating the gamma function with fixed precision.
The Lanczos approximation consists of the formula:
for the gamma function, with
The p coefficients are given by:
where C represents the (n, m)th element of the matrix of coefficients for the Chebyshev polynomials.
as equal to:
Log gamma is the following formula:
If a fixed g is chosen, the coefficients can be calculated in advance and the sum is recast into the following form:
Refer to Ag table.
Digamma is the following formula:
The multiplier of p is calculated from the following formula:
N = 1:
N = 2:
N = 3:
N > 3:
Refer to r table.
(Quote: wikipedia)