info prev up next book cdrom email home

Stirling's Approximation

Stirling's approximation gives an approximate value for the Factorial function $n!$ or the Gamma Function $\Gamma(n)$ for $n\gg 1$. The approximation can most simply be derived for $n$ an Integer by approximating the sum over the terms of the Factorial with an Integral, so that

$\displaystyle \ln n!$ $\textstyle =$ $\displaystyle \ln 1+\ln 2+\ldots+\ln n= \sum_{k=1}^n \ln k \approx \int_1^n \ln x\,dx$  
  $\textstyle =$ $\displaystyle [x\ln x-x]^n_1 = n\ln n-n+1 \approx n\ln n-n.$ (1)

The equation can also be derived using the integral definition of the Factorial,
\begin{displaymath}
n!=\int_0^\infty e^{-x} x^n\,dx.
\end{displaymath} (2)

Note that the derivative of the Logarithm of the integrand can be written
\begin{displaymath}
{d\over dx} \ln(e^{-x}x^n) = {d\over dx} (n\ln x-x) = {n\over x}-1.
\end{displaymath} (3)

The integrand is sharply peaked with the contribution important only near $x=n$. Therefore, let $x\equiv n+\xi$ where $\xi\ll n$, and write
\begin{displaymath}
\ln(x^n e^{-x})=n\ln x-x=n\ln(n+\xi)-(n+\xi).
\end{displaymath} (4)

Now,
$\displaystyle \ln(n+\xi)$ $\textstyle =$ $\displaystyle \ln\left[{n\left({1+{\xi\over n}}\right)}\right]= \ln n+\ln\left({1+{\xi\over n}}\right)$  
  $\textstyle =$ $\displaystyle \ln n+{\xi\over n}-{1\over 2} {\xi^2\over n^2}+\ldots,$ (5)

so
$\displaystyle \ln(x^ne^{-x})$ $\textstyle =$ $\displaystyle n\ln (n+\xi)-(n+\xi)$  
  $\textstyle =$ $\displaystyle n\ln n+\xi-{1\over 2} {\xi^2\over n}-n-\xi+\ldots$  
  $\textstyle =$ $\displaystyle n\ln n-n-{\xi^2\over 2n}+\ldots.$ (6)

Taking the Exponential of each side then gives
\begin{displaymath}
x^n e^{-x} \approx e^{n\ln n} e^{-n}e^{-\xi^2/2n} = n^n e^{-n}e^{-\xi^2/2n}.
\end{displaymath} (7)

Plugging into the integral expression for $n!$ then gives
$\displaystyle n!$ $\textstyle \approx$ $\displaystyle \int_{-n}^\infty n^n e^{-n} e^{-\xi^2/2n}\, d\xi \approx n^ne^{-n} \int_{-\infty}^\infty e^{-\xi^2/2n} \, d\xi$  
  $\textstyle =$ $\displaystyle n^n.$ (8)

Evaluating the integral gives
$\displaystyle n!$ $\textstyle \approx$ $\displaystyle n^ne^{-n}\sqrt{2\pi n},$ (9)
  $\textstyle \approx$ $\displaystyle \sqrt{2\pi}\,n^{n+1/2} e^{-n}.$ (10)

Taking the Logarithm of both sides then gives
\begin{displaymath}
\ln n!\approx n\ln n-n+{\textstyle{1\over 2}}\ln(2\pi n) = (n+{\textstyle{1\over 2}})\ln n-n+{\textstyle{1\over 2}}\ln(2\pi).
\end{displaymath} (11)

This is Stirling's Series with only the first term retained and, for large $n$, it reduces to Stirling's approximation
\begin{displaymath}
\ln n!\approx n\ln n-n.
\end{displaymath} (12)

Gosper notes that a better approximation to $n!$ (i.e., one which approximates the terms in Stirling's Series instead of truncating them) is given by
\begin{displaymath}
n!\approx \sqrt{(2n+{\textstyle{1\over 3}})\pi}\,n^n e^{-n}.
\end{displaymath} (13)

This also gives a much closer approximation to the Factorial of 0, $0!=1$, yielding $\sqrt{\pi/3}\approx 1.02333$ instead of 0 obtained with the conventional Stirling approximation.

See also Stirling's Series



info prev up next book cdrom email home

© 1996-9 Eric W. Weisstein
1999-05-26