Subject: Calculus

# Stirlings Approximation

**Stirling's approximation** is a technique widely used in mathematics in approximating factorials. especially large factorials. This approximation is also commonly known as **Stirling's Formula** named after the famous mathematician James Stirling. One simple application of Stirling's approximation is the Stirling's formula for factorial.

## Stirling's Factorial Approximation

Stirling's formula for the factorial is given by

So when we want to calculate say 9!, we just play with Stirling's formula;

Therefore, using Stirling's formula, we get

which is not too bad an approximation compared the real value of 9! which is 362 880.

We have just verified that the Stirling's formula works for factorials. Now, maybe we can add a little twist. If we take the natural logarithm of the Stirling's formula, we can also make an approximation of the \ln{n!} out of Stirling's formula;

For large values of n, the first term is usually neglected leaving

This is now the Stirling's approximation for the natural logarithm of n!.

### Example #1

Using Stirling's formula, calculate the factorial of 12.

From Stirling's factorial formula,

we have the factorial of 12 as

The real value of 12! is 479 001 600 which is close to what we got above.

### Example #2

From the calculated value of 9! and 12! using Stirling's formula, show that Stirling's approximation is more accurate for large values of n.

Our goal here is to show that 12! is more accurate than 9! when we use Stirling's approximation in calculating the corresponding factorials, To so this, we will calculate the percent error of each factorials with respect to each real values.

- For 12! :

Using Stirling's formula, the value of 12!, as calculated from example #1, is 475 568 258. The real value of 12! is 479 001 600.

Now,

- For 9! :

Using Stirling's formula, the value of 12!, as calculated above, is 359446.757. The real value of 9! is 362880.

Now,

From the percent errors above, 12! is clearly less than the corresponding %error of 9!.

### Example #3

Calculate the percent error of 3! when the factorial is calculated using Stirling's formula. Give an assessment regarding the degree of accuracy of Stirling's approximation.

From Stirling's factorial formula,

we have the factorial of 3 as

Now, we know that 3! = 6. So, lets compute the error.

This error is huge considering the percent error of 12! and 9! in the previous examples. As the value of n goes bigger, the Stirling's approximation gets better and better.

### Example #4

Approximate the value of the natural logarithm of 4! using Stirling's formula.

Stirling's formula holds that,

For n=4, we have:

### Example #5

Using the approximated value of the natural logarithm of 4! in example #4, was it a good approximation?

No.

It was not a good approximation.

Reason? Well, the real value of \ln{4!}=3.178. Whereas Stirling approximates it around 1.54517744 as what is shown in example #4. If we will compute the percent error, it will approach to more than 50\%!. Thus, it is not a good approximation.

**NEXT TOPIC:** Bernoulli numbers