# A proof of Stirling's Formula

I need to gain understanding of a proof of Stirling's formula. I have read through Tim Gowers' and Terence Tao's but I'm struggling to follow them. How rigorous is this proof, if at all? Thank you.

$$\Gamma(n+1)=n!=\int_0^\infty t^n\mathrm{e}^{-t}\,\mathrm{d}t$$

Take the log of the integrand:

$$\mathrm{log}(t^n\mathrm{e}^{-t})=n\mathrm{log}(t)-t$$

Let $t=n+\epsilon$, then:

\begin{aligned} \mathrm{log}(t^n\mathrm{e}^{-t})&=n\mathrm{log}(n+\epsilon)-(n+\epsilon) \\ &=n\mathrm{log}\left(n\left(1+\frac{\epsilon}{n}\right)\right)-(n+\epsilon) \\ &=n\left(\mathrm{log}(n)+\mathrm{log}\left(1+\frac{\epsilon}{n}\right)\right)-(n+\epsilon) \\ \end{aligned}

For very large $n$, $\tfrac{\epsilon}{n}<1$

Taylors series for $\mathrm{log}(1+x)$ is:

\begin{aligned} \mathrm{log}(1+x) &= x - \frac{x^2}{2}+\frac{x^3}{3}-\frac{x^4}{4}\pm \ldots \\ \implies \mathrm{log}(1+\tfrac{\epsilon}{n})&=\sum_{k=1}^{\infty} \frac{{(-1)}^{k+1}}{k} \frac{\epsilon^{k}}{n^k} \end{aligned}

\begin{aligned} \therefore \,\,\, \mathrm{log}(t^n\mathrm{e}^{-t})&=n\Bigg(\mathrm{log}(n)+\sum_{k=1}^{\infty} \frac{{(-1)}^{k+1}}{k} \frac{\epsilon^{k}}{n^k}\Bigg)-n-\epsilon \\ &=n\mathrm{log}(n)-n+\sum_{k=1}^{\infty} \frac{{(-1)}^{k+1}}{k} \frac{\epsilon^{k}}{n^{k-1}} \\ &=n\mathrm{log}(n)-n-\frac{\epsilon^2}{2n}+\frac{\epsilon^{3}}{3n^{2}}-\frac{\epsilon^{4}}{4n^{3}} \end{aligned}

As this is only an approximation, take only the first term in the series,

\begin{aligned} \therefore \,\,\, \mathrm{log}(t^n\mathrm{e}^{-t}) &\approx n\mathrm{log}(n)-n-\frac{\epsilon^2}{2n} \\ \implies t^n\mathrm{e}^{-t} &\approx \frac{n^n}{\mathrm{e}^n}\mathrm{e}^{-\frac{\epsilon^2}{2n}} \end{aligned}

Then putting it into our original integral:

$$n!=\int_0^\infty t^n\mathrm{e}^{-t}\,\mathrm{d}t=\int_{-n}^\infty \frac{n^n}{\mathrm{e}^n}\mathrm{e}^{-\frac{\epsilon^2}{2n}}{d}\epsilon$$

As $\int_0^\infty \mathrm{e}^{-px^2}\,\mathrm{d}x=\sqrt{\frac{\pi}{p}}$

$$n!\approx n^n\mathrm{e}^{-n}\sqrt{2\pi n}$$

• I don't like how they say "for very large n, $\epsilon/n < 1$" then proceed to fix $n$ and integrate $\epsilon$ up to infinity. – user58512 Mar 12 '13 at 13:01
• Take $\epsilon$ consistently small wrt $n$, say $\epsilon = O(n^{1/2})$. – marty cohen Mar 13 '13 at 3:19

$$\log N! = \sum_{n=1}^N \log n = \sum_{n=1}^N \sum_{m=1}^n \bigg( \log m - \log (m-1) \bigg) = \sum_{n=1}^N \sum_{m=1}^n - \log \bigg(1 - \frac{1}{m} \bigg)$$
Then we can use the identity $\log (1+x) \approx x$ to obtain a Harmonic series:
$$\sum_{n=1}^N \sum_{m=1}^n - \log \bigg(1 - \frac{1}{m} \bigg) \approx \sum_{n=1}^N \sum_{m=1}^n \frac{1}{m} = \sum_{m=1}^N \frac{N-m}{m} = \sum_{m=1}^N \left( N \cdot \frac{1}{m}- 1 \right)\approx N \log N - N$$