Is there an intuitive explanation for the occurrence of e and pi in Stirling's approximation? - $n!\approx \sqrt{2\pi n} (n/e)^n$ Is there an intuitive explanation for the occurrence of e and pi in Stirling's approximation? 
$$n!\approx \frac{n^n}{e^n}\sqrt{2\pi n}$$
Any help would be much appreciated. 
 A: Is explained based on the gamma function 
$$n! = \Gamma(n +1) = \int_0^{\infty} t^ne^{-t}\,dt$$
$$\log(t^ne^{-t}) = n \log(t) - t = n\log(n + \epsilon) - (n + \epsilon)$$
Let
$$\log(n + \epsilon) = \log\left(1 + \frac{\epsilon}n\right)=\log n + \log\left(1 + \frac{\epsilon}n\right)$$
For very large $n$, we can guarantee that $\frac{\epsilon}n < 1$

Through Taylor Series we know that:
$$\log\left(1 + \frac{\epsilon}n\right) = \sum_{k=1}^\infty\frac{(-1)^{k+1}}{k} \frac{\epsilon^k}{n^k}$$
So
$$n\log(n + \epsilon) - (n + \epsilon ) = n\left( \log n + \sum_{k=1}^\infty\frac{(-1)^{k+1}}{k} \frac{\epsilon^k}{n^k}  \right) - n - \epsilon$$
$$n\log n - n + \sum_{k=1}^\infty\frac{(-1)^{k+1}}{k} \frac{\epsilon^k}{n^k}-\epsilon$$
$$n\log n - n + \sum_{k=1}^\infty\frac{(-1)^{k+1}}{k} \frac{\epsilon^k}{n^k}$$
$$n\log n - n - \frac{\epsilon^{2}}{2n} +  \frac{\epsilon^{3}}{3n}- \frac{\epsilon^{4}}{4n} \dots$$
In this way
$$\log(t^n e^{-t})\approx n\log n - n - \frac{\epsilon^2}{2n}\quad\quad\quad\quad  t^ne^{-t} \approx \frac{n^n}{e^n}e^{-\frac{\epsilon^2}{2n}}$$
$$n! \approx \int_0^{\infty} t^ne^{-t}\,dt \approx \int^\infty_{-n}\frac{n^n}{e^n}e^{-\frac{\epsilon^2}{2n}}\,d\epsilon$$
knowing that $\sqrt{\frac{\pi}{p}} = \int_{-\infty}^{\infty} e^{-px^2}\,dx$ we get

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

You can see this video  
A: We have the identity $n!=\Gamma(n+1)=\int_0^\infty t^n e^{-t} dt$. From this point of view, the point of Stirling's approximation is that $t^n e^{-t}$ attains its maximum at $t=n$, so we expect that this is where the main contribution to the integral comes from. So we select a function that we know how to integrate which agrees very nicely with the integrand near $t=n$ and has suitable decay far away from $t=n$.
Obviously we cannot just do a Taylor approximation directly because then there is no decay far away. So we isolate the "manageable" part first. We do this by taking the logarithm and then adding and subtracting $n \log(n) -n$. Thus:
$$\log(t^n e^{-t})=n \log(n) - n + n \log(t/n) - (t-n).$$
Then we Taylor expand the last two terms to leading order at $t=n$. The result is $-\frac{(t-n)^2}{2n}$ (there is a cancellation that occurs, which is essentially because $t=n$ was a maximum in the first place). This gives the approximations
$$t^n e^{-t} \approx \frac{n^n}{e^n} e^{-\frac{(t-n)^2}{2n}} \\
n! \approx \frac{n^n}{e^n} \int_0^\infty e^{-\frac{(t-n)^2}{2n}} dt. $$
You can now look up the "Gaussian integral" to see how to exactly integrate $\int_{-\infty}^\infty e^{-\frac{(t-n)^2}{2n}} dt$, which serves as an approximation of $\int_0^\infty e^{-\frac{(t-n)^2}{2n}} dt$ for large $n$ (intuitively because the mean is $\sqrt{n} \gg 1$ standard deviations away from $0$).
