Thursday, October 11, 2007

Stirling's approximation

In the last homework, we made frequent use of Stirling's approximation for the log of a factorial. In fact, this approximation occurs again and again in statistical mechanics. You may have been wondering where it comes from. Here is a simple derivation. For large N we can write the derivative of ln(N!) as:

d ln(N!) / dN ~ [ln(N!) - ln((N-1)!)] / (N - (N-1))

= ln[N!/(N-1)!]

= ln N

Now, integrating we have:

ln(N!) = N ln(N) - N + const

Usually we take the constant to be zero, since it is negligible if N is very large. In general, Stirling's approximation works very well in statistical mechanical theory because we are using very large values of N.

Also, you might have noticed that Stirling's approximation simplifies the expression for number of combinations of M items picked from N. Notice that N! = N^N / e^N according to Stirling's formula. Then we can write

N!/M!(N-M)! ~ N^N / M^M (N-M)^(N-M)

Notice that the exponential terms canceled out of this expression. A little manipulation puts this formula in a nicer form:

N!/M!(N-M!) = [x^x * (1-x)^(1-x)]^(-N)

where x = M/N. Just about any time you use the combination expression, it will greatly simplify your life to convert to this kind of expression. If you don't see where this comes from, try the derivation yourself. It's just a little algebraic manipulation.

1 comment:

Anonymous said...

In case anyone is interested, here's an alternative "quick and dirty" derivation that gives you the integration constant, so you can see that it is small compared to N:

ln(N!) = ln( N (N-1) (N-2) ... )
= ln N + ln (N-1) + ln (N-2) + ...
= Sum (n=1 to N) ln n

Approximate the sum with an integral, which can then evaluate exactly:
= Integral (n=1 to N) ln n
= (N ln N - N) - (1 ln 1 - 1)
= N ln N - N + 1

N>>1 => drop the 1
=> ln(N!) approx = N ln N - N

There are multiple ways to get higher-order terms for ln(N!): one approach is to use the Euler-McLaurin formula, which gives an exact result for the error you make when you replace a sum by an integral as in the above derivation; others involve analysis of the so-called gamma function, which is an extension of the factorial to non-integers.

With the addition of the next term in the series (which is ln(2 Pi N)/2 ), the formula has less than 1% error at N=4, so calculating high-order terms is rarely important!