Lanczos approximation: Difference between revisions

Content deleted Content added
ce
Line 14:
:<math>\Gamma(1-z) \; \Gamma(z) = {\pi \over \sin \pi z}.</math>
 
The series ''A'' is [[convergent series|convergent]], and may be truncated to obtain an approximation with the desired precision. By choosing an appropriate ''g'' (typically a small integer), only some 5–10 terms of the series are needed to compute the Gammagamma function with typical [[single precision|single]] or [[double precision|double]] [[floating point|floating-point]] precision. If a fixed ''g'' is chosen, the coefficients can be calculated in advance and the sum is recast into the following form:
 
:<math>A_g(z) = c_0 + \sum_{k=1}^{N} \frac{c_k}{z+k}</math>
 
Thus computing the gamma function becomes a matter of evaluating only a small number of [[elementary function]]s and multiplying by stored constants. The Lanczos approximation was popularized by ''[[Numerical Recipes]]'', according to which computing the Gammagamma function becomes "not much more difficult than other built-in functions that we take for granted, such as sin&nbsp;''x'' or ''e''<sup>''x''</sup>". The method is also implemented in the [[GNU Scientific Library]].
 
==Coefficients==