Stirling's approximation

From Wikipedia, the free encyclopedia
(Redirected from Stirling approximation)

Template:Short description Template:CS1 config Template:Dark mode invert In mathematics, Stirling's approximation (or Stirling's formula) is an asymptotic approximation for factorials. It is a good approximation, leading to accurate results even for small values of n. It is named after James Stirling, though a related but less precise result was first stated by Abraham de Moivre.[1]Template:R/superscript[2]Template:R/superscript[3]Template:R/superscript

One way of stating the approximation involves the logarithm of the factorial: lnn!=nlnnn+O(lnn), where the big O notation means that, for all sufficiently large values of n, the difference between lnn! and nlnnn will be at most proportional to the logarithm of n. In computer science applications such as the worst-case lower bound for comparison sorting, it is convenient to instead use the binary logarithm, giving the equivalent form log2n!=nlog2nnlog2e+O(log2n). The error term in either base can be expressed more precisely as 12log(2πn)+O(1n), corresponding to an approximate formula for the factorial itself, n!2πn(ne)n. Here the sign means that the two quantities are asymptotic, that is, their ratio tends to 1 as n tends to infinity.

History

The formula was first discovered by Abraham de Moivre[2]Template:R/superscript in 1721 in the form n![constant]nn+12en.

De Moivre gave an approximate rational-number expression for the natural logarithm of the constant. Stirling's contribution in 1730 consisted of showing that the constant is precisely 2π.[3]Template:R/superscript[4]

Derivation

The simplest version of Stirling's formula is n!=2πn(ne)n(1+O(1n)). It can be quickly obtained by approximating the sum lnn!=j=1nlnj with an integral: j=1nlnj1nlnxdx=nlnnn+1.

The full formula, together with precise estimates of its error, can be derived as follows. Instead of approximating n!, one considers its natural logarithm, as this is a slowly varying function: lnn!=ln1+ln2++lnn.

The right-hand side of this equation minus 12(ln1+lnn)=12lnn is the approximation by the trapezoid rule of the integral lnn!12lnn1nlnxdx=nlnnn+1,

and the error in this approximation is given by the Euler–Maclaurin formula: lnn!12lnn=ln1+ln2+ln3++ln(n1)+12lnn=nlnnn+1+k=2m(1)kBkk(k1)(1nk11)+Rm,n,

where Bk is a Bernoulli number, and Rm,n is the remainder term in the Euler–Maclaurin formula. Take limits to find that limn(lnn!nlnn+n12lnn)=1k=2m(1)kBkk(k1)+limnRm,n.

Denote this limit as y. Because the remainder Rm,n in the Euler–Maclaurin formula satisfies Rm,n=limnRm,n+O(1nm),

where big-O notation is used, combining the equations above yields the approximation formula in its logarithmic form: lnn!=nln(ne)+12lnn+y+k=2m(1)kBkk(k1)nk1+O(1nm).

Taking the exponential of both sides and choosing any positive integer m, one obtains a formula involving an unknown quantity ey. For m = 1, the formula is n!=eyn(ne)n(1+O(1n)).

The quantity ey can be found by taking the limit on both sides as n tends to infinity and using Wallis' product, which shows that ey=2π. Therefore, one obtains Stirling's formula.

Alternative derivations

An alternative formula for n! using the gamma function is n!=0xnexdx. (as can be seen by repeated integration by parts). Rewriting and changing variables x = ny, one obtains n!=0enlnxxdx=enlnnn0en(lnyy)dy. Applying Laplace's method one has 0en(lnyy)dy2πnen, which recovers Stirling's formula: n!enlnnn2πnen=2πn(ne)n.

Higher orders

Further corrections can also be obtained using Laplace's method. Stirling's formula to two orders isn!=2πn(ne)n(1+112n+O(1n2)).

From previous result, we know that Γ(x)xxex, so we "peel off" this dominant term, then perform two changes of variables, to obtain:xxexΓ(x)=ex(1+tet)dtTo verify this: ex(1+tet)dt=tlntex0tx1extdt=tt/xxxex0ettx1dt=xxexΓ(x).

Now the function t1+tet is unimodal, with maximum value zero. Locally around zero, it looks like t2/2, which is why we are able to perform Laplace's method. In order to extend Laplace's method to higher orders, we perform another change of variables by 1+tet=τ2/2. This equation cannot be solved in closed form, but it can be solved by serial expansion, which gives us t=ττ2/6+τ3/36+a4τ4+O(τ5). Now plug back to the equation to obtainxxexΓ(x)=exτ2/2(1τ/3+τ2/12+4a4τ3+O(τ4))dτ=2π(x1/2+x3/2/12)+O(x5/2)notice how we don't need to actually find a4, since it is cancelled out by the integral. Higher orders can be achieved by computing more terms in t=τ+, which can be obtained programmatically.Template:NoteTag

Complex-analytic version

A complex-analysis version of this method[5]Template:R/superscript is to consider 1n! as a Taylor coefficient of the exponential function ez=n=0znn!, computed by Cauchy's integral formula as 1n!=12πi|z|=rezzn+1dz.

This line integral can then be approximated using the saddle-point method with an appropriate choice of contour radius r=rn. The dominant portion of the integral near the saddle point is then approximated by a real integral and Laplace's method, while the remaining portion of the integral can be bounded above to give an error term.

Using the Central Limit Theorem and the Poisson distribution

An alternative version uses the fact that the Poisson distribution converges to a normal distribution by the Central Limit Theorem.[6]

Since the Poisson distribution with parameter μ converges to a normal distribution with mean μ and variance μ, their density functions will be approximately the same:

exp(μ)μxx!12πμexp(12(xμμ)2)

Evaluating this expression at the mean, at which the approximation is particularly accurate, simplifies this expression to:

exp(μ)μμμ!12πμ

Taking logs then results in

μ+μlnμlnμ!12ln(2πμ)

which can easily be rearranged to give:

lnμ!μlnμμ+12ln(2πμ)

Evaluating at μ=n gives the usual, more precise form of Stirling's approximation.

Speed of convergence and error estimates

Template:Dark mode invert

Stirling's formula is in fact the first approximation to the following series (now called the Stirling series):[7]Template:R/superscript n!2πn(ne)n(1+112n+1288n213951840n35712488320n4+163879209018880n5).

An explicit formula for the coefficients in this series was given by G. Nemes.[8]Template:R/superscript Further terms are listed in the On-Line Encyclopedia of Integer Sequences as A001163 and A001164. The first graph in this section shows the relative error vs. n, for 1 through all 5 terms listed above. The coefficients have the following asymptotic formula:[9] A2j+1(1)j2(2j)!(2π)2(j+1)which shows that it grows superexponentially, and that by the ratio test the radius of convergence is zero.

However, the representation obtained directly from the Euler–Maclaurin approximation, in which the correction term itself is the argument of the exponential function, converges much faster (needs half the number of correction terms for the same accuracy):[citation needed] n!2πn(ne)nexp(112n1360n3+11260n511680n7+11188n9). The kth coefficient (for the reciprocal of the (2k1)th power of n) is directly calculated using Bernoulli numbers and ck=B2k2k(2k1). Template:Dark mode invert

As n → ∞, 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 accuracy worsens. This is shown in the next graph, which shows the relative error versus the number of terms in the series, for larger numbers of terms. More precisely, let St (n) be the Stirling series to t terms evaluated at n. The graphs show |lnSt(n)n!|, which, when small, is essentially the relative error.

Writing Stirling's series in the form lnn!nlnnn+12ln(2πn)+112n1360n3+11260n511680n7+, it is known that the error in truncating the series is always of the opposite sign and at most the same magnitude as the first omitted term.[citation needed]

Other bounds, due to Robbins,[10]Template:R/superscript valid for all positive integers n are 2πn(ne)ne112n+1<n!<2πn(ne)ne112n. This upper bound corresponds to stopping the above series for lnn! after the 1n term. The lower bound is weaker than that obtained by stopping the series after the 1n3 term. A looser version of this bound is that n!ennn+12(2π,e] for all n1.

Stirling's formula for the gamma function

For all positive integers, n!=Γ(n+1), where Γ denotes the gamma function.

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(z) > 0, then lnΓ(z)=zlnzz+12ln2πz+02arctan(tz)e2πt1dt.

Repeated integration by parts gives lnΓ(z)zlnzz+12ln2πz+n=1N1B2n2n(2n1)z2n1=zlnzz+12ln2πz+112z1360z3+11260z5+,

where Bn is the nth Bernoulli number (note that the limit of the sum as N is not convergent, so this formula is just an asymptotic expansion). The formula is valid for z large enough in absolute value, when Template:Abs < π − ε, where ε is positive, with an error term of O(z−2N+ 1). The corresponding approximation may now be written: Γ(z)=2πz(ze)z(1+O(1z)).

where the expansion is identical to that of Stirling's series above for n!, except that n is replaced with z − 1.[11]Template:R/superscript

A further application of this asymptotic expansion is for complex argument z with constant Re(z). See for example the Stirling formula applied in Im(z) = t of the Riemann–Siegel theta function on the straight line Page Template:Sfrac/styles.css has no content.1/4 + it.

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.[12]Template:R/superscript Obtaining a convergent version of Stirling's formula entails evaluating Binet's formula: 02arctan(tx)e2πt1dt=lnΓ(x)xlnx+x12ln2πx.

One way to do this is by means of a convergent series of inverted rising factorials. If zn¯=z(z+1)(z+n1), then 02arctan(tx)e2πt1dt=n=1cn(x+1)n¯, where cn=1n01xn¯(x12)dx=12nk=1nk|s(n,k)|(k+1)(k+2), where s(nk) denotes the Stirling numbers of the first kind. From this one obtains a version of Stirling's series lnΓ(x)=xlnxx+12ln2πx+112(x+1)+112(x+1)(x+2)+59360(x+1)(x+2)(x+3)+2960(x+1)(x+2)(x+3)(x+4)+, which converges when Re(x) > 0. Stirling's formula may also be given in convergent form as[13] Γ(x)=2πxx12ex+μ(x) where μ(x)=n=0((x+n+12)ln(1+1x+n)1).

Versions suitable for calculators

The approximation Γ(z)2πz(zezsinh1z+1810z6)z and its equivalent form 2lnΓ(z)ln(2π)lnz+z(2lnz+ln(zsinh1z+1810z6)2) 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.[14]Template:R/superscript

Gergő Nemes proposed in 2007 an approximation which gives the same number of exact digits as the Windschitl approximation but is much simpler:[15]Template:R/superscript Γ(z)2πz(1e(z+112z110z))z, or equivalently, lnΓ(z)12(ln(2π)lnz)+z(ln(z+112z110z)1).

An alternative approximation for the gamma function stated by Srinivasa Ramanujan in Ramanujan's lost notebook[16] is Γ(1+x)π(xe)x(8x3+4x2+x+130)16 for x ≥ 0. The equivalent approximation for ln n! has an asymptotic error of Page Template:Sfrac/styles.css has no content.1/1400n3 and is given by lnn!nlnnn+16ln(8n3+4n2+n+130)+12lnπ.

The approximation may be made precise by giving paired upper and lower bounds; one such inequality is[17]Template:R/superscript[18]Template:R/superscript[19]Template:R/superscript[20]Template:R/superscript π(xe)x(8x3+4x2+x+1100)1/6<Γ(1+x)<π(xe)x(8x3+4x2+x+130)1/6.

See also

References

Page Template:Reflist/styles.css has no content.

  1. ^ Page Module:Citation/CS1/styles.css has no content.Dutka, Jacques (1991), "The early history of the factorial function", Archive for History of Exact Sciences, 43 (3): 225–249, doi:10.1007/BF00389433, S2CID 122237769
  2. ^ a b Page Module:Citation/CS1/styles.css has no content.Le Cam, L. (1986), "The central limit theorem around 1935", Statistical Science, 1 (1): 78–96, doi:10.1214/ss/1177013818, JSTOR 2245503, MR 0833276; see p. 81, "The result, obtained using a formula originally proved by de Moivre but now called Stirling's formula, occurs in his 'Doctrine of Chances' of 1733."
  3. ^ a b Page Module:Citation/CS1/styles.css has no content.Pearson, Karl (1924), "Historical note on the origin of the normal curve of errors", Biometrika, 16 (3/4): 402–404 [p. 403], doi:10.2307/2331714, JSTOR 2331714, I consider that the fact that Stirling showed that De Moivre's arithmetical constant was 2π does not entitle him to claim the theorem, [...]
  4. ^ Methodus Differentialis: Sive Tractatus de Summatione et Interpolatione Serierum Infinitarum, Jacob Stirling, London, 1730
  5. ^ Page Module:Citation/CS1/styles.css has no content.Flajolet, Philippe; Sedgewick, Robert (2009), Analytic Combinatorics, Cambridge, UK: Cambridge University Press, p. 555, doi:10.1017/CBO9780511801655, ISBN 978-0-521-89806-5, MR 2483235, S2CID 27509971
  6. ^ Page Module:Citation/CS1/styles.css has no content.MacKay, David J. C. (2019), Information theory, inference, and learning algorithms (22nd printing ed.), Cambridge: Cambridge University Press, ISBN 978-0-521-64298-9
  7. ^ Page Module:Citation/CS1/styles.css has no content.Olver, F. W. J.; Olde Daalhuis, A. B.; Lozier, D. W.; Schneider, B. I.; Boisvert, R. F.; Clark, C. W.; Miller, B. R. & Saunders, B. V., "5.11 Gamma function properties: Asymptotic Expansions", NIST Digital Library of Mathematical Functions, Release 1.0.13 of 2016-09-16
  8. ^ Page Module:Citation/CS1/styles.css has no content.Nemes, Gergő (2010), "On the coefficients of the asymptotic expansion of n!", Journal of Integer Sequences, 13 (6): 5
  9. ^ Page Module:Citation/CS1/styles.css has no content.Bender, Carl M.; Orszag, Steven A. (2009), Advanced mathematical methods for scientists and engineers. 1: Asymptotic methods and perturbation theory (Nachdr. ed.), New York, N p=218: Springer, ISBN 978-0-387-98931-0{{cite book}}: CS1 maint: location (link)
  10. ^ Page Module:Citation/CS1/styles.css has no content.Robbins, Herbert (1955), "A Remark on Stirling's Formula", The American Mathematical Monthly, 62 (1): 26–29, doi:10.2307/2308012, JSTOR 2308012
  11. ^ Page Module:Citation/CS1/styles.css has no content.Spiegel, M. R. (1999), Mathematical handbook of formulas and tables, McGraw-Hill, p. 148
  12. ^ Page Module:Citation/CS1/styles.css has no content.Bayes, Thomas (24 November 1763), "A letter from the late Reverend Mr. Thomas Bayes, F. R. S. to John Canton, M. A. and F. R. S." (PDF), Philosophical Transactions, 53: 269, Bibcode:1763RSPT...53..269B, archived (PDF) from the original on 2012-01-28, retrieved 2012-03-01
  13. ^ Page Module:Citation/CS1/styles.css has no content.Artin, Emil (2015), The Gamma Function, Dover, p. 24
  14. ^ Toth, V. T. Programmable Calculators: Calculators and the Gamma Function (2006) Script error: No such module "webarchive"..
  15. ^ Page Module:Citation/CS1/styles.css has no content.Nemes, Gergő (2010), "New asymptotic expansion for the Gamma function", Archiv der Mathematik, 95 (2): 161–169, doi:10.1007/s00013-010-0146-9, S2CID 121820640
  16. ^ Page Module:Citation/CS1/styles.css has no content.Ramanujan, Srinivasa (14 August 1920), Lost Notebook and Other Unpublished Papers, p. 339 – via Internet Archive
  17. ^ Page Module:Citation/CS1/styles.css has no content.Karatsuba, Ekatherina A. (2001), "On the asymptotic representation of the Euler gamma function by Ramanujan", Journal of Computational and Applied Mathematics, 135 (2): 225–240, Bibcode:2001JCoAM.135..225K, doi:10.1016/S0377-0427(00)00586-0, MR 1850542
  18. ^ Page Module:Citation/CS1/styles.css has no content.Mortici, Cristinel (2011), "Ramanujan's estimate for the gamma function via monotonicity arguments", Ramanujan J., 25 (2): 149–154, doi:10.1007/s11139-010-9265-y, S2CID 119530041
  19. ^ Page Module:Citation/CS1/styles.css has no content.Mortici, Cristinel (2011), "Improved asymptotic formulas for the gamma function", Comput. Math. Appl., 61 (11): 3364–3369, doi:10.1016/j.camwa.2011.04.036.
  20. ^ Page Module:Citation/CS1/styles.css has no content.Mortici, Cristinel (2011), "On Ramanujan's large argument formula for the gamma function", Ramanujan J., 26 (2): 185–192, doi:10.1007/s11139-010-9281-y, S2CID 120371952.

Further reading


Page Template:Reflist/styles.css has no content.

Page Module:Side box/styles.css has no content.Page Template:Sister project/styles.css has no content.

Lua error in package.lua at line 80: module 'Module:Navbox/configuration' not found.