






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







The point: Techniques for computing integrals are derived, using interpolation and piece- wise constructions (composite formulas). In addition, the asymptotic error series for the trapezoidal rule is introduced, enabling the use of Richardson extrapolation for integration.
Related reading: 9.1-9.4; 9.6 (there is a detailed proof for Newton-Cotes formulas that is skipped here to derive the error term).
In this section we derive formulas to approximate a definite integral
∫ (^) b
a
f (x) dx
for a continuous function f given its values at a set of nodes, following the same interpolation strategy employed for differentiation. The approach leads to Newton-Cotes formulas.
It will be useful to recall the mean value theorem in its two forms:
Mean value theorem (MVT), two forms:
f ′(c) =
f (b) − f (a) b − a
∫ (^) b
a
f (x)g(x) dx = f (ξ)
∫ (^) b
a
g(x) dx (MVT)
Important caveat: Note that g must be single signed for the integral version to apply. For instance,
− 1 x^ ·^ x dx^6 =^ C^
− 1 x dx^ for any constant^ C; the integral of^ x^ is zero.
Given nodes x 0 , x 1 , · · · xn in the interval (a, b), construct the interpolating polynomial in Lagrange form (with ωn =
∏n j=0(x^ −^ xj^ )):
f (x) = pn(x) + E(x)
=
∑^ n
i=
f (xi)`i(x) +
f (n+1)(ηx) (n + 1)!
ωn(x).
Then integrate over [a, b] to obtain the formula and error:
∫ (^) b
a
f (x) dx =
∑^ n
i=
f (xi)
(∫ (^) b
a
`i(x) dx
∫ (^) b
a
E(x) dx.
Since pn is a linear combination of the function values f (xi), the formula has the form
∫ (^) b
a
f (x) dx ≈
∑^ n
i=
cif (xi)
for constants ci. The error has the form
∫ (^) b
a
E(x) dx =
∫ (^) b
a
f (n+1)(ηx) (n + 1)!
ωn(x) dx,
which takes some work to simplify into a nicer form.
Change of interval: To simplify the derivation, it is easiest to first ontain formulas for a fixed interval like [0, 1] and then transform to [a, b] via
s ∈ [0, 1] → x ∈ [a, b], x = a + (b − a)s. (CoI)
The general formula can then be obtained from the fixed one by
∫ (^) b
a
f (x) dx = (b − a)
0
g(s) ds, g(s) := f (a + (b − a)s)
Note that g(n+1)(ηs) transforms into (b − a)n+1f (n+1)(ξx) due to the chain rule (for some ξx in [a, b] depending on x).
The familiar trapezoidal rule from calculus is a Newton-Cotes formula (see ??). Consider first integrating g(s) on the interval s ∈ [0, 1] with nodes s 0 = 0, s 1 = 1. The Lagrange basis polynomials are
0 (s) = 1 − s, 1 (s) = s
Since x − x 0 changes sign in the interval, the MVT cannot be applied. In fact, the error term in the above is misleading. Observe that if f ∈ P 1 then f ′^ = const. so
error =
0
C(s − 1 /2) ds = C
0
(s − 1 /2) ds = 0.
Thus, the formula actually has degree of accuracy ≥ 1 (easily checked to be exactly one), even though the interpolant has degree of accuracy zero.
Simplifying the error: There are two ways around the MVT issue. One is to use Taylor series instead to derive the formula; just expand g(s) in a Taylor series around the midpoint:
∫ (^1)
0
g(s) ds =
0
g(1/2) + g′(1/2)(s − 1 /2) +
g′′(η)(s − 1 /2)^2 ds
= g(1/2) + g′(1/2)
0
(s − 1 /2) ds ︸ ︷︷ ︸ =
0
g′′(ηs)(s − 1 /2)^2 ds
Since (s − 1 /2)^2 ≥ 0 the mean value theorem applies so
∫ (^1)
0
g(s) ds = g(1/2) + g′′(η)
0
(s − 1 /2)^2 ds = g(1/2) +
g′′(η).
It follows, after transforming to [a, b], that the midpoint rule formula with error is
∫ (^) b
a
f (x) dx = hf (x 0 ) +
f ′′(ξ) 24
h^3
with x 0 = (a + b)/2 and h = b − a. It has the same order/degree as the trapezoidal rule, but the error has an extra factor of 1/2. Surprisingly, the midpoint rule ttypically has a smaller error than the trapezoidal rule (same order, better constant), despite using only one point!
The procedure can be generalized to interpolants of any degree. The two types are:
The formulas, using the transformation from s → x to simplify a bit, have the form ∫ (^) b
a
f (x) dx = h
∑^ n
i=
cifi + hn+
∫ (^) b
a
g(n+1)(ηs) (n + 1)!
ωn(s) ds, ωn(s) :=
∏^ n
i=
(s − si)
where g(s) = f (x) and si = i/n and the coefficients are
ci =
∫ (^) b
a
`i(x) dx =
0
∏^ n
j=0, j 6 =i
s − sj si − sj
ds
Now plug in a polynomial of degree n + 1. It is true (check this!) that ∫ (^1)
0
ωn(s) ds =
0 for odd n 6 = 0 for even n
One can show that the error must have the usual form, so it follows that for odd n, the formula has degree exactly n and
error =
Cf (n+1)(ξ) (n + 1)!
hn+
Here C denotes a constant that depends on n. Note that n + 1 factors of h come from the ωn term, plus one more from the integral over [a, b].
However, the error vanishes for f ∈ Pn+1 due to
0 ωn(s)^ ds^ = 0.^ The degree turns out to be n + 1 exactly and instead the error has the form^1
error =
Cf (n+2)(ξ) (n + 2)!
hn+3.
In the even case, the symmetry provides an extra factor of h and an extra degree. The key point is that the formulas with symmetry gain an extra degree of accuracy, so they are preferable when available (simpson’s rule below; the midpoint rule...)
(^1) The unpleasant proof involves integrating by parts to manipulate the error into a form where the MVT
applies, then use some technical results to simplify. See Section 9.3 of the textbook for the proof.
For the error, suppose for simplicity that the points are equally spaced (h = xk+1 − xk). Then, including the error term from before in each sub-interval,
∫ (^) b
a
f (x) dx =
n∑− 1
k=
h 2
(f (xk) + f (xk+1)) + ET
where, for some constants ηk ∈ [xk, xk+1],
n∑− 1
k=
f (2)(ηk) 12
h^3.
Also suppose that |f (2)(x)| ≤ M for x ∈ [a, b].
The terms can all be bounded by M h^3 /12, which do not depend on n, so it follows that
nM h^3 12
Now one can write the error in terms of n or h:
M (b − a)^3 12 n^2
M (b − a) 12
h^2.
Thus the error is O(1/n^2 ) as n → ∞ or alternatively O(h^2 ) as h → 0.
Note that the error in each sub-interval is O(h^3 ), and there are O(1/h) sub-intervals, so the total error is O(h^3 · 1 /h) (a useful rule of a thumb). The total error is proportional (roughly) to the interval width times the local error.
Precise simplification: The IVT trick use for derivatives can also be used to simplify the error as well. Write
nh^3 12
(n− 1 ∑
k=
n
f (2)(ηk)
nh^3 12
f (2)(ξ)
since the weights 1/n are positive and sum to 1.
The error can be improved by upgrading the trapezoidal rule to Simpson’s rule (linear to quadratic). Assume there are an even number of sub-intervals (n is even). Then use Simpson’s rule (3) on the sub-intervals
[x 2 k, x 2 k+2], k = 0, · · · n/ 2 − 1
as shown below (here h = xk+1 − xk is now half the sub-interval width). The result is a formula with an error
ES = −
(b − a)h^4 f (4)(η).
The formula is O(h^4 ) if f ∈ C^4.
Convergence rate: As an example, the convergence is shown for ∫ (^2)
0
xex^ dx
using the composite trapezoidal rule and composite Simpson’s rule. The integral was com- puted with spacing h = (b − a)2−n^ and the error is plotted vs. n. Since the error is O(hp), we expect the log-log plot to be linear, with slope −p log 2 (depending on the base used).
Reference lines that are Chp^ for p = −2 and p = −4 are plotted to show that the error does indeed have the right slope. This is the ‘generic’ case for both rules when the function f is smooth enough that the error bound holds (f ∈ C^2 for the trapezoidal rule and f ∈ C^4 for Simpson’s) and has no special properties (so it does not do better).
101 102 103 n
10 12
10 10
10 8
10 6
10 4
10 2
100
err.
trap. simp. p=- p=-
Define the composite trapezoidal rule Thf as in the previous section (eq. (4)).
Thf = trapezoidal rule applied to f with n + 1 equally spaced points, spacing h.
and let I =
∫ (^) b a f^ (x)^ dx. Then the Euler-Maclaurin formula says that Thf = I + c 2 h^2 + c 4 h^4 + · · ·
assuming that f is smooth. Let
R 0 ,j = trapezoidal rule with 2j^ sub-intervals = Thf with h = (b − a)2−j^.
Then by the same procedure as we saw for derivatives,
Th/ 2 f = I +
c 2 4
h^2 +
c 4 16
h^4 + · · ·
(4Th/ 2 − Th) = I + b 4 h^4 + · · ·
We then define the next iteration of R’s as this approximation:
R 1 ,j =
(4R 0 ,j+1 − R 0 ,j ).
The process is then continued via Richardson extrapolation (details: homework). Continuing this process, we obtain
Ri,j :=
4 i^ − 1
(4iRi− 1 ,j+1 − Ri− 1 ,j ).
This process is called Romberg integration. Essentially, we are taking the trapezoidal rule and employing Richardson extrapolation to get an accurate approximation.
A small improvement: The process can be optimized a bit by observing that half the points of Th/ 2 are also in Th. We have that
Thf = 2Th/ 2 f −
n/ ∑ 2 − 1
i=
hf (a + (2i − 1)h)
so only half of the sum in the rule needs to be updated.
Each new column in the table is a formula for
∫ (^) b a f^ (x)^ dx^ using 2
i (^) subintervals; R 0 , 0 is the
trapezoidal rule, R 1 , 0 is Simpson’s rule and so on.
Suppose we want to design an ‘adaptive’ scheme to estimate
∫ (^) b
a
f (x) dx
that takes in f , the interval [a, b] and a value and returns an approximation to I with error at most (b − a). The idea is that the scheme should be able to assess its own accuracy and do only work as needed. Essentially, we want to use a method like Romberg integration, but only split intervals in half when the accuracy is needed.
Let S(a, b) denote Simpson’s rule in [a, b] with h = (b − a)/2:
S(a, b) :=
h 3
(f (a) + 4f (a + h) + f (b)).
A more accurate approximation can be computed by splitting the interval in half and ap- plying Simpson’s rule to both halves. Let c = (a + b)/2 and
S 1 = S(a, b), S 2 = S(a, c) + S(c, b).
Both are approximations to I. We have that
I = S(a, b) −
f (4)(ξ 1 ) 90
h^5 ︸ ︷︷ ︸ E
I = S(a, c) + S(c, b) −
f (4)(ξ 2 ) 90
(h/2)^5 ︸ ︷︷ ︸ ≈E/ 32
f (4)(ξ 3 ) 90
(h/2)^5 ︸ ︷︷ ︸ ≈E/ 32
We wish to estimate the error E in Simpson’s rule. To do so, assume that the ξ’s are equal (not true, but close) to get two equations for E and I:
Solving for E, we get |E| ≈ 15 |S 2 − S 1 |. (5)
The algorithm can then proceed recursively as follows, given , a, b and f :