taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Volume C1 · Basic concepts · TAOCP Section 1.2.11.3

Some asymptotic calculations

Draft. This chapter is written and checked by the tools of the project, and a person has not reviewed it yet. Read it with care.

Read it next to Section 1.2.11.3 of the book. The nodes and the exercises of the section.

Contents
  1. Some asymptotic calculations

Some asymptotic calculations

Overview

Section 1.2.11.3 of TAOCP defines three sums. P(n)P(n) and Q(n)Q(n) have n+1n+1 and nn terms, and R(n)R(n) has infinitely many terms. Each term is a product of fractions that are close to 11 at first and then fall. The question is how large each sum is when nn is large. The answer is the same for the three sums to first order: each is close to πn/2\sqrt{\pi n/2}. The sums differ in the second term, which is −23-\frac23 for PP, −13-\frac13 for QQ and +13+\frac13 for RR.

The section proves the result for QQ and RR through the incomplete gamma function γ(a,x)\gamma(a, x). Eq. (4) says that Q+RQ + R is n! en/nnn!\, e^n/n^n. Eq. (9) says that RR is n! en/nnn!\, e^n/n^n times γ(n,n)/(n−1)!\gamma(n, n)/(n-1)!. Theorem A then gives the size of γ(x+1,x+y)/Γ(x+1)\gamma(x+1, x+y)/\Gamma(x+1) for large xx. The proof of Theorem A splits the integral at t=xt = x, treats the upper tail by the substitution v=u−ln⁡(1+u)v = u - \ln(1+u) and treats the short middle part by a Taylor expansion. The sum P(n)P(n) needs another idea: it compares a sum with an integral by the trapezoid form of Euler's formula.

The ideas

QQ and RR are two halves of one exponential series. The terms of QQ are the first nn terms of ene^n, and the terms of RR are the rest, each scaled by n!/nnn!/n^n. This gives eq. (4) at once. The size of Q+RQ + R is 2πn\sqrt{2\pi n} by Stirling's formula, so each of the two is about half of this.

The incomplete gamma function measures the cut. The partial sum of the series for exe^x equals exe^x times the fraction of Γ(n)\Gamma(n) that the integral of e−ttn−1e^{-t} t^{n-1} misses beyond xx. This is eq. (5) and eq. (9). With x=nx = n the cut is at the peak of the integrand, and the fraction is close to 12\frac12.

Near its peak the integrand is a Gaussian. The function e−ttxe^{-t} t^x has its peak at t=xt = x. A change of variable that turns txe−tt^x e^{-t} into e−xve^{-xv} moves the work to a power series in v\sqrt v. Watson's lemma then turns each power into a gamma value.

A short interval needs only a Taylor series. The piece of the integral from xx to x+yx + y has a length that does not grow. There the exponent is −u2/(2x)+u3/(3x2)+⋯-u^2/(2x) + u^3/(3x^2) + \cdots, and a few terms are enough.

A sum can be turned into an integral. The terms of P(n)P(n) are close to jn+1/2e−jj^{n+1/2} e^{-j} after Stirling's formula. The sum of these is the integral plus the half of the last term plus a small remainder. The integral is again a value of γ\gamma.

C1 follows the order of the section. Each numbered equation of the section has its own block, and the five-term forms of PP, QQ and RR are Theorems C1.1.2.11.3.27 to C1.1.2.11.3.29. C1 adds two blocks that the section has only as text or exercises: the change of variable of Lemma C1.1.2.11.3.11 and Watson's lemma (Lemma C1.1.2.11.3.16).

Definitions, results and proofs

Definition C1.1.2.11.3.1 (the sum P(n)P(n), TAOCP eq. 1.2.11.3(1)). For an integer n≥1n \ge 1 let

P(n)=∑k=0n(n−k)k (n−k)!n!=1+n−1n+(n−2)2n(n−1)+⋯ .P(n) = \sum_{k=0}^{n} \frac{(n-k)^k\, (n-k)!}{n!} = 1 + \frac{n-1}{n} + \frac{(n-2)^2}{n(n-1)} + \cdots.

Node: TACDQGD0S2 · Lean: TAOCP.S1_2_11.P · status: not stated yet

Explanation. The term k=0k = 0 is 11. The term k=nk = n is 0n⋅0!/n!=00^n \cdot 0!/n! = 0 for n≥1n \ge 1. The sum has nn nonzero terms. The terms are positive and they first fall slowly and then fast.

Example. For n=5n = 5 the terms for k=0,…,5k = 0, \ldots, 5 are 11, 45\frac45, 920\frac9{20}, 215\frac2{15}, 1120\frac1{120} and 00. The sum is P(5)=287120=2.391667P(5) = \frac{287}{120} = 2.391667. The exact values for small nn are P(1)=1P(1) = 1, P(2)=32P(2) = \frac32, P(3)=116P(3) = \frac{11}6 and P(4)=178P(4) = \frac{17}8.

Proof. The definition is a formula, and a formula has no proof. The check of the terms for n=5n = 5 is a calculation: for k=2k = 2 the term is 32⋅3!/5!=54/120=9203^2 \cdot 3!/5! = 54/120 = \frac9{20}, and for k=4k = 4 the term is 14⋅1!/5!=11201^4 \cdot 1!/5! = \frac1{120}. □\square

Definition C1.1.2.11.3.2 (the sum Q(n)Q(n), TAOCP eq. 1.2.11.3(2)). For an integer n≥1n \ge 1 let

Q(n)=∑k=1nn!(n−k)! nk=1+n−1n+n−2n⋅n−1n+⋯ .Q(n) = \sum_{k=1}^{n} \frac{n!}{(n-k)!\, n^k} = 1 + \frac{n-1}{n} + \frac{n-2}{n}\cdot\frac{n-1}{n} + \cdots.

Node: TAWARCR6R7 · Lean: TAOCP.S1_2_11.Q · status: not stated yet

Explanation. The kk-th term is nn⋅n−1n⋯n−k+1n\frac nn \cdot \frac{n-1}{n} \cdots \frac{n-k+1}{n}, a product of kk factors. The first factor is 11. The last term has k=nk = n and equals n!/nnn!/n^n.

Example. For n=5n = 5 the terms are 11, 45\frac45, 1225\frac{12}{25}, 24125\frac{24}{125} and 24625\frac{24}{625}. The sum is Q(5)=1569625=2.5104Q(5) = \frac{1569}{625} = 2.5104. Also Q(1)=1Q(1) = 1, Q(2)=32Q(2) = \frac32, Q(3)=179Q(3) = \frac{17}9 and Q(4)=7132Q(4) = \frac{71}{32}.

Proof. The factor form follows from n!/(n−k)!=n(n−1)⋯(n−k+1)n!/(n-k)! = n(n-1)\cdots(n-k+1). For n=5n = 5 and k=3k = 3 the product is 55⋅45⋅35=1225\frac55\cdot\frac45\cdot\frac35 = \frac{12}{25}. □\square

Definition C1.1.2.11.3.3 (the sum R(n)R(n), TAOCP eq. 1.2.11.3(3)). For an integer n≥1n \ge 1 let

R(n)=∑k≥0n! nk(n+k)!=1+nn+1+nn+1⋅nn+2+⋯ .R(n) = \sum_{k \ge 0} \frac{n!\, n^k}{(n+k)!} = 1 + \frac{n}{n+1} + \frac{n}{n+1}\cdot\frac{n}{n+2} + \cdots.

Node: TARR5ZVXYG · Lean: TAOCP.S1_2_11.R · status: not stated yet

Explanation. The kk-th term is a product of kk factors nn+j\frac{n}{n+j} with 1≤j≤k1 \le j \le k. Each factor is below 11, so the terms decrease. The ratio of the term k+1k+1 to the term kk is n/(n+k+1)n/(n+k+1), so the series converges.

Example. For n=5n = 5 the first terms are 11, 0.8333330.833333, 0.5952380.595238, 0.3720240.372024, 0.2066800.206680, 0.1033400.103340. The sum of the whole series is R(5)=3.188665R(5) = 3.188665.

Proof. The term kk of the sum is n! nk(n+k)!\frac{n!\, n^k}{(n+k)!}. For k≥1k \ge 1 the term equals ∏j=1knn+j\prod_{j=1}^{k} \frac{n}{n+j}, since (n+k)!/n!=(n+1)⋯(n+k)(n+k)!/n! = (n+1)\cdots(n+k). The series converges by the comparison with a geometric series: for k≥nk \ge n the ratio of two terms is at most n/(2n+1)<12n/(2n+1) < \frac12. □\square

Theorem C1.1.2.11.3.4 (the sum of QQ and RR, TAOCP eq. 1.2.11.3(4)). For every integer n≥1n \ge 1,

Q(n)+R(n)=n! ennn.Q(n) + R(n) = \frac{n!\, e^n}{n^n}.

Node: TA49N7ZT9R · Lean: TAOCP.S1_2_11.eq4_QR · status: not stated yet

Explanation. The right side is about 2πn\sqrt{2\pi n} by Stirling's formula, since n!≈2πn (n/e)nn! \approx \sqrt{2\pi n}\,(n/e)^n. If QQ and RR have the same size, each is about 2πn/2=πn/2\sqrt{2\pi n}/2 = \sqrt{\pi n/2}. The proof shows that the two sums are two parts of the series of ene^n.

Example. For n=5n = 5, Q(5)+R(5)=2.510400+3.188665=5.699065Q(5) + R(5) = 2.510400 + 3.188665 = 5.699065. The right side is 5! e5/55=120⋅148.413159/3125=5.6990655!\, e^5/5^5 = 120 \cdot 148.413159/3125 = 5.699065.

Proof. In Q(n)Q(n) put j=n−kj = n - k. Then jj runs from 00 to n−1n - 1, and n!(n−k)! nk=n!nn⋅njj!\frac{n!}{(n-k)!\, n^k} = \frac{n!}{n^n}\cdot\frac{n^{j}}{j!} since n−k=nj−nn^{-k} = n^{j-n}. So Q(n)=n!nn∑j=0n−1njj!Q(n) = \frac{n!}{n^n} \sum_{j=0}^{n-1} \frac{n^j}{j!}. In R(n)R(n) put j=n+kj = n + k. Then n! nk(n+k)!=n!nn⋅njj!\frac{n!\, n^k}{(n+k)!} = \frac{n!}{n^n}\cdot\frac{n^{j}}{j!} and jj runs from nn to infinity. The two ranges of jj do not overlap, and together they are all j≥0j \ge 0. So Q(n)+R(n)=n!nn∑j≥0njj!=n!nn enQ(n) + R(n) = \frac{n!}{n^n} \sum_{j \ge 0} \frac{n^j}{j!} = \frac{n!}{n^n}\, e^n. □\square

Theorem C1.1.2.11.3.5 (Taylor's formula with the integral remainder, TAOCP eq. 1.2.11.3(5)). Let n≥0n \ge 0 be an integer and let ff have n+1n+1 continuous derivatives on an interval that contains 00 and xx. Then

f(x)=∑k=0nf(k)(0)k! xk+∫0xtnn! f(n+1)(x−t) dt.f(x) = \sum_{k=0}^{n} \frac{f^{(k)}(0)}{k!}\, x^k + \int_0^x \frac{t^n}{n!}\, f^{(n+1)}(x - t)\, dt.

Node: TAC9XV0GX3 · status: not stated yet

Explanation. The sum is the Taylor polynomial of degree nn at 00, and the integral is the exact error. The section uses the case f=exf = e^x. There every derivative is exe^x, and the formula with n−1n - 1 in place of nn says

ex−∑k=0n−1xkk!=1(n−1)!∫0xtn−1 ex−t dt=ex(n−1)!∫0xe−t tn−1 dt.e^x - \sum_{k=0}^{n-1} \frac{x^k}{k!} = \frac{1}{(n-1)!} \int_0^x t^{n-1}\, e^{x-t}\, dt = \frac{e^x}{(n-1)!} \int_0^x e^{-t}\, t^{n-1}\, dt.

So the tail of the exponential series is exe^x times an integral of e−ttn−1e^{-t} t^{n-1}, and this is the incomplete gamma function of the next definition.

Example. Take f=exf = e^x, n=3n = 3 and x=3x = 3. The left side of the second display is e3−(1+3+92+92)=20.085537−13=7.085537e^3 - (1 + 3 + \frac92 + \frac92) = 20.085537 - 13 = 7.085537. The integral ∫03t3e3−t dt\int_0^3 t^3 e^{3-t}\, dt has the value 42.51322242.513222, and one sixth of it is 7.0855377.085537. For f(x)=ln⁡(1+x)f(x) = \ln(1 + x), n=1n = 1 and x=1x = 1 the formula says ln⁡2=0+1−∫01t (2−t)−2 dt\ln 2 = 0 + 1 - \int_0^1 t\,(2 - t)^{-2}\, dt, and indeed the integral is 1−ln⁡2=0.3068531 - \ln 2 = 0.306853.

Proof. Induction on nn. For n=0n = 0 the claim is f(x)=f(0)+∫0xf′(x−t) dtf(x) = f(0) + \int_0^x f'(x - t)\, dt, which is the fundamental theorem of calculus after the change s=x−ts = x - t. Suppose the claim holds for n−1n - 1, with the remainder ∫0xtn−1(n−1)!f(n)(x−t) dt\int_0^x \frac{t^{n-1}}{(n-1)!} f^{(n)}(x - t)\, dt. Integrate it by parts with U=f(n)(x−t)U = f^{(n)}(x - t) and dV=tn−1 dt/(n−1)!dV = t^{n-1}\, dt/(n-1)!, so that dU=−f(n+1)(x−t) dtdU = -f^{(n+1)}(x - t)\, dt and V=tn/n!V = t^n/n!. This gives

∫0xtn−1(n−1)!f(n)(x−t) dt=xnn!f(n)(0)+∫0xtnn!f(n+1)(x−t) dt.\int_0^x \frac{t^{n-1}}{(n-1)!} f^{(n)}(x - t)\, dt = \frac{x^n}{n!} f^{(n)}(0) + \int_0^x \frac{t^n}{n!} f^{(n+1)}(x - t)\, dt.

The first term on the right is the term k=nk = n of the sum, so the claim holds for nn. For the case f=exf = e^x replace nn by n−1n - 1, then put f(n)(x−t)=ex−tf^{(n)}(x - t) = e^{x-t} and take exe^x out of the integral. □\square

Definition C1.1.2.11.3.6 (the incomplete gamma function, TAOCP eq. 1.2.11.3(6)). For a>0a > 0 and x≥0x \ge 0 let

γ(a,x)=∫0xe−t ta−1 dt.\gamma(a, x) = \int_0^x e^{-t}\, t^{a-1}\, dt.

Node: TAM8ZK8DEJ · status: not stated yet

Explanation. The integral converges at 00 for a>0a > 0, since ta−1t^{a-1} is integrable there. As x→∞x \to \infty the value tends to Γ(a)=∫0∞e−tta−1 dt\Gamma(a) = \int_0^\infty e^{-t} t^{a-1}\, dt. This is why γ\gamma has its name. By the case f=exf = e^x of Theorem C1.1.2.11.3.5, for an integer n≥1n \ge 1,

∑k=0n−1xkk!=ex(1−γ(n,x)(n−1)!).\sum_{k=0}^{n-1} \frac{x^k}{k!} = e^x\Bigl(1 - \frac{\gamma(n, x)}{(n-1)!}\Bigr).

Example. γ(1,x)=1−e−x\gamma(1, x) = 1 - e^{-x}, and γ(2,1)=∫01te−t dt=1−2/e=0.264241\gamma(2, 1) = \int_0^1 t e^{-t}\, dt = 1 - 2/e = 0.264241. For n=3n = 3 and x=2x = 2 the displayed relation says 1+2+2=e2(1−γ(3,2)/2)1 + 2 + 2 = e^2 (1 - \gamma(3,2)/2), and indeed γ(3,2)/2=0.323324=1−5e−2\gamma(3, 2)/2 = 0.323324 = 1 - 5e^{-2}.

Proof. The case f=exf = e^x of Theorem C1.1.2.11.3.5 gives ex−∑k<nxk/k!=ex(n−1)!∫0xe−ttn−1 dt=ex γ(n,x)(n−1)!e^x - \sum_{k<n} x^k/k! = \frac{e^x}{(n-1)!} \int_0^x e^{-t} t^{n-1}\, dt = \frac{e^x\, \gamma(n, x)}{(n-1)!}. So ∑k<nxk/k!=ex−exγ(n,x)/(n−1)!\sum_{k<n} x^k/k! = e^x - e^x \gamma(n,x)/(n-1)!. For the first claim: 0≤e−tta−1≤ta−10 \le e^{-t} t^{a-1} \le t^{a-1} on (0,1](0, 1] and ∫01ta−1 dt=1/a\int_0^1 t^{a-1}\, dt = 1/a. Therefore γ(a,x)\gamma(a, x) exists for a>0a > 0 and increases with xx. □\square

Theorem C1.1.2.11.3.7 (the power series of γ\gamma, TAOCP eq. 1.2.11.3(7)). For a>0a > 0 and x≥0x \ge 0,

γ(a,x)=∑k≥0(−1)k xk+ak! (k+a)=xaa−xa+1a+1+xa+22! (a+2)−⋯ .\gamma(a, x) = \sum_{k \ge 0} \frac{(-1)^k\, x^{k+a}}{k!\,(k+a)} = \frac{x^a}{a} - \frac{x^{a+1}}{a+1} + \frac{x^{a+2}}{2!\,(a+2)} - \cdots.

Node: TAHHR66KSW · status: not stated yet

Explanation. The series is the integral of the series of e−te^{-t}, term by term. It converges for all xx and it is useful for small xx. For large xx it has large terms of both signs and loses digits.

Example. For a=2a = 2 and x=1x = 1 the series is 12−13+18−130+1144−⋯\frac12 - \frac13 + \frac18 - \frac1{30} + \frac1{144} - \cdots. The partial sums are 0.50.5, 0.16670.1667, 0.29170.2917, 0.25830.2583, 0.26530.2653, and the limit is 1−2/e=0.2642411 - 2/e = 0.264241.

Proof. On [0,x][0, x] the series e−t=∑k(−t)k/k!e^{-t} = \sum_k (-t)^k/k! converges uniformly, and ta−1t^{a-1} is integrable. So the series times ta−1t^{a-1} can be integrated term by term. Since ∫0xtk+a−1 dt=xk+a/(k+a)\int_0^x t^{k+a-1}\, dt = x^{k+a}/(k+a), the claim follows. □\square

Theorem C1.1.2.11.3.8 (the series of exγe^x \gamma, TAOCP eq. 1.2.11.3(8)). For a>0a > 0 and x≥0x \ge 0,

ex γ(a,x)=∑k≥0xk+aa(a+1)⋯(a+k)=xaa+xa+1a(a+1)+⋯ .e^x\, \gamma(a, x) = \sum_{k \ge 0} \frac{x^{k+a}}{a(a+1)\cdots(a+k)} = \frac{x^a}{a} + \frac{x^{a+1}}{a(a+1)} + \cdots.

Node: TADV1EVMP5 · status: not stated yet

Explanation. All terms are positive. There is no loss of digits for any xx. This is the series that gives R(n)R(n) in the next theorem.

Example. For a=2a = 2 and x=1x = 1 the series is 12+16+124+⋯=∑k≥21/k!=e−2=0.718282\frac12 + \frac16 + \frac1{24} + \cdots = \sum_{k \ge 2} 1/k! = e - 2 = 0.718282. The left side is e⋅0.264241=0.718282e \cdot 0.264241 = 0.718282.

Proof. Let S(x)S(x) be the sum of the series. The ratio of two terms is x/(a+k+1)x/(a+k+1), so the series converges for all xx, and it can be differentiated term by term. The derivative of xk+a/(a⋯(a+k))x^{k+a}/(a \cdots (a+k)) is xk+a−1/(a⋯(a+k−1))x^{k+a-1}/(a \cdots (a+k-1)) for k≥1k \ge 1, and xa−1x^{a-1} for k=0k = 0. So S′(x)=xa−1+S(x)S'(x) = x^{a-1} + S(x). Hence (e−xS)′=e−xxa−1(e^{-x} S)' = e^{-x} x^{a-1}. As x→0x \to 0 the value e−xS(x)e^{-x} S(x) tends to 00, since S(x)∼xa/aS(x) \sim x^a/a. Integrating from 00 gives e−xS(x)=γ(a,x)e^{-x} S(x) = \gamma(a, x). □\square

Theorem C1.1.2.11.3.9 (RR in terms of γ\gamma, TAOCP eq. 1.2.11.3(9)). For every integer n≥1n \ge 1,

R(n)=n! ennn⋅γ(n,n)(n−1)!.R(n) = \frac{n!\, e^n}{n^n}\cdot\frac{\gamma(n, n)}{(n-1)!}.

Node: TADZYKRXBK · status: not stated yet

Explanation. With Theorem C1.1.2.11.3.4 and the relation after Definition C1.1.2.11.3.6 this gives Q(n)=n! ennn(1−γ(n,n)/(n−1)!)Q(n) = \frac{n!\, e^n}{n^n}\bigl(1 - \gamma(n,n)/(n-1)!\bigr). So both QQ and RR depend on the one number γ(n,n)/(n−1)!\gamma(n, n)/(n-1)!, which is the part of the Gamma integral that lies to the left of its peak.

Example. For n=5n = 5: 5! e5/55=5.6990655!\, e^5/5^5 = 5.699065 and γ(5,5)/4!=0.559507\gamma(5, 5)/4! = 0.559507. The product is 3.188665=R(5)3.188665 = R(5).

Proof. Put a=x=na = x = n in Theorem C1.1.2.11.3.8. Since n(n+1)⋯(n+k)=(n+k)!/(n−1)!n(n+1)\cdots(n+k) = (n+k)!/(n-1)!,

en γ(n,n)=(n−1)! nn∑k≥0nk(n+k)!.e^n\, \gamma(n, n) = (n-1)!\, n^n \sum_{k \ge 0} \frac{n^k}{(n+k)!}.

Multiply by n!/(nn(n−1)!)n!/\bigl(n^n (n-1)!\bigr). The right side becomes n!∑knk/(n+k)!=R(n)n! \sum_k n^k/(n+k)! = R(n). □\square

Theorem C1.1.2.11.3.10 (the split of the ratio, TAOCP eq. 1.2.11.3(10)). For x>0x > 0 and real yy with x+y>0x + y > 0,

γ(x+1,x+y)Γ(x+1)=1−1Γ(x+1)∫x∞e−t tx dt+1Γ(x+1)∫xx+ye−t tx dt.\frac{\gamma(x+1, x+y)}{\Gamma(x+1)} = 1 - \frac{1}{\Gamma(x+1)} \int_x^\infty e^{-t}\, t^x\, dt + \frac{1}{\Gamma(x+1)} \int_x^{x+y} e^{-t}\, t^x\, dt.

Node: TAVKMMJZAZ · status: not stated yet

Explanation. The first integral is the upper tail beyond the peak at t=xt = x. The second integral is signed: it is negative when y<0y < 0. The tail needs a change of variable. The middle part has a bounded length and needs a Taylor series. For the sums, x=n−1x = n - 1 and y=1y = 1.

Example. For x=4x = 4 and y=1y = 1 the left side is γ(5,5)/Γ(5)=0.559507\gamma(5, 5)/\Gamma(5) = 0.559507. The tail is 0.6288370.628837 and the middle part is 0.1883440.188344. So 1−0.628837+0.188344=0.5595071 - 0.628837 + 0.188344 = 0.559507.

Proof. By definition γ(x+1,x+y)=Γ(x+1)−∫x+y∞e−ttx dt\gamma(x+1, x+y) = \Gamma(x+1) - \int_{x+y}^\infty e^{-t} t^x\, dt. Write ∫x+y∞=∫x∞−∫xx+y\int_{x+y}^\infty = \int_x^\infty - \int_x^{x+y}. This holds for both signs of yy. Divide by Γ(x+1)\Gamma(x+1). □\square

Lemma C1.1.2.11.3.11 (the change of variable v=u−ln⁡(1+u)v = u - \ln(1+u), TAOCP Section 1.2.11.3, text before eq. (11)). Let v=u−ln⁡(1+u)v = u - \ln(1+u) for u≥0u \ge 0. Then vv is a continuous, strictly increasing function of uu with v(0)=0v(0) = 0 and v→∞v \to \infty as u→∞u \to \infty. For every real xx and every u>0u > 0,

(1+u)x e−xu=e−xv,du=(1+1u)dv.(1+u)^x\, e^{-xu} = e^{-xv}, \qquad du = \Bigl(1 + \frac1u\Bigr) dv.

Node: none

Explanation. The substitution removes the factor (1+u)x(1+u)^x from the integrand, since all of its dependence on xx goes into the exponent −xv-xv. The price is the factor 1+1/u1 + 1/u, which is large near u=0u = 0 and must be written as a function of vv (Lemma C1.1.2.11.3.13).

Example. For u=12u = \frac12 the value is v=0.5−ln⁡1.5=0.0945349v = 0.5 - \ln 1.5 = 0.0945349. For x=2x = 2: (1.5)2e−1=0.827728(1.5)^2 e^{-1} = 0.827728 and e−2v=0.827728e^{-2v} = 0.827728. The slope is dv/du=u/(1+u)=13dv/du = u/(1+u) = \frac13, so du/dv=3=1+1/udu/dv = 3 = 1 + 1/u.

Proof. The derivative is dv/du=1−11+u=u1+udv/du = 1 - \frac1{1+u} = \frac{u}{1+u}. It is positive for u>0u > 0, so vv is strictly increasing. Also v(0)=0v(0) = 0, and v→∞v \to \infty since ln⁡(1+u)=o(u)\ln(1+u) = o(u). Take exponentials of xln⁡(1+u)−xu=−xvx \ln(1+u) - xu = -xv to get the first equation. The inverse of dv/du=u/(1+u)dv/du = u/(1+u) is du/dv=(1+u)/u=1+1/udu/dv = (1+u)/u = 1 + 1/u. □\square

Theorem C1.1.2.11.3.12 (the tail integral after the substitution, TAOCP eq. 1.2.11.3(11)). For x>0x > 0 let I1=∫x∞e−t tx dtI_1 = \int_x^\infty e^{-t}\, t^x\, dt. Let uu be the function of vv that Lemma C1.1.2.11.3.11 defines. Then

I1=e−xxx∫0∞x e−xu(1+u)x du=e−xxx∫0∞x e−xv(1+1u)dv.I_1 = e^{-x} x^x \int_0^\infty x\, e^{-xu}(1+u)^x\, du = e^{-x} x^x \int_0^\infty x\, e^{-xv}\Bigl(1 + \frac1u\Bigr) dv.

Node: TAK2P03SBW · status: not stated yet

Explanation. The first form puts the lower limit at 00 and shows the factor e−xxxe^{-x}x^x that sets the scale. The second form is a Laplace integral: the weight is xe−xvx e^{-xv}, which has total mass 11, and the function that it averages is 1+1/u1 + 1/u.

Example. For x=10x = 10 the ratio I1/(e−xxx)I_1/(e^{-x} x^x) has the value 4.6602164.660216. A direct quadrature of ∫0∞10 e−10u(1+u)10 du\int_0^\infty 10\, e^{-10u}(1+u)^{10}\, du gives the same value.

Proof. Put t=x(1+u)t = x(1+u). Then dt=x dudt = x\, du, tt runs from xx to ∞\infty as uu runs from 00 to ∞\infty, and e−ttx=e−x e−xu xx(1+u)xe^{-t} t^x = e^{-x}\, e^{-xu}\, x^x (1+u)^x. This is the first form. The second form follows from Lemma C1.1.2.11.3.11, which gives e−xu(1+u)x du=e−xv(1+1/u) dve^{-xu}(1+u)^x\, du = e^{-xv}(1 + 1/u)\, dv. □\square

Lemma C1.1.2.11.3.13 (the series for 1+1/u1 + 1/u, TAOCP eq. 1.2.11.3(12)). Let w=2vw = \sqrt{2v} with v=u−ln⁡(1+u)v = u - \ln(1+u). For small w>0w > 0 there is a unique u>0u > 0. It has the first series below, and 1+1/u1 + 1/u has the second series, with w=2vw = \sqrt{2v}.

u=w+13w2+136w3−1270w4+14320w5+O(w6).u = w + \tfrac13 w^2 + \tfrac1{36} w^3 - \tfrac1{270} w^4 + \tfrac1{4320} w^5 + O(w^6).

1+1u=12 v−1/2+23+212 v1/2−4135 v+2432 v3/2+O(v2).1 + \frac1u = \frac{1}{\sqrt2}\, v^{-1/2} + \frac23 + \frac{\sqrt2}{12}\, v^{1/2} - \frac{4}{135}\, v + \frac{\sqrt2}{432}\, v^{3/2} + O(v^2).

Node: TAG5N33C8A · status: not stated yet

Explanation. The coefficient of vv is −4135-\frac4{135}. The terms come in powers of v1/2v^{1/2}, since v≈u2/2v \approx u^2/2 near 00. The second display is the series that Theorem C1.1.2.11.3.17 integrates term by term.

Example. For v=0.01v = 0.01 the exact root is u=0.14816512u = 0.14816512. The series for uu with the five terms gives 0.148165120.14816512. The second display gives 1+1/u=7.74922661 + 1/u = 7.7492266 against the exact value 7.74922677.7492267. The difference is 1.3⋅10−71.3 \cdot 10^{-7}, and the next term 42835v2\frac4{2835} v^2 is 1.4⋅10−71.4 \cdot 10^{-7}.

Proof. The expansion ln⁡(1+u)=u−u2/2+u3/3−⋯\ln(1+u) = u - u^2/2 + u^3/3 - \cdots gives w2=2v=u2−23u3+12u4−25u5+⋯w^2 = 2v = u^2 - \frac23 u^3 + \frac12 u^4 - \frac25 u^5 + \cdots. So w=u h(u)w = u\, h(u) with h(u)=1−23u+12u2−⋯h(u) = \sqrt{1 - \frac23 u + \frac12 u^2 - \cdots}. The function hh is analytic near 00 with h(0)=1h(0) = 1. Its first terms are

w=u−13u2+736u3−73540u4+133112960u5−⋯ .w = u - \tfrac13 u^2 + \tfrac7{36} u^3 - \tfrac{73}{540} u^4 + \tfrac{1331}{12960} u^5 - \cdots.

Since dw/du=1dw/du = 1 at u=0u = 0, the inverse function is analytic near 00, and u=∑k≥1ckwku = \sum_{k \ge 1} c_k w^k. Put this series in the display above and compare the coefficients of wkw^k. For k=1k = 1 it gives c1=1c_1 = 1. For k=2k = 2 it gives c2−13=0c_2 - \frac13 = 0, so c2=13c_2 = \frac13. For k=3k = 3 it gives c3−23c2+736=0c_3 - \frac23 c_2 + \frac7{36} = 0, so c3=29−736=136c_3 = \frac29 - \frac7{36} = \frac1{36}. For k=4k = 4 it gives c4−13(2c3+c22)+712c2−73540=0c_4 - \frac13(2c_3 + c_2^2) + \frac7{12} c_2 - \frac{73}{540} = 0, so c4=118−736+73540=−1270c_4 = \frac1{18} - \frac7{36} + \frac{73}{540} = -\frac1{270}. The same step for k=5k = 5 gives c5=14320c_5 = \frac1{4320}. The uniqueness of uu holds since vv is strictly increasing (Lemma C1.1.2.11.3.11).

For the second display write u=w(1+13w+136w2−1270w3+14320w4+⋯ )u = w\bigl(1 + \frac13 w + \frac1{36} w^2 - \frac1{270} w^3 + \frac1{4320} w^4 + \cdots\bigr). The reciprocal of the bracket is 1−13w+112w2−2135w3+1864w4+O(w5)1 - \frac13 w + \frac1{12} w^2 - \frac2{135} w^3 + \frac1{864} w^4 + O(w^5). So 1u=1w−13+112w−2135w2+1864w3+O(w4)\frac1u = \frac1w - \frac13 + \frac1{12} w - \frac2{135} w^2 + \frac1{864} w^3 + O(w^4). Add 11 and put w=2vw = \sqrt{2v}. The powers are w−1=v−1/2/2w^{-1} = v^{-1/2}/\sqrt2, w=2 v1/2w = \sqrt2\, v^{1/2}, w2=2vw^2 = 2v and w3=22 v3/2w^3 = 2\sqrt2\, v^{3/2}. The coefficients become 212\frac{\sqrt2}{12}, −2135⋅2=−4135-\frac2{135}\cdot 2 = -\frac4{135} and 22864=2432\frac{2\sqrt2}{864} = \frac{\sqrt2}{432}. The constant is 1−13=231 - \frac13 = \frac23. □\square

Theorem C1.1.2.11.3.14 (the far part of the tail integral, TAOCP eq. 1.2.11.3(13)). Let uu be the function of vv that Lemma C1.1.2.11.3.11 defines, and let r>0r > 0 be fixed. Then the integral below is O(e−rx)O(e^{-rx}) as x→∞x \to \infty. More precisely, for every x>0x > 0,

0<∫r∞x e−xv(1+1u)dv≤(1+1u(r))e−rx.0 < \int_r^\infty x\, e^{-xv}\Bigl(1 + \frac1u\Bigr) dv \le \Bigl(1 + \frac{1}{u(r)}\Bigr) e^{-rx}.

Node: TAVKJ30ZB5 · status: not stated yet

Explanation. The series of Lemma C1.1.2.11.3.13 holds only for small vv, so the integral of Theorem C1.1.2.11.3.12 is cut at a small rr. This theorem says that the part beyond rr does not matter: it falls faster than every power x−kx^{-k}, so it is absorbed by any error term of the form O(x−k)O(x^{-k}).

Example. Take r=12r = \frac12 and x=10x = 10. The root of u−ln⁡(1+u)=12u - \ln(1+u) = \frac12 is u(12)=1.357677u(\frac12) = 1.357677, so the constant is 1+1/u(12)=1.7365521 + 1/u(\frac12) = 1.736552. The integral has the value 0.01120190.0112019, and the bound is 1.736552 e−5=0.01170081.736552\, e^{-5} = 0.0117008.

Proof. The function v(u)v(u) of Lemma C1.1.2.11.3.11 is strictly increasing, so its inverse u(v)u(v) is increasing too. For v≥rv \ge r this gives u(v)≥u(r)>0u(v) \ge u(r) > 0 and 0<1+1/u(v)≤1+1/u(r)0 < 1 + 1/u(v) \le 1 + 1/u(r). Hence the integral is positive and at most (1+1/u(r))∫r∞x e−xv dv=(1+1/u(r))e−rx\bigl(1 + 1/u(r)\bigr) \int_r^\infty x\, e^{-xv}\, dv = \bigl(1 + 1/u(r)\bigr) e^{-rx}. □\square

Theorem C1.1.2.11.3.15 (a Laplace integral of a power, TAOCP eq. 1.2.11.3(14)). For α>−1\alpha > -1 and x>0x > 0,

∫0∞x e−xv vα dv=Γ(α+1)xα.\int_0^\infty x\, e^{-xv}\, v^\alpha\, dv = \frac{\Gamma(\alpha+1)}{x^\alpha}.

Node: TAJ7BS8GDF · status: not stated yet

Explanation. This is the only integral that the method needs. It turns the power vαv^\alpha into the power x−αx^{-\alpha} and a gamma value.

Example. For α=12\alpha = \frac12 and x=4x = 4 the integral is ∫0∞4e−4vv dv=0.443113\int_0^\infty 4 e^{-4v} \sqrt v\, dv = 0.443113. The right side is Γ(32)/4=0.886227/2=0.443113\Gamma(\frac32)/\sqrt4 = 0.886227/2 = 0.443113.

Proof. Put s=xvs = xv. Then x dv=dsx\, dv = ds and vα=sαx−αv^\alpha = s^\alpha x^{-\alpha}. So the integral is x−α∫0∞e−ssα ds=x−α Γ(α+1)x^{-\alpha} \int_0^\infty e^{-s} s^\alpha\, ds = x^{-\alpha}\, \Gamma(\alpha+1). The integral converges since α+1>0\alpha + 1 > 0. □\square

Lemma C1.1.2.11.3.16 (Watson's lemma, TAOCP Section 1.2.11.3, exercises 19 and 20). Let gg be a function on (0,∞)(0, \infty) with ∫0∞e−s0v∣g(v)∣ dv<∞\int_0^\infty e^{-s_0 v} |g(v)|\, dv < \infty for some s0>0s_0 > 0. Let α>−1\alpha > -1, r>0r > 0 and m≥1m \ge 1. First claim: if g(v)=O(vα)g(v) = O(v^\alpha) for 0<v≤r0 < v \le r, then ∫0∞e−sv g(v) dv=O(s−1−α)\int_0^\infty e^{-sv}\, g(v)\, dv = O(s^{-1-\alpha}) as s→∞s \to \infty. Second claim: if gg is bounded on [r,∞)[r, \infty) and g(v)=∑j=0m−1aj v(j−1)/2+O(v(m−1)/2)g(v) = \sum_{j=0}^{m-1} a_j\, v^{(j-1)/2} + O(v^{(m-1)/2}) for 0<v≤r0 < v \le r, then as s→∞s \to \infty

∫0∞s e−sv g(v) dv=∑j=0m−1aj Γ(j+12) s−(j−1)/2+O(s−(m−1)/2).\int_0^\infty s\, e^{-sv}\, g(v)\, dv = \sum_{j=0}^{m-1} a_j\, \Gamma\bigl(\tfrac{j+1}{2}\bigr)\, s^{-(j-1)/2} + O\bigl(s^{-(m-1)/2}\bigr).

Node: none

Explanation. Only the values of gg near v=0v = 0 decide the integral, since the weight e−sve^{-sv} kills the rest. The second claim says that the expansion of gg near 00 can be integrated term by term. This is the tool of Theorem C1.1.2.11.3.17. The condition on s0s_0 says that the integral exists, and it holds for every gg that grows at most like a power.

Example. Let g(v)=v e−vg(v) = \sqrt v\, e^{-v}. Then ∫0∞e−svg(v) dv=Γ(32)(s+1)−3/2\int_0^\infty e^{-sv} g(v)\, dv = \Gamma(\frac32)(s+1)^{-3/2}. For s=50s = 50 the value is 0.00243330.0024333, and s3/2s^{3/2} times it is 0.86030.8603. This is bounded, as the first claim says with α=12\alpha = \frac12, and it tends to Γ(32)=0.8862\Gamma(\frac32) = 0.8862.

Proof. For the first claim split the integral at rr. On (0,r](0, r] let ∣g(v)∣≤Kvα|g(v)| \le K v^\alpha. Then ∫0re−sv∣g∣ dv≤K∫0∞e−svvα dv=K Γ(α+1) s−1−α\int_0^r e^{-sv} |g|\, dv \le K \int_0^\infty e^{-sv} v^\alpha\, dv = K\, \Gamma(\alpha+1)\, s^{-1-\alpha}. On [r,∞)[r, \infty) and for s≥s0s \ge s_0 the bound e−sv≤e−(s−s0)r e−s0ve^{-sv} \le e^{-(s - s_0) r}\, e^{-s_0 v} holds. So ∫r∞e−sv∣g∣ dv≤e−(s−s0)r∫0∞e−s0v∣g∣ dv=O(e−sr)\int_r^\infty e^{-sv} |g|\, dv \le e^{-(s-s_0) r} \int_0^\infty e^{-s_0 v} |g|\, dv = O(e^{-sr}). This is O(s−1−α)O(s^{-1-\alpha}), since an exponential beats every power.

For the second claim let h(v)=g(v)−∑j<majv(j−1)/2h(v) = g(v) - \sum_{j<m} a_j v^{(j-1)/2}. On (0,r](0, r] the bound is h=O(v(m−1)/2)h = O(v^{(m-1)/2}), with α=(m−1)/2>−1\alpha = (m-1)/2 > -1. On [r,∞)[r, \infty) the function hh grows at most like a power of vv, so e−vhe^{-v} h is integrable and the first claim applies. It gives ∫e−svh dv=O(s−1−(m−1)/2)\int e^{-sv} h\, dv = O(s^{-1-(m-1)/2}), and the factor ss gives O(s−(m−1)/2)O(s^{-(m-1)/2}). The remaining terms are exact by Theorem C1.1.2.11.3.15 with α=(j−1)/2\alpha = (j-1)/2, which is above −1-1 for j≥0j \ge 0. □\square

Theorem C1.1.2.11.3.17 (the size of the tail integral, TAOCP eq. 1.2.11.3(15)). As x→∞x \to \infty,

I1=e−xxx(πx2+23+2π24 x−1/2−4135 x−1+2π576 x−3/2+O(x−2)).I_1 = e^{-x} x^x \Bigl(\sqrt{\frac{\pi x}{2}} + \frac23 + \frac{\sqrt{2\pi}}{24}\, x^{-1/2} - \frac{4}{135}\, x^{-1} + \frac{\sqrt{2\pi}}{576}\, x^{-3/2} + O(x^{-2})\Bigr).

Node: TA7TJQDG3J · status: not stated yet

Explanation. The leading term is πx/2\sqrt{\pi x/2}, and it is half of Γ(x+1)/(e−xxx)≈2πx\Gamma(x+1)/(e^{-x}x^x) \approx \sqrt{2\pi x}. So the tail is about half of the whole integral, as the symmetry of the peak suggests. The constant 23\frac23 is the first correction.

Example. For x=10x = 10 the bracket has the five terms 3.9633273.963327, 0.6666670.666667, 0.0330280.033028, −0.002963-0.002963 and 0.0001380.000138. Their sum is 4.6601964.660196. The exact value is 4.6602164.660216. The difference is 2⋅10−52 \cdot 10^{-5}, well inside O(x−2)O(x^{-2}).

Proof. Apply Lemma C1.1.2.11.3.16 to the second form of Theorem C1.1.2.11.3.12 with s=xs = x and g(v)=1+1/u(v)g(v) = 1 + 1/u(v). By Lemma C1.1.2.11.3.13, gg has the expansion with m=5m = 5 and the error O(v2)O(v^2) on a short interval (0,r](0, r]. On [r,∞)[r, \infty) the proof of Theorem C1.1.2.11.3.14 gives 0<g≤1+1/u(r)0 < g \le 1 + 1/u(r), so gg is bounded there, and the part of the integral beyond rr is O(e−rx)O(e^{-rx}) by that theorem. The coefficients a0,…,a4a_0, \ldots, a_4 are 12\frac1{\sqrt2}, 23\frac23, 212\frac{\sqrt2}{12}, −4135-\frac4{135} and 2432\frac{\sqrt2}{432}. The gamma values are Γ(12)=π\Gamma(\frac12) = \sqrt\pi, Γ(1)=1\Gamma(1) = 1, Γ(32)=π2\Gamma(\frac32) = \frac{\sqrt\pi}{2}, Γ(2)=1\Gamma(2) = 1 and Γ(52)=3π4\Gamma(\frac52) = \frac{3\sqrt\pi}{4}. The products are π2x1/2=πx/2\frac{\sqrt\pi}{\sqrt2}x^{1/2} = \sqrt{\pi x/2}, then 23\frac23, then 212⋅π2=2π24\frac{\sqrt2}{12}\cdot\frac{\sqrt\pi}{2} = \frac{\sqrt{2\pi}}{24}, then −4135-\frac4{135} and 2432⋅3π4=2π576\frac{\sqrt2}{432}\cdot\frac{3\sqrt\pi}4 = \frac{\sqrt{2\pi}}{576}. The error is O(x−2)O(x^{-2}). □\square

Lemma C1.1.2.11.3.18 (the middle integral after the shift, TAOCP eq. 1.2.11.3(16)). For x>0x > 0 and real yy with x+y>0x + y > 0, let I2=∫xx+ye−t tx dtI_2 = \int_x^{x+y} e^{-t}\, t^x\, dt. Then

I2=e−xxx∫0ye−u(1+ux)xdu.I_2 = e^{-x} x^x \int_0^y e^{-u}\Bigl(1 + \frac ux\Bigr)^x du.

Node: TA3GKQW5EX · status: not stated yet

Explanation. The shift t=x+ut = x + u puts the peak at u=0u = 0. The factor e−u(1+u/x)xe^{-u}(1 + u/x)^x is 11 at u=0u = 0 and it falls slowly when xx is large. For y<0y < 0 the integral over uu is oriented from 00 down to yy, and it is negative.

Example. For x=10x = 10 and y=1y = 1 the ratio I2/(e−xxx)I_2/(e^{-x} x^x) is 0.9843420.984342. For y=−1y = -1 the ratio is −0.982723-0.982723.

Proof. Put t=x+ut = x + u. Then dt=dudt = du and e−ttx=e−x e−u xx(1+u/x)xe^{-t} t^x = e^{-x}\, e^{-u}\, x^x (1 + u/x)^x. The limits t=xt = x and t=x+yt = x + y become u=0u = 0 and u=yu = y. □\square

Theorem C1.1.2.11.3.19 (the size of the middle integral, TAOCP eq. 1.2.11.3(17)). For fixed real yy, as x→∞x \to \infty,

I2=e−xxx(y−y36 x−1+(y412+y540)x−2+O(x−3)).I_2 = e^{-x} x^x \Bigl(y - \frac{y^3}{6}\, x^{-1} + \Bigl(\frac{y^4}{12} + \frac{y^5}{40}\Bigr) x^{-2} + O(x^{-3})\Bigr).

Node: TA2HMW6KBH · status: not stated yet

Explanation. The first term is the length yy of the interval. The correction is of order 1/x1/x and has the sign of −y3-y^3. Both y>0y > 0 and y<0y < 0 are allowed.

Example. For x=10x = 10 and y=1y = 1 the bracket is 1−0.016667+0.001083=0.9844171 - 0.016667 + 0.001083 = 0.984417, and the exact ratio is 0.9843420.984342. For y=−1y = -1 the bracket is −1+0.016667+0.000583=−0.982750-1 + 0.016667 + 0.000583 = -0.982750, and the exact ratio is −0.982723-0.982723. The differences are of the size x−3x^{-3} times a constant.

Proof. Let ∣u∣≤∣y∣|u| \le |y|. The series of the logarithm gives xln⁡(1+u/x)=u−u22x+u33x2−⋯x \ln(1 + u/x) = u - \frac{u^2}{2x} + \frac{u^3}{3x^2} - \cdots, so

e−u(1+ux)x=exp⁡(−u22x+u33x2+O(x−3)),e^{-u}\Bigl(1+\frac ux\Bigr)^x = \exp\Bigl(-\frac{u^2}{2x} + \frac{u^3}{3x^2} + O(x^{-3})\Bigr),

and the OO is uniform for ∣u∣≤∣y∣|u| \le |y|. Expand the exponential: exp⁡(ϵ)=1+ϵ+ϵ2/2+O(ϵ3)\exp(\epsilon) = 1 + \epsilon + \epsilon^2/2 + O(\epsilon^3) with ϵ=O(1/x)\epsilon = O(1/x). The result is 1−u22x+u33x2+u48x2+O(x−3)1 - \frac{u^2}{2x} + \frac{u^3}{3x^2} + \frac{u^4}{8x^2} + O(x^{-3}). Integrate from 00 to yy: the terms give yy, −y36x-\frac{y^3}{6x}, y412x2\frac{y^4}{12x^2} and y540x2\frac{y^5}{40x^2}. The integral of an O(x−3)O(x^{-3}) function over an interval of fixed length is O(x−3)O(x^{-3}). Lemma C1.1.2.11.3.18 supplies the factor e−xxxe^{-x}x^x. □\square

Theorem C1.1.2.11.3.20 (the scale factor, TAOCP eq. 1.2.11.3(18)). As x→∞x \to \infty,

e−xxxΓ(x+1)=12π(x−1/2−112 x−3/2+1288 x−5/2+O(x−7/2)).\frac{e^{-x} x^x}{\Gamma(x+1)} = \frac{1}{\sqrt{2\pi}}\Bigl(x^{-1/2} - \frac{1}{12}\, x^{-3/2} + \frac{1}{288}\, x^{-5/2} + O(x^{-7/2})\Bigr).

Node: TAW2XR1EWM · status: not stated yet

Explanation. This is the reciprocal of Stirling's series for the real argument xx. The theorem is the link between the sizes of I1I_1 and I2I_2 and the ratio of the incomplete gamma function to the complete one.

Example. For x=10x = 10 the exact value is 0.125110040.12511004. The three terms give 0.125109700.12510970. The difference is 3.4⋅10−73.4 \cdot 10^{-7}. The next term of the series is x−7/2/2πx^{-7/2}/\sqrt{2\pi} times 1360−110368=0.00268\frac1{360} - \frac1{10368} = 0.00268, and this is 3.4⋅10−73.4 \cdot 10^{-7} at x=10x = 10.

Proof. Theorem C1.1.2.11.2.21 gives ln⁡Γ(x)=(x−12)ln⁡x−x+12ln⁡2π+B22x+B412x3+O(x−5)\ln \Gamma(x) = (x - \frac12)\ln x - x + \frac12 \ln 2\pi + \frac{B_2}{2x} + \frac{B_4}{12 x^3} + O(x^{-5}) with B2=16B_2 = \frac16, B3=0B_3 = 0 and B4=−130B_4 = -\frac1{30}. Since Γ(x+1)=x Γ(x)\Gamma(x+1) = x\,\Gamma(x), ln⁡Γ(x+1)=(x+12)ln⁡x−x+12ln⁡2π+112x+O(x−3)\ln \Gamma(x+1) = (x + \frac12) \ln x - x + \frac12 \ln 2\pi + \frac{1}{12x} + O(x^{-3}). So Γ(x+1)=2πx xxe−x e1/(12x)+O(x−3)\Gamma(x+1) = \sqrt{2\pi x}\, x^x e^{-x}\, e^{1/(12x) + O(x^{-3})}. Take the reciprocal. Then e−xxxΓ(x+1)=12πx e−1/(12x)+O(x−3)\frac{e^{-x}x^x}{\Gamma(x+1)} = \frac{1}{\sqrt{2\pi x}}\, e^{-1/(12x) + O(x^{-3})}. Let τ=1/(12x)\tau = 1/(12x). Then e−τ=1−τ+τ22+O(τ3)e^{-\tau} = 1 - \tau + \frac{\tau^2}2 + O(\tau^3), and τ2/2=1288x2\tau^2/2 = \frac{1}{288x^2}. □\square

Theorem C1.1.2.11.3.21 (Theorem A, TAOCP Theorem 1.2.11.3A). For fixed yy and large xx,

γ(x+1,x+y)Γ(x+1)=12+y−232π x−1/2+12π(23270−y12−y36)x−3/2+O(x−5/2).\frac{\gamma(x+1, x+y)}{\Gamma(x+1)} = \frac12 + \frac{y - \frac23}{\sqrt{2\pi}}\, x^{-1/2} + \frac{1}{\sqrt{2\pi}}\Bigl(\frac{23}{270} - \frac{y}{12} - \frac{y^3}{6}\Bigr) x^{-3/2} + O(x^{-5/2}).

Node: TAADTS71HC · status: not stated yet

Explanation. At the peak the ratio is 12\frac12, as it must be. The shift yy moves the cut to the right of the peak when y>0y > 0 and so raises the ratio, by about y/2πxy/\sqrt{2\pi x}. The terms of order x−1x^{-1} and x−2x^{-2} cancel.

Example. For y=1y = 1: at x=100x = 100 the exact ratio is 0.51323280.5132328 and the three terms give 0.51323230.5132323. At x=1000x = 1000 the values are 0.504203140.50420314 and 0.504203140.50420314. The scaled difference x5/2x^{5/2} times (exact minus formula) is 0.04680.0468 at x=100x = 100 and 0.04710.0471 at x=1000x = 1000. This is a constant, so the error is of order x−5/2x^{-5/2}. For y=0y = 0 the ratio at x=100x = 100 is 0.47343780.4734378, and the formula gives 0.47343780.4734378.

Proof. Write c=1/2πc = 1/\sqrt{2\pi} and C=c (x−1/2−112x−3/2+1288x−5/2)C = c\,(x^{-1/2} - \frac1{12} x^{-3/2} + \frac1{288} x^{-5/2}). By Theorem C1.1.2.11.3.10, the ratio is 1−C J1+C J21 - C\, J_1 + C\, J_2, where J1=I1/(e−xxx)J_1 = I_1/(e^{-x}x^x) and J2=I2/(e−xxx)J_2 = I_2/(e^{-x}x^x) are the brackets of Theorems C1.1.2.11.3.17 and C1.1.2.11.3.19. Collect the powers of xx in CJ1C J_1:

  • x0x^0: cπ/2=12c \sqrt{\pi/2} = \frac12.
  • x−1/2x^{-1/2}: 23c\frac23 c.
  • x−1x^{-1}: c⋅2π24−c12π2=124−124=0c \cdot \frac{\sqrt{2\pi}}{24} - \frac{c}{12}\sqrt{\frac\pi2} = \frac1{24} - \frac1{24} = 0.
  • x−3/2x^{-3/2}: c(−4135−112⋅23)=−23270 cc\bigl(-\frac4{135} - \frac1{12}\cdot\frac23\bigr) = -\frac{23}{270}\, c.
  • x−2x^{-2}: 1576−1288+1576=0\frac{1}{576} - \frac{1}{288} + \frac1{576} = 0.

In CJ2C J_2 the powers x−1/2x^{-1/2} and x−3/2x^{-3/2} have the coefficients c yc\, y and −c(y36+y12)-c\bigl(\frac{y^3}6 + \frac y{12}\bigr). The error of J1J_1 is O(x−2)O(x^{-2}) and the factor C=O(x−1/2)C = O(x^{-1/2}) turns it into O(x−5/2)O(x^{-5/2}). The error of J2J_2 is O(x−3)O(x^{-3}), and the error of CC is O(x−7/2)O(x^{-7/2}) times a bracket of size O(x)O(\sqrt x), so O(x−3)O(x^{-3}). So 1−CJ1+CJ21 - CJ_1 + CJ_2 has the constant 1−12=121 - \frac12 = \frac12, the term c (y−23)x−1/2c\,(y - \frac23) x^{-1/2} and the term c(23270−y12−y36)x−3/2c\bigl(\frac{23}{270} - \frac y{12} - \frac{y^3}6\bigr) x^{-3/2}. □\square

Theorem C1.1.2.11.3.22 (the expansion of the ratio, TAOCP eq. 1.2.11.3(19)). For fixed real yy, as x→∞x \to \infty,

γ(x+1,x+y)Γ(x+1)=12+y−232π x−1/2+12π(23270−y12−y36)x−3/2+O(x−5/2).\frac{\gamma(x+1, x+y)}{\Gamma(x+1)} = \frac12 + \frac{y - \frac23}{\sqrt{2\pi}}\, x^{-1/2} + \frac{1}{\sqrt{2\pi}}\Bigl(\frac{23}{270} - \frac{y}{12} - \frac{y^3}{6}\Bigr) x^{-3/2} + O(x^{-5/2}).

Node: TAYSC8E1TP · status: not stated yet

Explanation. The ratio is the probability that a gamma random variable with shape x+1x + 1 is at most x+yx + y. The term of order x−1/2x^{-1/2} vanishes at y=23y = \frac23. So the median of this distribution, the point where the ratio is 12\frac12, lies at x+23+o(1)x + \frac23 + o(1), and not at the peak xx of the density. At y=23y = \frac23 the coefficient of x−3/2x^{-3/2} is 23270−118−481=−8405\frac{23}{270} - \frac1{18} - \frac4{81} = -\frac{8}{405}. Since the derivative of the right side in yy is about x−1/2/2πx^{-1/2}/\sqrt{2\pi}, the median is close to x+23+8405xx + \frac23 + \frac{8}{405 x}.

Example. For x=100x = 100 and y=23y = \frac23 the exact ratio is 0.499992190.49999219, and the formula gives 0.499992120.49999212. The exact median for x=100x = 100 is 100.666863100.666863, and 100+23+840500=100.666864100 + \frac23 + \frac8{40500} = 100.666864.

Proof. This is the conclusion of Theorem C1.1.2.11.3.21. At y=23y = \frac23 the coefficient is 23270−118−481=69−45−40810=−8405\frac{23}{270} - \frac{1}{18} - \frac{4}{81} = \frac{69 - 45 - 40}{810} = -\frac{8}{405}. □\square

Theorem C1.1.2.11.3.23 (the terms of P(n)P(n) after Stirling's formula, TAOCP eq. 1.2.11.3(20)). For n≥1n \ge 1,

P(n)=1n!∑j=1nj n−j j!=2πn!∑j=1nj n+1/2 e−j(1+112j+O(j−2)).P(n) = \frac{1}{n!} \sum_{j=1}^{n} j^{\,n-j}\, j! = \frac{\sqrt{2\pi}}{n!} \sum_{j=1}^{n} j^{\,n+1/2}\, e^{-j}\Bigl(1 + \frac{1}{12j} + O(j^{-2})\Bigr).

Node: TAEEFV9391 · status: not stated yet

Explanation. The first form has the index j=n−kj = n - k of Definition C1.1.2.11.3.1. The second form replaces j! j−jj!\, j^{-j} by its Stirling series, so that P(n)P(n) becomes a sum of the type ∑jn+1/2e−j\sum j^{n+1/2} e^{-j}. The OO-term holds uniformly for j≥1j \ge 1.

Example. For n=5n = 5 the terms jn−jj!/n!j^{n-j} j!/n! for j=1,…,5j = 1, \ldots, 5 are 1120\frac1{120}, 16120\frac{16}{120}, 54120\frac{54}{120}, 96120\frac{96}{120} and 120120\frac{120}{120}, and they sum to 287120\frac{287}{120}. With the factor 1+112j+1288j21 + \frac1{12j} + \frac1{288j^2} the second form gives 2.3918242.391824. Without the correction, with the factor 11, it gives 2.3403662.340366.

Proof. In Definition C1.1.2.11.3.1 put j=n−kj = n - k. The term for kk is jn−j j!/n!j^{n-j}\, j!/n!, and k=nk = n (j=0j = 0) gives 00 for n≥1n \ge 1. This is the first form. Next, jn−jj!=jn⋅j! j−jj^{n-j} j! = j^n \cdot j!\, j^{-j}, and by Theorem C1.1.2.11.2.19, j! j−j=2πj e−j(1+112j+O(j−2))j!\, j^{-j} = \sqrt{2\pi j}\, e^{-j}\bigl(1 + \frac1{12j} + O(j^{-2})\bigr). So jn−jj!=2π jn+1/2e−j(1+112j+O(j−2))j^{n-j} j! = \sqrt{2\pi}\, j^{n+1/2} e^{-j}\bigl(1 + \frac1{12j} + O(j^{-2})\bigr). The OO is uniform for j≥1j \ge 1, since the ratio j! j−jej/2πjj!\,j^{-j} e^{j}/\sqrt{2\pi j} is a bounded function that tends to 11. □\square

Theorem C1.1.2.11.3.24 (the sum of kn+1/2e−kk^{n+1/2} e^{-k} by Euler's formula, TAOCP eq. 1.2.11.3(21)). Let n≥1n \ge 1 be an integer, let f(t)=tn+1/2e−tf(t) = t^{n+1/2} e^{-t} and let B2(t)=t2−t+16B_2(t) = t^2 - t + \frac16. Then

∑k=0nkn+1/2e−k=∫0ntn+1/2e−t dt+12 nn+1/2e−n+124 nn−1/2e−n−R,R=∫0n12B2({t}) f′′(t) dt.\sum_{k=0}^{n} k^{n+1/2} e^{-k} = \int_0^n t^{n+1/2} e^{-t}\, dt + \frac12\, n^{n+1/2} e^{-n} + \frac1{24}\, n^{n-1/2} e^{-n} - R, \qquad R = \int_0^n \tfrac12 B_2(\{t\})\, f''(t)\, dt.

Node: 1.2.11.3-(21) · Lean: not yet stated

Explanation. This is Euler's summation formula of Section 1.2.11.2 with m=2m = 2, applied to ff on [0,n][0, n]. The term 12f(n)\frac12 f(n) is the half of the last term, and 124nn−1/2e−n\frac1{24} n^{n-1/2} e^{-n} is 112f′(n)\frac1{12} f'(n). The point of the formula is that the integral is a value of the incomplete gamma function and that RR is small.

Example. For n=10n = 10 the sum is 4984849.63974984849.6397. The integral is 4261043.09064261043.0906, the half term is 717835.9183717835.9183, the term with 124\frac1{24} is 5981.96605981.9660, and R=11.3352R = 11.3352. A direct quadrature of the integral that defines RR gives the same value 11.335211.3352. Indeed 4261043.0906+717835.9183+5981.9660−11.3352=4984849.63974261043.0906 + 717835.9183 + 5981.9660 - 11.3352 = 4984849.6397.

Proof. Write N=n+12N = n + \frac12. Lemma C1.1.2.11.2.2, applied on each interval [j,j+1][j, j+1] and summed over 0≤j<n0 \le j < n, gives

∑k=0nf(k)=∫0nf dt+12(f(0)+f(n))+∫0n({t}−12)f′(t) dt.\sum_{k=0}^{n} f(k) = \int_0^n f\, dt + \tfrac12\bigl(f(0) + f(n)\bigr) + \int_0^n \bigl(\{t\} - \tfrac12\bigr) f'(t)\, dt.

The function 12B2({t})\frac12 B_2(\{t\}) is continuous, has period 11, equals 112\frac1{12} at the integers and has the derivative {t}−12\{t\} - \frac12 between them. Integration by parts gives ∫0n({t}−12)f′ dt=112(f′(n)−f′(0))−R\int_0^n (\{t\} - \frac12) f'\, dt = \frac1{12}\bigl(f'(n) - f'(0)\bigr) - R. Here f(0)=f′(0)=0f(0) = f'(0) = 0, since N>1N > 1. Finally f′(t)=f(t)(N/t−1)f'(t) = f(t)(N/t - 1), so f′(n)=f(n)/(2n)=12nn−1/2e−nf'(n) = f(n)/(2n) = \frac12 n^{n-1/2} e^{-n} and 112f′(n)=124nn−1/2e−n\frac1{12} f'(n) = \frac1{24} n^{n-1/2} e^{-n}. □\square

Theorem C1.1.2.11.3.25 (the sum as an incomplete gamma value, TAOCP eq. 1.2.11.3(22)). As n→∞n \to \infty,

∑k=0nkn+1/2e−k=γ(n+32,n)+12 nn+1/2e−n+O(nne−n).\sum_{k=0}^{n} k^{n+1/2} e^{-k} = \gamma\bigl(n + \tfrac32, n\bigr) + \frac12\, n^{n+1/2} e^{-n} + O(n^n e^{-n}).

Node: 1.2.11.3-(22) · Lean: not yet stated

Explanation. The integral of Theorem C1.1.2.11.3.24 is γ(n+32,n)\gamma(n + \frac32, n) by Definition C1.1.2.11.3.6. The term with 124\frac1{24} and the remainder RR are both smaller than the half term by a factor of order n−1/2n^{-1/2}, so they go into the OO. The value γ(n+32,n)\gamma(n + \frac32, n) is the case x=n+12x = n + \frac12, y=−12y = -\frac12 of Theorem A.

Example. The difference of the two sides without the OO term, divided by nne−nn^n e^{-n}, is 0.0131510.013151 for n=10n = 10 and 0.00416600.0041660 for n=100n = 100. These are close to 124n\frac1{24\sqrt n}, which is 0.0131760.013176 and 0.00416670.0041667: the term with 124\frac1{24} is most of the difference, and RR is much smaller.

Proof. Let N=n+12N = n + \frac12 and f(t)=tNe−tf(t) = t^N e^{-t}. The term 124nn−1/2e−n\frac1{24} n^{n-1/2} e^{-n} is at most nne−nn^n e^{-n}. It remains to show that R=O(nne−n)R = O(n^n e^{-n}). Since ∣B2({t})∣≤16|B_2(\{t\})| \le \frac16, ∣R∣≤112∫0n∣f′′∣ dt|R| \le \frac1{12} \int_0^n |f''|\, dt. The second derivative is f′′(t)=f(t)((N−t)2−N)/t2f''(t) = f(t)\bigl((N - t)^2 - N\bigr)/t^2. Let t1=N−Nt_1 = N - \sqrt N. Then f′′≥0f'' \ge 0 on (0,t1](0, t_1] and f′′≤0f'' \le 0 on [t1,n][t_1, n], since n<N+Nn < N + \sqrt N. So f′f' rises from 00 to f′(t1)f'(t_1) and then falls to f′(n)>0f'(n) > 0, and ∫0n∣f′′∣ dt=2f′(t1)−f′(n)≤2f′(t1)\int_0^n |f''|\, dt = 2 f'(t_1) - f'(n) \le 2 f'(t_1). Next f′(t1)=f(t1)(N/t1−1)=f(t1)N/(N−N)f'(t_1) = f(t_1)(N/t_1 - 1) = f(t_1)\sqrt N/(N - \sqrt N), and f(t1)≤f(N)=NNe−Nf(t_1) \le f(N) = N^N e^{-N}, since ff has its maximum at t=Nt = N. Also NNe−N=nNe−n(1+12n)Ne−1/2≤nNe−ne1/(4n)N^N e^{-N} = n^N e^{-n} (1 + \frac1{2n})^N e^{-1/2} \le n^N e^{-n} e^{1/(4n)}, since ln⁡(1+z)≤z\ln(1 + z) \le z. Hence ∫0n∣f′′∣ dt=O(nNe−nn−1/2)=O(nne−n)\int_0^n |f''|\, dt = O(n^N e^{-n} n^{-1/2}) = O(n^n e^{-n}). □\square

Lemma C1.1.2.11.3.26 (a power with a shifted base, TAOCP eq. 1.2.11.3(23)). For fixed real α\alpha and β\beta, as n→∞n \to \infty,

(n+α)n+β=nn+β eα(1+α(β−α/2)n+O(n−2)).(n + \alpha)^{n+\beta} = n^{n+\beta}\, e^{\alpha} \Bigl(1 + \frac{\alpha(\beta - \alpha/2)}{n} + O(n^{-2})\Bigr).

Node: 1.2.11.3-(23) · Lean: not yet stated

Explanation. The factor (1+α/n)n(1 + \alpha/n)^n tends to eαe^\alpha, and the lemma gives the first correction. The proofs below use it to move between the scales NNe−NN^N e^{-N} and nNe−nn^N e^{-n} with N=n+12N = n + \frac12. With α=β=12\alpha = \beta = \frac12 it says NNe−N=nNe−n(1+18n+O(n−2))N^N e^{-N} = n^N e^{-n}\bigl(1 + \frac1{8n} + O(n^{-2})\bigr).

Example. For n=100n = 100, α=12\alpha = \frac12 and β=1\beta = 1 the exact ratio (n+α)n+β/(nn+βeα)(n + \alpha)^{n+\beta}/(n^{n+\beta} e^\alpha) is 1.00374871.0037487, and 1+0.5⋅0.75100=1.003751 + \frac{0.5 \cdot 0.75}{100} = 1.00375. For α=−1\alpha = -1 and β=0\beta = 0 the ratio is 0.99497910.9949791 against 1+(−1)(12)100=0.9951 + \frac{(-1)(\frac12)}{100} = 0.995.

Proof. For n>2∣α∣n > 2|\alpha| take logarithms. The series of the logarithm gives (n+β)ln⁡(1+α/n)=(n+β)(αn−α22n2+O(n−3))=α+αβ−α2/2n+O(n−2)(n + \beta) \ln(1 + \alpha/n) = (n + \beta)\bigl(\frac\alpha n - \frac{\alpha^2}{2n^2} + O(n^{-3})\bigr) = \alpha + \frac{\alpha\beta - \alpha^2/2}{n} + O(n^{-2}). So the logarithm of the ratio is z=α(β−α/2)/n+O(n−2)z = \alpha(\beta - \alpha/2)/n + O(n^{-2}), and ez=1+z+O(z2)e^z = 1 + z + O(z^2). □\square

Theorem C1.1.2.11.3.27 (the size of P(n)P(n), TAOCP eq. 1.2.11.3(24)). As n→∞n \to \infty,

P(n)=πn2−23+1124π2n+4135n−711152π2n3+O(n−2).P(n) = \sqrt{\frac{\pi n}{2}} - \frac23 + \frac{11}{24}\sqrt{\frac{\pi}{2n}} + \frac{4}{135 n} - \frac{71}{1152}\sqrt{\frac{\pi}{2n^3}} + O(n^{-2}).

Node: 1.2.11.3-(24) · Lean: not yet stated

Explanation. The leading term is the same as for QQ and RR below, and the constant is −23-\frac23. The proof below derives the first two terms in full and the third term with one bound that it only sketches. The last two terms need one more term of every expansion in the proof. They follow from exercise 14, which treats sums of the form ∑kkn+αe−k\sum_k k^{n+\alpha} e^{-k} in general, and this chapter checks them only by computation.

Example. For n=100n = 100 the exact value is P(100)=11.9241371P(100) = 11.9241371. The five terms are 12.533141412.5331414, −0.6666667-0.6666667, 0.05744360.0574436, 0.00029630.0002963 and −0.0000772-0.0000772, with the sum 11.924137311.9241373. The difference, times n2n^2, is −0.0003-0.0003, −0.0019-0.0019 and −0.0025-0.0025 for n=10n = 10, 100100 and 10001000, so it stays bounded. With four terms the difference, times n3/2n^{3/2}, is −0.07735-0.07735, −0.07743-0.07743 and −0.07732-0.07732, close to −711152π/2=−0.07724-\frac{71}{1152}\sqrt{\pi/2} = -0.07724.

Proof. Let N=n+12N = n + \frac12, c=1/2πc = 1/\sqrt{2\pi}, f(t)=tNe−tf(t) = t^N e^{-t} and A=∑k=0nf(k)A = \sum_{k=0}^{n} f(k).

Step 1: the factor of Stirling. Write k! k−k=2πk e−k(1+ϵk)k!\, k^{-k} = \sqrt{2\pi k}\, e^{-k}(1 + \epsilon_k). By Theorem C1.1.2.11.2.18 with m=2m = 2, the number ln⁡(1+ϵk)\ln(1 + \epsilon_k) equals 112k−θ360k3\frac1{12k} - \frac{\theta}{360 k^3} with 0≤θ≤10 \le \theta \le 1, so it lies between 00 and 112k\frac1{12k}, and 0≤ϵk≤e1/(12k)−1≤110k0 \le \epsilon_k \le e^{1/(12k)} - 1 \le \frac1{10k}. By Theorem C1.1.2.11.3.23, P(n)=2πn!(A+E)P(n) = \frac{\sqrt{2\pi}}{n!}(A + E) with 0≤E≤110∑k=1ng(k)0 \le E \le \frac1{10}\sum_{k=1}^{n} g(k) and g(t)=tn−1/2e−tg(t) = t^{n-1/2} e^{-t}. The function gg rises and then falls. Each term below the peak is at most the integral of gg over the next unit interval, each term above the peak is at most the integral over the previous one, and at most two terms remain. So ∑k=1ng(k)≤Γ(n+12)+2g(n−12)=O(nne−n)\sum_{k=1}^n g(k) \le \Gamma(n + \frac12) + 2 g(n - \frac12) = O(n^n e^{-n}), and E=O(nne−n)E = O(n^n e^{-n}).

Step 2: the main sum. By Theorem C1.1.2.11.3.25, A=γ(N+1,n)+12f(n)+O(nne−n)A = \gamma(N + 1, n) + \frac12 f(n) + O(n^n e^{-n}). Theorem A with x=Nx = N and y=−12y = -\frac12 gives γ(N+1,n)=Γ(N+1)(12−76c N−1/2+O(N−3/2))\gamma(N+1, n) = \Gamma(N+1)\bigl(\frac12 - \frac76 c\, N^{-1/2} + O(N^{-3/2})\bigr), and Theorem C1.1.2.11.3.20 gives Γ(N+1)=c−1N1/2NNe−N(1+O(1/N))\Gamma(N+1) = c^{-1} N^{1/2} N^N e^{-N}\bigl(1 + O(1/N)\bigr). By Lemma C1.1.2.11.3.26, NNe−N=f(n)(1+O(1/n))N^N e^{-N} = f(n)\bigl(1 + O(1/n)\bigr), and N1/2=n1/2(1+O(1/n))N^{1/2} = n^{1/2}\bigl(1 + O(1/n)\bigr). So γ(N+1,n)=f(n)(πn/2−76+O(n−1/2))\gamma(N+1, n) = f(n)\bigl(\sqrt{\pi n/2} - \frac76 + O(n^{-1/2})\bigr) and A=f(n)(πn/2−23+O(n−1/2))A = f(n)\bigl(\sqrt{\pi n/2} - \frac23 + O(n^{-1/2})\bigr).

Step 3: the first two terms. By Theorem C1.1.2.11.2.19, 2π f(n)/n!=2πn nne−n/n!=1+O(1/n)\sqrt{2\pi}\, f(n)/n! = \sqrt{2\pi n}\, n^n e^{-n}/n! = 1 + O(1/n). Since nne−n=f(n) n−1/2n^n e^{-n} = f(n)\, n^{-1/2}, Steps 1 and 2 give P(n)=(1+O(1/n))(πn/2−23+O(n−1/2))=πn/2−23+O(n−1/2)P(n) = \bigl(1 + O(1/n)\bigr)\bigl(\sqrt{\pi n/2} - \frac23 + O(n^{-1/2})\bigr) = \sqrt{\pi n/2} - \frac23 + O(n^{-1/2}).

Step 4: the third term. Every error of order n−1/2n^{-1/2} in Step 3 must now be found up to O(n−1)O(n^{-1}). Three facts are needed. First, E=112∑k≤ng(k)+O(nn−1/2e−n)E = \frac1{12}\sum_{k \le n} g(k) + O(n^{n-1/2} e^{-n}) by Theorem C1.1.2.11.2.19, and the method of Steps 1 and 2 with Theorem A at x=n−12x = n - \frac12, y=12y = \frac12 gives ∑k≤ng(k)=nn−1/2e−n(πn/2+O(1))\sum_{k \le n} g(k) = n^{n-1/2} e^{-n}\bigl(\sqrt{\pi n/2} + O(1)\bigr). Second, Γ(N+1)/n!=n1/2(1+38n+O(n−2))\Gamma(N+1)/n! = n^{1/2}\bigl(1 + \frac3{8n} + O(n^{-2})\bigr) by Theorems C1.1.2.11.3.20 and C1.1.2.11.2.19 and Lemma C1.1.2.11.3.26 with α=12\alpha = \frac12 and β=1\beta = 1. Third, the remainder RR of Theorem C1.1.2.11.3.24 is O(nn−1/2e−n)O(n^{n-1/2} e^{-n}). This is a sharper bound than in Theorem C1.1.2.11.3.25. It comes from one more integration by parts, which turns RR into −16∫0nB3({t})f′′′(t) dt-\frac16 \int_0^n B_3(\{t\}) f'''(t)\, dt with B3(t)=t3−32t2+12tB_3(t) = t^3 - \frac32 t^2 + \frac12 t. This chapter does not write out the bound for that integral. Its size is confirmed by computation: R/(nn−1/2e−n)R/(n^{n-1/2} e^{-n}) is 7.9⋅10−57.9 \cdot 10^{-5} at n=10n = 10 and 7.0⋅10−67.0 \cdot 10^{-6} at n=100n = 100. With these facts, 2πn! 12γ(N+1,n)\frac{\sqrt{2\pi}}{n!}\,\frac12\gamma(N+1, n) contributes πn/2+38π/(2n)\sqrt{\pi n/2} + \frac38\sqrt{\pi/(2n)}, and 2πn!E\frac{\sqrt{2\pi}}{n!} E contributes 112π/(2n)\frac1{12}\sqrt{\pi/(2n)}. The terms −76-\frac76 and 12\frac12 change only by O(1/n)O(1/n). The coefficient of π/(2n)\sqrt{\pi/(2n)} is 38+112=1124\frac38 + \frac1{12} = \frac{11}{24}. □\square

Theorem C1.1.2.11.3.28 (the size of Q(n)Q(n), TAOCP eq. 1.2.11.3(25)). As n→∞n \to \infty,

Q(n)=πn2−13+112π2n−4135n+1288π2n3+O(n−2).Q(n) = \sqrt{\frac{\pi n}{2}} - \frac13 + \frac1{12}\sqrt{\frac{\pi}{2n}} - \frac{4}{135 n} + \frac1{288}\sqrt{\frac{\pi}{2n^3}} + O(n^{-2}).

Node: 1.2.11.3-(25) · Lean: not yet stated

Explanation. QQ lies above PP by about 13\frac13 and below RR by about 23\frac23. The terms with half-integer powers of nn are the same for QQ and RR, since they come from 12 n! en/nn\frac12\, n!\, e^n/n^n. The terms with integer powers have opposite signs.

Example. For n=100n = 100 the exact value is Q(100)=12.2099606Q(100) = 12.2099606, and the five terms give 12.209960412.2099604. The difference, times n2n^2, is 0.00190.0019, 0.00250.0025 and 0.00270.0027 for n=10n = 10, 100100 and 10001000.

Proof. Let c=1/2πc = 1/\sqrt{2\pi}, ρ=γ(n,n)/(n−1)!\rho = \gamma(n, n)/(n-1)! and M=n! en/nnM = n!\, e^n/n^n. By Theorems C1.1.2.11.3.4 and C1.1.2.11.3.9, R(n)=MρR(n) = M\rho and Q(n)=M(1−ρ)Q(n) = M(1 - \rho). Theorem A with x=n−1x = n - 1 and y=1y = 1 gives ρ=12+c3(n−1)−1/2−89540 c (n−1)−3/2+O(n−5/2)\rho = \frac12 + \frac c3 (n-1)^{-1/2} - \frac{89}{540}\, c\, (n-1)^{-3/2} + O(n^{-5/2}), since 23270−112−16=−89540\frac{23}{270} - \frac1{12} - \frac16 = -\frac{89}{540}. Now (n−1)−1/2=n−1/2(1+12n+O(n−2))(n-1)^{-1/2} = n^{-1/2}\bigl(1 + \frac1{2n} + O(n^{-2})\bigr) and (n−1)−3/2=n−3/2(1+O(1/n))(n-1)^{-3/2} = n^{-3/2}\bigl(1 + O(1/n)\bigr). Since 16−89540=1540\frac16 - \frac{89}{540} = \frac1{540},

ρ=12+c3 n−1/2+c540 n−3/2+O(n−5/2).\rho = \frac12 + \frac c3\, n^{-1/2} + \frac{c}{540}\, n^{-3/2} + O(n^{-5/2}).

By Theorem C1.1.2.11.2.19, M=c−1n1/2(1+112n+1288n2+O(n−3))M = c^{-1} n^{1/2}\bigl(1 + \frac1{12n} + \frac1{288n^2} + O(n^{-3})\bigr). Multiply term by term. The product 12M\frac12 M is πn/2+112π/(2n)+1288π/(2n3)+O(n−5/2)\sqrt{\pi n/2} + \frac1{12}\sqrt{\pi/(2n)} + \frac1{288}\sqrt{\pi/(2n^3)} + O(n^{-5/2}), since 12c=π/2\frac1{2c} = \sqrt{\pi/2}. The product M c3n−1/2M\,\frac c3 n^{-1/2} is 13+136n+O(n−2)\frac13 + \frac1{36n} + O(n^{-2}). The product M c540n−3/2M\,\frac{c}{540} n^{-3/2} is 1540n+O(n−2)\frac1{540n} + O(n^{-2}). The product of MM and O(n−5/2)O(n^{-5/2}) is O(n−2)O(n^{-2}). Since 136+1540=4135\frac1{36} + \frac1{540} = \frac4{135}, the difference M(1−ρ)=12M−(Mρ−12M)M(1 - \rho) = \frac12 M - \bigl(M\rho - \frac12 M\bigr) is the claim. □\square

Theorem C1.1.2.11.3.29 (the size of R(n)R(n), TAOCP eq. 1.2.11.3(26)). As n→∞n \to \infty,

R(n)=πn2+13+112π2n+4135n+1288π2n3+O(n−2).R(n) = \sqrt{\frac{\pi n}{2}} + \frac13 + \frac1{12}\sqrt{\frac{\pi}{2n}} + \frac{4}{135 n} + \frac1{288}\sqrt{\frac{\pi}{2n^3}} + O(n^{-2}).

Node: 1.2.11.3-(26) · Lean: not yet stated

Explanation. With Theorem C1.1.2.11.3.28 this gives R(n)−Q(n)=23+8135n+O(n−2)R(n) - Q(n) = \frac23 + \frac{8}{135n} + O(n^{-2}), and R(n)+Q(n)=2πn (1+112n+1288n2)+O(n−5/2)R(n) + Q(n) = \sqrt{2\pi n}\,\bigl(1 + \frac1{12n} + \frac1{288n^2}\bigr) + O(n^{-5/2}), which is Stirling's series for n! en/nnn!\, e^n/n^n.

Example. For n=100n = 100 the exact value is R(100)=12.8772193R(100) = 12.8772193, and the five terms give 12.877219612.8772196. The difference, times n2n^2, is −0.0041-0.0041, −0.0032-0.0032 and −0.0029-0.0029 for n=10n = 10, 100100 and 10001000. The value n(R(n)−Q(n)−23)n\bigl(R(n) - Q(n) - \frac23\bigr) is 0.058660.05866, 0.059200.05920 and 0.059250.05925, and 8135=0.05926\frac8{135} = 0.05926.

Proof. In the proof of Theorem C1.1.2.11.3.28, R(n)=Mρ=12M+(Mρ−12M)R(n) = M\rho = \frac12 M + \bigl(M\rho - \frac12 M\bigr). The four products found there give the claim, now with the plus sign on 13+4135n\frac13 + \frac{4}{135n}. □\square

Algorithms and programs

Section 1.2.11.3 has no algorithm and no program. The sums have short exact procedures. Each of P(n)P(n) and Q(n)Q(n) has finitely many rational terms, so exact arithmetic gives it. R(n)R(n) has terms t0=1t_0 = 1 and tk=tk−1 n/(n+k)t_k = t_{k-1}\, n/(n+k), and the ratio of two terms is below 12\frac12 once k≥nk \ge n, so a loop that stops when tkt_k is below the wanted error finds R(n)R(n). All the exact values and the checks in this chapter come from these procedures, from the identity of Theorem C1.1.2.11.3.4 and from numerical integration of the integrals I1I_1 and I2I_2.

The exercises

The table has the exercises of Section 1.2.11.3. The kind is the class of spec 06.3, and the indexer of S0 fixes it in the map.

Exercise Rating Markers Kind Lean Solution
1.2.11.3-1 20 HM K1 not yet stated X1, 1.2.11.3-1
1.2.11.3-2 20 HM K1 not yet stated X1, 1.2.11.3-2
1.2.11.3-3 20 M K1 not yet stated X1, 1.2.11.3-3
1.2.11.3-4 10 ▶ HM K1 not yet stated X1, 1.2.11.3-4
1.2.11.3-5 24 HM K1 not yet stated X1, 1.2.11.3-5
1.2.11.3-6 20 ▶ HM K1 not yet stated X1, 1.2.11.3-6
1.2.11.3-7 30 ▶ HM K3 not yet stated X1, 1.2.11.3-7
1.2.11.3-8 30 HM K1 not yet stated X1, 1.2.11.3-8
1.2.11.3-9 36 ▶ HM K3 not yet stated X1, 1.2.11.3-9
1.2.11.3-10 34 HM K3 not yet stated X1, 1.2.11.3-10
1.2.11.3-11 35 ▶ HM K3 not yet stated X1, 1.2.11.3-11
1.2.11.3-12 20 HM K3 not yet stated X1, 1.2.11.3-12
1.2.11.3-13 42 HM K1 not yet stated X1, 1.2.11.3-13
1.2.11.3-14 39 ▶ HM K1 not yet stated X1, 1.2.11.3-14
1.2.11.3-15 20 HM K1 not yet stated X1, 1.2.11.3-15
1.2.11.3-16 24 M K1 not yet stated X1, 1.2.11.3-16
1.2.11.3-17 29 HM K3 not yet stated X1, 1.2.11.3-17
1.2.11.3-18 25 M K3 not yet stated X1, 1.2.11.3-18
1.2.11.3-19 30 HM K1 not yet stated X1, 1.2.11.3-19
1.2.11.3-20 30 HM K1 not yet stated X1, 1.2.11.3-20

Notes on the exercises. Each note uses the results proved above.

  • Exercise 1 is Theorem C1.1.2.11.3.5, proved by induction on nn.
  • Exercise 2 is Theorem C1.1.2.11.3.7, and exercise 3 is Theorem C1.1.2.11.3.8. A second proof of exercise 3 multiplies the series of Theorem C1.1.2.11.3.7 by ex=∑xj/j!e^x = \sum x^j/j!. The coefficient of xk+ax^{k+a} is 1k!∑j=0k(−1)j(kj)1j+a\frac1{k!}\sum_{j=0}^{k} (-1)^j \binom kj \frac1{j+a}. This equals 1a(a+1)⋯(a+k)\frac{1}{a(a+1)\cdots(a+k)} by partial fractions.
  • Exercise 4 is Theorem C1.1.2.11.3.14.
  • Exercise 5 is the bound on RR in the proof of Theorem C1.1.2.11.3.25: ∣R∣≤112∫0n∣f′′∣ dt=O(nne−n)|R| \le \frac1{12}\int_0^n |f''|\, dt = O(n^{n} e^{-n}).
  • Exercise 6 is Lemma C1.1.2.11.3.26.
  • Exercise 7: put u=s x1/4u = s\, x^{1/4} and expand the exponent −u22x+u33x2−u44x3+⋯-\frac{u^2}{2x} + \frac{u^3}{3x^2} - \frac{u^4}{4x^3} + \cdots in powers of x−1/4x^{-1/4}. The result is ∫0yx1/4e−u(1+ux)xdu=yx1/4−y36x−1/4+y540x−3/4+y412x−1−y7336x−5/4−y636x−3/2+(y93456−y520)x−7/4+O(x−2).\int_0^{y x^{1/4}} e^{-u}\Bigl(1 + \frac ux\Bigr)^x du = y x^{1/4} - \frac{y^3}{6} x^{-1/4} + \frac{y^5}{40} x^{-3/4} + \frac{y^4}{12} x^{-1} - \frac{y^7}{336} x^{-5/4} - \frac{y^6}{36} x^{-3/2} + \Bigl(\frac{y^9}{3456} - \frac{y^5}{20}\Bigr) x^{-7/4} + O(x^{-2}). For x=104x = 10^4 and y=2y = 2 the integral is 19.867594284219.8675942842 and the seven terms give 19.867594267519.8675942675. The difference is 1.7⋅10−81.7 \cdot 10^{-8}, which is x−2x^{-2} times 1.671.67, and the next term has the coefficient y8192=1.33\frac{y^8}{192} = 1.33.
  • Exercise 8: for 0≤u≤f(x)0 \le u \le f(x) the remainder of the series of xln⁡(1+u/x)−ux \ln(1 + u/x) - u after the term um/(mxm−1)u^m/(m x^{m-1}) is O(um+1/xm)O(u^{m+1}/x^m). This is O(xr(m+1)−m)O(x^{r(m+1) - m}). The truncated exponent is at most 00 for large xx, so eB−1=O(remainder)e^{B} - 1 = O(\text{remainder}) multiplies a bounded integrand. Integrating over a length O(xr)O(x^r) gives the error O(xr(m+2)−m)O(x^{r(m+2) - m}). This is O(x−s)O(x^{-s}) exactly when m(1−r)≥s+2rm(1 - r) \ge s + 2r, which is the stated value of mm. For Tricomi's case r=12r = \frac12 and s=0s = 0 give m=2m = 2, and the substitution u=t2xu = t\sqrt{2x} gives the second form.
  • Exercise 9: Let T=pxT = px and cx=(pe1−p)x/2πxc_x = (p e^{1-p})^x/\sqrt{2\pi x}. For p<1p < 1, including negative pp with integer xx, γ(x+1,px)Γ(x+1)=cx p1−p(1−112x−1(1−p)2x+O(x−2)).\frac{\gamma(x+1, px)}{\Gamma(x+1)} = c_x\, \frac{p}{1-p}\Bigl(1 - \frac1{12x} - \frac1{(1-p)^2 x} + O(x^{-2})\Bigr). For p>1p > 1 the ratio is 1−cxpp−1(1−112x−1(p−1)2x+O(x−2))1 - c_x \frac{p}{p-1}\bigl(1 - \frac1{12x} - \frac1{(p-1)^2 x} + O(x^{-2})\bigr). For p=1p = 1 Theorem C1.1.2.11.3.21 with y=0y = 0 applies. The proof integrates by parts twice with e−ttx=ge^{-t} t^x = g and g=g′ t/(x−t)g = g'\, t/(x - t). This gives ∫0Tg=g(T)Tx−T−∫0Tgx(x−t)2 dt\int_0^T g = g(T) \frac{T}{x - T} - \int_0^T g \frac{x}{(x-t)^2}\, dt, and the last integral is g(T)xT(x−T)3(1+O(1/x))g(T) \frac{xT}{(x-T)^3}(1 + O(1/x)). Then divide by Γ(x+1)\Gamma(x+1) and use Theorem C1.1.2.11.3.20. For p=2p = 2 and x=40x = 40 the exact value of the ratio, divided by cxp1−pc_x \frac{p}{1-p}, is 0.975590.97559, and the bracket is 0.972920.97292. The difference times x2x^2 is 4.274.27.
  • Exercise 10: with T=pxT = px and δ=py/(p−1)\delta = py/(p-1) the integral is g(T)∫0δexp⁡(xln⁡(1+s/T)−s)dsg(T) \int_0^\delta \exp\bigl(x \ln(1 + s/T) - s\bigr) ds. Since xln⁡(1+s/T)=s/p+O(1/x)x \ln(1 + s/T) = s/p + O(1/x), the exponent is s(1−p)/p+O(1/x)s(1-p)/p + O(1/x), and the integral of the leading part is p1−p(e−y−1)\frac{p}{1-p}(e^{-y} - 1). So the leading term of the difference over Γ(x+1)\Gamma(x+1) is cx p1−p (e−y−1)c_x\,\frac{p}{1-p}\,(e^{-y} - 1). For x=40x = 40, p=12p = \frac12 and y=1y = 1 the exact ratio to this term is 0.9850.985. The second term of the expansion is not worked out in this chapter.
  • Exercise 11: for 0<x<10 < x < 1 the factor xkx^k makes the terms of both sums geometric. The kk-th term of Qx(n)Q_x(n) and of Rx(n)R_x(n) is xk(1−k(k+1)2n+O(k4n−2))x^k\bigl(1 - \frac{k(k+1)}{2n} + O(k^4 n^{-2})\bigr). Since ∑kk(k+1)xk=2x(1−x)3\sum_k k(k+1) x^k = \frac{2x}{(1-x)^3}, both sums equal 11−x−x(1−x)3 n+O(n−2)\frac{1}{1-x} - \frac{x}{(1-x)^3\, n} + O(n^{-2}). For x=12x = \frac12 and n=1000n = 1000 the sums are 1.9960201.996020 and 1.9960321.996032, and the formula gives 1.9960001.996000. The case x>1x > 1 is not worked out in this chapter.
  • Exercise 12: put s=t2/2s = t^2/2. Then ∫0xe−t2/2 dt=12 γ(12,x22)\int_0^x e^{-t^2/2}\, dt = \frac{1}{\sqrt2}\,\gamma\bigl(\frac12, \frac{x^2}{2}\bigr) for x≥0x \ge 0. So a=12a = \frac12, b=12b = \frac1{\sqrt2} and y=x22y = \frac{x^2}2. For x=1x = 1 both sides are 0.8556240.855624.
  • Exercise 13: Theorems C1.1.2.11.3.28 and C1.1.2.11.3.29 give R(n)−Q(n)=23+8135n+O(n−2)R(n) - Q(n) = \frac23 + \frac{8}{135 n} + O(n^{-2}). This is the form of Ramanujan's result up to the size of the remainder. The sharp bounds 221≤θ(n)≤845\frac2{21} \le \theta(n) \le \frac8{45} are not proved in this chapter. The value θ(n)\theta(n) defined by the identity is 0.1480.148, 0.1270.127, 0.1090.109, 0.10240.1024 and 0.09670.0967 for n=1,2,5,10,50n = 1, 2, 5, 10, 50, and all five lie in the interval.
  • Exercise 14: Part (a) is the substitution j→n−jj \to n - j in the sum. It gives (n−k)n+αe−(n−k)=nn+αe−n (1−k/n)αexp⁡(nln⁡(1−k/n)+k)(n-k)^{n+\alpha} e^{-(n-k)} = n^{n+\alpha} e^{-n}\, (1 - k/n)^\alpha \exp\bigl(n\ln(1 - k/n) + k\bigr), and nln⁡(1−k/n)+k=−k22n−k33n2−⋯n \ln(1 - k/n) + k = -\frac{k^2}{2n} - \frac{k^3}{3n^2} - \cdots. Part (e) is the result. For α=12\alpha = \frac12 its first terms πn/2−16−α=πn/2−23\sqrt{\pi n/2} - \frac16 - \alpha = \sqrt{\pi n/2} - \frac23 are the terms of A/f(n)A/f(n) in Step 2 of the proof of Theorem C1.1.2.11.3.27. For n=100n = 100 and α=12\alpha = \frac12 the sum divided by the four terms of part (e) is 0.999950.99995. The tail bounds of parts (b) to (d) are not written out in this chapter.
  • Exercise 15: put t=n+zt = n + z. The integral is enn−n∫n∞tne−t dt=enn−n(n!−γ(n+1,n))e^n n^{-n} \int_n^\infty t^n e^{-t}\, dt = e^n n^{-n}\bigl(n! - \gamma(n+1, n)\bigr). Integration by parts gives γ(n+1,n)=n γ(n,n)−nne−n\gamma(n+1, n) = n\,\gamma(n, n) - n^n e^{-n}. So the integral is n! ennn(1−γ(n,n)(n−1)!)+1\frac{n!\, e^n}{n^n}\bigl(1 - \frac{\gamma(n,n)}{(n-1)!}\bigr) + 1. By Theorems C1.1.2.11.3.4 and C1.1.2.11.3.9 the first part is Q(n)Q(n). So the integral is 1+Q(n)1 + Q(n). For n=5n = 5 it is 3.5104=1+Q(5)3.5104 = 1 + Q(5).
  • Exercise 16: write Q(k)=∑j≥1kj‾/kjQ(k) = \sum_{j \ge 1} k^{\underline j}/k^j, where kj‾k^{\underline j} is the falling power and kj‾=0k^{\underline j} = 0 for j>kj > k. Let g(k)=kn−1Q(k)g(k) = k^{n-1} Q(k) for 0≤k≤n0 \le k \le n, with g(0)=0g(0) = 0. Split the terms into j≤n−1j \le n - 1 and j≥nj \ge n. For j≤n−1j \le n-1 the term kn−1−jkj‾k^{n-1-j} k^{\underline j} is a polynomial in kk of degree n−1n - 1, and it is 00 at k=0k = 0. The nn-th difference of a polynomial of degree below nn is 00, and ∑k(−1)k(nk)p(k)\sum_k (-1)^k \binom nk p(k) is that difference up to the sign (−1)n(-1)^n. For j≥nj \ge n and 0≤k≤n0 \le k \le n the only nonzero term is j=k=nj = k = n, and it is n−1 n!=(n−1)!n^{-1}\, n! = (n-1)!. So the sum is (−1)n(nn)(n−1)!=(−1)n(n−1)!(-1)^n \binom nn (n-1)! = (-1)^n (n-1)!. For n=4n = 4 both sides are 66.
  • Exercise 17: put j=n+kj = n + k. The kk-th term of S(n)S(n) is (j−1)! j n−j(n−1)!=j n−1 j! j−j(n−1)!\frac{(j-1)!\, j^{\,n-j}}{(n-1)!} = \frac{j^{\,n-1}\, j!\, j^{-j}}{(n-1)!}, so S(n)=2π(n−1)!∑j≥nj n−1/2e−j(1+ϵj)S(n) = \frac{\sqrt{2\pi}}{(n-1)!} \sum_{j \ge n} j^{\,n - 1/2} e^{-j}(1 + \epsilon_j) with 0≤ϵj≤110j0 \le \epsilon_j \le \frac1{10j}. This is the sum of Theorem C1.1.2.11.3.23 turned around, and Steps 1 to 3 of the proof of Theorem C1.1.2.11.3.27 apply to it. Take N=n−12N = n - \frac12 and the upper sum. The integral from nn to ∞\infty is Γ(N+1)−γ(N+1,N+12)\Gamma(N+1) - \gamma(N+1, N + \frac12), and Theorem A with y=12y = \frac12 gives NNe−N(πN/2+16+O(N−1/2))N^N e^{-N}\bigl(\sqrt{\pi N/2} + \frac16 + O(N^{-1/2})\bigr). The edge term +12f(n)+\frac12 f(n) adds 12\frac12. So S(n)=πn/2+23+O(n−1/2)S(n) = \sqrt{\pi n/2} + \frac23 + O(n^{-1/2}). The values are S(10)=4.612017S(10) = 4.612017 and S(100)=13.194341S(100) = 13.194341, against 4.6299944.629994 and 13.19980813.199808 from the two terms. The sum P(n)+S(n)P(n) + S(n) is close to 2πn/22\sqrt{\pi n/2}, so SS is to PP as RR is to QQ.
  • Exercise 18: both identities are ∑k(nk)kk(n−k)n−k=nn(1+Q(n))\sum_k \binom nk k^k (n-k)^{n-k} = n^n\bigl(1 + Q(n)\bigr) and ∑k(nk)(k+1)k(n−k)n−k=(n+1)n Q(n+1)\sum_k \binom nk (k+1)^k (n-k)^{n-k} = (n+1)^n\, Q(n+1), with 00=10^0 = 1. Exact arithmetic confirms them for 1≤n≤81 \le n \le 8. For n=4n = 4 the first sum is 824=256⋅(1+7132)824 = 256 \cdot (1 + \frac{71}{32}) and the second is 1569=54⋅Q(5)1569 = 5^4 \cdot Q(5). A proof is not given in this chapter.
  • Exercise 19 is Lemma C1.1.2.11.3.16, first claim.
  • Exercise 20: by exercise 15 and z=nuz = nu, 1+Q(n)=n∫0∞(1+u)ne−nu du1 + Q(n) = n \int_0^\infty (1+u)^n e^{-nu}\, du. By Lemma C1.1.2.11.3.11 this is n∫0∞e−nv dudv dvn \int_0^\infty e^{-nv}\, \frac{du}{dv}\, dv. With w=2vw = \sqrt{2v} and dv=w dwdv = w\, dw the derivative is dudv=1wdudw=∑kkckwk−2=∑kkck(2v)(k−2)/2\frac{du}{dv} = \frac1w\frac{du}{dw} = \sum_k k c_k w^{k-2} = \sum_k k c_k (2v)^{(k-2)/2}. The function du/dv=1+1/udu/dv = 1 + 1/u is bounded for v≥rv \ge r. The second claim of Lemma C1.1.2.11.3.16 with s=ns = n and the terms k=1,…,m−1k = 1, \ldots, m-1 gives ∑k=1m−1kck 2(k−2)/2 Γ(k/2) n1−k/2+O(n1−m/2)\sum_{k=1}^{m-1} k c_k\, 2^{(k-2)/2}\, \Gamma(k/2)\, n^{1 - k/2} + O(n^{1 - m/2}). Since 2(k−2)/2n1−k/2=(n/2)1−k/22^{(k-2)/2} n^{1-k/2} = (n/2)^{1-k/2}, this is the claim. For k=1k = 1 the term is πn/2\sqrt{\pi n/2}, and for k=2k = 2 it is 23\frac23. For n=10n = 10 the five terms k=1,…,5k = 1, \ldots, 5 give 4.6601964.660196, and 1+Q(10)=4.6602161 + Q(10) = 4.660216.

Lean

The Lean code of tamnd/taocp-lean at main has the file TAOCP/V1/S1_2_11.lean, in the namespace TAOCP.S1_2_11. It defines the three sums and states one identity. The Node lines name the declarations.

  • TAOCP.S1_2_11.P, TAOCP.S1_2_11.Q and TAOCP.S1_2_11.R are the sums of eqs. (1), (2) and (3). In Q the quotient n!/(n−k)!n!/(n-k)! is Nat.descFactorial, which is exact. R is a tsum.
  • TAOCP.S1_2_11.P_two and TAOCP.S1_2_11.Q_two check that P(2)=Q(2)=3/2P(2) = Q(2) = 3/2.
  • TAOCP.S1_2_11.eq4_QR is eq. (4), Q(n)+R(n)=n! en/nnQ(n) + R(n) = n!\,e^n/n^n for n≥1n \ge 1.

Not yet stated: the Node lines that say "Lean: not yet stated". They include the incomplete gamma function, Theorem A and the asymptotic series for PP, QQ and RR.

Notes and history

The three sums have a long history. Ramanujan stated results equivalent to Theorems C1.1.2.11.3.28 and C1.1.2.11.3.29 for QQ and RR in the Journal of the Indian Mathematical Society in 1911 and 1912. His series for 12 n! en/nn−Q(n)\frac12\, n!\, e^n/n^n - Q(n) is 13+4135n−82835n2−⋯\frac13 + \frac4{135 n} - \frac{8}{2835 n^2} - \cdots, which is the series for 12(R−Q)\frac12(R - Q), since 12 n! en/nn−Q(n)=12(R(n)−Q(n))\frac12\, n!\, e^n/n^n - Q(n) = \frac12\bigl(R(n) - Q(n)\bigr) by Theorem C1.1.2.11.3.4. The first two terms agree with Theorems C1.1.2.11.3.28 and C1.1.2.11.3.29. The third term −82835n2-\frac{8}{2835 n^2} is confirmed by exact computation at n=100n = 100 and n=1000n = 1000. Ramanujan treated I1I_1 with the substitution t=x+u2xt = x + u\sqrt{2x}, which turns it directly into a sum of Gaussian moments. The method of this section, which splits the Gamma integral at its peak, is due to R. Furch, in the Zeitschrift für Physik in 1939. His question was the shift yy for which γ(x+1,x+y)\gamma(x+1, x+y) is half of Γ(x+1)\Gamma(x+1), and Theorem C1.1.2.11.3.22 shows that this shift tends to 23\frac23. The asymptotic value of P(n)P(n) was first found by H. B. Demuth in his Stanford thesis of 1956, by another method. Exercise 20 gives a shorter route for QQ through Watson's lemma.

The expansion of γ(x+1,x+y)/Γ(x+1)\gamma(x+1, x+y)/\Gamma(x+1) was extended to complex arguments by Tricomi, in the Mathematische Zeitschrift in 1950. Exercise 8 gives his real result for the middle integral.

Three different methods appear in this section: the incomplete gamma function for RR and QQ, the series inversion of Lemma C1.1.2.11.3.13 with Watson's lemma, and Euler's formula for PP. Exercise 14 gives a fourth method that treats all three sums in one scheme.

The project has no errata of Section 1.2.11.3 to report.

Section 1.2.11.3 of TAOCP studies three sums, P(n)P(n), Q(n)Q(n) and R(n)R(n), that look alike and have the same size, about πn/2\sqrt{\pi n/2}. The section finds their size with three different tools: the incomplete gamma function, a change of variable and a power series, and a comparison of a sum with an integral. This chapter of C1 proves each equation of the section, supplies the steps that the section leaves open, and checks every series against exact values.

The source of this page. Something is wrong? Report it.