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 Here g is a real constant that may be chosen arbitrarily subject to the restriction that Re(z+g+1/2) > 0.
If a fixed g is chosen, the coefficients can be calculated in advance and, thanks to partial fraction decomposition, the sum is recast into the following form: Thus computing the gamma function becomes a matter of evaluating only a small number of elementary functions and multiplying by stored constants.
The method is also implemented in the GNU Scientific Library, Boost, CPython and musl.
The following implementation in the Python programming language works for complex arguments and typically gives 13 correct decimal places.