Stirling's Approximation - Derivation

Derivation

The formula, together with precise estimates of its error, can be derived as follows. Instead of approximating n!, one considers its natural logarithm as this is a slowly varying function:

The right-hand side of this equation minus is the approximation by the trapezoid rule of the integral and the error in this approximation is given by the Euler–Maclaurin formula:


\begin{align}
\ln (n!) - \frac{\ln n}{2} & = \frac{\ln 1}{2} + \ln 2 + \ln 3 + \cdots + \ln(n-1) + \frac{\ln n}{2}\\
& = n \ln n - n + 1 + \sum_{k=2}^{m} \frac{(-1)^k B_k}{k(k-1)} \left( \frac{1}{n^{k-1}} - 1 \right) + R_{m,n},
\end{align}

where Bk is a Bernoulli number and Rm,n is the remainder term in the Euler–Maclaurin formula. Take limits to find that

Denote this limit by y. Because the remainder Rm,n in the Euler–Maclaurin formula satisfies

where we use Big-O notation, combining the equations above yields the approximation formula in its logarithmic form:

Taking the exponential of both sides, and choosing any positive integer m, we get a formula involving an unknown quantity ey. For m=1, the formula is

The quantity ey can be found by taking the limit on both sides as n tends to infinity and using Wallis' product, which shows that . Therefore, we get Stirling's formula:

The formula may also be obtained by repeated integration by parts, and the leading term can be found through Laplace's method. Stirling's formula, without the factor that is often irrelevant in applications, can be quickly obtained by approximating the sum

with an integral:

Read more about this topic:  Stirling's Approximation