# Stirling's approximation

Stirling's approximation

In mathematics, Stirling's approximation (or Stirling's formula) is an approximation for large factorials. It is named in honour of James Stirling.

The formula is written as

:$n! approx sqrt\left\{2pi n\right\}, left\left(frac\left\{n\right\}\left\{e\right\} ight\right)^\left\{n\right\}.$

Roughly, this means that these quantities approximate each other for all sufficiently large integers "n". More precisely, Stirling's formula says that

:$lim_\left\{n ightarrow infty\right\} \left\{frac\left\{n!\right\}\left\{sqrt\left\{2pi n\right\}, left\left(frac\left\{n\right\}\left\{e\right\} ight\right)^\left\{n\right\} = 1$

or

:$lim_\left\{n ightarrow infty\right\} \left\{frac\left\{e^n, n!\right\}\left\{n^n sqrt\left\{n\right\} = sqrt\left\{2 pi\right\}.$

or

:$lim_\left\{n ightarrow infty\right\} \left\{frac\left\{\left(1+frac\left\{1\right\}\left\{n\right\}\right)^\left\{n^2\right\}, n!\right\}\left\{n^n sqrt\left\{n\right\} = sqrt\left\{2 pi\right\}.$

or

:$lim_\left\{n ightarrow infty\right\} \left\{frac\left\{\left(\left(n+1\right)^\left\{n\right\}\right)^\left\{n\right\}, n!\right\} \left\{\left(\left(n\right)^n\right)^\left\{\left(n+1\right)\right\} sqrt\left\{n\right\} = sqrt\left\{2 pi\right\}.$

Derivation

The formula, together with precise estimates of its error, can be derived as follows. Instead of approximating "n"!, one considers its natural logarithm:

:$ln\left(n!\right) = ln 1 + ln 2 + cdots + ln n.$

The right-hand side of this equation is (almost) the approximation of the integral $int_1^n ln\left(x\right),dx = n ln n - n + 1$ using the trapezoid rule,and the error in this approximation is given by the Euler–Maclaurin formula:

:$ln \left(n!\right) - frac\left\{ln n\right\}\left\{2\right\} = ln 1 + ln 2 + cdots + ln\left(n-1\right) + frac\left\{ln n\right\}\left\{2\right\}= n ln n - n + 1 + sum_\left\{k=2\right\}^\left\{m\right\} frac\left\{B_k \left\{\left(-1\right)\right\}^k\right\}\left\{k\left(k-1\right)\right\} left\left( frac\left\{1\right\}\left\{n^\left\{k-1 - 1 ight\right) + R_\left\{m,n\right\},$

where "B""k" is Bernoulli number and "R"m,n is the remainder term in the Euler–Maclaurin formula.Take limits to find that

:$lim_\left\{n o infty\right\} left\left( ln n! - n ln n + n - frac\left\{ln n\right\}\left\{2\right\} ight\right) = 1 - sum_\left\{k=2\right\}^\left\{m\right\} frac\left\{B_k \left\{\left(-1\right)\right\}^k\right\}\left\{k\left(k-1\right)\right\} + lim_\left\{n o infty\right\} R_\left\{m,n\right\}.$

Denote this limit by "y". Because the remainder "R""m","n" in the Euler–Maclaurin formula satisfies

:$R_\left\{m,n\right\} = lim_\left\{n o infty\right\} R_\left\{m,n\right\} + O left\left( frac\left\{1\right\}\left\{n^m\right\} ight\right),$

where we use Big-O notation, combining the equations above yields the approximation formula in its logarithmic form:

:$ln n! = n ln left\left( frac\left\{n\right\}\left\{e\right\} ight\right) + frac\left\{ln n\right\}\left\{2\right\} + y + sum_\left\{k=2\right\}^\left\{m\right\} frac\left\{B_k \left\{\left(-1\right)\right\}^k\right\}\left\{k\left(k-1\right)n^\left\{k-1 + O left\left( frac\left\{1\right\}\left\{n^m\right\} ight\right).$

Taking the exponential of both sides, and choosing any positive integer "m", we get a formula involving an unknown quantity "e""y".For "m"="1", the formula is

:$n! = e^\left\{y\right\} sqrt\left\{n\right\}~\left\{left\left( frac\left\{n\right\}\left\{e\right\} ight\right)\right\}^n left\left( 1 + O left\left( frac\left\{1\right\}\left\{n\right\} ight\right) ight\right).$

The quantity "e""y" can be found by taking the limit on both sides as "n" tends to infinity and using Wallis' product,which shows that $e^y = sqrt\left\{2 pi\right\}$. Therefore, we get Stirling's formula:

:$n! = sqrt\left\{2 pi n\right\}~\left\{left\left( frac\left\{n\right\}\left\{e\right\} ight\right)\right\}^n left\left( 1 + O left\left( frac\left\{1\right\}\left\{n\right\} ight\right) ight\right).$

The formula may also be obtained by repeated integration by parts, and the leading term can be found through the method of steepest descent.Stirling's formula, without the factor $sqrt\left\{2 pi n\right\}$ that is often irrelevant in applications, can be quickly obtained by approximating the sum

:$ln\left(n!\right) = sum_\left\{j=1\right\}^\left\{n\right\} ln j$

with an integral:

:$sum_\left\{j=1\right\}^\left\{n\right\} ln j approx int_1^n ln x , dx = nln n - n + 1.$

Speed of convergence and error estimates

More precisely,

:$n! = sqrt\left\{2 pi n\right\} ; left\left(frac\left\{n\right\}\left\{e\right\} ight\right)^\left\{n\right\}e^\left\{lambda_n\right\}$

with

:$frac\left\{1\right\}\left\{12n+1\right\} < lambda_n < frac\left\{1\right\}\left\{12n\right\}.$

Stirling's formula is in fact the first approximation to the following series (now called the Stirling series):

:$n!=sqrt\left\{2pi n\right\}left\left(\left\{nover e\right\} ight\right)^n left\left( 1 +\left\{1over12n\right\} +\left\{1over288n^2\right\} -\left\{139over51840n^3\right\} -\left\{571over2488320n^4\right\} + cdots ight\right).$

As $n o infty$, the error in the truncated series is asymptotically equal to the first omitted term. This is an example of an asymptotic expansion. It is not a convergent series; for any "particular" value of "n" there are only so many terms of the series that improve accuracy, after which point accuracy actually gets worse. Let $S\left(n, t\right)$ be the Stirling series to $t$ terms evaluated at $n$. The graph shows $left | ln \left(S\left(n, t\right) / n!\right) ight |$, which, when small, is essentially the relative error.

The asymptotic expansion of the logarithm is also called "Stirling's series":

:$ln n!=nln n - n + \left\{1over 2\right\}ln\left(2pi n\right) +\left\{1over12n\right\} -\left\{1over360n^3\right\} +\left\{1over1260n^5\right\} -\left\{1over 1680n^7\right\} +cdots.$

In this case, it is known that the error in truncating the series is always of the same sign and at most the same magnitude as the first omitted term.

tirling's formula for the Gamma function

For all positive integers,

:$n! = Pi\left(n\right) = Gamma\left(n+1\right).$

However, the Gamma function, unlike the factorial, is more broadly defined for all complex numbers other than non-positive integers; nevertheless, Stirling's formula may still be applied. If $Re\left(z\right) > 0$ then

:$ln Gamma \left(z\right) = left\left(z-frac12 ight\right)ln z -z + frac\left\{ln \left\{2 pi\left\{2\right\} + 2 int_0^infty frac\left\{arctan frac\left\{t\right\}\left\{z\left\{exp\left(2 pi t\right)-1\right\}, dt.$

Repeated integration by parts gives the asymptotic expansion

:$ln Gamma \left(z\right) = left\left(z-frac12 ight\right)ln z -z + frac\left\{ln \left\{2 pi\left\{2\right\} + sum_\left\{n=1\right\}^infty frac\left\{\left(-1\right)^\left\{n-1\right\}B_\left\{n\left\{2n\left(2n-1\right)z^\left\{2n-1$

where "B""n" is the nth Bernoulli number. The formula is valid for "z" large enough in absolute value when $|arg z| < pi - epsilon$, where ε is positive, with an error term of$O\left(z^\left\{-m - 1/2\right\}\right)$ when the first "m" terms are used. The corresponding approximation may now be written:

:$Gamma\left(z\right) = sqrt\left\{frac\left\{2 pi\right\}\left\{ z~\left\{left\left( frac\left\{z\right\}\left\{e\right\} ight\right)\right\}^z left\left( 1 + O left\left( frac\left\{1\right\}\left\{z\right\} ight\right) ight\right).$

A convergent version of Stirling's formula

Thomas Bayes showed, in a letter to John Canton published by the Royal Society in 1763, that Stirling's formula did not give a convergent series. [http://www.york.ac.uk/depts/maths/histstat/letter.pdf]

Obtaining a convergent version of Stirling's formula entails evaluating

:$int_0^infty frac\left\{2arctan frac\left\{t\right\}\left\{z\left\{exp\left(2 pi t\right)-1\right\}, dt= lnGamma \left(z\right) - left\left( z-frac12 ight\right) ln z +z - frac12ln\left(2pi\right).$

One way to do this is by means of a convergent series of inverted rising exponentials. If $z^\left\{overline n\right\} = z\left(z+1\right) cdots \left(z+n-1\right)$, then

:$int_0^infty frac\left\{2arctan frac\left\{t\right\}\left\{z\left\{exp\left(2 pi t\right)-1\right\} , dt= sum_\left\{n=1\right\}^infty frac\left\{c_n\right\}\left\{\left(z+1\right)^\left\{overline n$

where

:$c_n = frac\left\{1\right\}\left\{n\right\} int_0^1 x^\left\{overline n\right\} left\left( x-frac12 ight\right) , dx.$

From this we obtain a version of Stirling's series

:$ln Gamma \left(z\right) = left\left( z-frac12 ight\right) ln z -z + frac\left\{ln \left\{2 pi\left\{2\right\}$:::$\left\{\right\} + frac\left\{1\right\}\left\{12\left(z+1\right)\right\} + frac\left\{1\right\}\left\{12\left(z+1\right)\left(z+2\right)\right\} + frac\left\{59\right\}\left\{360\left(z+1\right)\left(z+2\right)\left(z+3\right)\right\} + frac\left\{29\right\}\left\{60\left(z+1\right)\left(z+2\right)\left(z+3\right)\left(z+4\right)\right\} + cdots$

which converges when $Re\left(z\right)>0$.

A version suitable for calculators

The approximation

:$Gamma\left(z\right) approx sqrt\left\{frac\left\{2 pi\right\}\left\{z\right\} \right\} left\left( frac\left\{z\right\}\left\{e\right\} sqrt\left\{ z sinh frac\left\{1\right\}\left\{z\right\} + frac\left\{1\right\}\left\{810z^6\right\} \right\} ight\right)^\left\{z\right\},$

or equivalently,

:$2 ln Gamma\left(z\right) approx ln\left(2 pi\right) - ln z + z left\left(2 ln z + ln left\left( z sinh frac\left\{1\right\}\left\{z\right\} + frac\left\{1\right\}\left\{810z^6\right\} ight\right) - 2 ight\right),$

can be obtained by rearranging Stirling's extended formula and observing a coincidence between the resultant power series and the Taylor series expansion of the hyperbolic sine function. This approximation is good to more than 8 decimal digits for "z" with a real part greater than 8. Robert H. Windschitl suggested it in 2002 for computing the Gamma function with fair accuracy on calculators with limited program or register memory (see ref. 'Toth').

Gergő Nemes proposed in 2007 an approximation which gives the same number of exact digits as the Windschitl approximation but is much simpler:

:$Gamma\left(z\right) approx sqrt\left\{frac\left\{2 pi\right\}\left\{z\right\} \right\} left\left( frac\left\{1\right\}\left\{e\right\} left\left( z + frac\left\{1\right\}\left\{12z- frac\left\{1\right\}\left\{10z ight\right) ight\right)^\left\{z\right\},$

or equivalently,

:$ln Gamma\left(z\right) approx frac\left\{1\right\}\left\{2\right\} left\left(ln\left(2 pi\right) - ln z ight\right) + z left\left(ln left\left( z + frac\left\{1\right\}\left\{12z- frac\left\{1\right\}\left\{10z ight\right)-1 ight\right).$

History

The formula was first discovered by Abraham de Moivre in the form:$n!sim \left[\left\{ m constant\right\}\right] cdot n^\left\{n+1/2\right\} e^\left\{-n\right\}.$Stirling's contribution consisted of showing that the constantis $sqrt\left\{2pi\right\}$. The more precise versions are due to
Jacques Binet.

ee also

* Lanczos approximation
* Spouge's approximation

References

* Abramowitz, M. and Stegun, I., "Handbook of Mathematical Functions", http://www.math.hkbu.edu.hk/support/aands/toc.htm
* Paris, R. B., and Kaminsky, D., "Asymptotics and the Mellin-Barnes Integrals", Cambridge University Press, 2001
* Whittaker, E. T., and Watson, G. N., "A Course in Modern Analysis", fourth edition, Cambridge University Press, 1963. ISBN 0-521-58807-3
* Toth, V. T. "Programmable Calculators: Calculators and the Gamma Function". http://www.rskey.org/gamma.htm, modified 2006
*
*

Wikimedia Foundation. 2010.

### Look at other dictionaries:

• Stirling (disambiguation) — Stirling is a city in Scotland (formerly the Royal Burgh of Stirling). It also refers to several places related to this city:* Stirling (council area) * Stirling (Scottish Parliament constituency) * Stirling (UK Parliament constituency) *… …   Wikipedia

• Stirling-Formel — Die Stirling Formel ist eine mathematische Formel, mit der man für große Fakultäten Näherungswerte berechnen kann. Sie ist benannt nach dem Mathematiker James Stirling. Inhaltsverzeichnis 1 Grundlegendes 1.1 Herleitung der ersten beiden Glieder 2 …   Deutsch Wikipedia

• Stirling-Reihe — Die Stirling Formel ist eine mathematische Formel, mit der man für große Fakultäten Näherungswerte berechnen kann. Sie ist benannt nach dem Mathematiker James Stirling. Inhaltsverzeichnis 1 Grundlegendes 1.1 Herleitung der ersten beiden Glieder 2 …   Deutsch Wikipedia

• Stirling engine — Alpha type Stirling engine. There are two cylinders. The expansion cylinder (red) is maintained at a high temperature while the compression cylinder (blue) is cooled. The passage between the two cylinders contains the regenerator …   Wikipedia

• Formule de Stirling — Pour les articles homonymes, voir Stirling. La formule de Stirling, du nom du mathématicien écossais James Stirling, donne un équivalent de la factorielle au voisinage de l infini réel (quand n tend vers l infini) : que l on trouve souvent… …   Wikipédia en Français

• Lanczos approximation — In mathematics, the Lanczos approximation is a method for computing the Gamma function numerically, published by Cornelius Lanczos in 1964. It is a practical alternative to the more popular Stirling s approximation for calculating the Gamma… …   Wikipedia

• James Stirling (mathematician) — James Stirling (April 22, 1692 ndash;December 5, 1770) was a Scottish mathematician. He was educated at Balliol College, Oxford where he was a Snell exhibitionerThe Stirling numbers and Stirling s approximation are named after him. =External… …   Wikipedia

• Spouge's approximation — In mathematics, Spouge s approximation is a formula for the gamma function due to John L. Spouge. The formula is a modification of Stirling s approximation, and has the form:Gamma(z+1) = (z+a)^{z+1/2} e^{ (z+a)} left [ c 0 + sum {k=1}^{a 1}… …   Wikipedia

• Formule De Stirling — Pour les articles homonymes, voir Stirling. La formule de Stirling, du nom du mathématicien James Stirling, donne un équivalent de la factorielle au voisinage de l infini réel (quand n tend vers l infini) : que l on trouve souvent …   Wikipédia en Français

• Formule de stirling — Pour les articles homonymes, voir Stirling. La formule de Stirling, du nom du mathématicien James Stirling, donne un équivalent de la factorielle au voisinage de l infini réel (quand n tend vers l infini) : que l on trouve souvent …   Wikipédia en Français