Euler-Maclaurin formula
Michael S. Floater May 2, 2019
In these notes we derive the Euler-Maclaurin formula and apply it to numerical integration.
1 Bernoulli numbers
We start by defining the Bernoulli numbers Bn, n = 0, 1, 2,.... We define them as the coefficients in the expansion
∞ x X xj = B . ex − 1 j j! j=0
This means that x B0 = lim = 1. x→0 ex − 1 x We obtain Bn, n ≥ 1 recursively. By the Maclaurin expansion of e we have
∞ i ! ∞ j ! ∞ n−1 ! X x X x X X Bj x = B = xn, i! j j! (n − j)!j! i=1 j=0 n=1 j=0 which implies that n−1 X n B = 0, n ≥ 2. (1) j j j=0 Thus, 1 1 B = − B = − , 1 2 0 2
1 1 1 B = − (B + 3B ) = , 2 3 0 1 6 1 B = − (B + 4B + 6B ) = 0, 3 4 0 1 2 and so on, and we find
n 0 1 2 3 4 5 6 Bn 1 -1/2 1/6 0 -1/30 0 1/42
We will show that Bn = 0 for n ≥ 3 and n odd. This follows from the fact that x f(x) := − (B + B x) ex − 1 0 1 is symmetric, i.e., f(x) = f(−x). To show this observe that the constant B0 is trivially symmetric, and so it is sufficient to show that
x x x(ex + 1) g(x) := + = ex − 1 2 2(ex − 1) is symmetric. To show this we compute
−x(e−x + 1) −x(1 + ex) g(−x) = = = g(x). 2(e−x − 1) 2(1 − ex)
2 Bernoulli polynomials
We define the Bernoulli polynomial of degree n ≥ 0 as
n X n B (t) = B tn−j. n j j j=0
2 So
B0(t) = 1, 1 B (t) = t − , 1 2 1 B (t) = t2 − t + , 2 6 3 1 B (t) = t3 − t2 + t, 3 2 2 1 B (t) = t4 − 2t3 + t2 − , 4 30 5 5 1 B (t) = t5 − t4 + t3 − t, 5 2 3 6 5 1 1 B (t) = t6 − 3t5 + t4 − t2 + , 6 2 2 42 and so on. From the definition and using (1) we deduce the following prop- erties: • Endpoint property:
n X n B (1) = B = B = B (0), n ≥ 2. n j j n n j=0
• Differentiation:
n−1 X n B0 (t) = (n − j) B tn−j−1 = nB (t), n ≥ 1. n j j n−1 j=0
• Integration:
Z 1 Z 1 1 0 Bn(t) dt = Bn+1(t) dt = 0, n ≥ 1. 0 n + 1 0
We will also derive the • Upper bound: |B2r(t)| ≤ |B2r|, r ≥ 0.
3 To do this we use Fourier series. We define
Bbn(t) = Bn(t − j), j ≤ t ≤ j + 1, j ∈ Z, the 1-periodic extension of Bn : [0, 1] → R. By repeated differentiation, n! B(j)(t) = B (t), j = 0, 1, . . . , n, n ≥ 1, n (n − j)! n−j which implies that
(j) (j) Bn (0) = Bn (1), j = 0, 1, . . . , n − 2,
n−2 and therefore Bbn ∈ C (R). Consider the Fourier series of Bbn,
∞ X 2πikt Bbn(t) = cke . k=−∞
Because Bbn(t) is real, c−k = ck. So letting ck = ak + ibk, we have a−k = ak and b−k = −bk, and so
∞ ∞ X X Bbn(t) = a0 + 2 ak cos(2πikt) + 2 bk sin(2πikt). k=1 k=1
The coefficients of Bbn are Z 1 −2πikt ck = Bn(t)e dt. 0 We find Z 1 c0 = Bn(t) dt = 0, n ≥ 1, 0 and for k 6= 0,
−2πikt 1 Z 1 e −2πikt ck = Bn(t) + n Bn−1(t)e dt = −2πik 0 0 Z 1 n! −2πikt −n! ··· = n−1 B1(t)e dt = n = ak + ibk. (2πik) 0 (2πik)
4 It follows that a0 = b0 = 0 and for k 6= 0, (2r)! a = (−1)r−1 , b = 0, if n = 2r, k (2πk)2r k
(2r − 1)! a = 0, b = (−1)r , if n = 2r − 1. k k (2πk)2r−1 We now deduce that
∞ r−1 X cos(2πkt) Bb2r(t) = (−1) 2(2r)! , (2πk)2r k=1 and ∞ r X sin(2πkt) Bb2r−1(t) = (−1) 2(2r − 1)! . (2πk)2r−1 k=1 From this we obtain the claimed upper bound since
∞ X 1 |Bb2r(t)| ≤ 2(2r)! = |Bb2r(0)| = |B2r|. (2πk)2r k=1 3 Local Euler-Maclaurin expansion
We next use the Bernoulli polynomials to expand the integral of a function F : [0, 1] → R in terms of the trapezoidal rule and endpoint derivatives of odd order. We use integration by parts successively.
Lemma 1 For r ≥ 0 and F ∈ C2r+2[0, 1],
Z 1 r+1 1 X B2k F (t) dt = (F (0) + F (1)) − (F (2k−1)(1) − F (2k−1)(0)) + R , 2 (2k)! r 0 k=1 where Z 1 1 (2r+2) Rr := B2r+2(t)F (t) dt. (2r + 2)! 0
5 Proof. Using integration by parts twice,
Z 1 Z 1 1 Z 1 h i 0 F (t) dt = B0(t)F (t) dt = B1(t)F (t) − B1(t)F (t) dt 0 0 0 0 1 Z 1 1 1h 0 i 1 00 = (F (0) + F (1)) − B2(t)F (t) + B2(t)F (t) dt 2 2 0 2 0 1 B = (F (0) + F (1)) − 2 (F 0(1) − F 0(0)) + R , 2 2 0 which proves the lemma in the case r = 0. Otherwise, suppose r ≥ 1, and assume that the lemma holds with r replaced by r − 1. Then again using integration by parts twice,
Z 1 1 (2r) Rr−1 = B2r(t)F (t) dt (2r)! 0 1 Z 1 1 h (2r) i 1 (2r+1) = B2r+1(t)F (t) − B2r+1(t)F (t) dt (2r + 1)! 0 (2r + 1)! 0 1 Z 1 1 h (2r+1) i 1 (2r+2) = − B2r+2(t)F (t) + B2r+2(t)F (t) dt (2r + 2)! 0 (2r + 2)! 0 1 = − (F (2r+1)(1) − F (2r+1)(0)) + R , (2r + 2)! r which completes the proof. 2
The Bernoulli polynomial B2r+2(t) in the remainder term Rr is not of one sign, so we cannot apply the mean value theorem. However, we can fix this by combining Rr with the last term in the expansion. Lemma 2 For r ≥ 0 and F ∈ C2r+2[0, 1], there is some ξ ∈ (0, 1) such that
Z 1 r 1 X B2k F (t) dt = (F (0) + F (1)) − (F (2k−1)(1) − F (2k−1)(0)) − R, 2 (2k)! 0 k=1 where B R = 2r+2 F (2r+2)(ξ). (2r + 2)!
6 Proof. The last term in the expansion in Lemma 1 plus the remainder can be written as B − 2r+2 (F (2r+1)(1) − F (2r+1)(0)) + R (2r + 2)! r Z 1 B2r+2 (2r+2) = − F (t) dt + Rr = −R, (2r + 2)! 0 where Z 1 1 (2r+2) R := (B2r+2 − B2r+2(t))F (t) dt. (2r + 2)! 0
Using the upper bound on B2r(t) of the previous section, the difference B2r − B2r(t) is of one sign in [0, 1], because
sgn(B2r)(B2r − B2r(t)) = |B2r| − sgn(B2r)B2r(t) ≥ |B2r| − |B2r(t)| ≥ 0. So by the mean value theorem, there is some ξ ∈ (0, 1) such that
Z 1 1 (2r+2) B2r+2 (2r+2) R = (B2r+2 − B2r+2(t)) dt F (ξ) = F (ξ). (2r + 2)! 0 (2r + 2)! 2
4 Global Euler-Maclaurin expansion
We apply the local expansion to obtain the global one. Given an interval [a, b] choose n ≥ 1 and let h = (b − a)/n and xi = a + ih, i = 0, 1, . . . , n. Theorem 1 For r ≥ 0 and f ∈ C2r+2[a, b], there is some ξ ∈ (a, b) such that Z b r X B2k f(x) dx = T (h) − h2k(f (2k−1)(b) − f (2k−1)(a)) − R, (2k)! a k=1 where n−1 h X T (h) = (f(a) + f(b)) + h f(x ), 2 i i=1 and B R = 2r+2 (b − a)h2r+2f (2r+2)(ξ). (2r + 2)!
7 Proof. Let F (t) = f(xi−1 + ht), t ∈ [0, 1], i = 1, . . . , n. Then Lemma 2 gives
Z xi Z 1 f(x) dx = h F (t) dt = xi−1 0 r h X B2k (f(x ) + f(x )) − h2k(f (2k−1)(x ) − f (2k−1)(x )) − R , 2 i−1 i (2k)! i−1 i i k=1 where B R = 2r+2 h2r+3f (2r+2)(ξ ) i (2r + 2)! i for some ξi ∈ (xi−1, xi). Summing this equation over i = 1, . . . , n yields the desired expansion except that the remainder term is
n n X B2r+2 X R = R = h2r+3 f (2r+2)(ξ ). i (2r + 2)! i i=1 i=1 However, an application of the mean value theorem gives
n X (2r+2) (2r+2) f (ξi) = nf (ξ) i=1 for some ξ ∈ (a, b), and this leads to the remainder term as claimed. 2
5 Applications
5.1 Endpoint corrections We can view the endpoint derivatives in the Euler-Maclaurin expansion as correction terms that greatly improve the accuracy of the trapezoidal rule, if they are available. From Theorem 1 we have
Corollary 1 For r ≥ 0 and f ∈ C2r+2[a, b],
Z b r X B2k f(x) dx = T (h) − h2k(f (2k−1)(b) − f (2k−1)(a)) + O(h2r+2) (2k)! a k=1 as h → 0.
8 5.2 Superconvergence of the trapezoidal rule For some functions, the trapezoidal rule itself has higher accuracy than usual. Corollary 2 Suppose r ≥ 0 and f ∈ C2r+2[a, b]. If f (2k−1)(b) = f (2k−1)(a) for k = 1, . . . , r, then Z b f(x) dx = T (h) + O(h2r+2) as h → 0. a This we will be the case for any r ≥ 0 for functions f ∈ C∞(R) that are periodic with period b − a. In fact for some functions of this type, the trapezoidal rule is exact. Theorem 2 Let [a, b] = [0, 2π] and let
n−1 n−1 X X f(x) = ak cos(kx) + bk sin(kx), k=0 k=1 for any choice of ak and bk in R. Then T (h) is exact for f. Proof. It is sufficient to show that T (h) is exact for f(x) := eikx, k = 0, 1, . . . , n − 1. The integral of this f is ( Z 2π 2π, k = 0; f(x) dx = 0 0, k > 0. On the other hand, since f(0) = f(2π),
n−1 ! 1 X 2jπ T (h) = h (f(0) + f(2π)) + f 2 n j=1 n−1 n−1 X 2jπ X = h f = h e2jkiπ/n. n j=0 j=0 So if k = 0, T (h) = hn = 2π, and if 1 ≤ k ≤ n − 1,
n−1 X e2kiπ − 1 T (h) = h (e2kiπ/n)j = h = 0. e2kiπ/n − 1 j=0 2
9 5.3 Sums of p-th powers We can also use the expansion to obtain a formula for sums of p-th powers. Corollary 3 For p ≥ 1,
n−1 X 1 jp = (B (n) − B ). p + 1 p+1 p+1 j=1 The first examples are
n−1 X 1 1 j = n2 − n, 2 2 j=1 n−1 X 1 1 1 j2 = n3 − n2 + n, 3 2 6 j=1 n−1 X 1 1 1 j3 = n4 − n3 + n2, 4 2 4 j=1 n−1 X 1 1 1 1 j4 = n5 − n4 + n3 − n, 5 2 3 30 j=1 n−1 X 1 1 5 1 j5 = n6 − n5 + n4 − n2, 6 2 12 12 j=1
Proof. Let f(x) = xp, p ≥ 1, and [a, b] = [0, n]. Then Z b Z n np+1 f(x) = xp dx = . a 0 p + 1 With h = 1, the trapezoidal rule for f on [0, n] is
n−1 1 X T (h) = np + jp. 2 j=1 Let r be such that p = 2r or p = 2r + 1. Then Theorem 1 gives Z n r X B2k p! xp dx = T (h) − np−2k+1, (2k)! (p − 2k + 1)! 0 k=1
10 and therefore,
n−1 r X np+1 1 1 X p + 1 jp = − np + B np−2k+1 p + 1 2 p + 1 2k 2k j=1 k=1 p 1 X p + 1 = B np−k+1 p + 1 k k k=0 1 = (B (n) − B ). p + 1 p+1 p+1 2
11