Steven R. Dunbar
Department of Mathematics
203 Avery Hall
Lincoln, NE 68588-0130
http://www.math.unl.edu
Voice: 402-472-3731
Fax: 402-472-8466

Topics in
Probability Theory and Stochastic Processes
Steven R. Dunbar

__________________________________________________________________________

Stirling’s Formula Derived from the Gamma Function

_______________________________________________________________________

Note: To read these pages properly, you will need the latest version of the Mozilla Firefox browser, with the STIX fonts installed. In a few sections, you will also need the latest Java plug-in, and JavaScript must be enabled. If you use a browser other than Firefox, you should be able to access the pages and run the applets. However, mathematical expressions will probably not display correctly. Firefox is currently the only browser that supports all of the open standards.

_______________________________________________________________________________________________ ### Rating

Mathematicians Only: prolonged scenes of intense rigor.

_______________________________________________________________________________________________ ### Section Starter Question

Do you know of a function defined for, say the positive real numbers, which has the value $n!$ for positive integers $n$?

_______________________________________________________________________________________________ ### Key Concepts

1. Stirling’s Formula, also called Stirling’s Approximation, is the asymptotic relation
$n!\sim \sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}\phantom{\rule{0em}{0ex}}.$

2. The formula is useful in estimating large factorial values, but its main mathematical value is in limits involving factorials.
3. The Gamma function is generally defined as
$\Gamma \left(z\right)={\int }_{0}^{\infty }{x}^{z-1}{e}^{-x}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dx\phantom{\rule{0em}{0ex}}.$

For an integer $n$, $\Gamma \left(n\right)=\left(n-1\right)!$ .

__________________________________________________________________________ ### Vocabulary

1. Stirling’s Formula, also called Stirling’s Approximation, is the asymptotic relation
$n!\sim \sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}\phantom{\rule{0em}{0ex}}.$

2. The Gamma function is generally defined as
$\Gamma \left(z\right)={\int }_{0}^{\infty }{x}^{z-1}{e}^{-x}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dx\phantom{\rule{0em}{0ex}}.$

For an integer $n$, $\Gamma \left(n\right)=\left(n-1\right)!$ .

__________________________________________________________________________ ### Mathematical Ideas

Stirling’s Formula, also called Stirling’s Approximation, is the asymptotic relation

$n!\sim \sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}\phantom{\rule{0em}{0ex}}.$

The formula is useful in estimating large factorial values, but its main mathematical value is in limits involving factorials. Another attractive form of Stirling’s Formula is:

$n!\sim \sqrt{2\pi n}{\left(\frac{n}{e}\right)}^{n}\phantom{\rule{0em}{0ex}}.$

An improved inequality version of Stirling’s Formula is

 $\sqrt{2\pi }{n}^{n+1∕2}{e}^{-n+1∕\left(12n+1\right)} (1)

See Stirling’s Formula. in MathWorld.com.

First we formally define the Gamma function and its most important property. Then we give a heuristic argument for Stirling’s formula for the Gamma function using asymptotics of integrals, based on some notes by P. Garrett, . Here we rigorously derive Stirling’s Formula using the Gamma function and estimates of the logarithm function, based on the short note by R. Michel, .

#### Definition of the Gamma Function

Lemma 1 (Gamma Function).

$n!={\int }_{0}^{\infty }{x}^{n}{e}^{-x}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dx\phantom{\rule{0em}{0ex}}.$

Proof. The proof is by induction. Start with $n=0$,

${\int }_{0}^{\infty }{x}^{0}{e}^{-x}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dx={\int }_{0}^{\infty }{e}^{-x}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dx=1=0!\phantom{\rule{0em}{0ex}}.$

Then in general, integrating by parts

${\int }_{0}^{\infty }{x}^{n}{e}^{-x}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dx=n{\int }_{0}^{\infty }{x}^{n-1}{e}^{-x}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dx\phantom{\rule{0em}{0ex}}.$

Inductively,

$n!={\int }_{0}^{\infty }{x}^{n}{e}^{-x}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dx\phantom{\rule{0em}{0ex}}.$

Remark. The Gamma function is generally defined as

$\Gamma \left(z\right)={\int }_{0}^{\infty }{x}^{z-1}{e}^{-x}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dx\phantom{\rule{0em}{0ex}}.$

Then the same integration by parts shows $\Gamma \left(z\right)=\left(z-1\right)\Gamma \left(z-1\right)$ . For an integer $n$, $\Gamma \left(n\right)=\left(n-1\right)!$ .

#### Heuristic Derivation of Stirling’s Formula from Asymptotics of Integrals

Observe that

$\Gamma \left(z+1\right)={\int }_{0}^{\infty }{x}^{z}{e}^{-x}\phantom{\rule{0em}{0ex}}dx={\int }_{0}^{\infty }{e}^{-x+zlogx}\phantom{\rule{0em}{0ex}}dx.$

Note that $-x+zlogx$ has a unique critical point at $x=z$. The critical point is a maximum since the second derivative has value $-1∕z<0$ there. The idea is to replace $-x+zlogx$ by its second degree Taylor polynomial based at $z$, then evaluate the resulting integral. Note that the second degree Taylor polynomial is the quadratic polynomial best approximating a function. The idea is that most of the contribution to the integral comes from the maximum, and because of the negative exponential, contribution away from the maximum is slight.

So expand $-x+zlogx$ in a second-degree Taylor polynomial at the critical point $z$:

$-x+zlogx\approx -z+zlogz-\frac{1}{2!z}{\left(x-z\right)}^{2}.$

Thus we can approximate the Gamma function with

Note that last evaluation of the integral is over the whole real line. By Lemma 4 of DeMoivre-Laplace Central Limit Theorem.

${\int }_{-\infty }^{0}{e}^{-{\left(x-z\right)}^{2}∕2z}\phantom{\rule{0em}{0ex}}dx\le \frac{1}{2z}{e}^{-z∕4}.$

This is very small for large $z$, so heuristically the asymptotics of the integral over the whole line is of the same order as the integral over $\left[0,\infty \right)$.

To simplify the integral, replace $x$ by $zu$. Notice that a factor of $z$ cancels from both sides

$\Gamma \left(z\right)={e}^{-z}{z}^{z}{\int }_{-\infty }^{\infty }{e}^{-z{\left(u-1\right)}^{2}∕2}\phantom{\rule{0em}{0ex}}du.$

Make another change of variables $x=\sqrt{z}\left(u-1\right)$ so that

${e}^{-z}{z}^{z}{\int }_{-\infty }^{\infty }{e}^{-z{\left(u-1\right)}^{2}∕2}\phantom{\rule{0em}{0ex}}du={e}^{-z}{z}^{z}\frac{\sqrt{1}}{\sqrt{z}}{\int }_{-\infty }^{\infty }{e}^{\frac{-{x}^{2}}{2}}\phantom{\rule{0em}{0ex}}dx={e}^{-z}{z}^{z}\frac{\sqrt{2\pi }}{\sqrt{z}}.$

The last equality is derived in Evaluation of the Gaussian Density Integral..

Simplifying,

$\Gamma \left(s\right)\approx \sqrt{2\pi }{e}^{-z}{z}^{z-1∕2}.$

As an alternative, one can apply Laplace’s method (for asymptotics of integrals) to the integral in (2) and derive the same conclusion somewhat more rigorously.

#### Rigorous Derivation of Stirling’s Formula

Lemma 2.

$n!={n}^{n}\sqrt{n}{e}^{-n}{\int }_{-\infty }^{\infty }{g}_{n}\left(y\right)\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dy$

where

${g}_{n}\left(y\right)={\left(1+\frac{y}{\sqrt{n}}\right)}^{n}{e}^{-y\sqrt{n}}{1}_{\left(-\sqrt{n},\infty \right)}\left(y\right)\phantom{\rule{0em}{0ex}}.$

Proof. In Lemma 1 make the substitution $x=\sqrt{n}y+n$ (or equivalently $y=\frac{x}{\sqrt{n}}-\sqrt{n}$) with $\phantom{\rule{0em}{0ex}}dx=\sqrt{n}\phantom{\rule{0em}{0ex}}dy$ to give

$\begin{array}{llll}\hfill {\int }_{0}^{\infty }{x}^{n}{e}^{-x}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dx& ={\int }_{-\sqrt{n}}^{\infty }{\left(y\sqrt{n}+n\right)}^{n}{e}^{-\left(y\sqrt{n}+n\right)}\phantom{\rule{0em}{0ex}}\sqrt{n}\phantom{\rule{0em}{0ex}}dy\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & ={n}^{n}\sqrt{n}{e}^{-n}{\int }_{-\sqrt{n}}^{\infty }{\left(y∕\sqrt{n}+1\right)}^{n}{e}^{-\left(y\sqrt{n}\right)}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dy\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & ={n}^{n}\sqrt{n}{e}^{-n}{\int }_{-\infty }^{\infty }{g}_{n}\left(y\right)\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dy\phantom{\rule{0em}{0ex}}.\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\end{array}$

Remark. This means that what remains is to show the integral ${\int }_{-\infty }^{\infty }{g}_{n}\left(y\right)\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dy$ approaches the asymptotic constant $\sqrt{2\pi }$ .

Lemma 3. For $|x|<1$,

$\left|log\left(1+x\right)-x+\frac{1}{2}{x}^{2}\right|\le \frac{1}{3}\frac{|x{|}^{3}}{1-|x|}\phantom{\rule{0em}{0ex}}.$ Figure 1: A graph of the functions in Lemma 3 with $|log\left(1+x\right)-x+\frac{{x}^{2}}{2}|$ in red and $\frac{1}{3}\cdot \frac{|x{|}^{3}}{1-|x|}$ in blue.

Remark. Note further that

 $\frac{|x{|}^{3}}{1-|x|}\le |x{|}^{2}$ (3)

for $|x|\le 1∕2$. This will be used later to simplify the expression on the right side of the inequality in Lemma 3.

Proof. Expanding $log\left(1+x\right)$ in a Taylor series and applying the triangle inequality

$\left|log\left(1+x\right)-x+\frac{1}{2}{x}^{2}\right|\le \sum _{k=3}^{\infty }\frac{|x{|}^{3}}{k}\phantom{\rule{0em}{0ex}}.$

Grossly overestimating each term by using the least denominator and summing as a geometric series

$\sum _{k=3}^{\infty }\frac{|x{|}^{3}}{k}\le \frac{1}{3}\frac{|x{|}^{3}}{1-|x|}\phantom{\rule{0em}{0ex}}.$

Lemma 4.

$|{e}^{a}-{e}^{b}|\le {e}^{b}\cdot |a-b|\cdot {e}^{|a-b|}\phantom{\rule{0em}{0ex}}.$

Proof.

$|{e}^{a}-{e}^{b}|={e}^{b}|{e}^{a-b}-1|$

Notice that ${e}^{x}-1={\sum }_{k=1}^{\infty }\frac{{x}^{k}}{k!}=x{\sum }_{k=1}^{\infty }\frac{{x}^{k-1}}{k!}\le x{\sum }_{k=1}^{\infty }\frac{{x}^{k-1}}{\left(k-1\right)!}=x{\sum }_{k=0}^{\infty }\frac{{x}^{k}}{k!}=x{e}^{x}\phantom{\rule{0em}{0ex}}.$ Alternatively let $f\left(x\right)={e}^{x}-1$ and $g\left(x\right)=x{e}^{x}$ . Then $f\left(0\right)=0=g\left(0\right)$, and ${f}^{\prime }\left(x\right)={e}^{x}\le {e}^{x}+x{e}^{x}={g}^{\prime }\left(x\right)$ for $x>0$ . Likewise ${f}^{\prime }\left(x\right)={e}^{x}\ge {e}^{x}+x{e}^{x}={g}^{\prime }\left(x\right)$ for $x<0$ . Therefore ${e}^{x}-1=f\left(x\right)\le g\left(x\right)=x{e}^{x}$ for all $x$ . Then

${e}^{b}|{e}^{a-b}-1|\le {e}^{b}\cdot |a-b|\cdot {e}^{|a-b|}\phantom{\rule{0em}{0ex}}.$

Lemma 5. For $|y|\le \frac{\sqrt{n}}{2}$

$|{g}_{n}\left(y\right)-{e}^{-{y}^{2}∕2}|\le \frac{|y{|}^{3}}{\sqrt{n}}{e}^{-{y}^{2}∕6}\phantom{\rule{0em}{0ex}}.$

Proof. For $|y|\le \frac{\sqrt{n}}{2}$

Lemma 6.

$\underset{n\to \infty }{lim}{g}_{n}\left(y\right)={e}^{-{y}^{2}∕2}$

where the limit is uniform on compact subsets of $ℝ$ .

Proof. For $|y|\le \frac{\sqrt{n}}{2}$ use Lemma5

$|{g}_{n}\left(y\right)-{e}^{-{y}^{2}∕2}|\le \frac{|y{|}^{3}}{\sqrt{n}}{e}^{-{y}^{2}∕6}\phantom{\rule{0em}{0ex}}.$

Note that $|y{|}^{3}{e}^{-{y}^{2}∕6}$ has a maximum value of $27{e}^{-3∕2}$ .

Let $K$ be a compact subset of $ℝ$ with $M$ be a bound so that $K\subset \left\{x:|x| . Let $ϵ>0$ be given. Let $n$ be so large that $M<\sqrt{n}∕2$ and $27{e}^{-3∕2}∕\sqrt{n}<ϵ$ . Then for all $y\in K$, $|{g}_{n}\left(y\right)-{e}^{-{y}^{2}∕2}|\le \frac{|y{|}^{3}}{\sqrt{n}}{e}^{-{y}^{2}∕6}\le 27{e}^{-3∕2}∕\sqrt{n}<ϵ$ . □

Lemma 7. For $x>-1$

$log\left(1+x\right)\le x-\frac{5}{6}\frac{{x}^{2}}{2+x}\phantom{\rule{0em}{0ex}}.$ Figure 2: A graph of the functions in Lemma 7 with $log\left(1+x\right)$ in red and $x-\left(5∕6\right)\left({x}^{2}\right)∕\left(2+x\right)$ in blue.

Proof. Consider $f\left(x\right)=x-\frac{5}{6}\frac{{x}^{2}}{2+x}-log\left(1+x\right)$, with ${f}^{\prime }\left(x\right)=x\cdot \frac{{x}^{2}-x+4}{6\left(1+x\right){\left(2+x\right)}^{2}}$ . The only critical point on the domain $x>-1$ is $x=0$, and ${f}^{\prime }\left(x\right)<0$ for $-1, ${f}^{\prime }\left(x\right)>0$ for $x>0$ . Then $f\left(x\right)$ has a global minimum value of $0$ at $x=0$ . Hence $log\left(x\right)\le x-\frac{5}{6}\frac{{x}^{2}}{2+x}$ . □

Remark. Unfortunately, although the proof is straightforward the origin of the rational function on the right is unmotivated.

Lemma 8.

$0\le {g}_{n}\left(y\right)\le {e}^{-|y|∕6},\phantom{\rule{2em}{0ex}}|y|>\frac{1}{2}\sqrt{n}$

Proof. For $y>-\sqrt{n}$,

$\begin{array}{llll}\hfill log\left({g}_{n}\left(y\right)\right)& =nlog\left(1+\frac{y}{\sqrt{n}}\right)-y\sqrt{n}\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & \le -\frac{5}{6}\frac{{y}^{2}}{2+y∕\sqrt{n}}\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\end{array}$

using Lemma 7. For $|y|>\frac{1}{2}\sqrt{n}$ and on the domain $y>-\sqrt{n}$, $1<2+y∕\sqrt{n}\le 2+|y|∕\sqrt{n}$, so

$\frac{5|y|}{2+y∕\sqrt{n}}\ge \frac{5|y|}{2+|y|∕\sqrt{n}}\phantom{\rule{0em}{0ex}}.$

Now since $|y|>\frac{1}{2}\sqrt{n}$, it is true that $4|y|>2\sqrt{n}$, so $5|y|>2\sqrt{n}+|y|$ or $\frac{5|y|}{2+|y|∕\sqrt{n}}>\sqrt{n}$ . Finally multiplying through by $-|y|∕6$,

$\frac{-5}{6}\frac{{y}^{2}}{2+y∕\sqrt{n}}\le \frac{-5}{6}\frac{{y}^{2}}{2+|y|∕\sqrt{n}}<\frac{-|y|\sqrt{n}}{6}<\frac{-|y|}{6}\phantom{\rule{0em}{0ex}}.$

Theorem 9 (Stirling’s Formula).

$n!\sim \sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}\phantom{\rule{0em}{0ex}}.$

Proof. By Lemma 2

$n!={n}^{n}\sqrt{n}{e}^{-n}{\int }_{-\infty }^{\infty }{g}_{n}\left(y\right)\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dy$

where

${g}_{n}\left(y\right)={\left(1+\frac{y}{\sqrt{n}}\right)}^{n}{e}^{-y\sqrt{n}}{1}_{\left(-\sqrt{n},\infty \right)}\left(y\right)\phantom{\rule{0em}{0ex}}.$

From Lemma 6

$\underset{n\to \infty }{lim}{g}_{n}\left(y\right)={e}^{-{y}^{2}∕2}$

uniformly on compact sets and ${g}_{n}\left(y\right)$ is integrable by Lemma 8. Hence by the Lebesgue Convergence Theorem

$\underset{n\to \infty }{lim}{\int }_{-\infty }^{\infty }{g}_{n}\left(y\right)\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dy={\int }_{-\infty }^{\infty }{e}^{-{y}^{2}∕2}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dy$

and since ${\int }_{-\infty }^{\infty }{e}^{-{y}^{2}∕2}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dy=\sqrt{2\pi }$ it follows that

$\underset{n\to \infty }{lim}\frac{n!}{\sqrt{2\pi }{n}^{n}\sqrt{n}{e}^{-n}}=\underset{n\to \infty }{lim}\frac{{\int }_{-\infty }^{\infty }{g}_{n}\left(y\right)\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dy}{\sqrt{2\pi }}=1\phantom{\rule{0em}{0ex}}.$

#### Asymptotic Expansions

Lemma 10. For $x>0$

$0<1+\frac{1}{12}\cdot \frac{{x}^{2}}{1+x}-\left(\frac{1}{x}+\frac{1}{2}\right)log\left(1+x\right)\le \frac{{x}^{4}}{120}\phantom{\rule{0em}{0ex}}.$

Remark. Unfortunately, although the proof is straightforward the origin of the function on the left is unmotivated. Figure 3: A graph of the functions in Lemma 10 with $1+\frac{1}{12}\cdot \frac{{x}^{2}}{1+x}-\left(\frac{1}{x}+\frac{1}{2}\right)log\left(1+x\right)$ in red and $\frac{{x}^{4}}{120}$ in blue.

Proof. Let $f\left(x\right)=2x+\frac{1}{6}\frac{{x}^{3}}{1+x}-\left(x+2\right)log\left(1+x\right)$ for $x>-1$ so ${f}^{\prime }\left(x\right)=-\frac{1}{6}\phantom{\rule{0em}{0ex}}\frac{{x}^{3}}{{\left(1+x\right)}^{2}}-\frac{1}{2}\phantom{\rule{0em}{0ex}}\frac{{x}^{2}}{2\left(1+x\right)}-log\left(1+x\right)-\frac{x+2}{x+1}+2$ . Then $f\left(0\right)=0$, and ${f}^{\prime }\left(0\right)=0$ . Further ${f}^{\prime \prime }\left(x\right)=\frac{1}{3}\cdot \frac{{x}^{3}}{{\left(1+x\right)}^{3}}$ and ${f}^{\prime \prime }\left(x\right)>0$ for $x>0$ . Therefore, $f\left(x\right)>0$ for $x>0$ and dividing through by $2x$ yields the left inequality.

For the right side, consider $h\left(x\right)=\frac{{x}^{5}}{60}-f\left(x\right)$ . Again $h\left(0\right)={h}^{\prime }\left(0\right)=0$ . Further ${h}^{\prime \prime }\left(x\right)=\frac{{x}^{3}}{3}-\frac{1}{3}\cdot \frac{{x}^{3}}{{\left(1+x\right)}^{3}}>0$ for $x>-1$ . The right side inequality follows immediately. □

Lemma 11. For $x>0$,

${e}^{x}\le 1+x+\frac{1}{2}{x}^{2}+\frac{1}{6}{x}^{3}{e}^{x}\phantom{\rule{0em}{0ex}}.$

Proof. For $x>0$, expanding ${e}^{x}$ in a Taylor series

$\begin{array}{llll}\hfill {e}^{x}& =1+x+\frac{1}{2}{x}^{2}+\sum _{k=3}^{\infty }\frac{{x}^{k}}{k!}\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & =1+x+\frac{1}{2}{x}^{2}+\frac{1}{6}{x}^{3}\sum _{k=3}^{\infty }\frac{{x}^{k-3}}{k!∕6}\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & =1+x+\frac{1}{2}{x}^{2}+\frac{1}{6}{x}^{3}\sum _{k=0}^{\infty }\frac{{x}^{k}}{\left(k+3\right)!∕6}\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & \le 1+x+\frac{1}{2}{x}^{2}+\frac{1}{6}{x}^{3}\sum _{k=0}^{\infty }\frac{{x}^{k}}{k!}\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & \phantom{\rule{2em}{0ex}}& \hfill \end{array}$

since $\left(k+3\right)!∕6\ge k!$ . □

Lemma 12.

$\frac{1}{6}\frac{{e}^{1∕24}}{1{2}^{3}}\le \frac{1}{9440}$

Remark. Numerically $\frac{1}{6}\frac{{e}^{1∕24}}{1{2}^{3}}\approx 0.0001005542925$ and $\frac{1}{9440}\approx 0.0001059322034$, so the difference is about $5×1{0}^{-6}$ .

Proof. I don’t have a rigorous proof based on, say, elementary comparisons in the rational number system. In fact, it is not clear how the denominator $9440$ arises. However, as will be seen in the proof of Theorem 13 what is really needed is that $\frac{1}{6}\frac{{e}^{1∕24}}{1{2}^{3}}$ is a finite constant. Finding a rational number with unit numerator and 4-digit denominator to bound the constant is simply a convenience. □

Theorem 13. For $n\ge 2$,

$\left|\frac{n!}{\sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}}-1-\frac{1}{12n}\right|\le \frac{1}{288{n}^{2}}+\frac{1}{9940{n}^{3}}\phantom{\rule{0em}{0ex}}.$

Proof. Let ${a}_{n}=\frac{n!}{\sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}}$ . Then $\frac{{a}_{n}}{{a}_{n+1}}={\left(\frac{n+1}{n}\right)}^{n+1∕2}{e}^{-1}$ and $log\left(\frac{{a}_{n}}{{a}_{n+1}}\right)=\left(n+1∕2\right)log\left(1+1∕n\right)-1$ . Using the left inequality in Lemma 10 with $x=1∕n$

$log\left(\frac{{a}_{n}}{{a}_{n+1}}\right)\le \frac{1}{12n\left(n+1\right)}\phantom{\rule{0em}{0ex}}.$

Then

$log\left(\frac{{a}_{n}}{{a}_{n+r}}\right)=\sum _{k=n}^{n+r-1}log\left(\frac{{a}_{k}}{{a}_{k+1}}\right)\le \frac{1}{12}\sum _{k=n}^{n+r-1}\frac{1}{k\left(k+1\right)}=\frac{1}{12}\left(\frac{1}{n}-\frac{1}{n+r}\right)\phantom{\rule{0em}{0ex}}.$

Now let $r\to \infty$, noting that $\underset{r\to \infty }{lim}{a}_{n+r}=1$, so $log\left({a}_{n}\right)\le \frac{1}{12n}$ and ${a}_{n}\le {e}^{1∕\left(12n\right)}$ . Now use Lemma 11 and Lemma 12 to yield

$\begin{array}{llll}\hfill {a}_{n}& \le 1+\frac{1}{12n}+\frac{1}{2}\frac{1}{{\left(12n\right)}^{2}}+\frac{1}{6}\frac{1}{{\left(12n\right)}^{3}}{e}^{1∕\left(12n\right)}\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & \le 1+\frac{1}{12n}+\frac{1}{2}\frac{1}{{\left(12n\right)}^{2}}+\frac{1}{6}\frac{1}{{\left(12n\right)}^{3}}{e}^{1∕\left(12\cdot 2\right)}\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & \le 1+\frac{1}{12n}+\frac{1}{2}\frac{1}{{\left(12n\right)}^{2}}+\frac{1}{9440{n}^{3}}\phantom{\rule{0em}{0ex}}.\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\end{array}$

Then

$\frac{n!}{\sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}}-1-\frac{1}{12n}\le \frac{1}{2}\frac{1}{{\left(12n\right)}^{2}}+\frac{1}{9440{n}^{3}}\phantom{\rule{0em}{0ex}}.$

Likewise, using the right inequality in Lemma 10 with $x=1∕n$

$log\left(\frac{{a}_{n}}{{a}_{n+1}}\right)\ge \frac{1}{12\left(n\left(n+1\right)\right)}-\frac{1}{120}\frac{1}{{n}^{4}}\phantom{\rule{0em}{0ex}}.$

Then

$\begin{array}{c}log\left(\frac{{a}_{n}}{{a}_{n+r}}\right)=\sum _{k=n}^{n+r-1}log\left(\frac{{a}_{k}}{{a}_{k+1}}\right)\ge \frac{1}{12}\sum _{k=n}^{n+r-1}\frac{1}{k\left(k+1\right)}-\frac{1}{120}\sum _{k=n}^{n+r-1}\frac{1}{{k}^{4}}\\ =\frac{1}{12}\left(\frac{1}{n}-\frac{1}{n+r}\right)-\frac{1}{120}\sum _{k=n}^{n+r-1}\frac{1}{{k}^{4}}\phantom{\rule{0em}{0ex}}.\end{array}$

Again let $r\to \infty$, noting that $\underset{r\to \infty }{lim}{a}_{n+r}=1$ to obtain

$log\left({a}_{n}\right)\ge \frac{1}{12n}-\frac{1}{120}\sum _{k=n}^{\infty }\frac{1}{{k}^{4}}=\frac{1}{12n}-\frac{1}{120}\frac{1}{{n}^{4}}-\sum _{k=n+1}^{\infty }\frac{1}{{k}^{4}}\ge \frac{1}{12n}-\frac{1}{120}\frac{1}{{n}^{4}}-\frac{1}{360{n}^{3}}$

because ${\sum }_{k=n+1}^{\infty }\frac{1}{{k}^{4}}\le {\int }_{n}^{\infty }\frac{1}{{x}^{4}}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dx$ using right-box Riemann sums with width 1.

Let ${r}_{n}=\frac{1}{12n}-\frac{1}{120}\frac{1}{{n}^{4}}-\frac{1}{360{n}^{3}}$ . Hence ${a}_{n}\ge {e}^{{r}_{n}}$ . By a well-known estimate ${e}^{{r}_{n}}\ge 1+{r}_{n}$ . Therefore,

${a}_{n}\ge 1+\frac{1}{12n}-\frac{1}{120}\frac{1}{{n}^{4}}-\frac{1}{360{n}^{3}}$

Equivalently,

$\frac{n!}{\sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}}-1-\frac{1}{12n}\ge -\frac{1}{360{n}^{3}}-\frac{1}{120}\frac{1}{{n}^{4}}\phantom{\rule{0em}{0ex}}.$

Since

$\frac{1}{360{n}^{3}}+\frac{1}{120}\frac{1}{{n}^{4}}\le \frac{1}{2}\frac{1}{{\left(12n\right)}^{2}}+\frac{1}{9440{n}^{3}}$

the two inequalities can be summarized as

$\frac{n!}{\sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}}-1-\frac{1}{12n}\le \frac{1}{2}\frac{1}{{\left(12n\right)}^{2}}+\frac{1}{9440{n}^{3}}\phantom{\rule{0em}{0ex}}.$

Remark. The proof actually shows the slightly stronger bounds

$-\frac{1}{360{n}^{3}}-\frac{1}{120}\frac{1}{{n}^{4}}\le \frac{n!}{\sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}}-1-\frac{1}{12n}\le \frac{1}{2}\frac{1}{{\left(12n\right)}^{2}}+\frac{1}{9440{n}^{3}}\phantom{\rule{0em}{0ex}}.$

Remark. Using similar reasoning, from the well-known estimate ${e}^{{r}_{n}}\ge 1+{r}_{n}+\frac{1}{2}{r}_{n}^{2}$, one can derive the estimate

$\left|\frac{n!}{\sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}}-1-\frac{1}{12n}-\frac{1}{288{n}^{2}}\right|\le \frac{1}{360{n}^{3}}+\frac{1}{108{n}^{4}}$

valid for $n\ge 3$ .

Remark. Note that for $n=1$,

$\frac{n!}{\sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}}=\frac{e}{\sqrt{2\pi }}\ge \frac{13}{12}=1+\frac{1}{12}$

since $\frac{e}{\sqrt{2\pi }}\approx 1.0844$ and $\frac{13}{12}\approx 1.08334$ . Similarly for $n=2$

$\frac{n!}{\sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}}=\frac{{e}^{2}}{\sqrt{2\pi }\phantom{\rule{0em}{0ex}}{2}^{3∕2}}\ge \frac{25}{24}=1+\frac{1}{12\cdot 2}$

since $\frac{{e}^{2}}{\sqrt{2\pi }\phantom{\rule{0em}{0ex}}{2}^{3∕2}}\approx 1.042207$ and $\frac{25}{24}\approx 1.041664$ . From the remark above, for $n\ge 3$

$\frac{n!}{\sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}}-1-\frac{1}{12n}\ge \frac{1}{288{n}^{2}}-\frac{1}{360{n}^{3}}-\frac{1}{108{n}^{4}}>0\phantom{\rule{0em}{0ex}}.$

Then for all $n\ge 1$,

$\frac{n!}{\sqrt{2\pi }{n}^{n+1∕2}{e}^{-n}}\ge 1+\frac{1}{12n}$

which is a better bound than ${e}^{1∕\left(2n+1\right)}$ quoted in equation (1). In order to see this bound, consider $f\left(x\right)=log\left(1+x\right)-\frac{2x}{2+x}$, defined for $x>-1$. Then ${f}^{\prime }\left(x\right)=\frac{{x}^{2}}{\left(1+x\right){\left(2+x\right)}^{2}}$ and $f\left(0\right)=0$, ${f}^{\prime }\left(x\right)>0$ for $x>0$. Then $log\left(1+\frac{1}{12n}\right)>\frac{2}{24n+1}>\frac{1}{12n+1}$. Hence $1+\frac{1}{12n}>{e}^{1∕\left(12n+1\right)}$ .

#### Alternate Derivation of Stirling’s Asymptotic Formula

Note that ${x}^{t}{e}^{-x}$ has its maximum value at $x=t$. That is, most of the value of the Gamma Function comes from values of $x$ near $t$. Therefore use a partition of the Gamma Function with $t>0$, $f\left(x\right)={x}^{t}{e}^{-x}$ for $x>0$, and $A=\left\{x:|x-t|\ge t∕2\right\}$. Then

$\begin{array}{llll}\hfill \Gamma \left(t+1\right)& ={\int }_{0}^{\infty }{x}^{t}{e}^{-x}\phantom{\rule{0em}{0ex}}dx\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & ={\int }_{t∕2}^{3t∕2}f\left(x\right)\phantom{\rule{0em}{0ex}}dx+{\int }_{0}^{\infty }{1}_{A}\left(x\right)f\left(x\right)\phantom{\rule{0em}{0ex}}dx\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\end{array}$

where ${1}_{A}\left(\cdot \right)$ is the indicator function (or characteristic function) of $A$. For $x\in A$, $1\le 4{\left(x-t\right)}^{2}∕{t}^{2}$, so we have ${1}_{A}\left(x\right)\le 4{\left(x-t\right)}^{2}∕{t}^{2}$. Then

$\begin{array}{llll}\hfill \left|1-\frac{1}{\Gamma \left(t+1\right)}{\int }_{t∕2}^{3t∕2}{x}^{t}{e}^{-x}\phantom{\rule{0em}{0ex}}dx\right|& \le \frac{1}{\Gamma \left(t+1\right)}{\int }_{\left\{x:|x-t|\ge t∕2\right\}}\frac{4{\left(x-t\right)}^{2}}{{t}^{2}}{x}^{t}{e}^{-x}\phantom{\rule{0em}{0ex}}dx\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & \le \frac{4}{\Gamma \left(t+1\right){t}^{2}}{\int }_{0}^{\infty }{\left(x-t\right)}^{2}{x}^{t}{e}^{-x}\phantom{\rule{0em}{0ex}}dx\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & \phantom{\rule{2em}{0ex}}& \hfill \end{array}$

Expanding ${\left(x-t\right)}^{2}$ and using $\Gamma \left(z+1\right)=z\Gamma \left(z\right)$ from the remark following Lemma1 yields

${\int }_{0}^{\infty }{\left(x-t\right)}^{2}{x}^{t}{e}^{-x}\phantom{\rule{0em}{0ex}}dx=\left(t+2\right)\left(t+1\right)\Gamma \left(t+1\right)-2t\left(t+1\right)\Gamma \left(t+1\right)+{t}^{2}\Gamma \left(t+1\right).$

Then simplifying the right side

$\left|1-\frac{1}{\Gamma \left(t+1\right)}{\int }_{t∕2}^{3t∕2}{x}^{t}{e}^{-x}\phantom{\rule{0em}{0ex}}dx\right|\le 4\frac{2+t}{{t}^{2}}$

Making the change of variables $x=y\sqrt{t}+t$ and setting ${g}_{t}\left(y\right)={\left(1+y∕\sqrt{t}\right)}^{t}{e}^{-y\sqrt{t}}$ for $y>-\sqrt{t}$ just as in the proof of Lemma2, we get

 $\underset{t\to \infty }{lim}\frac{{t}^{t}\sqrt{t}}{\Gamma \left(t+1\right){e}^{t}}{\int }_{-\sqrt{t}∕2}^{\sqrt{t}∕2}{g}_{t}\left(y\right)\phantom{\rule{0em}{0ex}}dy=1.$ (4)

Now using $|x|\le 1∕2$ and Lemma3

$\left|log\left(1+x\right)-x+\frac{1}{2}{x}^{2}\right|\le \frac{1}{3}\frac{|x{|}^{3}}{1-|x|}\le \frac{2}{3}|x{|}^{3}\phantom{\rule{0em}{0ex}}.$

Then using Lemma5

$\left|{g}_{t}\left(y\right)-{e}^{-{y}^{2}∕2}\right|\le \frac{|y{|}^{3}}{\sqrt{t}}{e}^{-{y}^{2}∕6}$

for $|y|\le \sqrt{t}∕2$. Then

$\begin{array}{llll}\hfill \left|{\int }_{-\sqrt{t}∕2}^{\sqrt{t}∕2}{g}_{t}\left(y\right)\phantom{\rule{0em}{0ex}}dy-{\int }_{-\infty }^{\infty }{e}^{-{y}^{2}∕2}\phantom{\rule{0em}{0ex}}dy\right|& \le \frac{1}{\sqrt{t}}{\int }_{-\sqrt{t}∕2}^{\sqrt{t}∕2}|y{|}^{3}{e}^{-{y}^{2}∕6}\phantom{\rule{0em}{0ex}}dy+{\int }_{|y|>\sqrt{t}∕2}{e}^{-{y}^{2}}∕2\phantom{\rule{0em}{0ex}}dy\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & =\frac{-3\sqrt{t}{e}^{-t∕24}}{2}-\frac{36{e}^{-t∕24}}{\sqrt{t}}+\frac{36}{\sqrt{t}}+{\int }_{|y|>\sqrt{t}∕2}{e}^{-{y}^{2}}∕2\phantom{\rule{0em}{0ex}}dy\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & \phantom{\rule{2em}{0ex}}& \hfill \end{array}$

Therefore,

$\underset{t\to \infty }{lim}{\int }_{-\sqrt{t}∕2}^{\sqrt{t}∕2}{g}_{t}\left(y\right)\phantom{\rule{0em}{0ex}}dy={\int }_{-\infty }^{\infty }{e}^{-{y}^{2}∕2}\phantom{\rule{0em}{0ex}}dy=\sqrt{2\pi }\phantom{\rule{0em}{0ex}}.$

Combining this with the limit in equation 4, we have

$\underset{t\to \infty }{lim}\frac{\Gamma \left(t+1\right){e}^{t}}{\sqrt{2\pi }{t}^{t+1∕2}}=1\phantom{\rule{0em}{0ex}}.$

#### Sources

The main part of this section is adapted from the short note by R. Michel, . The alternate derivation is adapted from the even shorter note by R. Michel, .

_______________________________________________________________________________________________ ### Problems to Work for Understanding

1. Show that ${\int }_{-\infty }^{\infty }{e}^{-{y}^{2}∕2}\phantom{\rule{0em}{0ex}}\phantom{\rule{0em}{0ex}}dy=\sqrt{2\pi }$ .

__________________________________________________________________________ ### References

   Paul Garrett. Asymptotics of integrals. Online, accessed November 2012, July 2011.

   Reinhard Michel. On Stirling’s formula. American Mathematical Monthly, 109(4):388–390, April 2002.

   Reinhard Michel. The $\left(n+1\right)$th proof of Stirling’s Formula. American Mathematical Monthly, 115(9):844–845, November 2008.

__________________________________________________________________________ __________________________________________________________________________

I check all the information on each page for correctness and typographical errors. Nevertheless, some errors may occur and I would be grateful if you would alert me to such errors. I make every reasonable effort to present current and accurate information for public use, however I do not guarantee the accuracy or timeliness of information on this website. Your use of the information from this website is strictly voluntary and at your risk.

I have checked the links to external sites for usefulness. Links to external websites are provided as a convenience. I do not endorse, control, monitor, or guarantee the information contained in any external website. I don’t guarantee that the links are active at all times. Use the links here with the same caution as you would all information on the Internet. This website reflects the thoughts, interests and opinions of its author. They do not explicitly represent official positions or policies of my employer.

Information on this website is subject to change without notice.