# Stirling’s approximation

Stirling’s formula gives an approximation for $n!$, the factorial . It is

$$n!\approx \sqrt{2n\pi}{n}^{n}{e}^{-n}$$ |

We can derive this from the gamma function^{}. Note that for large $x$,

$$\mathrm{\Gamma}(x)=\sqrt{2\pi}{x}^{x-\frac{1}{2}}{e}^{-x+\mu (x)}$$ | (1) |

where

$$\mu (x)=\sum _{n=0}^{\mathrm{\infty}}\left(x+n+\frac{1}{2}\right)\mathrm{ln}\left(1+\frac{1}{x+n}\right)-1=\frac{\theta}{12x}$$ |

with $$. Taking $x=n$ and multiplying by $n$, we have

$$n!=\sqrt{2\pi}{n}^{n+\frac{1}{2}}{e}^{-n+\frac{\theta}{12n}}$$ | (2) |

Taking the approximation for large $n$ gives us Stirling’s formula.

There is also a big-O notation version of Stirling’s approximation:

$$n!=\left(\sqrt{2\pi n}\right){\left(\frac{n}{e}\right)}^{n}\left(1+\mathcal{O}\left(\frac{1}{n}\right)\right)$$ | (3) |

We can prove this equality starting from (2). It is clear that the big-O portion of (3) must come from ${e}^{\frac{\theta}{12n}}$, so we must consider the asymptotic behavior of $e$.

First we observe that the Taylor series^{} for ${e}^{x}$ is

$${e}^{x}=1+\frac{x}{1}+\frac{{x}^{2}}{2!}+\frac{{x}^{3}}{3!}+\mathrm{\cdots}$$ |

But in our case we have $e$ to a vanishing exponent^{}. Note that if we vary $x$ as $\frac{1}{n}$, we have as $n\u27f6\mathrm{\infty}$

$${e}^{x}=1+\mathcal{O}\left(\frac{1}{n}\right)$$ |

We can then (almost) directly plug this in to (2) to get (3) (note that the factor of 12 gets absorbed by the big-O notation.)

Title | Stirling’s approximation |

Canonical name | StirlingsApproximation |

Date of creation | 2013-03-22 12:00:36 |

Last modified on | 2013-03-22 12:00:36 |

Owner | drini (3) |

Last modified by | drini (3) |

Numerical id | 22 |

Author | drini (3) |

Entry type | Theorem |

Classification | msc 68Q25 |

Classification | msc 30E15 |

Classification | msc 41A60 |

Synonym | Stirling’s formula |

Synonym | Stirling’s approximation formula |

Related topic | MinkowskisConstant |

Related topic | AsymptoticBoundsForFactorial |