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.2

Euler's summation formula

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.2 of the book. The nodes and the exercises of the section.

Contents
  1. Euler's summation formula

Euler's summation formula

Overview

Section 1.2.11.2 of TAOCP compares a sum ∑f(k)\sum f(k) with the integral ∫f\int f. The two differ by a short list of boundary terms and a remainder. The boundary terms use the values of the derivatives of ff at the two ends, and their coefficients are the Bernoulli numbers BkB_k. The remainder is an integral that has a bound in terms of f(m)f^{(m)}. The section defines the Bernoulli numbers and polynomials, proves the formula, and bounds the remainder. It then applies the formula twice. For f(x)=1/xf(x) = 1/x the result is the series for HnH_n and the value of Euler's constant γ\gamma. For f(x)=ln⁡xf(x) = \ln x the result is Stirling's series for ln⁡n!\ln n! and, after exponentiation, the series for n!n! itself.

The ideas

A sum is a trapezoid sum plus a correction. On one unit interval the average 12(f(k)+f(k+1))\frac12(f(k) + f(k+1)) differs from ∫f\int f by an integral of f′f' against the sawtooth function {x}−12\{x\} - \frac12 (eq. (2)). Adding the intervals gives eq. (3). Integration by parts, repeated, replaces the sawtooth by the Bernoulli polynomials and gives eq. (10).

The Bernoulli numbers are fixed by one generating function. The function z/(ez−1)z/(e^z - 1) has the power series ∑Bkzk/k!\sum B_k z^k/k! (eq. (4)). This one definition gives the values (5), the vanishing of the odd numbers (6), the recursion (7) and the properties (8) and (9) of the polynomials. The proof of Euler's formula needs only that Bm(0)=Bm(1)B_m(0) = B_m(1) for m≥2m \ge 2 and that Bm′=mBm−1B_m' = m B_{m-1}.

The remainder is small, and it has a sign. The periodic function Bm({x})B_m(\{x\}) has a Fourier series, and this series gives the bound 4 m!/(2π)m4\,m!/(2\pi)^m (eq. (12)). For even mm it also shows that Bm({x})−BmB_m(\{x\}) - B_m keeps one sign. This fixes the sign of the remainder and gives eq. (13): the error of the formula lies between 00 and the first omitted term.

The series do not converge, and they still work. The Bernoulli numbers grow faster than any geometric sequence. For fixed nn the series for HnH_n and for ln⁡n!\ln n! diverge. Yet each truncation is correct, and the error is at most the first omitted term.

One constant needs a separate argument. The formula for ln⁡n!\ln n! has an unknown constant σ\sigma. Wallis' product gives σ=12ln⁡2π\sigma = \frac12\ln 2\pi.

C1 follows the order of the section. It adds three results that later parts of C1 need: the value of σ\sigma (Theorem C1.1.2.11.2.20), the extension of Stirling's series to real arguments (Theorem C1.1.2.11.2.21) and the series with a shift ss (Theorem C1.1.2.11.2.22). The last one is used in Section 1.2.11.1.

Definitions, results and proofs

Definition C1.1.2.11.2.1 (the fractional part, TAOCP eq. 1.2.11.2(1)). For a real number xx let ⌊x⌋\lfloor x \rfloor be the greatest integer not larger than xx. The fractional part of xx is

{x}=x−⌊x⌋.\{x\} = x - \lfloor x \rfloor.

Node: TA4YMH1RQQ · Lean: TAOCP.S1_2_11.fract_eq · status: not stated yet

Explanation. The value {x}\{x\} lies in the interval [0,1)[0, 1). The function has period 11, and it rises with slope 11 from 00 up to 11 on each interval [k,k+1)[k, k+1). For a negative xx the value is still non-negative, so {−0.25}=0.75\{-0.25\} = 0.75 and not 0.250.25. The graph is a sawtooth with jumps at the integers.

Example. {3.7}=0.7\{3.7\} = 0.7, {5}=0\{5\} = 0 and {−2.25}=−2.25−(−3)=0.75\{-2.25\} = -2.25 - (-3) = 0.75. Also {−2.25+1}={−1.25}=0.75\{-2.25 + 1\} = \{-1.25\} = 0.75, as the period requires.

Proof. By the definition of the floor, ⌊x⌋≤x<⌊x⌋+1\lfloor x \rfloor \le x < \lfloor x \rfloor + 1, so 0≤{x}<10 \le \{x\} < 1. Since ⌊x+1⌋=⌊x⌋+1\lfloor x + 1 \rfloor = \lfloor x \rfloor + 1, it follows that {x+1}={x}\{x + 1\} = \{x\}. On [k,k+1)[k, k+1) the floor is kk, so {x}=x−k\{x\} = x - k. □\square

Lemma C1.1.2.11.2.2 (one interval, TAOCP eq. 1.2.11.2(2)). Let kk be an integer and let ff have a continuous derivative on [k,k+1][k, k+1]. Then

∫kk+1({x}−12)f′(x) dx=12(f(k)+f(k+1))−∫kk+1f(x) dx.\int_k^{k+1} \Bigl(\{x\} - \tfrac12\Bigr) f'(x)\, dx = \tfrac12\bigl(f(k) + f(k+1)\bigr) - \int_k^{k+1} f(x)\, dx.

Node: TAJZCN62RC · Lean: TAOCP.S1_2_11.eq2_euler (partial) · status: not stated yet

Explanation. The left side measures how far the trapezoid rule on one interval is from the exact integral. The weight {x}−12\{x\} - \frac12 runs from −12-\frac12 to +12+\frac12 and has mean 00 on the interval. The proof is one integration by parts.

Example. Take f(x)=x2f(x) = x^2 and k=1k = 1. The left side is ∫12(x−32) 2x dx=[23x3−32x2]12=(163−6)−(23−32)=16\int_1^2 (x - \frac32)\, 2x\, dx = \bigl[\frac23 x^3 - \frac32 x^2\bigr]_1^2 = (\frac{16}{3} - 6) - (\frac23 - \frac32) = \frac16. The right side is 12(1+4)−73=52−73=16\frac12(1 + 4) - \frac73 = \frac52 - \frac73 = \frac16.

Proof. On [k,k+1)[k, k+1) the value {x}−12\{x\} - \frac12 is x−k−12x - k - \frac12. Integrate by parts with u=x−k−12u = x - k - \frac12 and dv=f′(x) dxdv = f'(x)\, dx:

∫kk+1(x−k−12)f′(x) dx=[(x−k−12)f(x)]kk+1−∫kk+1f(x) dx.\int_k^{k+1} \Bigl(x - k - \tfrac12\Bigr) f'(x)\, dx = \Bigl[\Bigl(x - k - \tfrac12\Bigr) f(x)\Bigr]_k^{k+1} - \int_k^{k+1} f(x)\, dx.

The bracket is 12f(k+1)+12f(k)\frac12 f(k+1) + \frac12 f(k). □\square

Theorem C1.1.2.11.2.3 (the first summation formula, TAOCP eq. 1.2.11.2(3)). Let n≥2n \ge 2 be an integer and let ff have a continuous derivative on [1,n][1, n]. Then

∑1≤k<nf(k)=∫1nf(x) dx−12(f(n)−f(1))+∫1n({x}−12)f′(x) dx.\sum_{1 \le k < n} f(k) = \int_1^n f(x)\, dx - \tfrac12\bigl(f(n) - f(1)\bigr) + \int_1^n \Bigl(\{x\} - \tfrac12\Bigr) f'(x)\, dx.

Node: TAVWN7C9JT · Lean: TAOCP.S1_2_11.eq3_euler (partial) · status: not stated yet

Explanation. The sum has n−1n - 1 terms and omits f(n)f(n). The first two terms on the right are the integral and half the jump of ff across the interval. They are the first two terms of the series that Theorem C1.1.2.11.2.10 builds. The last integral is the error of this two-term approximation. It is small when f′f' is small.

Example. Let f(x)=1/xf(x) = 1/x and n=10n = 10. The sum is H9=2.8289682540H_9 = 2.8289682540. The integral is ln⁡10=2.3025850930\ln 10 = 2.3025850930. The middle term is −12(110−1)=0.45-\frac12(\frac1{10} - 1) = 0.45. The last integral, with f′(x)=−x−2f'(x) = -x^{-2}, equals 0.07638316100.0763831610 by numerical integration. The three parts add to 2.82896825402.8289682540.

Proof. Add Lemma C1.1.2.11.2.2 over k=1,…,n−1k = 1, \ldots, n-1. The left sides add to ∫1n({x}−12)f′\int_1^n (\{x\} - \frac12) f'. The right sides add to ∑k=1n−112(f(k)+f(k+1))−∫1nf\sum_{k=1}^{n-1} \frac12 (f(k) + f(k+1)) - \int_1^n f. The first sum is ∑1≤k<nf(k)+12(f(n)−f(1))\sum_{1 \le k < n} f(k) + \frac12 (f(n) - f(1)), because each value f(k)f(k) with 1<k<n1 < k < n appears twice with weight 12\frac12. Move the boundary part to the other side. □\square

Definition C1.1.2.11.2.4 (the Bernoulli numbers, TAOCP eq. 1.2.11.2(4)). The Bernoulli numbers B0,B1,B2,…B_0, B_1, B_2, \ldots are the coefficients of the following power series. The left side has the value 11 at z=0z = 0.

zez−1=∑k≥0Bk zkk!.\frac{z}{e^z - 1} = \sum_{k \ge 0} B_k\, \frac{z^k}{k!}.

Node: TAZDCDM2GZ · Lean: TAOCP.S1_2_11.eq4_bernoulli · status: not stated yet

Explanation. The function z/(ez−1)z/(e^z - 1) is analytic near 00. Its only singularities are the points ±2πi,±4πi,…\pm 2\pi i, \pm 4\pi i, \ldots where ez=1e^z = 1 and z≠0z \ne 0. So the series converges for ∣z∣<2π|z| < 2\pi. This gives ∣Bk∣/k!≈2/(2π)k|B_k|/k! \approx 2/(2\pi)^k for large even kk, so the numbers BkB_k grow faster than any geometric sequence (Theorem C1.1.2.11.2.12 gives the exact form). The numbers are rational, as the example shows.

Example. Write (ez−1)/z=1+z/2+z2/6+z3/24+⋯(e^z - 1)/z = 1 + z/2 + z^2/6 + z^3/24 + \cdots. The reciprocal is 1−(z/2+z2/6)+(z/2)2+O(z3)=1−z/2+z2/12+O(z3)1 - (z/2 + z^2/6) + (z/2)^2 + O(z^3) = 1 - z/2 + z^2/12 + O(z^3). So B0=1B_0 = 1, B1=−12B_1 = -\frac12 and B2=2!⋅112=16B_2 = 2! \cdot \frac1{12} = \frac16.

Proof that the definition is sound. The series (ez−1)/z=∑k≥0zk/(k+1)!(e^z - 1)/z = \sum_{k \ge 0} z^k/(k+1)! has constant term 11. A power series with a non-zero constant term has a reciprocal power series, and its coefficients are rational when the original ones are. So the numbers BkB_k exist, they are unique, and they are rational. □\square

Theorem C1.1.2.11.2.5 (the first Bernoulli numbers, TAOCP eq. 1.2.11.2(5)). The odd numbers BkB_k with 3≤k≤113 \le k \le 11 are 00. The even-index numbers with 0≤k≤120 \le k \le 12 and the number B1B_1 are

B0=1, B1=−12, B2=16, B4=−130, B6=142, B8=−130, B10=566, B12=−6912730.B_0 = 1,\ B_1 = -\tfrac12,\ B_2 = \tfrac16,\ B_4 = -\tfrac1{30},\ B_6 = \tfrac1{42},\ B_8 = -\tfrac1{30},\ B_{10} = \tfrac5{66},\ B_{12} = -\tfrac{691}{2730}.

Node: TA81DXSQMW · Lean: TAOCP.S1_2_11.eq5_bernoulli (partial) · status: not stated yet

Explanation. The signs of the non-zero numbers B2iB_{2i} alternate, and their size first falls and then grows without bound. The values come from the recursion of Theorem C1.1.2.11.2.7 and the vanishing of Theorem C1.1.2.11.2.6. Each new number needs the earlier ones.

Example. Use ∑k=0n−1(nk)Bk=0\sum_{k=0}^{n-1} \binom{n}{k} B_k = 0 from Theorem C1.1.2.11.2.7 with n=5n = 5. It gives 1+5(−12)+10⋅16+10B3+5B4=01 + 5(-\frac12) + 10 \cdot \frac16 + 10 B_3 + 5 B_4 = 0. Since B3=0B_3 = 0, the equation gives 5B4=−(1−52+53)=−165 B_4 = -(1 - \frac52 + \frac53) = -\frac16, so B4=−130B_4 = -\frac1{30}. The check for B12B_{12} in exact arithmetic gives −691/2730-691/2730, and B12/12!=−5.28⋅10−10B_{12}/12! = -5.28 \cdot 10^{-10}, which agrees in size with 2 ζ(12)/(2π)12=5.28⋅10−102\,\zeta(12)/(2\pi)^{12} = 5.28 \cdot 10^{-10} of Theorem C1.1.2.11.2.12.

Proof. Definition C1.1.2.11.2.4 gives B0=1B_0 = 1 and B1=−12B_1 = -\frac12, and the example above gives B2=16B_2 = \frac16. Theorem C1.1.2.11.2.6 gives the zeros. For the even numbers use the recursion in the form Bn−1=−1n∑k=0n−2(nk)BkB_{n-1} = -\frac1n \sum_{k=0}^{n-2} \binom nk B_k with n=5,7,9,11,13n = 5, 7, 9, 11, 13. Each step is an exact rational computation. For n=7n = 7: 1+7(−12)+21⋅16+35⋅(−130)+7B6=01 + 7(-\frac12) + 21 \cdot \frac16 + 35 \cdot (-\frac1{30}) + 7 B_6 = 0, that is 1−72+72−76+7B6=01 - \frac72 + \frac72 - \frac76 + 7B_6 = 0, so B6=142B_6 = \frac1{42}. The steps n=9,11,13n = 9, 11, 13 give B8B_8, B10B_{10} and B12B_{12} in the same way. □\square

Theorem C1.1.2.11.2.6 (the odd Bernoulli numbers, TAOCP eq. 1.2.11.2(6)). For every odd k≥3k \ge 3, Bk=0B_k = 0.

Node: TA0NZSEGE3 · Lean: TAOCP.S1_2_11.eq6_bernoulli · status: not stated yet

Explanation. Apart from B1B_1 there are no odd Bernoulli numbers to compute. The proof shows that the function z/(ez−1)+z/2z/(e^z - 1) + z/2 is even. This is why the formulas of this section have only even powers of 1/n1/n after the first term.

Example. The exact values B3=B5=B7=0B_3 = B_5 = B_7 = 0 agree with the recursion. For n=4n = 4 it gives 1+4(−12)+6⋅16+4B3=01 + 4(-\frac12) + 6 \cdot \frac16 + 4 B_3 = 0. The first three terms add to 00, so B3=0B_3 = 0.

Proof. Let g(z)=z/(ez−1)+z/2g(z) = z/(e^z - 1) + z/2. Then

g(z)=z2⋅ez+1ez−1=z2⋅ez/2+e−z/2ez/2−e−z/2.g(z) = \frac z2 \cdot \frac{e^z + 1}{e^z - 1} = \frac z2 \cdot \frac{e^{z/2} + e^{-z/2}}{e^{z/2} - e^{-z/2}}.

The factor (ez/2+e−z/2)/(ez/2−e−z/2)(e^{z/2} + e^{-z/2})/(e^{z/2} - e^{-z/2}) is odd in zz, and the factor z/2z/2 is odd, so gg is even. The series of gg is ∑kBkzk/k!\sum_k B_k z^k/k! with the term B1z=−z/2B_1 z = -z/2 replaced by 00. An even function has no odd powers, so Bk=0B_k = 0 for odd k≥3k \ge 3. □\square

Theorem C1.1.2.11.2.7 (the recursion, TAOCP eq. 1.2.11.2(7)). For every integer n≥0n \ge 0, with δn1=1\delta_{n1} = 1 for n=1n = 1 and δn1=0\delta_{n1} = 0 otherwise,

∑k=0n(nk)Bk=Bn+δn1,so that∑k=0n−1(nk)Bk=0(n≥2).\sum_{k=0}^{n} \binom nk B_k = B_n + \delta_{n1}, \qquad\text{so that}\qquad \sum_{k=0}^{n-1} \binom nk B_k = 0 \quad (n \ge 2).

Node: TAJ8XDASNC · Lean: TAOCP.S1_2_11.eq7_bernoulli · status: not stated yet

Explanation. The relation gives Bn−1B_{n-1} from B0,…,Bn−2B_0, \ldots, B_{n-2}, because the coefficient of Bn−1B_{n-1} is (nn−1)=n\binom n{n-1} = n. For n=1n = 1 the sum over k<nk < n is B0=1B_0 = 1 and not 00. The term δn1\delta_{n1} records this one exception.

Example. For n=6n = 6: (60)B0+(61)B1+(62)B2+(64)B4=1−3+156−1530=0\binom60 B_0 + \binom61 B_1 + \binom62 B_2 + \binom64 B_4 = 1 - 3 + \frac{15}6 - \frac{15}{30} = 0. The terms for k=3k = 3 and k=5k = 5 vanish. For n=7n = 7 the sum is 1−72+216−3530+7B6=−16+7B61 - \frac72 + \frac{21}6 - \frac{35}{30} + 7 B_6 = -\frac16 + 7 B_6, which is 00 for B6=142B_6 = \frac1{42}.

Proof. Multiply the series of Definition C1.1.2.11.2.4 by ez−1=∑j≥1zj/j!e^z - 1 = \sum_{j \ge 1} z^j/j!:

z=(ez−1)∑k≥0Bkzkk!=∑n≥1znn!∑k=0n−1(nk)Bk.z = (e^z - 1) \sum_{k \ge 0} B_k \frac{z^k}{k!} = \sum_{n \ge 1} \frac{z^n}{n!} \sum_{k=0}^{n-1} \binom nk B_k.

The coefficient of zn/n!z^n/n! in the Cauchy product is ∑j+k=n, j≥1n!j! k!Bk=∑k=0n−1(nk)Bk\sum_{j+k = n,\, j \ge 1} \frac{n!}{j!\,k!} B_k = \sum_{k=0}^{n-1} \binom nk B_k. The left side zz has the coefficient 11 for n=1n = 1 and 00 for n≥2n \ge 2. So ∑k=0n−1(nk)Bk=δn1\sum_{k=0}^{n-1} \binom nk B_k = \delta_{n1} for n≥1n \ge 1. Add BnB_n to both sides for the first form. For n=0n = 0 both sides of the first form are B0B_0. □\square

Definition C1.1.2.11.2.8 (the Bernoulli polynomials, TAOCP eq. 1.2.11.2(8)). For an integer m≥0m \ge 0 the Bernoulli polynomial of degree mm is the first display below. It has the generating function of the second display.

Bm(x)=∑k=0m(mk)Bk xm−k,z exzez−1=∑m≥0Bm(x) zmm!.B_m(x) = \sum_{k=0}^{m} \binom mk B_k\, x^{m-k}, \qquad \frac{z\, e^{xz}}{e^z - 1} = \sum_{m \ge 0} B_m(x)\, \frac{z^m}{m!}.

Node: TA995SXDS1 · Lean: TAOCP.S1_2_11.eq8_bernoulli · status: not stated yet

Explanation. The polynomial Bm(x)B_m(x) is the "umbral" power (x+B)m(x + B)^m, where after expansion the power BkB^k is replaced by the number BkB_k. The polynomial has degree mm, leading coefficient 11, and constant term BmB_m. The second form is the generating function. It is the tool for Theorem C1.1.2.11.2.9.

Example. B0(x)=1B_0(x) = 1, B1(x)=x−12B_1(x) = x - \frac12, B2(x)=x2−x+16B_2(x) = x^2 - x + \frac16 and B3(x)=x3−32x2+12xB_3(x) = x^3 - \frac32 x^2 + \frac12 x. For the last one: (30)x3+(31)B1x2+(32)B2x+B3=x3−32x2+12x+0\binom30 x^3 + \binom31 B_1 x^2 + \binom32 B_2 x + B_3 = x^3 - \frac32 x^2 + \frac12 x + 0.

Proof that the two forms agree. The series of exze^{xz} is ∑jxjzj/j!\sum_j x^j z^j/j!. Multiply it by the series of Definition C1.1.2.11.2.4. The coefficient of zm/m!z^m/m! in the Cauchy product is ∑j+k=mm!j! k!xjBk=∑k(mk)Bkxm−k\sum_{j+k=m} \frac{m!}{j!\,k!} x^j B_k = \sum_k \binom mk B_k x^{m-k}. □\square

Theorem C1.1.2.11.2.9 (the properties of Bm(x)B_m(x), TAOCP eq. 1.2.11.2(9)). For every m≥0m \ge 0:

  • Bm(0)=BmB_m(0) = B_m;
  • Bm′(x)=m Bm−1(x)B_m'(x) = m\, B_{m-1}(x) for m≥1m \ge 1;
  • Bm(x+1)−Bm(x)=m xm−1B_m(x + 1) - B_m(x) = m\, x^{m-1} for m≥1m \ge 1;
  • Bm(1)=Bm(0)=BmB_m(1) = B_m(0) = B_m for m≥2m \ge 2.

Node: TAWQZ5D7S0 · Lean: TAOCP.S1_2_11.eq9_bernoulli, TAOCP.S1_2_11.bernoulli_poly_zero_one (partial) · status: not stated yet

Explanation. The second property says that the polynomials form an Appell sequence: each one is the integral of the one before, with constant of integration chosen so that the mean on [0,1][0, 1] is 00. The fourth property says that Bm({x})B_m(\{x\}) is continuous for m≥2m \ge 2. Both properties are all that Theorem C1.1.2.11.2.10 uses. The third property gives the sums of powers (exercise 4 below).

Example. For m=3m = 3: B3′(x)=3x2−3x+12=3B2(x)B_3'(x) = 3x^2 - 3x + \frac12 = 3 B_2(x). Also B3(1)=1−32+12=0=B3B_3(1) = 1 - \frac32 + \frac12 = 0 = B_3. For m=2m = 2: B2(x+1)−B2(x)=(x2+2x+1)−(x+1)−x2+x=2xB_2(x+1) - B_2(x) = (x^2 + 2x + 1) - (x + 1) - x^2 + x = 2x.

Proof. The first property is the case x=0x = 0 of Definition C1.1.2.11.2.8, since only the term k=mk = m survives. For the second, differentiate the sum term by term, and use (mk)(m−k)=m(m−1k)\binom mk (m-k) = m \binom{m-1}k:

Bm′(x)=∑k=0m−1(mk)(m−k)Bk xm−1−k=m∑k=0m−1(m−1k)Bk xm−1−k=m Bm−1(x).B_m'(x) = \sum_{k=0}^{m-1} \binom mk (m-k) B_k\, x^{m-1-k} = m \sum_{k=0}^{m-1} \binom{m-1}k B_k\, x^{m-1-k} = m\, B_{m-1}(x).

For the third, subtract the generating functions of Definition C1.1.2.11.2.8 for x+1x + 1 and for xx:

z e(x+1)z−z exzez−1=z exz=∑m≥1m xm−1 zmm!.\frac{z\, e^{(x+1)z} - z\, e^{xz}}{e^z - 1} = z\, e^{xz} = \sum_{m \ge 1} m\, x^{m-1}\, \frac{z^m}{m!}.

Compare the coefficients of zm/m!z^m/m!. For the fourth, put x=0x = 0 in the third property. Then Bm(1)−Bm(0)=m⋅0m−1=0B_m(1) - B_m(0) = m \cdot 0^{m-1} = 0 for m≥2m \ge 2. □\square

Theorem C1.1.2.11.2.10 (Euler's summation formula, TAOCP eq. 1.2.11.2(10)). Let a<ba < b be integers, let m≥1m \ge 1, and let ff have a continuous derivative of order mm on [a,b][a, b]. Let Rm(a,b)R_m(a, b) be the remainder of Definition C1.1.2.11.2.11. Then

∑a≤k<bf(k)=∫abf(x) dx+∑k=1mBkk!(f(k−1)(b)−f(k−1)(a))+Rm(a,b).\sum_{a \le k < b} f(k) = \int_a^b f(x)\, dx + \sum_{k=1}^{m} \frac{B_k}{k!}\bigl(f^{(k-1)}(b) - f^{(k-1)}(a)\bigr) + R_m(a, b).

Node: TA1Z5A2RTV · status: not stated yet

Explanation. The case a=1a = 1 and b=nb = n is the form of the book, with Rmn=Rm(1,n)R_{mn} = R_m(1, n). The term k=1k = 1 is B1(f(b)−f(a))=−12(f(b)−f(a))B_1 (f(b) - f(a)) = -\frac12 (f(b) - f(a)), which is the boundary term of eq. (3). The next terms are 112(f′(b)−f′(a))\frac1{12} (f'(b) - f'(a)), then −1720(f′′′(b)−f′′′(a))-\frac1{720} (f'''(b) - f'''(a)), and so on. Only the odd derivatives appear, because Bk=0B_k = 0 for odd k≥3k \ge 3. The sum of the corrections need not converge when m→∞m \to \infty. The remainder is the exact difference at each mm.

Example. Let f(x)=x3f(x) = x^3, a=1a = 1, b=5b = 5, m=3m = 3. The sum is 1+8+27+64=1001 + 8 + 27 + 64 = 100. The integral is (625−1)/4=156(625 - 1)/4 = 156. The terms are k=1k = 1: −12(125−1)=−62-\frac12 (125 - 1) = -62; k=2k = 2: 112(75−3)=6\frac1{12} (75 - 3) = 6; k=3k = 3: 00. Since f′′′=6f''' = 6 is constant, the remainder is R3=∫15B3({x}) dx=0R_3 = \int_1^5 B_3(\{x\})\, dx = 0, so the total is 156−62+6=100156 - 62 + 6 = 100. For f(x)=1/xf(x) = 1/x and n=10n = 10 the formula with m=4m = 4 is worked in Theorem C1.1.2.11.2.14.

Proof. The proof is by induction on mm. For m=1m = 1 the statement is Theorem C1.1.2.11.2.3 with the limits aa and bb (the same proof), since B1({x})={x}−12B_1(\{x\}) = \{x\} - \frac12 and R1(a,b)=∫ab({x}−12)f′R_1(a, b) = \int_a^b (\{x\} - \frac12) f'.

Assume the statement for mm, and let ff have m+1m + 1 continuous derivatives. Put g=f(m)g = f^{(m)}. On [k,k+1][k, k+1] with integer kk the function Bm({x})B_m(\{x\}) is Bm(x−k)B_m(x - k), and by Theorem C1.1.2.11.2.9, ddxBm+1(x−k)=(m+1)Bm(x−k)\frac d{dx} B_{m+1}(x - k) = (m+1) B_m(x - k). Integrate by parts:

∫kk+1Bm(x−k) g(x) dx=[1m+1Bm+1(x−k) g(x)]kk+1−1m+1∫kk+1Bm+1(x−k) g′(x) dx.\int_k^{k+1} B_m(x - k)\, g(x)\, dx = \Bigl[\tfrac{1}{m+1} B_{m+1}(x - k)\, g(x)\Bigr]_k^{k+1} - \tfrac1{m+1} \int_k^{k+1} B_{m+1}(x - k)\, g'(x)\, dx.

Since m+1≥2m + 1 \ge 2, Theorem C1.1.2.11.2.9 gives Bm+1(1)=Bm+1(0)=Bm+1B_{m+1}(1) = B_{m+1}(0) = B_{m+1}. The bracket is Bm+1m+1(g(k+1)−g(k))\frac{B_{m+1}}{m+1} (g(k+1) - g(k)). Sum over k=a,…,b−1k = a, \ldots, b-1. The brackets telescope, and

∫abBm({x}) f(m) dx=Bm+1m+1(f(m)(b)−f(m)(a))−1m+1∫abBm+1({x}) f(m+1) dx.\int_a^b B_m(\{x\})\, f^{(m)}\, dx = \frac{B_{m+1}}{m+1} \bigl(f^{(m)}(b) - f^{(m)}(a)\bigr) - \frac1{m+1} \int_a^b B_{m+1}(\{x\})\, f^{(m+1)}\, dx.

Multiply by (−1)m+1/m!(-1)^{m+1}/m!. The left side becomes Rm(a,b)R_m(a, b). The right side becomes (−1)m+1Bm+1(m+1)!(f(m)(b)−f(m)(a))+Rm+1(a,b)(-1)^{m+1} \frac{B_{m+1}}{(m+1)!} (f^{(m)}(b) - f^{(m)}(a)) + R_{m+1}(a, b). The factor (−1)m+1(-1)^{m+1} is 11 when m+1m + 1 is even. When m+1m + 1 is odd, it is at least 33, and Bm+1=0B_{m+1} = 0 by Theorem C1.1.2.11.2.6. So in all cases (−1)m+1Bm+1=Bm+1(-1)^{m+1} B_{m+1} = B_{m+1}, and

Rm(a,b)=Bm+1(m+1)!(f(m)(b)−f(m)(a))+Rm+1(a,b).(∗)R_m(a, b) = \frac{B_{m+1}}{(m+1)!} \bigl(f^{(m)}(b) - f^{(m)}(a)\bigr) + R_{m+1}(a, b). \tag{$*$}

Substitute this in the formula for mm. The new term is the term k=m+1k = m + 1 of the sum, so the formula holds for m+1m + 1. □\square

Definition C1.1.2.11.2.11 (the remainder, TAOCP eq. 1.2.11.2(11)). Let m≥1m \ge 1 and let ff have a continuous derivative of order mm on [a,b][a, b]. Write RmnR_{mn} for Rm(1,n)R_m(1, n), and write Ck(a,b)=Bkk!(f(k−1)(b)−f(k−1)(a))C_{k}(a, b) = \frac{B_k}{k!}\bigl(f^{(k-1)}(b) - f^{(k-1)}(a)\bigr) for the kk-th correction term of Theorem C1.1.2.11.2.10. The remainder of order mm is

Rm(a,b)=(−1)m+1m!∫abBm({x}) f(m)(x) dx.R_m(a, b) = \frac{(-1)^{m+1}}{m!} \int_a^b B_m(\{x\})\, f^{(m)}(x)\, dx.

Node: TAQEFSKTG5 · status: not stated yet

Explanation. The remainder is defined by an integral, and Theorem C1.1.2.11.2.10 shows that it equals the exact error of the formula. The relation (∗)(*) of that proof says Rm=Cm+1+Rm+1R_m = C_{m+1} + R_{m+1}. For even m≥2m \ge 2 it also gives Rm=Rm+1R_m = R_{m+1}, since Cm+1=0C_{m+1} = 0. So the remainder after an even number of corrections equals the remainder after the next odd one.

Example. For f(x)=1/xf(x) = 1/x, m=2m = 2 and n=10n = 10 the second derivative is f′′=2x−3f'' = 2x^{-3}, and R2,10=−12∫110B2({x})⋅2x−3 dx=−∫110B2({x}) x−3 dxR_{2,10} = -\frac12 \int_1^{10} B_2(\{x\}) \cdot 2 x^{-3}\, dx = -\int_1^{10} B_2(\{x\})\, x^{-3}\, dx. A numerical integration gives −0.0061168390-0.0061168390. This equals H9−(ln⁡10+0.45+0.0825)=2.8289682540−2.8350850930H_9 - (\ln 10 + 0.45 + 0.0825) = 2.8289682540 - 2.8350850930, the exact error of the two-term formula of Theorem C1.1.2.11.2.14.

Proof of the relation Rm=Rm+1R_m = R_{m+1} for even mm. The relation (∗)(*) with mm even has m+1m + 1 odd, and for m≥2m \ge 2 this gives m+1≥3m + 1 \ge 3. Then Bm+1=0B_{m+1} = 0, and (∗)(*) reads Rm=Rm+1R_m = R_{m+1}. □\square

Theorem C1.1.2.11.2.12 (the size of the remainder, TAOCP eq. 1.2.11.2(12)). Let m≥2m \ge 2. Then:

  • ∣Bm({x})∣≤4 m!/(2π)m|B_m(\{x\})| \le 4\, m!/(2\pi)^m for all real xx;
  • for even mm, Bm=(−1)m/2+1 2 m! ζ(m)/(2π)mB_m = (-1)^{m/2+1}\, 2\, m!\, \zeta(m)/(2\pi)^m, where ζ(m)=∑k≥1k−m\zeta(m) = \sum_{k \ge 1} k^{-m};
  • for even mm, ∣Bm({x})∣≤∣Bm∣|B_m(\{x\})| \le |B_m|, and Bm({x})−BmB_m(\{x\}) - B_m is zero or has the sign (−1)m/2(-1)^{m/2};
  • if ff has mm continuous derivatives on [a,b][a, b], then ∣Rm(a,b)∣≤4(2π)m∫ab∣f(m)(x)∣ dx|R_m(a, b)| \le \frac{4}{(2\pi)^m} \int_a^b |f^{(m)}(x)|\, dx, and for even mm also ∣Rm(a,b)∣≤∣Bm∣m!∫ab∣f(m)(x)∣ dx|R_m(a, b)| \le \frac{|B_m|}{m!} \int_a^b |f^{(m)}(x)|\, dx.

Node: TAQ1B81939 · status: not stated yet

Explanation. The bound shows that the remainder is of the size of the correction term with the same index. It follows that a truncated series has an error of the order of its last term. The closed form for even mm says how the Bernoulli numbers grow: ∣B2j∣/(2j)!≈2/(2π)2j|B_{2j}|/(2j)! \approx 2/(2\pi)^{2j}. The numbers B2jB_{2j} themselves grow like (2j)!/(2π)2j(2j)!/(2\pi)^{2j} and no geometric bound holds.

Example. The largest value of ∣Bm(x)∣/m!|B_m(x)|/m! on [0,1][0, 1] is 0.0833330.083333 for m=2m = 2 (it equals ∣B2∣/2!=112|B_2|/2! = \frac1{12}), 0.00138890.0013889 for m=4m = 4 and 3.3069⋅10−53.3069 \cdot 10^{-5} for m=6m = 6. The bound 4/(2π)m4/(2\pi)^m is 0.101320.10132, 0.00256650.0025665 and 6.5010⋅10−56.5010 \cdot 10^{-5}. For odd mm the largest values are 0.00801880.0080188 for m=3m = 3 and 0.000203820.00020382 for m=5m = 5, below 0.0161260.016126 and 0.000408470.00040847. The closed form gives B6=2⋅720⋅ζ(6)/(2π)6=0.0238095=142B_6 = 2 \cdot 720 \cdot \zeta(6)/(2\pi)^6 = 0.0238095 = \frac1{42}.

Proof. Step 1: the Fourier series. Let m≥2m \ge 2. The function x↦Bm({x})x \mapsto B_m(\{x\}) has period 11. It is continuous, because Bm(1)=Bm(0)B_m(1) = B_m(0) by Theorem C1.1.2.11.2.9. It is also piecewise smooth. So its Fourier series ∑kcke2πikx\sum_k c_k e^{2\pi i k x} converges to it at every point. The coefficients are ck(m)=∫01Bm(x) e−2πikx dxc_k^{(m)} = \int_0^1 B_m(x)\, e^{-2\pi i k x}\, dx. For k=0k = 0: ∫01Bm=1m+1(Bm+1(1)−Bm+1(0))=0\int_0^1 B_m = \frac1{m+1} (B_{m+1}(1) - B_{m+1}(0)) = 0. For k≠0k \ne 0 and m≥2m \ge 2 integrate by parts. The boundary term vanishes, since Bm(1)=Bm(0)B_m(1) = B_m(0) and the exponential is 11 at both ends. Then

ck(m)=m2πik ck(m−1).c_k^{(m)} = \frac{m}{2\pi i k}\, c_k^{(m-1)}.

For m=1m = 1: ck(1)=∫01(x−12)e−2πikx dx=−12πikc_k^{(1)} = \int_0^1 (x - \frac12) e^{-2\pi i k x}\, dx = -\frac1{2\pi i k}. By induction ck(m)=−m!/(2πik)mc_k^{(m)} = -m!/(2\pi i k)^m. So for m≥2m \ge 2,

Bm({x})=−m!∑k≠0e2πikx(2πik)m.B_m(\{x\}) = -m! \sum_{k \ne 0} \frac{e^{2\pi i k x}}{(2\pi i k)^m}.

Step 2: the bounds. Take absolute values: ∣Bm({x})∣≤m!⋅2∑k≥1(2πk)−m=2 m! ζ(m)/(2π)m|B_m(\{x\})| \le m! \cdot 2 \sum_{k \ge 1} (2\pi k)^{-m} = 2\, m!\, \zeta(m)/(2\pi)^m. Since ζ(m)≤ζ(2)=π2/6<2\zeta(m) \le \zeta(2) = \pi^2/6 < 2, this is less than 4 m!/(2π)m4\, m!/(2\pi)^m.

Step 3: even mm. Pair kk with −k-k. Since (±2πik)m=(−1)m/2(2πk)m(\pm 2\pi i k)^m = (-1)^{m/2} (2\pi k)^m, the two terms add to a cosine:

Bm({x})=(−1)m/2+1 2 m!∑k≥1cos⁡2πkx(2πk)m.B_m(\{x\}) = (-1)^{m/2+1}\, 2\, m! \sum_{k \ge 1} \frac{\cos 2\pi k x}{(2\pi k)^m}.

At x=0x = 0 this is the formula for BmB_m. The cosines are at most 11, so ∣Bm({x})∣≤∣Bm∣|B_m(\{x\})| \le |B_m|. Also Bm({x})−Bm=(−1)m/2+12 m!∑k(cos⁡2πkx−1)/(2πk)mB_m(\{x\}) - B_m = (-1)^{m/2+1} 2\, m! \sum_k (\cos 2\pi k x - 1)/(2\pi k)^m, and each term of the sum is at most 00. So the difference has the sign (−1)m/2(-1)^{m/2} or is zero.

Step 4: the bounds for RmR_m follow from the definition and the bounds on Bm({x})B_m(\{x\}). □\square

Theorem C1.1.2.11.2.13 (the remainder has the sign of the next term, TAOCP eq. 1.2.11.2(13)). Let m≥2m \ge 2 be even, let ff have continuous derivatives up to order m+4m + 4 on [a,b][a, b], and suppose that f(m+2)f^{(m+2)} and f(m+4)f^{(m+4)} are both ≥0\ge 0 on [a,b][a, b] or both ≤0\le 0. Then:

  • Rm(a,b)=θ Cm+2(a,b)=θ Bm+2(m+2)!(f(m+1)(b)−f(m+1)(a))R_m(a, b) = \theta\, C_{m+2}(a, b) = \theta\, \frac{B_{m+2}}{(m+2)!} \bigl(f^{(m+1)}(b) - f^{(m+1)}(a)\bigr) for some θ\theta with 0≤θ≤10 \le \theta \le 1;
  • if the same signs hold on [a,∞)[a, \infty), f(m+1)(x)→0f^{(m+1)}(x) \to 0 and ∫a∞∣f(m)∣ dx<∞\int_a^\infty |f^{(m)}|\, dx < \infty, then T=lim⁡b→∞Rm(a,b)T = \lim_{b \to \infty} R_m(a, b) exists, and T=−θ Bm+2(m+2)! f(m+1)(a)T = -\theta\, \frac{B_{m+2}}{(m+2)!}\, f^{(m+1)}(a) for some θ\theta with 0≤θ≤10 \le \theta \le 1.

Node: TAXBHY0X7D · status: not stated yet

Explanation. The error of the formula after the correction with index mm is between 00 and the next correction. So the best place to stop a series of this kind is just before its smallest term, and the error is then at most that term. The condition holds for 1/x1/x, for ln⁡x\ln x and for any function whose derivatives of order m+2m + 2 and m+4m + 4 have one common sign on the interval.

Example. For f(x)=1/xf(x) = 1/x and n=10n = 10 the derivatives have the signs (−1)k(-1)^k, so the condition holds for even mm. The ratio Rm,10/Cm+2R_{m,10}/C_{m+2} is 0.7340.734 for m=2m = 2, 0.5580.558 for m=4m = 4 and 0.4210.421 for m=6m = 6. All lie in [0,1][0, 1].

Proof. Step 1: a formula for Rk−1R_{k-1} with even k≥2k \ge 2. From (∗)(*) with m=k−1m = k - 1, Rk−1=Ck+RkR_{k-1} = C_k + R_k. The definition gives Rk=−1k!∫Bk({x})f(k) dxR_k = -\frac1{k!} \int B_k(\{x\}) f^{(k)}\, dx for even kk, and Ck=Bkk!∫abf(k) dxC_k = \frac{B_k}{k!} \int_a^b f^{(k)}\, dx. So

Rk−1(a,b)=−1k!∫ab(Bk({x})−Bk) f(k)(x) dx.(∗∗)R_{k-1}(a, b) = -\frac1{k!} \int_a^b \bigl(B_k(\{x\}) - B_k\bigr)\, f^{(k)}(x)\, dx. \tag{$**$}

Step 2: signs. By Theorem C1.1.2.11.2.12, Bk({x})−BkB_k(\{x\}) - B_k is zero or has the sign (−1)k/2(-1)^{k/2}, and BkB_k has the sign (−1)k/2+1(-1)^{k/2+1}. So the factor −(Bk({x})−Bk)-(B_k(\{x\}) - B_k) has the sign of BkB_k. If f(k)f^{(k)} has one sign on [a,b][a, b], then Rk−1R_{k-1} is zero or has the sign of Bkf(k)B_k f^{(k)}. The correction CkC_k has the same sign, since f(k−1)(b)−f(k−1)(a)=∫f(k)f^{(k-1)}(b) - f^{(k-1)}(a) = \int f^{(k)} has the sign of f(k)f^{(k)}.

Step 3: the ratio. For even mm, Rm=Rm+1R_m = R_{m+1} and Rm=Cm+2+Rm+2R_m = C_{m+2} + R_{m+2}, with Rm+2=Rm+3R_{m+2} = R_{m+3}. Apply Step 2 with k=m+2k = m + 2 to Rm+1=RmR_{m+1} = R_m: this has the sign of Bm+2f(m+2)B_{m+2} f^{(m+2)}, the sign of Cm+2C_{m+2}. So Rm/Cm+2≥0R_m / C_{m+2} \ge 0. Apply Step 2 with k=m+4k = m + 4 to Rm+3=Rm+2R_{m+3} = R_{m+2}: this has the sign of Bm+4f(m+4)B_{m+4} f^{(m+4)}. The numbers Bm+2B_{m+2} and Bm+4B_{m+4} have opposite signs, and f(m+2)f^{(m+2)}, f(m+4)f^{(m+4)} have the same sign. So Rm+2R_{m+2} has the sign opposite to Cm+2C_{m+2}, and Rm+2/Cm+2≤0R_{m+2}/C_{m+2} \le 0. Hence Rm/Cm+2=1+Rm+2/Cm+2≤1R_m/C_{m+2} = 1 + R_{m+2}/C_{m+2} \le 1. If Cm+2=0C_{m+2} = 0, then f(m+2)≡0f^{(m+2)} \equiv 0 and (∗∗)(**) shows Rm=0R_m = 0, and any θ\theta works.

Step 4: the tail. Apply the first part on [a,b][a, b]. The ratio θb\theta_b is in [0,1][0, 1]. The integral Rm(a,b)R_m(a, b) converges when b→∞b \to \infty by Theorem C1.1.2.11.2.12 and the integrability of f(m)f^{(m)}. Also Cm+2(a,b)→−Bm+2(m+2)!f(m+1)(a)C_{m+2}(a, b) \to -\frac{B_{m+2}}{(m+2)!} f^{(m+1)}(a). So the limit TT lies between 00 and this number, which is the claim. □\square

Theorem C1.1.2.11.2.14 (the formula for 1/x1/x, TAOCP eq. 1.2.11.2(14)). For integers n≥2n \ge 2 and m≥1m \ge 1,

Hn−1=ln⁡n+∑k=1m(−1)k−1Bkk(1nk−1)+Rmn,Rmn=−∫1nBm({x})xm+1 dx.H_{n-1} = \ln n + \sum_{k=1}^{m} (-1)^{k-1} \frac{B_k}{k} \Bigl(\frac1{n^k} - 1\Bigr) + R_{mn}, \qquad R_{mn} = -\int_1^n \frac{B_m(\{x\})}{x^{m+1}}\, dx.

Node: TADJEMRBFT · status: not stated yet

Explanation. This is Theorem C1.1.2.11.2.10 with f(x)=1/xf(x) = 1/x. The sum ∑1≤k<n1/k\sum_{1 \le k < n} 1/k is Hn−1H_{n-1}. The corrections have the factor Bk/kB_k/k, and the powers of nn appear with negative exponents. The constants −(−1)k−1Bk/k-(-1)^{k-1} B_k/k are the same for all nn. They add up to Euler's constant in the next theorem.

Example. For n=10n = 10 the sum is H9=2.8289682540H_9 = 2.8289682540. With m=2m = 2: ln⁡10+B11(110−1)−B22(1100−1)=2.302585+0.45+0.082500=2.835085\ln 10 + \frac{B_1}1 (\frac1{10} - 1) - \frac{B_2}{2}(\frac1{100} - 1) = 2.302585 + 0.45 + 0.082500 = 2.835085, with an error of −0.0061168-0.0061168. With m=4m = 4 the value is 2.82675262.8267526 and the error is +0.0022157+0.0022157. With m=6m = 6 it is 2.83072082.8307208 and the error is −0.0017526-0.0017526. Each error equals Rm,10R_{m,10}.

Proof. The derivative is f(k−1)(x)=(−1)k−1(k−1)! x−kf^{(k-1)}(x) = (-1)^{k-1} (k-1)!\, x^{-k}. So Ck=Bkk!(−1)k−1(k−1)!(n−k−1)=(−1)k−1Bkk(n−k−1)C_k = \frac{B_k}{k!} (-1)^{k-1} (k-1)! (n^{-k} - 1) = (-1)^{k-1} \frac{B_k}{k} (n^{-k} - 1). The integral is ln⁡n\ln n. For the remainder, f(m)(x)=(−1)mm! x−m−1f^{(m)}(x) = (-1)^m m!\, x^{-m-1} and (−1)m+1/m!⋅(−1)mm!=−1(-1)^{m+1}/m! \cdot (-1)^m m! = -1. □\square

Theorem C1.1.2.11.2.15 (Euler's constant, TAOCP eq. 1.2.11.2(15)). The limit γ=lim⁡n→∞(Hn−ln⁡n)\gamma = \lim_{n \to \infty} (H_n - \ln n) exists. For every m≥1m \ge 1 the first display below holds. For even m=2jm = 2j there is a θ\theta with 0≤θ≤10 \le \theta \le 1 such that the second display holds.

γ=∑k=1m(−1)kBkk+Rm∞,Rm∞=−∫1∞Bm({x})xm+1 dx,\gamma = \sum_{k=1}^{m} (-1)^k \frac{B_k}{k} + R_{m\infty}, \qquad R_{m\infty} = -\int_1^\infty \frac{B_m(\{x\})}{x^{m+1}}\, dx,

γ=12+∑i=1jB2i2i+θ B2j+22j+2.\gamma = \frac12 + \sum_{i=1}^{j} \frac{B_{2i}}{2i} + \theta\, \frac{B_{2j+2}}{2j+2}.

Node: TAC48KZF81 · status: not stated yet

Explanation. The series 12+112−1120+1252−1240+⋯\frac12 + \frac1{12} - \frac1{120} + \frac1{252} - \frac1{240} + \cdots does not converge. Its terms fall at first and then grow. Each partial sum after an even index estimates γ\gamma with an error between 00 and the next term, so the accuracy is limited by the smallest term. A better value comes from the formula at a larger nn, which Theorem C1.1.2.11.2.16 gives.

Example. The partial sums with m=2,4,6,8m = 2, 4, 6, 8 are 0.5833330.583333, 0.5750000.575000, 0.5789680.578968 and 0.5748020.574802. The constant is γ=0.5772157\gamma = 0.5772157. The errors are −0.0061-0.0061, +0.0022+0.0022, −0.0018-0.0018 and +0.0024+0.0024. They alternate in sign and they do not shrink, since the series has been used past its smallest term. For m=4m = 4: γ−0.575=0.0022157=θ⋅1252\gamma - 0.575 = 0.0022157 = \theta \cdot \frac1{252} with θ=0.558\theta = 0.558.

Proof. For m≥2m \ge 2 Theorem C1.1.2.11.2.12 bounds ∣Bm({x})∣|B_m(\{x\})| by a constant, and ∣f(m)(x)∣=m! x−m−1|f^{(m)}(x)| = m!\, x^{-m-1} is integrable on [1,∞)[1, \infty). For m=1m = 1 use ∣B1({x})∣≤12|B_1(\{x\})| \le \frac12. So Rmn→Rm∞R_{mn} \to R_{m\infty}. In Theorem C1.1.2.11.2.14 let n→∞n \to \infty. The terms n−kn^{-k} go to 00. So Hn−1−ln⁡n→−∑k=1m(−1)k−1Bkk+Rm∞=∑k=1m(−1)kBkk+Rm∞H_{n-1} - \ln n \to -\sum_{k=1}^m (-1)^{k-1} \frac{B_k}k + R_{m\infty} = \sum_{k=1}^{m} (-1)^k \frac{B_k}{k} + R_{m\infty}. Since Hn−ln⁡n=Hn−1−ln⁡n+1/nH_n - \ln n = H_{n-1} - \ln n + 1/n, the limit of Hn−ln⁡nH_n - \ln n exists and has the same value. For the formula with θ\theta use m=2jm = 2j. The term k=1k = 1 is −B1=12-B_1 = \frac12, and the terms with odd k≥3k \ge 3 vanish. Theorem C1.1.2.11.2.13 with a=1a = 1 and the tail form gives Rm∞=−θBm+2(m+2)!f(m+1)(1)R_{m\infty} = -\theta \frac{B_{m+2}}{(m+2)!} f^{(m+1)}(1). Here f(m+1)(1)=−(m+1)!f^{(m+1)}(1) = -(m+1)!, so Rm∞=θBm+2/(m+2)R_{m\infty} = \theta B_{m+2}/(m+2). □\square

Theorem C1.1.2.11.2.16 (the series for HnH_n, TAOCP eq. 1.2.11.2(16)). Let n≥1n \ge 1 and j≥1j \ge 1. There is a number θ\theta with 0≤θ≤10 \le \theta \le 1 such that the first display holds. For j=2j = 2 it reads as the second display.

Hn=ln⁡n+γ+12n−∑i=1jB2i2i n2i−θ B2j+2(2j+2) n2j+2,H_n = \ln n + \gamma + \frac1{2n} - \sum_{i=1}^{j} \frac{B_{2i}}{2i\, n^{2i}} - \theta\, \frac{B_{2j+2}}{(2j+2)\, n^{2j+2}},

Hn=ln⁡n+γ+12n−112n2+1120n4−θ252n6.H_n = \ln n + \gamma + \frac1{2n} - \frac1{12 n^2} + \frac1{120 n^4} - \frac{\theta}{252 n^6}.

Node: TA96315216 · status: not stated yet

Explanation. This is the series of Section 1.2.7. The error is at most the first omitted term and has its sign. It is not claimed that the series converges. For jj large and nn fixed the terms eventually grow, and one chooses jj so that the next term is small.

Example. For n=10n = 10 the value is H10=2.9289682540H_{10} = 2.9289682540. The sum ln⁡10+γ+120−11200+11200000\ln 10 + \gamma + \frac1{20} - \frac1{1200} + \frac1{1200000} is 2.92896825792.9289682579. The difference is −3.93⋅10−9-3.93 \cdot 10^{-9}, and 1252⋅106=3.97⋅10−9\frac1{252 \cdot 10^6} = 3.97 \cdot 10^{-9}. So θ=0.99\theta = 0.99. For n=5n = 5 the difference is −2.44⋅10−7-2.44 \cdot 10^{-7} and the bound is 2.54⋅10−72.54 \cdot 10^{-7}.

Proof. Put m=2jm = 2j in Theorem C1.1.2.11.2.14 and subtract Theorem C1.1.2.11.2.15 for the same mm:

Hn−1−ln⁡n−γ=∑k=1m(−1)k−1Bkk nk+(Rmn−Rm∞).H_{n-1} - \ln n - \gamma = \sum_{k=1}^{m} (-1)^{k-1} \frac{B_k}{k\, n^k} + \bigl(R_{mn} - R_{m\infty}\bigr).

Here Rmn−Rm∞=−TR_{mn} - R_{m\infty} = -T with T=lim⁡NRm(n,N)T = \lim_N R_m(n, N), the tail of Theorem C1.1.2.11.2.13. For f=1/xf = 1/x the derivatives of order m+2m + 2 and m+4m + 4 have the same sign, and f(m+1)(n)=−(m+1)!/nm+2f^{(m+1)}(n) = -(m+1)!/n^{m+2}. So T=θBm+2/((m+2)nm+2)T = \theta B_{m+2}/((m+2) n^{m+2}) with 0≤θ≤10 \le \theta \le 1. The terms with k=1k = 1 and with even k=2ik = 2i are −12n-\frac1{2n} and −B2i2i n2i-\frac{B_{2i}}{2i\, n^{2i}}; the other terms vanish. Add 1/n1/n to pass from Hn−1H_{n-1} to HnH_n. □\square

Theorem C1.1.2.11.2.17 (the formula for ln⁡x\ln x, TAOCP eq. 1.2.11.2(17)). Let n≥2n \ge 2 and m≥2m \ge 2 be integers, and let Rmn=1m∫1nBm({x}) x−m dxR_{mn} = \frac1m \int_1^n B_m(\{x\})\, x^{-m}\, dx. Then

ln⁡(n−1)!=nln⁡n−n+1−12ln⁡n+∑k=2m(−1)kBkk(k−1)(n1−k−1)+Rmn.\ln (n-1)! = n \ln n - n + 1 - \tfrac12 \ln n + \sum_{k=2}^{m} \frac{(-1)^k B_k}{k(k-1)} \bigl(n^{1-k} - 1\bigr) + R_{mn}.

Node: TAMPNGG8K6 · status: not stated yet

Explanation. This is Theorem C1.1.2.11.2.10 with f(x)=ln⁡xf(x) = \ln x. The sum ∑1≤k<nln⁡k\sum_{1 \le k < n} \ln k is ln⁡(n−1)!\ln (n-1)!. The integral is nln⁡n−n+1n \ln n - n + 1. The term with k=1k = 1 is B1ln⁡n=−12ln⁡nB_1 \ln n = -\frac12 \ln n. The terms with k≥2k \ge 2 use the derivatives of 1/x1/x.

Example. For n=10n = 10: ln⁡9!=12.8018275\ln 9! = 12.8018275. The terms before the sum give 10ln⁡10−10+1−12ln⁡10=12.874558410 \ln 10 - 10 + 1 - \frac12 \ln 10 = 12.8745584. With m=2m = 2 the value is 12.799558412.7995584, with m=4m = 4 it is 12.802333412.8023334 and with m=6m = 6 it is 12.801539712.8015397. The errors are +0.00227+0.00227, −0.00051-0.00051 and +0.00029+0.00029. Each error is Rm,10R_{m,10}.

Proof. For k≥2k \ge 2, f(k−1)(x)=(−1)k−2(k−2)! x1−kf^{(k-1)}(x) = (-1)^{k-2} (k-2)!\, x^{1-k}. So Ck=Bkk!(−1)k(k−2)!(n1−k−1)=(−1)kBkk(k−1)(n1−k−1)C_k = \frac{B_k}{k!} (-1)^k (k-2)! (n^{1-k} - 1) = \frac{(-1)^k B_k}{k(k-1)} (n^{1-k} - 1). For the remainder, f(m)(x)=(−1)m−1(m−1)! x−mf^{(m)}(x) = (-1)^{m-1} (m-1)!\, x^{-m} and (−1)m+1m!(−1)m−1(m−1)!=1m\frac{(-1)^{m+1}}{m!} (-1)^{m-1} (m-1)! = \frac1m. □\square

Theorem C1.1.2.11.2.18 (Stirling's series for ln⁡n!\ln n!, TAOCP eq. 1.2.11.2(18)). The limit σ=lim⁡n→∞(ln⁡n!−(n+12)ln⁡n+n)\sigma = \lim_{n \to \infty} \bigl(\ln n! - (n + \frac12)\ln n + n\bigr) exists. For even m=2jm = 2j the error of the series below is θ\theta times the first omitted term B2j+2/((2j+2)(2j+1) n2j+1)B_{2j+2}/((2j+2)(2j+1)\, n^{2j+1}), with 0≤θ≤10 \le \theta \le 1. The first terms of the series are 112n−1360n3+11260n5−11680n7\frac1{12 n} - \frac1{360 n^3} + \frac1{1260 n^5} - \frac1{1680 n^7}. For every m≥2m \ge 2,

ln⁡n!=(n+12)ln⁡n−n+σ+∑k=2m(−1)kBkk(k−1) nk−1+O(n−m).\ln n! = \bigl(n + \tfrac12\bigr) \ln n - n + \sigma + \sum_{k=2}^{m} \frac{(-1)^k B_k}{k(k-1)\, n^{k-1}} + O(n^{-m}).

Node: TA2ESFXPF9 · status: not stated yet

Explanation. The constant σ\sigma does not follow from the formula. The formula gives it as a limit, and Theorem C1.1.2.11.2.20 shows that σ=12ln⁡2π\sigma = \frac12 \ln 2\pi. The first terms of the series agree with the book's 112n\frac1{12n} and −1360n3-\frac1{360 n^3}.

Example. With σ=12ln⁡2π=0.9189385332\sigma = \frac12 \ln 2\pi = 0.9189385332 and n=10n = 10, the true value is ln⁡10!=15.1044125731\ln 10! = 15.1044125731. The sum through 1360n3\frac1{360 n^3} gives 15.104412565215.1044125652, with error +7.9⋅10−9+7.9 \cdot 10^{-9}, and the first omitted term is +11260n5=7.9⋅10−9+\frac1{1260 n^5} = 7.9 \cdot 10^{-9}. Through 11260n5\frac1{1260 n^5} the error is −5.9⋅10−11-5.9 \cdot 10^{-11}, and the next term is −11680n7=−6.0⋅10−11-\frac1{1680 n^7} = -6.0 \cdot 10^{-11}. The partial sums of σ=1+∑k=2m(−1)k+1Bk/(k(k−1))+Rm∞\sigma = 1 + \sum_{k=2}^m (-1)^{k+1} B_k/(k(k-1)) + R_{m\infty} for m=2,4,6m = 2, 4, 6 are 0.916670.91667, 0.919440.91944 and 0.918650.91865.

Proof. Step 1: the constant. Theorem C1.1.2.11.2.17 gives ln⁡(n−1)!−(n−12)ln⁡n+n=1−∑k=2m(−1)kBkk(k−1)+∑k=2m(−1)kBkk(k−1) nk−1+Rmn\ln (n-1)! - (n - \frac12) \ln n + n = 1 - \sum_{k=2}^m \frac{(-1)^k B_k}{k(k-1)} + \sum_{k=2}^m \frac{(-1)^k B_k}{k(k-1)\, n^{k-1}} + R_{mn}. By Theorem C1.1.2.11.2.12 and ∫1∞x−m dx<∞\int_1^\infty x^{-m}\, dx < \infty for m≥2m \ge 2, the remainder RmnR_{mn} tends to Rm∞R_{m\infty}. So the left side has a limit, and it is the constant σ\sigma, because ln⁡n!=ln⁡(n−1)!+ln⁡n\ln n! = \ln (n-1)! + \ln n. Thus σ=1+∑k=2m(−1)k+1Bkk(k−1)+Rm∞\sigma = 1 + \sum_{k=2}^m \frac{(-1)^{k+1} B_k}{k(k-1)} + R_{m\infty}.

Step 2: the series. Subtract the formula for the constant. Then ln⁡(n−1)!=(n−12)ln⁡n−n+σ+∑k=2m(−1)kBkk(k−1) nk−1−Tm(n)\ln (n-1)! = (n - \frac12)\ln n - n + \sigma + \sum_{k=2}^m \frac{(-1)^k B_k}{k(k-1)\, n^{k-1}} - T_m(n), with Tm(n)=Rm∞−RmnT_m(n) = R_{m\infty} - R_{mn} the tail. Add ln⁡n\ln n.

Step 3: the error. By Theorem C1.1.2.11.2.12 with m+1m + 1 in place of mm, and f(m+1)(x)=(−1)mm! x−m−1f^{(m+1)}(x) = (-1)^m m!\, x^{-m-1}, the tail satisfies ∣Tm+1(n)∣≤4 m!(2π)m+1∫n∞x−m−1 dx=O(n−m)|T_{m+1}(n)| \le \frac{4\, m!}{(2\pi)^{m+1}} \int_n^\infty x^{-m-1}\, dx = O(n^{-m}). So the series through k=m+1k = m + 1 has the error O(n−m)O(n^{-m}). The term with k=m+1k = m + 1 is itself O(n−m)O(n^{-m}), so the series through k=mk = m has the error O(n−m)O(n^{-m}).

Step 4: the sign. For even mm apply Theorem C1.1.2.11.2.13 with f=ln⁡xf = \ln x, whose derivatives of order m+2m + 2 and m+4m + 4 have the same sign. Then Tm(n)=−θ Bm+2(m+2)!f(m+1)(n)T_m(n) = -\theta\, \frac{B_{m+2}}{(m+2)!} f^{(m+1)}(n) and f(m+1)(n)=m!/nm+1f^{(m+1)}(n) = m!/n^{m+1}, so −Tm(n)=θ Bm+2(m+2)(m+1) nm+1-T_m(n) = \theta\, \frac{B_{m+2}}{(m+2)(m+1)\, n^{m+1}}, which is θ\theta times the term with k=m+2k = m + 2. □\square

Theorem C1.1.2.11.2.19 (Stirling's series for n!n!, TAOCP eq. 1.2.11.2(19)). As n→∞n \to \infty,

n!=2πn (ne)n(1+112n+1288n2−13951840 n3−5712488320 n4+O(n−5)).n! = \sqrt{2\pi n}\,\Bigl(\frac ne\Bigr)^n \Bigl(1 + \frac1{12 n} + \frac1{288 n^2} - \frac{139}{51840\, n^3} - \frac{571}{2488320\, n^4} + O\bigl(n^{-5}\bigr)\Bigr).

Node: TA7RWZC321 · Lean: TAOCP.S1_2_11.eq19_stirling (partial) · status: not stated yet

Explanation. This is the exponential of eq. (18) with σ=12ln⁡2π\sigma = \frac12 \ln 2\pi. The coefficients are the coefficients of exp⁡(t12−t3360+⋯ )\exp\bigl(\frac t{12} - \frac{t^3}{360} + \cdots\bigr) with t=1/nt = 1/n. The next coefficient is 163879209018880≈0.00078\frac{163879}{209018880} \approx 0.00078, and the proof below can be pushed one step further with one more term of the exponent.

Example. For n=10n = 10 the exact ratio n!/(2πn(n/e)n)n!/(\sqrt{2\pi n} (n/e)^n) is 1.008365359131.00836535913. The polynomial gives 1+0.008333333+0.000347222−0.000002681−0.000000229=1.008365351281 + 0.008333333 + 0.000347222 - 0.000002681 - 0.000000229 = 1.00836535128. The difference 7.85⋅10−97.85 \cdot 10^{-9} times n5n^5 is 0.0007850.000785, close to the next coefficient 0.000780.00078. For n=5n = 5 the ratio is 1.016783985831.01678398583 and the polynomial gives 1.016783737781.01678373778. For n=1n = 1 the series gives 1.08391.0839 and the true ratio is 1.08441.0844.

Proof. Let t=1/nt = 1/n. By Theorem C1.1.2.11.2.18 with m=5m = 5 and Theorem C1.1.2.11.2.20, ln⁡n!−ln⁡(2πn(n/e)n)=S(t)=t12−t3360+O(t5)\ln n! - \ln(\sqrt{2\pi n} (n/e)^n) = S(t) = \frac t{12} - \frac{t^3}{360} + O(t^5). Exponentiate. Since eO(t5)=1+O(t5)e^{O(t^5)} = 1 + O(t^5),

eS(t)=et/12 e−t3/360(1+O(t5)).e^{S(t)} = e^{t/12}\, e^{-t^3/360} \bigl(1 + O(t^5)\bigr).

The first factor is 1+t12+t2288+t310368+t4497664+O(t5)1 + \frac t{12} + \frac{t^2}{288} + \frac{t^3}{10368} + \frac{t^4}{497664} + O(t^5). The second is 1−t3360+O(t6)1 - \frac{t^3}{360} + O(t^6). Multiply them. The coefficient of t3t^3 is 110368−1360=5−14451840=−13951840\frac1{10368} - \frac1{360} = \frac{5 - 144}{51840} = -\frac{139}{51840}. The coefficient of t4t^4 is 1497664−112⋅360=5−5762488320=−5712488320\frac1{497664} - \frac1{12 \cdot 360} = \frac{5 - 576}{2488320} = -\frac{571}{2488320}. The coefficients of tt and t2t^2 are 112\frac1{12} and 1288\frac1{288}. □\square

Theorem C1.1.2.11.2.20 (the value of σ\sigma, TAOCP Section 1.2.11.2). The constant of Theorem C1.1.2.11.2.18 is σ=12ln⁡2π\sigma = \frac12 \ln 2\pi. Also (2nn)πn/4n→1\binom{2n}{n} \sqrt{\pi n}/4^n \to 1.

Node: none

Explanation. Euler's formula gives the form of ln⁡n!\ln n! and leaves one constant open. The central binomial coefficient is the link: it is a ratio of three factorials in which the factors of the form nn+1/2e−nn^{n+1/2} e^{-n} cancel, and only eσe^\sigma is left. Wallis' integrals give the value of the ratio independently.

Example. The ratio (2nn)πn/4n\binom{2n}n \sqrt{\pi n}/4^n is 0.987580.98758 for n=10n = 10 and 0.998750.99875 for n=100n = 100. These are close to 1−18n1 - \frac1{8n}, which is 0.987500.98750 and 0.998750.99875.

Proof. Step 1: Wallis. Let Wk=∫0π/2sin⁡kx dxW_k = \int_0^{\pi/2} \sin^k x\, dx. Integration by parts gives Wk=k−1kWk−2W_k = \frac{k-1}k W_{k-2}, with W0=π2W_0 = \frac\pi2 and W1=1W_1 = 1. So W2n=π2(2nn)4−nW_{2n} = \frac\pi2 \binom{2n}n 4^{-n} and W2n+1=4n/((2n+1)(2nn))W_{2n+1} = 4^n / \bigl((2n+1)\binom{2n}n\bigr). On [0,π/2][0, \pi/2] the power sin⁡kx\sin^k x falls with kk, so W2n+1≤W2n≤W2n−1=2n+12nW2n+1W_{2n+1} \le W_{2n} \le W_{2n-1} = \frac{2n+1}{2n} W_{2n+1}. Thus W2n/W2n+1→1W_{2n}/W_{2n+1} \to 1, that is

π2 (2nn)2 2n+116n→1,so(2nn)∼4nπn.\frac\pi2\, \binom{2n}n^2\, \frac{2n+1}{16^n} \to 1, \qquad\text{so}\qquad \binom{2n}n \sim \frac{4^n}{\sqrt{\pi n}}.

Step 2: Stirling. Theorem C1.1.2.11.2.18 with m=2m = 2 gives n!=eσn (n/e)n(1+O(1/n))n! = e^\sigma \sqrt n\, (n/e)^n (1 + O(1/n)). Then

(2nn)=(2n)!n!2=eσ2n (2n/e)2ne2σ n (n/e)2n(1+O(1/n))=2 4neσn(1+O(1/n)).\binom{2n}n = \frac{(2n)!}{n!^2} = \frac{e^\sigma \sqrt{2n}\, (2n/e)^{2n}}{e^{2\sigma}\, n\, (n/e)^{2n}} (1 + O(1/n)) = \frac{\sqrt 2\, 4^n}{e^\sigma \sqrt n}(1 + O(1/n)).

Compare with Step 1: 2 e−σ=1/π\sqrt 2\, e^{-\sigma} = 1/\sqrt\pi, so eσ=2πe^\sigma = \sqrt{2\pi} and σ=12ln⁡2π\sigma = \frac12 \ln 2\pi. The second claim is Step 1. □\square

Theorem C1.1.2.11.2.21 (Stirling's series for real arguments, TAOCP Section 1.2.11.2, exercise 6). For a fixed integer M≥1M \ge 1 and real y→∞y \to \infty,

ln⁡Γ(y)=(y−12)ln⁡y−y+12ln⁡2π+∑k=2M(−1)kBkk(k−1) yk−1+O(y−M).\ln \Gamma(y) = \bigl(y - \tfrac12\bigr) \ln y - y + \tfrac12 \ln 2\pi + \sum_{k=2}^{M} \frac{(-1)^k B_k}{k(k-1)\, y^{k-1}} + O\bigl(y^{-M}\bigr).

Node: none

Explanation. At an integer y=ny = n the left side is ln⁡(n−1)!=ln⁡n!−ln⁡n\ln (n-1)! = \ln n! - \ln n, and the right side is the series of Theorem C1.1.2.11.2.18 minus ln⁡n\ln n. So the theorem extends that series from the integers to all large real yy. The integer case cannot reach non-integer yy by itself. The proof adds two steps: the difference Γ(y+1)/Γ(y)=y\Gamma(y+1)/\Gamma(y) = y and the behaviour of Γ(x+s)/Γ(x)\Gamma(x + s)/\Gamma(x) for 0<s<10 < s < 1.

Example. For y=5.5y = 5.5 the value is ln⁡Γ(5.5)=3.9578139676\ln \Gamma(5.5) = 3.9578139676. The series with M=2M = 2 gives 3.95783050953.9578305095, with M=4M = 4 it gives 3.95781381373.9578138137, and with M=6M = 6 it gives 3.95781397143.9578139714, with error −3.7⋅10−9-3.7 \cdot 10^{-9}. The first omitted term for M=6M = 6 is −11680 y7=−3.9⋅10−9-\frac1{1680\, y^7} = -3.9 \cdot 10^{-9}.

Proof. Let AM(y)A_M(y) be the right side without the OO term, and let DM(y)=ln⁡Γ(y)−AM(y)D_M(y) = \ln \Gamma(y) - A_M(y).

Step 1: the difference of AMA_M. Put eM(y)=AM(y+1)−AM(y)−ln⁡ye_M(y) = A_M(y + 1) - A_M(y) - \ln y. Since Γ(n)=(n−1)!\Gamma(n) = (n-1)!, Theorem C1.1.2.11.2.18 gives DM(n)=O(n−M)D_M(n) = O(n^{-M}) on the integers, and eM(n)=DM(n)−DM(n+1)=O(n−M)e_M(n) = D_M(n) - D_M(n+1) = O(n^{-M}). The function eM(y)e_M(y) has a Taylor expansion ∑j≤Jejy−j+O(y−J−1)\sum_{j \le J} e_j y^{-j} + O(y^{-J-1}) for each JJ. A series whose values on the integers are O(n−M)O(n^{-M}) has no term below y−My^{-M}. So eM(y)=O(y−M)e_M(y) = O(y^{-M}) for real yy. Apply this with M+1M + 1 in place of MM: eM+1(y)=O(y−M−1)e_{M+1}(y) = O(y^{-M-1}), and DM+1(y+1)−DM+1(y)=−eM+1(y)=O(y−M−1)D_{M+1}(y + 1) - D_{M+1}(y) = -e_{M+1}(y) = O(y^{-M-1}).

Step 2: the limit along a shift. Claim: DM+1(y+N)→0D_{M+1}(y + N) \to 0 when N→∞N \to \infty through the integers, for each real y>0y > 0. Write y=x+ry = x + r with x∈(0,1]x \in (0, 1] and rr a non-negative integer. It is enough to treat y=xy = x. For x=1x = 1 this is Theorem C1.1.2.11.2.18. Let 0<x<10 < x < 1. The function ln⁡Γ\ln\Gamma is convex on (0,∞)(0, \infty), because Γ(a)=∫0∞ta−1e−t dt\Gamma(a) = \int_0^\infty t^{a-1}e^{-t}\, dt and Hölder's inequality gives Γ(λa+(1−λ)b)≤Γ(a)λΓ(b)1−λ\Gamma(\lambda a + (1-\lambda) b) \le \Gamma(a)^\lambda \Gamma(b)^{1-\lambda}. Since N+x=(1−x)N+x(N+1)N + x = (1-x) N + x (N+1), convexity gives Γ(N+x)≤Γ(N)1−xΓ(N+1)x=Γ(N) Nx\Gamma(N + x) \le \Gamma(N)^{1-x} \Gamma(N+1)^x = \Gamma(N)\, N^x. Since N+1=x(N+x)+(1−x)(N+x+1)N + 1 = x (N + x) + (1-x)(N + x + 1), convexity gives Γ(N+1)≤Γ(N+x)xΓ(N+x+1)1−x=Γ(N+x) (N+x)1−x\Gamma(N + 1) \le \Gamma(N+x)^x \Gamma(N + x + 1)^{1-x} = \Gamma(N+x)\,(N+x)^{1-x}. Together,

N1−x(N+x)x−1≤Γ(N+x)Γ(N) Nx≤1.N^{1-x} (N+x)^{x-1} \le \frac{\Gamma(N + x)}{\Gamma(N)\, N^x} \le 1.

The left side tends to 11. So ln⁡Γ(N+x)−ln⁡Γ(N)−xln⁡N→0\ln\Gamma(N + x) - \ln\Gamma(N) - x \ln N \to 0. A Taylor expansion gives AM+1(N+x)−AM+1(N)−xln⁡N→0A_{M+1}(N + x) - A_{M+1}(N) - x \ln N \to 0. Subtract: DM+1(N+x)−DM+1(N)→0D_{M+1}(N + x) - D_{M+1}(N) \to 0, and DM+1(N)→0D_{M+1}(N) \to 0 by Step 1. So DM+1(N+x)→0D_{M+1}(N + x) \to 0.

Step 3: the sum. For each NN, DM+1(y)=DM+1(y+N)−∑k=0N−1(DM+1(y+k+1)−DM+1(y+k))D_{M+1}(y) = D_{M+1}(y + N) - \sum_{k=0}^{N-1} \bigl(D_{M+1}(y + k + 1) - D_{M+1}(y + k)\bigr). Let N→∞N \to \infty. Then ∣DM+1(y)∣≤∑k≥0O((y+k)−M−1)=O(y−M)|D_{M+1}(y)| \le \sum_{k \ge 0} O\bigl((y + k)^{-M-1}\bigr) = O(y^{-M}). Finally AM+1−AMA_{M+1} - A_M is the term with k=M+1k = M + 1, which is O(y−M)O(y^{-M}). So DM(y)=O(y−M)D_M(y) = O(y^{-M}). □\square

Theorem C1.1.2.11.2.22 (Stirling's series with a shift, TAOCP Section 1.2.11.2). Let ss be a fixed real number and m≥1m \ge 1. As x→∞x \to \infty,

ln⁡Γ(x+s)=(x+s−12)ln⁡x−x+12ln⁡2π+∑j=1m(−1)j+1Bj+1(s)j(j+1) x−j+O(x−m−1).\ln \Gamma(x + s) = \bigl(x + s - \tfrac12\bigr)\ln x - x + \tfrac12 \ln 2\pi + \sum_{j=1}^{m} \frac{(-1)^{j+1} B_{j+1}(s)}{j(j+1)}\, x^{-j} + O\bigl(x^{-m-1}\bigr).

Node: none

Explanation. For s=0s = 0 the sum has the terms k=j+1k = j + 1 of Theorem C1.1.2.11.2.21, so this is the same series. For s≠0s \ne 0 the numbers Bj+1B_{j+1} are replaced by the polynomials Bj+1(s)B_{j+1}(s). The theorem is the tool of Lemma C1.1.2.11.1.21: it gives the expansion of Γ(x+s)/Γ(x)\Gamma(x + s)/\Gamma(x) in powers of 1/x1/x.

Example. Take s=0.3s = 0.3. For x=10x = 10 the error with m=1,2,3,5m = 1, 2, 3, 5 is −6.9⋅10−5-6.9 \cdot 10^{-5}, 1.0⋅10−61.0 \cdot 10^{-6}, 1.1⋅10−71.1 \cdot 10^{-7} and −5.6⋅10−10-5.6 \cdot 10^{-10}. Times xm+1x^{m+1} these are −0.0069-0.0069, 0.00100.0010, 0.00110.0011 and −0.00056-0.00056. For x=40x = 40 the values are −0.0070-0.0070, 0.000930.00093, 0.00110.0011 and −0.00058-0.00058. The scaled errors stay bounded, as the OO term requires.

Proof. Step 1: change of variable. Put y=x+sy = x + s in Theorem C1.1.2.11.2.21 with M=m+1M = m + 1:

ln⁡Γ(x+s)=(x+s−12)(ln⁡x+ln⁡(1+sx))−x−s+12ln⁡2π+∑k=2m+1(−1)kBkk(k−1) (x+s)1−k+O(x−m−1).\ln \Gamma(x + s) = \bigl(x + s - \tfrac12\bigr)\bigl(\ln x + \ln(1 + \tfrac sx)\bigr) - x - s + \tfrac12 \ln 2\pi + \sum_{k=2}^{m+1} \frac{(-1)^k B_k}{k(k-1)}\, (x + s)^{1-k} + O(x^{-m-1}).

Expand ln⁡(1+s/x)\ln(1 + s/x) and (x+s)1−k=x1−k(1+s/x)1−k(x + s)^{1-k} = x^{1-k} (1 + s/x)^{1-k} in powers of 1/x1/x with the error O(x−m−1)O(x^{-m-1}). The result is (x+s−12)ln⁡x−x+12ln⁡2π+∑j=1mcj(s) x−j+O(x−m−1)(x + s - \frac12)\ln x - x + \frac12 \ln 2\pi + \sum_{j=1}^{m} c_j(s)\, x^{-j} + O(x^{-m-1}), where cj(s)c_j(s) is a polynomial in ss. It remains to show cj(s)=(−1)j+1Bj+1(s)/(j(j+1))c_j(s) = (-1)^{j+1} B_{j+1}(s)/(j(j+1)).

Step 2: the formal series. With u=1/xu = 1/x let Λ(s,u)\Lambda(s, u) be the formal power series in uu that is the expansion of

Λ(s,u)=(1u+s−12)ln⁡(1+su)−s+∑k≥2(−1)kBkk(k−1)(u1+su)k−1.\Lambda(s, u) = \Bigl(\frac1u + s - \frac12\Bigr) \ln(1 + su) - s + \sum_{k \ge 2} \frac{(-1)^k B_k}{k(k-1)} \Bigl(\frac u{1 + su}\Bigr)^{k-1}.

Its coefficient of uju^j is cj(s)c_j(s). Let Φ(s,u)=∑j≥1(−1)j+1Bj+1(s)j(j+1)uj\Phi(s, u) = \sum_{j \ge 1} \frac{(-1)^{j+1} B_{j+1}(s)}{j(j+1)} u^j. Both are formal series in uu with polynomial coefficients in ss. At s=0s = 0 the logarithm and the term −s-s vanish, and Λ(0,u)=∑k≥2(−1)kBkk(k−1)uk−1=Φ(0,u)\Lambda(0, u) = \sum_{k \ge 2} \frac{(-1)^k B_k}{k(k-1)} u^{k-1} = \Phi(0, u), since Bj+1(0)=Bj+1B_{j+1}(0) = B_{j+1}. To show Λ=Φ\Lambda = \Phi, differentiate in ss.

Step 3: the derivative of Φ\Phi. By Theorem C1.1.2.11.2.9, ∂sBj+1(s)=(j+1)Bj(s)\partial_s B_{j+1}(s) = (j+1) B_j(s). So ∂sΦ=∑j≥1(−1)j+1jBj(s) uj\partial_s \Phi = \sum_{j \ge 1} \frac{(-1)^{j+1}}{j} B_j(s)\, u^j.

Step 4: the derivative of Λ\Lambda. Let v=u/(1+su)v = u/(1 + su), which is the expansion of 1/(x+s)1/(x + s). Then ∂sv=−v2\partial_s v = -v^2. The first two parts of Λ\Lambda have the derivative ln⁡(1+su)+(1u+s−12)u1+su−1=ln⁡(1+su)−v2\ln(1 + su) + (\frac1u + s - \frac12) \frac u{1 + su} - 1 = \ln(1 + su) - \frac v2. For k≥2k \ge 2 the derivative of (−1)kBkk(k−1)vk−1\frac{(-1)^k B_k}{k(k-1)} v^{k-1} is (−1)k+1Bkkvk\frac{(-1)^{k+1} B_k}{k} v^k. Since B1=−12B_1 = -\frac12, the term −v2-\frac v2 equals (−1)1+1B11v\frac{(-1)^{1+1} B_1}{1} v. So

∂sΛ=ln⁡(1+su)+∑k≥1(−1)k+1Bkk vk.\partial_s \Lambda = \ln(1 + su) + \sum_{k \ge 1} \frac{(-1)^{k+1} B_k}{k}\, v^k.

Step 5: the coefficient identity. By Steps 3 and 4 it is enough to show

∑j≥1(−1)j+1jBj(s) uj=ln⁡(1+su)+∑i≥1(−1)i+1Bii(u1+su)i.\sum_{j \ge 1} \frac{(-1)^{j+1}}{j} B_j(s)\, u^j = \ln(1 + su) + \sum_{i \ge 1} \frac{(-1)^{i+1} B_i}{i} \Bigl(\frac u{1 + su}\Bigr)^i.

Take the coefficient of uju^j. On the left it is (−1)j+1j∑i=0j(ji)Bi sj−i\frac{(-1)^{j+1}}j \sum_{i=0}^{j} \binom ji B_i\, s^{j-i}, by Definition C1.1.2.11.2.8. On the right, (1+su)−i=∑l(−il)slul(1 + su)^{-i} = \sum_l \binom{-i}{l} s^l u^l and (−il)=(−1)l(i+l−1l)\binom{-i}{l} = (-1)^l \binom{i+l-1}{l}. So the term with index i≥1i \ge 1 contributes, with l=j−il = j - i, the amount (−1)i+1Bii(−1)j−i(j−1j−i)sj−i=(−1)j+1Bii(j−1i−1)sj−i\frac{(-1)^{i+1} B_i}{i} (-1)^{j-i} \binom{j-1}{j-i} s^{j-i} = (-1)^{j+1} \frac{B_i}{i} \binom{j-1}{i-1} s^{j-i}. Since 1j(ji)=1i(j−1i−1)\frac1j \binom ji = \frac1i \binom{j-1}{i-1}, this equals the term ii on the left. The term i=0i = 0 on the left is (−1)j+1sj/j(-1)^{j+1} s^j/j, the coefficient of uju^j in ln⁡(1+su)\ln(1 + su). So the identity holds.

Step 6: the conclusion. The series Λ−Φ\Lambda - \Phi has ∂s(Λ−Φ)=0\partial_s(\Lambda - \Phi) = 0 and value 00 at s=0s = 0. A polynomial in ss with zero derivative and zero value at 00 is zero. So every coefficient of Λ−Φ\Lambda - \Phi vanishes, and cj(s)=(−1)j+1Bj+1(s)/(j(j+1))c_j(s) = (-1)^{j+1} B_{j+1}(s)/(j(j+1)). □\square

Algorithms and programs

Section 1.2.11.2 has no algorithm and no program. The recursion of Theorem C1.1.2.11.2.7 is a short procedure for the Bernoulli numbers: start with B0=1B_0 = 1 and use Bn−1=−1n∑k=0n−2(nk)BkB_{n-1} = -\frac1n \sum_{k=0}^{n-2}\binom nk B_k for n=2,3,…n = 2, 3, \ldots in exact rational arithmetic. The values of Theorem C1.1.2.11.2.5 and all the checks in this chapter come from this procedure and from the closed form of Theorem C1.1.2.11.2.12.

The exercises

The table has the exercises of Section 1.2.11.2. 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.2-1 18 M K1 not yet stated X1, 1.2.11.2-1
1.2.11.2-2 20 HM K1 not yet stated X1, 1.2.11.2-2
1.2.11.2-3 20 HM K1 not yet stated X1, 1.2.11.2-3
1.2.11.2-4 20 HM K3 not yet stated X1, 1.2.11.2-4
1.2.11.2-5 30 HM K1 not yet stated X1, 1.2.11.2-5
1.2.11.2-6 30 HM K1 not yet stated X1, 1.2.11.2-6
1.2.11.2-7 32 HM K4 not yet stated X1, 1.2.11.2-7
1.2.11.2-8 23 M K4 not yet stated X1, 1.2.11.2-8
1.2.11.2-9 25 M K4 not yet stated X1, 1.2.11.2-9

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

  • Exercise 1 is Theorem C1.1.2.11.2.7. The proof there multiplies the generating function by ez−1e^z - 1.
  • Exercise 2: the derivative rule of Theorem C1.1.2.11.2.9 fixes Bm(x)B_m(x) up to an additive constant. The condition Bm+1(1)=Bm+1(0)B_{m+1}(1) = B_{m+1}(0) gives ∫01Bm(x) dx=Bm+1(1)−Bm+1(0)m+1=0\int_0^1 B_m(x)\, dx = \frac{B_{m+1}(1) - B_{m+1}(0)}{m+1} = 0 and so fixes the constant. The proof of Theorem C1.1.2.11.2.10 uses exactly these two properties, because the boundary terms of the integration by parts cancel only when Bm+1(1)=Bm+1(0)B_{m+1}(1) = B_{m+1}(0). A sequence that satisfies the first property alone gives a formula with extra terms.
  • Exercise 3: let mm be even and let f(m)f^{(m)} have one sign, say f(m)≥0f^{(m)} \ge 0. By Step 1 of the proof of Theorem C1.1.2.11.2.13, Rm−1=1m!∫(Bm−Bm({x})) f(m) dxR_{m-1} = \frac{1}{m!} \int (B_m - B_m(\{x\}))\, f^{(m)}\, dx and Rm=Rm−1−CmR_m = R_{m-1} - C_m. By Theorem C1.1.2.11.2.12, 0≤(Bm−Bm({x}))/Bm≤20 \le (B_m - B_m(\{x\}))/B_m \le 2. So Rm−1/CmR_{m-1}/C_m lies in [0,2][0, 2], and ∣Rm∣=∣Cm∣⋅∣1−Rm−1/Cm∣≤∣Cm∣|R_m| = |C_m| \cdot |1 - R_{m-1}/C_m| \le |C_m|.
  • Exercise 4: Theorem C1.1.2.11.2.9 gives Bm+1(k+1)−Bm+1(k)=(m+1)kmB_{m+1}(k + 1) - B_{m+1}(k) = (m+1) k^m. Add this over 0≤k<n0 \le k < n. Then Sm(n)=∑0≤k<nkm=Bm+1(n)−Bm+1m+1S_m(n) = \sum_{0 \le k < n} k^m = \frac{B_{m+1}(n) - B_{m+1}}{m+1}. For m=3m = 3 and n=10n = 10 the value is (B4(10)−B4)/4=2025=03+13+⋯+93(B_4(10) - B_4)/4 = 2025 = 0^3 + 1^3 + \cdots + 9^3.
  • Exercise 5 is Theorem C1.1.2.11.2.20, and exercise 6 is Theorem C1.1.2.11.2.21.
  • Exercise 7: apply Theorem C1.1.2.11.2.10 with f(x)=xln⁡xf(x) = x \ln x and add f(n)f(n). The result is ln⁡∏k≤nkk=(n22+n2+112)ln⁡n−n24+ln⁡𝒜+O(n−2)\ln \prod_{k \le n} k^k = (\frac{n^2}2 + \frac n2 + \frac1{12}) \ln n - \frac{n^2}4 + \ln \mathcal A + O(n^{-2}), where 𝒜=1.2824271291…\mathcal A = 1.2824271291\ldots is a constant (the constant of Glaisher and Kinkelin). For n=10,100,1000n = 10, 100, 1000 the error times n2n^2 is 0.00138690.0013869, 0.00138890.0013889 and 0.00138890.0013889, close to 1720\frac1{720}, which is the next correction term.
  • Exercise 8: put N=an2+bnN = an^2 + bn in Theorem C1.1.2.11.2.18 and expand ln⁡N=ln⁡a+2ln⁡n+ln⁡(1+ban)\ln N = \ln a + 2 \ln n + \ln(1 + \frac b{an}). The result is ln⁡((an2+bn)!)=(an2+bn+12)(ln⁡a+2ln⁡n)−an2+b22a+12ln⁡2π+(b2a−b36a2)1n+O(n−2)\ln\bigl((an^2+bn)!\bigr) = (an^2 + bn + \frac12)(\ln a + 2 \ln n) - an^2 + \frac{b^2}{2a} + \frac12 \ln 2\pi + \bigl(\frac b{2a} - \frac{b^3}{6a^2}\bigr) \frac1n + O(n^{-2}). The same expansion carried one step further gives the coefficient 112a−b24a2+b412a3\frac1{12a} - \frac{b^2}{4a^2} + \frac{b^4}{12a^3} of n−2n^{-2}. For a=2a = 2, b=3b = 3 this is 3196=0.32292\frac{31}{96} = 0.32292, and the residual times n2n^2 is 0.29900.2990, 0.32030.3203 and 0.32270.3227 for n=10,100,1000n = 10, 100, 1000.
  • Exercise 9: apply Theorem C1.1.2.11.2.19 to (2n)!(2n)! and to n!2n!^2. The result is (2nn)=4nπn(1−18n+1128n2+51024n3+O(n−4))\binom{2n}n = \frac{4^n}{\sqrt{\pi n}} \bigl(1 - \frac1{8n} + \frac1{128 n^2} + \frac5{1024 n^3} + O(n^{-4})\bigr). For n=10n = 10 and n=100n = 100 the relative error times n4n^4 is −0.0008-0.0008 and −0.00066-0.00066.

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 states eqs. (1) to (9) and the leading term of eq. (19). The Node lines name the declarations. Where the Lean statement differs from the handbook, the Node line says "partial".

  • Eq. (1) is TAOCP.S1_2_11.fract_eq, with TAOCP.S1_2_11.fract_eq_sub_nat for the open interval. Eqs. (2) and (3) are TAOCP.S1_2_11.eq2_euler and TAOCP.S1_2_11.eq3_euler.
  • Eqs. (4) to (8) are TAOCP.S1_2_11.eq4_bernoulli to TAOCP.S1_2_11.eq8_bernoulli. Eq. (9) is TAOCP.S1_2_11.eq9_bernoulli, with TAOCP.S1_2_11.bernoulli_poly_zero_one.
  • Eq. (19) is TAOCP.S1_2_11.eq19_stirling.
  • The files TAOCP/Notation/Bernoulli.lean and TAOCP/Notation/Harmonic.lean have TAOCP.bernoulli_zero_eq, TAOCP.bernoulli_one_eq, TAOCP.bernoulli_two_eq and TAOCP.harmonicPow.

The Lean statement differs from the handbook in these places.

  • Eqs. (2) and (3) assume ContDiff ℝ 1 f, so ff has a continuous derivative on the whole real line. Eq. (3) is stated for n≥1n \ge 1 with the sum over Finset.Ico 1 n.
  • Eq. (4) is stated without division: the series of Bk/k!B_k/k! times ez−1e^z - 1 is zz.
  • Eq. (5) states B0B_0 to B4B_4 only. The handbook lists the numbers up to B12B_{12}.
  • Eq. (9) states Bm+1′(x)=(m+1)Bm(x)B_{m+1}'(x) = (m+1) B_m(x) and Bm(1)=Bm(0)B_m(1) = B_m(0) for m≥2m \ge 2. The other rules of the theorem are not stated.
  • Eq. (19) states the leading term only: the ratio of n!n! to 2πn (n/e)n\sqrt{2\pi n}\,(n/e)^n tends to 11.

Not yet stated: the Node lines that say "Lean: not yet stated", which include Euler's formula with the remainder, the bounds on the remainder and the series for ln⁡n!\ln n!.

Notes and history

The formula was found by L. Euler, in papers of 1732 to 1736, and independently by C. Maclaurin, who printed it in his Treatise of Fluxions of 1742. The Bernoulli numbers appear in the work of Jakob Bernoulli on sums of powers, printed in 1713 after his death. Exercise 4 gives the form of that result in the notation of this section.

A. de Moivre found the series for ln⁡n!\ln n! with an unknown constant, and J. Stirling found that the constant is 12ln⁡2π\frac12 \ln 2\pi. Both results were printed in 1730. Wallis' product was printed in 1656.

The series of Theorems C1.1.2.11.2.16 and C1.1.2.11.2.18 are asymptotic series in the sense that H. Poincaré defined in 1886. For fixed nn they diverge, since the closed form of Theorem C1.1.2.11.2.12 shows that ∣B2j∣|B_{2j}| grows like (2j)!/(2π)2j(2j)!/(2\pi)^{2j}. The bound "between 00 and the next term" is the reason that they are still useful.

Theorem C1.1.2.11.2.22 is not a separate result of the book. It is the form of Stirling's series that Section 1.2.11.1 uses to expand Γ(x+s)/Γ(x)\Gamma(x + s)/\Gamma(x), and this chapter proves it for that reason.

The project has no errata of Section 1.2.11.2 to report.

Section 1.2.11.2 of TAOCP turns a sum into an integral plus correction terms. The corrections have the Bernoulli numbers as coefficients, and the error after each stage is bounded. The section applies the formula to 1/x1/x and to ln⁡x\ln x. This gives the series for the harmonic numbers, the value of Euler's constant, and Stirling's series for n!n!. This chapter of C1 states and proves each equation of the section, adds the facts that the book leaves to the reader, and checks each series against exact values.

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