Steven R. Dunbar

Department of Mathematics

203 Avery Hall

University of Nebraska-Lincoln

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 from Wallis’ Formula and the Trapezoidal Approximation

_______________________________________________________________________

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.

_______________________________________________________________________________________________

Mathematically Mature: may contain mathematics beyond calculus with proofs.

_______________________________________________________________________________________________

Can you summarize the steps in the “classical” proof of Stirling’s Formula using the Euler-Maclaurin Formula? That is, where does the proof start, what happens next, and what approximations and limits are used in the proof? Can you speculate why the proof is organized in this way?

_______________________________________________________________________________________________

- The Trapezoidal Approximation for the integral of a function $f$
such that the second derivative exists for all $x\in \left[a,b\right]$
is
$${\int}_{a}^{b}f\left(t\right)\phantom{\rule{3.26288pt}{0ex}}dt-\frac{f\left(a\right)+f\left(b\right)}{2}\cdot \left(b-a\right)=-\frac{{f}^{\prime \prime}\left(c\right)}{12}\cdot {\left(b-a\right)}^{3}$$
for some $c\in \left[a,b\right]$.

- Stirling’s Formula as an asymptotic limit follows from Wallis’ Formula and elementary manipulations that can be estimated using the Trapezoidal Approximation.

__________________________________________________________________________

- The Trapezoidal Approximation for the integral of a function $f$
such that the second derivative exists for all $x\in \left[a,b\right]$
is
$${\int}_{a}^{b}f\left(t\right)\phantom{\rule{3.26288pt}{0ex}}dt-\frac{f\left(a\right)+f\left(b\right)}{2}\cdot \left(b-a\right)=-\frac{{f}^{\prime \prime}\left(c\right)}{12}\cdot {\left(b-a\right)}^{3}$$
for some $c\in \left[a,b\right]$.

__________________________________________________________________________

Lemma 1 (Trapezoidal Approximation with Error Term). If $f$ is a function such that the second derivative exists for all $x\in \left[a,b\right]$ then

$${\int}_{a}^{b}f\left(t\right)\phantom{\rule{3.33237pt}{0ex}}dt-\frac{f\left(a\right)+f\left(b\right)}{2}\cdot \left(b-a\right)=-\frac{{f}^{\prime \prime}\left(c\right)}{12}\cdot {\left(b-a\right)}^{3}$$

for some $c\in \left[a,b\right]$.

Proof. Define the constant $K$ by

$${\int}_{a}^{b}f\left(t\right)\phantom{\rule{3.26288pt}{0ex}}dt-\frac{f\left(a\right)+f\left(b\right)}{2}\cdot \left(b-a\right)=K\cdot {\left(b-a\right)}^{3}.$$

Then the function

$$F\left(x\right)={\int}_{a}^{x}f\left(t\right)\phantom{\rule{3.26288pt}{0ex}}dt-\frac{f\left(a\right)+f\left(x\right)}{2}\cdot \left(x-a\right)-K\cdot {\left(x-a\right)}^{3}$$

satisfies $F\left(a\right)=F\left(b\right)=0$. Apply Rolle’s Theorem to $F\left(x\right)$ to conclude that for some $t\in \left(a,b\right)$ the derivative

$${F}^{\prime}\left(x\right)=f\left(x\right)-\frac{{f}^{\prime}\left(x\right)}{2}\cdot \left(x-a\right)-\frac{f\left(a\right)+f\left(x\right)}{2}-3K\cdot {\left(x-a\right)}^{2}$$

is zero, ${F}^{\prime}\left(t\right)=0$. Furthermore ${F}^{\prime}\left(a\right)=0$, so applying Rolle’s Theorem again, there is some $c\in \left(a,t\right)$ with ${F}^{\prime \prime}\left(c\right)=0$. That is,

$${F}^{\prime \prime}\left(c\right)=0=-\frac{{f}^{\prime \prime}\left(c\right)}{2}\cdot \left(c-a\right)-6K\cdot \left(c-a\right)$$

so solving for $K$ gives $K=-\frac{{f}^{\prime \prime}\left(c\right)}{12}$. □

Remark. This version of the Trapezoidal Approximation is more general and more refined than Lemma 1 in Stirlings Formula by Euler-Maclaurin Summation.. The estimate there is only an upper bound on the error over the unit interval $\left[r-1,r\right]$ proved using a Taylor polynomial approximation. Numerical analysis texts usually derive the Trapezoidal Approximation and the error estimate by linear interpolation through the endpoints of integration, also known as Lagrange Interpolation, or the Newton-Cotes formula.

$$\frac{{\left(n!\right)}^{2}}{\left(2n\right)!}\sim \frac{\sqrt{\pi n}}{{2}^{2n}}$$ | (1) |

as $n\to \infty $.

Proof. This asymptotic limit follows easily from the asymptotic expression for the central binomial term, see Wallis’ Formula.. The details are left as an exercise. □

If we multiply the left hand side of (1) with $\frac{\left(2n\right)!}{n!}$, we get $n!$, the object of our attention. Rewrite $\frac{\left(2n\right)!}{n!}$ as

$$\begin{array}{llll}\hfill \frac{\left(2n\right)!}{n!}& =\left(2n\right)\left(2n-1\right)\cdots \left(n+1\right)\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & ={n}^{n}\left[\left(1+\frac{n}{n}\right)\left(1+\frac{n-1}{n}\right)\cdots \left(1+\frac{1}{n}\right)\right].\phantom{\rule{2em}{0ex}}& \hfill \text{(2)}\end{array}$$Take the logarithm of the bracketed product in (2) and then rewrite to obtain

$$\begin{array}{llll}\hfill & log\left(1+\frac{n}{n}\right)+log\left(1+\frac{n-1}{n}\right)+\cdots +log\left(1+\frac{1}{n}\right)\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & \phantom{\rule{1em}{0ex}}=n\left[\frac{1}{n}log\left(1+\frac{n}{n}\right)+\frac{1}{n}log\left(1+\frac{n-1}{n}\right)+\cdots +\frac{1}{n}log\left(1+\frac{1}{n}\right)\right]\phantom{\rule{2em}{0ex}}& \hfill \text{(3)}\\ \hfill & \phantom{\rule{1em}{0ex}}\approx n{\int}_{1}^{2}logxdx\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & \phantom{\rule{1em}{0ex}}=n\left(2log2-1\right).\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\end{array}$$Recognizing the second line (3) as a right-box Riemann sum written in reverse order we have discovered the way to approach Stirling’s Formula.

Write the trapezoidal approximation of ${\int}_{1}^{2}logxdx$ on the partition $\left\{{x}_{0}=1,{x}_{1}=1+1\u2215n,{x}_{3}=1+2\u2215n,\dots ,{x}_{n}=1+n\u2215n=2\right\}$ as

$$\frac{1}{2n}log1+\frac{1}{n}log\left(1+\frac{1}{n}\right)+\frac{1}{n}log\left(1+\frac{2}{n}\right)+\cdots +\frac{1}{n}log\left(1+\frac{n-1}{n}\right)+\frac{1}{2n}log2.$$ | (4) |

This trapezoidal approximation differs from the sum in brackets in (3) by only $\frac{1}{2n}log2$ since $log1$ is zero. The limit of expression (4) is still ${\int}_{1}^{2}logxdx=2log2-1$, but we can bound the error with Lemma 1.

$$\begin{array}{c}\left(2log2-1\right)-\\ \left[\frac{1}{2n}log1+\frac{1}{n}log\left(1+\frac{1}{n}\right)+\cdots +\frac{1}{n}log\left(1+\frac{n-1}{n}\right)+\frac{1}{2n}log2\right]\\ =\sum _{j=1}^{n}\frac{1}{12{c}_{j}^{2}}\frac{1}{{n}^{3}}.\end{array}$$The difference is positive since $log\left(x\right)$ is concave-down. Since $-{f}^{\prime \prime}\left(x\right)=1\u2215{x}^{2}$ is bounded above by 1 on $\left[1,2\right]$, we can uniformly estimate the upper bound so

$$\begin{array}{c}0\le \\ \left(2log2-1\right)-\left[\frac{1}{2n}log1+\frac{1}{n}log\left(1+\frac{1}{n}\right)+\cdots +\frac{1}{n}log\left(1+\frac{n-1}{n}\right)+\frac{1}{2n}log2\right]\\ \le \frac{1}{12{n}^{2}}.\end{array}$$Now use $log1=0$ and using knowledge of what Stirling’s Formula should look like, add in and subtract out $\frac{1}{2n}log2$ and rewrite the last summand to obtain

$$\begin{array}{c}0\le \\ \left(2log2-1\right)-\left[\frac{1}{n}log\left(1+\frac{1}{n}\right)+\cdots +\frac{1}{n}log\left(1+\frac{n}{n}\right)-\frac{1}{2n}log2\right]\\ \le \frac{1}{12{n}^{2}}.\end{array}$$

Multiply by $n$ and rearrange the result:

$$0\le n\left(2log2-1\right)+\frac{1}{2}log2-log\left[\left(1+\frac{1}{n}\right)\left(1+\frac{2}{n}\right)\cdots \left(1+\frac{n}{n}\right)\right]\le \frac{1}{12n}$$

Exponentiate both sides and taking the limit as $n\to \infty $ gives

$$\left(1+\frac{n}{n}\right)\left(1+\frac{n-1}{n}\right)\cdots \left(1+\frac{1}{n}\right)\sim {e}^{n\left(2log2-1\right)+log2\u22152}$$

Multiply by ${n}^{n}$ and rewrite the right side to get the asymptotic estimate for equation (2)

$$\frac{\left(2n\right)!}{n!}\sim \frac{{2}^{2n}{n}^{n}\sqrt{2}}{{e}^{n}},\phantom{\rule{2em}{0ex}}n\to \infty .$$ | (5) |

Recall from equation (1) in Lemma 2 that

$$\frac{{\left(n!\right)}^{2}}{\left(2n\right)!}\sim \frac{\sqrt{\pi n}}{{2}^{2n}}$$

and apply the Multiplication II Lemma from Asymptotic Limits. to this asymptotic limit to get

$$n!\sim \frac{\left(2n\right)!}{n!}\frac{\sqrt{n\pi}}{{2}^{2n}}.$$

Then put this together with the asymptotic limit (5) and use the Substitution Lemma from Asymptotic Limits. to finally obtain Stirling’s Formula:

$$n!\sim \frac{{n}^{n+1\u22152}}{{e}^{n}}\sqrt{2\pi}.$$

The classic proof of Stirling’s Formula starts with $log\left(n!\right)={\sum}_{j=1}^{n}log\left(j\right)$. The classic proof expresses this as ${\int}_{0}^{n-1}log\left(1+x\right)dx$ with an error term with the Euler-Maclaurin summation formula. The Euler-Maclaurin summation formula is an adaptation of the Trapezoidal Approximation. (Alternatively, the Euler-Maclaurin summation formula is a result of the Fundamental Theorem of Calculus, summation by parts, and integration by parts.) This allows us to write

$$log\left(n!\right)=nlog\left(n\right)-n+1+\frac{1}{2}log\left(n\right)+{\int}_{1}^{\infty}\frac{{B}_{1}\left(x\right)}{x}\phantom{\rule{0em}{0ex}}dx-{\u03f5}_{n}$$ | (6) |

where

$${\u03f5}_{n}={\int}_{n}^{\infty}\frac{{B}_{1}\left(x\right)}{x}\phantom{\rule{0em}{0ex}}dx$$

and ${\u03f5}_{n}\to 0$ as $n\to \infty $. Then start from Wallis’ Formula and take logarithms, replacing the logarithms of the factorials with equation (6). This provides an equation for the integral ${\int}_{1}^{\infty}\frac{{B}_{1}\left(x\right)}{x}\phantom{\rule{0em}{0ex}}dx$ which is solved for the value $log\left(\sqrt{2\pi}\right)-1$. Then the equation above can be exponentiated to express Stirling’s Formula.

The present proof of Stirling’s Formula starts from Wallis’ Formula in the form of an asymptotic estimate for the central binomial term ${\left(n!\right)}^{2}\u2215\left(2n\right)!$. Isolate $n!$ on one side of the central binomial term asymptotic estimate and write the other part $\left(2n\right)!\u2215n!$ as a Riemann sum for $n{\int}_{1}^{2}logxdx$. The present proof then uses the Trapezoidal Rule to express the approximation for

$$\frac{\left(2n\right)!}{n!}=\left(2n\right)\left(2n-1\right)\cdots \left(n+1\right)={n}^{n}\left[\left(1+\frac{n}{n}\right)\left(1+\frac{n-1}{n}\right)\cdots \left(1+\frac{1}{n}\right)\right].$$

with an error term. Then the proof combines this with the asymptotic form of Wallis Formula to produce the asymptotic form of Stirling’s Formula. The present proof cannot be immediately adapted to give Stirling’s Formula with an error estimate because an essential step is to use Wallis’ Formula as an asymptotic limit and we do not have a error estimate on that limit.

The present proof uses the same ingredients of the Trapezoidal Rule and Wallis Formula as the Euler-Maclaurin proof, but uses them in reverse order and in somewhat different ways.

This section is adapted from the short article [1] by Paul Levrie in the June 2011 issue of Mathematics Magazine.

_______________________________________________________________________________________________

- Show that
$$\frac{{\left(n!\right)}^{2}}{\left(2n\right)!}\sim \frac{\sqrt{\pi n}}{{2}^{2n}}$$
as $n\to \infty $.

__________________________________________________________________________

[1] Paul Levrie. Stirred, not shaken, by Stirling’s Formula. Mathematics Magazine, 84(3):208–211, June 2011.

__________________________________________________________________________

__________________________________________________________________________

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.

Steve Dunbar’s Home Page, http://www.math.unl.edu/~sdunbar1

Email to Steve Dunbar, sdunbar1 at unl dot edu

Last modified: Processed from LATEX source on October 10, 2011