Sunday, May 10, 2020

A quick proof of Stirling's Formula

Proposition. We have $$ \lim_{n\to\infty} \frac{n!}{n^{n+\frac{1}{2}}e^{-n}} = \sqrt{2\pi}. $$

Proof. Using the integral representation of the factorial, $$ \frac{n!}{n^{n+\frac{1}{2}}e^{-n}} = \sqrt{n}e^n \int_{0}^{\infty} x^n e^{-nx} \, \mathrm{d}x. $$ Substituting $x=1+\frac{u}{\sqrt{n}}$ and writing $x_+:=\max\{0,x\}$ for the positive part of $x$, $$=\int_{-\infty}^{\infty} \left(1+\frac{u}{\sqrt{n}}\right)_{+}^n e^{-\sqrt{n}u} \, \mathrm{d}u.$$ Using basic calculus, it is easy to prove that $\log(1+x) \leq x - \frac{x^2}{2(1+x_+)}$ holds for all $x > -1$. From this, we get $$ \left(1+\frac{u}{\sqrt{n}}\right)_{+}^n e^{-\sqrt{n}u} \leq e^{-\frac{u^2}{2(1+u_+)}} $$ holds for all $n\geq 1$ and for all $u\in\mathbb{R}$. So by the dominated convergence theorem, $$ \lim_{n\to\infty} \frac{n!}{n^{n+\frac{1}{2}}e^{-n}} =\int_{-\infty}^{\infty} \lim_{n\to\infty} \left(1+\frac{u}{\sqrt{n}}\right)_{+}^n e^{-\sqrt{n}u} \, \mathrm{d}u =\int_{-\infty}^{\infty} e^{-\frac{u^2}{2}} \, \mathrm{d}u =\sqrt{2\pi}.$$