Stirling's Approximation

A fast-growing factorial gets guessed by one simple formula here. On a log scale, the two curves nearly coincide.

Factorials grow too fast to keep computing head-on. The approximation tracks that growth almost exactly. Its relative error shrinks as the terms grow. Roughly, it falls like 1 over 12 times the index. Where π enters is only sketched at the idea level.

For example, guess a tall 🏢 building's height by counting steps. The taller the building, the smaller the share of one step's error in the whole. That is why the approximation sharpens for large numbers.

n!≈2πn(ne)nn!\approx\sqrt{2\pi n}\left(\frac{n}{e}\right)^n

Examples & Exercises

Compute the relative error of Stirling's formula at n=10n = 10 and compare with 1120\frac{1}{120}. (A numerical check, not a proof.)

∣S(10)−10!∣10!≈0.008296≈1120\frac{|S(10)-10!|}{10!} \approx 0.008296 \approx \frac{1}{120}
n=10n = 10: the two curves overlap on the log scale.
Show hint
  1. 10!=362880010! = 3628800. S(10)=20π(10e)10≈3598695.62S(10) = \sqrt{20\pi}\left(\frac{10}{e}\right)^{10} \approx 3598695.62.

  2. The relative error =3628800−3598695.623628800≈0.008296= \frac{3628800-3598695.62}{3628800} \approx 0.008296.

  3. 112⋅10=1120≈0.008333\frac{1}{12\cdot 10} = \frac{1}{120} \approx 0.008333 — matching the claim. (This is a numerical check, not a proof of the error formula.)

Explain the picture comparing ln⁡(n!)=∑k=1nln⁡k\ln(n!) = \sum_{k=1}^{n}\ln k with ∫1nln⁡x dx\int_1^n \ln x\,dx. (Idea level.)

∑k=1nln⁡k≈∫1nln⁡x dx=nln⁡n−n+1\sum_{k=1}^{n}\ln k \approx \int_1^n \ln x\,dx = n\ln n - n + 1
The sum of the bars and the area under the curve are close.
Show hint
  1. ln⁡(n!)=∑k=1nln⁡k\ln(n!) = \sum_{k=1}^{n}\ln k is the total area of bars under the graph of y=ln⁡xy = \ln x.

  2. The integral ∫1nln⁡x dx=nln⁡n−n+1\int_1^n \ln x\,dx = n\ln n - n + 1 is the area under the curve — close to the bar sum.

  3. The gap grows like 12ln⁡(2πn)\frac{1}{2}\ln(2\pi n), and that correction produces the 2πn\sqrt{2\pi n}. The rigorous derivation is omitted — idea level.

Assuming Stirling's formula, derive (2nn)∼4nπn\binom{2n}{n} \sim \frac{4^n}{\sqrt{\pi n}}.

(2nn)=(2n)!(n!)2∼4πn (2n/e)2n2πn (n/e)2n=4nπn\binom{2n}{n} = \frac{(2n)!}{(n!)^2} \sim \frac{\sqrt{4\pi n}\,(2n/e)^{2n}}{2\pi n\,(n/e)^{2n}} = \frac{4^n}{\sqrt{\pi n}}
The central binomial coefficient is smaller than 4n4^n by πn\sqrt{\pi n}.
Show proof
  1. Stirling in the numerator: (2n)!≈4πn(2ne)2n(2n)! \approx \sqrt{4\pi n}\left(\frac{2n}{e}\right)^{2n}.

  2. Denominator: (n!)2≈2πn(ne)2n(n!)^2 \approx 2\pi n\left(\frac{n}{e}\right)^{2n}.

  3. First note asymptotic equivalence is preserved under squaring and division: for positive sequences, if An∼BnA_n \sim B_n and Cn∼DnC_n \sim D_n, write An=Bn(1+o(1))A_n = B_n(1 + o(1)) and Cn=Dn(1+o(1))C_n = D_n(1 + o(1)); since the relative errors tend to 00, An2∼Bn2A_n^2 \sim B_n^2 and AnCn∼BnDn\frac{A_n}{C_n} \sim \frac{B_n}{D_n}. So reading the ≈\approx's above as ∼\sim is legitimate.

  4. Dividing gives 4πn2πn⋅(2n)2nn2n=1πn⋅4n\frac{\sqrt{4\pi n}}{2\pi n}\cdot\frac{(2n)^{2n}}{n^{2n}} = \frac{1}{\sqrt{\pi n}}\cdot 4^n. (Stirling's formula itself is assumed.)

7. Series