Special Functions

Stirling's approximation

/ STUR-ling /

How big is 100! ? Multiplying it out is hopeless by hand, and even a calculator overflows. Stirling's approximation gives a clean closed-form estimate of the factorial (and of the gamma function) for large arguments, turning an intractable product into a simple expression built from n, e, and pi. It answers 'roughly how large, and how fast does it grow?' without ever performing the multiplication.

The leading form is n! is approximately equal to square root of (2 pi n) times (n/e)^n. Equivalently, the logarithm satisfies ln(n!) is approximately n ln n minus n plus (1/2) ln(2 pi n). This is an asymptotic statement: the ratio of the two sides tends to 1 as n grows, even though their difference does not vanish. The full Stirling series adds correction terms, n! is approximately square root of (2 pi n) (n/e)^n times (1 + 1/(12n) + 1/(288 n^2) + ...). That tail is a divergent asymptotic series — adding ever more terms eventually makes the estimate worse — yet truncating it at the right place gives spectacular accuracy.

Stirling is everywhere large factorials appear: statistical mechanics (the entropy of a gas uses ln(N!) for N around 10^23), combinatorics and the central limit theorem, information theory, and the analysis of algorithms. It is the prototype example used to introduce asymptotic analysis and Laplace's method, because the integral definition of the gamma function has a sharp peak that Laplace's method approximates to reproduce exactly the Stirling form.

For n = 10: the true value is 10! = 3628800, while square root of (2 pi times 10) times (10/e)^10 is approximately 3598696 — about 0.83% low, with the relative error shrinking like 1/(12n).

Even at the modest value n = 10, the leading Stirling formula is already accurate to under one percent.

The Stirling correction series is asymptotic and divergent: it is not a convergent power series, so you truncate it at the best term rather than summing it to the end.

Also called
Stirling's formula斯特林公式斯特靈公式