## Motivation:

In a statistical physics course, I often encountered the following approximation due to Stirling:

$$\ln(N!) \approx N\ln(N) - N$$

It was very useful but my professor didn’t explain how good the approximation was. The derivation I found turned out to be very simple so I can present it in a few lines here.

## Derivation:

If we define

$$S = \sum_{n=1}^{N} \ln(n)$$

we have an upper-Riemann sum with $$\scriptsize \Delta x = 1$$. So we basically have the following approximation:

$$S = \sum_{n=1}^{N} \ln(n) \Delta x \approx \int_{1}^N \ln(x) dx = N\ln(N) - N$$

Now, by the intermediate-value theorem

$$\forall n \in \mathbb{N} \exists c_n \in (n,n+1), S’ = \sum_{n=1}^N \ln (c_n) \Delta x = \int_{1}^{N} \ln (x) dx$$

## Analysis:

We may easily check how good this approximation is by bounding the error-term:

$$|S-S’| \leq |\sum_{n=1}^{N} \ln(n)-\sum_{n=1}^N \ln (n+1)| = \ln(N+1)$$

This error grows very slowly. In fact, if $$\scriptsize N ≈ 10^{24}$$ i.e. the number of molecules in a glass of water,$$\scriptsize | ln(N!) − (N ln(N) − N)| < 60$$ which is a minuscule error relative to the number of molecules.