Reference: Daniel V. Schroeder, An Introduction to Thermal Physics, (Addison-Wesley, 2000) – Problems 2.15-2.16.
The methods for counting the number of microstates in interacting Einstein solids involve calculating binomial coefficients which in turn require factorials. For any but the smallest systems, the factorials rapidly become so large that computers cannot calculate them exactly. In such cases, we can resort to Stirling’s approximation for factorials of large numbers.
Although Stirling’s approximation is quoted in many textbooks, a derivation is not usually given. Schroeder provides a nice derivation in his appendix B.2 and B.3 so we’ll run through that here and then give a couple of examples of its use.
We start with the elementary integral
for some parameter . If we treat as a variable and take the derivative with respect to it, we get
Repeating the process, we get
Setting we get
This integral is the starting point for Stirling’s approximation. The integrand is a bell-shaped curve which a precise shape that depends on . The maximum value of the integrand is found from
The idea is to approximate the integrand by a Gaussian because then we can easily evaluate the Gaussian integral. We have
We now substitute :
Near the peak of the curve so and we can approximate the logarithm by expanding it in a Taylor series up to the second order term:
Plugging this back into 13 we get
so from 7 we get the approximation
[Note that the lower limit on the integral is now due to the substitution above.]
Since the peak of the Gaussian curve occurs at and is assumed to be large, we can extend the lower limit on the integral to without affecting the value much, so we get, doing the Gaussian integral:
which is Stirling’s approximation.
It’s common when doing approximations to sums to neglect a small term added to a much larger term, as in . What is at first glance harder to believe is that if we have a very large number and multiply it by a much smaller number, the result is essentially the same. For example
If we’re interested in and use Stirling’s approximation, we have
For large , the first term is much smaller than the last term and can often be neglected, so the logarithmic form of Stirling’s approximation is sometimes given as
Example 1 For , the exact and approximate values are
Thus even for (which can be handled exactly by most pocket calculators) Stirling’s approximation is reasonable.
Example 2 A larger coin flipping experiment. We flip a coin 1000 times. The probability of getting exactly 500 heads and 500 tails can be worked out using Stirling’s approximation. The total number of outcomes is , and the number of ways of getting 500 heads is
Thus the probability of getting exactly 500 heads is approximately
To get exactly 600 heads, we need
The probability is therefore
[Although Maple is capable of working out the large exponents directly, if you want to do this on a calculator, it would be better to work with logs.]
A general formula for the probability of getting heads in 1000 flips is
A plot of this is as follows:
It’s overwhelmingly probable that you’ll get something close to 500 heads for 1000 coin flips.