Stirling’s Approximation

In confronting statistical problems we often encounter factorials of very large numbers. The factorial N! is a product N(N-1)(N-2)..(2)(1). Therefore, ln N! is a sum

where we have used the property of logarithms that log(abc) = log(a) + log(b) + log(c). The sum is shown in figure below.

The sum of the area under the blue rectangles shown below up to N is ln N!. As you can see the rectangles begin to closely approximate the red curve as m gets larger. The area under the curve is given the integral of ln x.

To solve the integral use integration by parts

Here we let u = ln x and dv = dx. Then v = x and du = dx/x.

Notice that x/x = 1 in the last integral and x ln x is 0 when evaluated at zero, so we have

Which gives us Stirling’s approximation:

ln N! = N ln N – N

As is clear from the figure above Stirling’s approximation gets better as the number N gets larger. Let’s try a few numbers

N

N!

ln N!

N ln N – N

Error

10

3.63 x 106

15.1

13.02

13.8%

50

3.04 x 1064

148.4

145.6

1.88%

100

9.33 x 10157

363.7

360.5

0.88%

150

5.71 x 10262

605.0

601.6

0.56%

 

My calculator overheats at 200!. That is all right since we have shown that the result is converging. In thermodynamics we are often dealing very large N (i.e. of the order of Avagadro’s number). Clearly, for these values Stirling’s approximation is excellent.