logo

Simple Derivation of Stirling's Formula 📂Thermal Physics

Simple Derivation of Stirling's Formula

Formula

The following equation is called Stirling’s formula.

$$ \lim_{n \to \infty} {{n!} \over {e^{n \ln n - n} \sqrt{ 2 \pi n} }} = 1 $$

Explanation1

This approximation is useful for computing the factorial of large numbers. It is essential in fields such as thermodynamics and statistical mechanics, where a large number of molecules is assumed, and more simplified expressions such as

$$ \begin{align*} n! &\approx \sqrt{2\pi n}\left( \dfrac{n}{e} \right)^{n} \\[0.6em] \log_{2} n! &\approx n \log_{2} n - n \log_{2}e \\[0.6em] \ln n! &\approx n \ln n - n \end{align*} $$

are also used. The derivation below is somewhat lacking in analytical rigor, but it is sufficient if one only cares about the facts for the sake of applications.

See Also

Derivation2

Let us start from the gamma function $\displaystyle n! = \int_{0}^{\infty} x^{n} e^{-x} dx$. Setting $f(x) = n \ln x - x$, the following equation holds.

$$ e^{f(x)} = x^{n} e^{-x} $$

Since $\displaystyle {{df(x)} \over {dx}} = {{n } \over {x }} - 1$, $\displaystyle {{d^2 f(x)} \over {dx^2 }} = - {{n } \over {x^2 }}$, and $\displaystyle {{d^3 f(x)} \over {dx^3 }} = {{ 2n } \over {x^3 }}$, the Taylor expansion of $f$ is as follows.

$$ \begin{align*} f(x) =& f(n) + f '(n) (x-n) + {{1} \over {2!}} f ''(n) (x-n)^2 + {{1} \over {3!}} f^{(3)} (n) (x-n)^3 + \cdots \\ =& n \ln n - n + 0 \cdot (x-n) - {{1} \over {2}} {{n} \over{ n^2}} (x-n)^2 + {{1} \over {6}} {{2n} \over{ n^3}} (x-n)^3 + \cdots \\ =& n \ln n - n - {{ (x-n)^2 } \over{ 2n }} + {{ (x-n)^3 } \over{ 3 n^2 }} + \cdots \end{align*} $$

When $n$ is sufficiently large, the terms after $\displaystyle {{ (x-n)^2 } \over{ 2 n }}$ can be neglected since their denominators grow too fast. Therefore, we obtain the following result.

$$ f(x) \approx n \ln n - n - {{ (x-n)^2 } \over{ 2n }} $$

20181022\_163326.png

Moreover, if $n$ is sufficiently large, it makes little difference whether the Gaussian curve is integrated from $0$ to $\infty$ or from $-\infty$ to $\infty$. Consequently, for sufficiently large $n$, $$ n! = e^{n \ln n - n} \int_{0}^{\infty} e^{-(x-n)^2 / 2n + \cdots } dx \approx e^{n \ln n - n} \int_{-\infty}^{\infty} e^{-(x-n)^2 / 2n } dx $$ By the Gaussian integral, $\displaystyle \int_{-\infty}^{\infty} e^{-(x-n)^2 / 2n } dx = \sqrt{ 2 \pi n}$, so the following equation holds.

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

Taking the logarithm of both sides yields the equation below.

$$ \ln n! \approx n \ln n - n + \dfrac{1}{2}\ln 2\pi n $$

If $n$ is very large, the following approximation holds.

$$ \ln n! \approx n \ln n - n $$


  1. Stephen J. Blundell and Katherine M. Blundell, 열 물리학(Concepts in Thermal Physics, 이재우 역) (2nd Edition, 2014), p12 ↩︎

  2. Stephen J. Blundell and Katherine M. Blundell, 열 물리학(Concepts in Thermal Physics, 이재우 역) (2nd Edition, 2014), p591-593 ↩︎