# Stirling's approximation

We want to derive here Stirling's approximation, i.e. we want to show that for large $n$ we have:

$n!\sim {\sqrt {2\pi n}}\left({\frac {n}{e}}\right)^{n}$ We start by writing $n!$ with Euler's $\Gamma$ function:

$n!=\int _{0}^{\infty }t^{n}e^{-t}dt$ Changing variable to $s=t/n$ we get:
$n!=\int _{0}^{\infty }s^{n}n^{n}e^{-sn}nds=\int _{0}^{\infty }s^{n}e^{-sn}n^{n+1}ds$ which we rewrite as:
$n!=\int _{0}^{\infty }e^{-sn+n\ln s+(n+1)\ln n}ds=e^{(n+1)\ln n}\int _{0}^{\infty }e^{n(\ln s-s)}ds$ The last one is an integral in the form of those studied in the appendix The saddle point approximation; using the notation shown there we have $f(s)=\ln s-s$ and its maximum is at $s=1$ . Since $f''(1)=-1$ , we get:
$n!\sim e^{(n+1)\ln n}{\sqrt {\frac {2\pi }{n\cdot |-1|}}}e^{-n}=n^{n}n{\sqrt {\frac {2\pi }{n}}}e^{-n}={\sqrt {2\pi n}}\left({\frac {n}{e}}\right)^{n}$ Therefore:
$n!\sim {\sqrt {2\pi n}}\left({\frac {n}{e}}\right)^{n}$ Taking the logarithm we find another famous expression for Stirling's approximation:

$\ln n!\sim n\ln n-n+{\frac {1}{2}}\ln(2\pi n)$ 