Lecture22 PDF
Lecture22 PDF
f (x)
10
✓ ◆
b a 6
xj = j .
n
4
R 10
Riemann sums: partition [ a, b] into smaller subintervals, and use Figure 3.1: Estimates of 0 f ( x ) dx,
low-degree interpolants to approximate the integral on each of these shown in gray: the first approximates f
by a constant interpolant; the second, a
smaller domains. Such methods are called composite quadrature rules. composite rule, uses a piecewise constant
In some cases, the function f may be fairly regular over most of interpolant. You probably have encoun-
the domain [ a, b], but then have some small region of rapid growth or tered this second approximation as a
Riemann sum.
oscillation. Modern adaptive quadrature rules are composite rules on
which the subintervals of [ a, b] vary in size, depending on estimates
of how rapidly f is changing in a given part of the domain. Such
methods seek to balance the competing goals of highly accurate
approximate integrals and as few evaluations of f as possible.We
shall not dwell much on these sophisticated quadrature procedures
here, but rather start by understanding some methods you were
probably introduced to in your first calculus class.
In summary, 12
63.5714198. . . (trapezoid)
73.4543644. . . (exact)
Trapezoid rule: 10
Z b
b a⇣ ⌘ 8
f ( x ) dx ⇡ f ( a) + f (b) .
a 2
6
4
The procedure behind the trapezoid rule is illustrated in Figure 3.2
where the area approximating the integral is colored gray. 2
1 00 1 1 2 1 1 3
= f (h )( a3 a b + ab2 b ) The mean value theorem for inte-
2 6 2 2 6 grals states that if h, g 2 C [ a, b] and
h does not change sign on [ a, b], then
1 00
= f (h )(b a )3 there exists some h 2 [ a, b] such that
12 Rb Rb
a g ( t ) h ( t ) dt = g ( h ) a h ( t ) dt. The re-
quirement that h not change sign is es-
for some h 2 [ a, b]. The second step follows from the mean value
sential. For example, if g(t) = h(t) = t
theorem for integrals. R1
then 1 g(t)h(t) dt = 1 t2 dt = 2/3,
R1
bound, plus bounds for more complicated schemes, too. For now, we
summarize the bound in the following Theorem.
10 -8
10 -10 O(
h 3)
10 -12
10 0 10 -1 10 -2 10 -3
h
x0 = a, x1 = ( a + b)/2, x2 = b.
where
Z b✓ ◆✓ ◆
x x1 x x2 b a
w0 = dx =
a x0 x1 x0 x2 6
Z b✓ ◆✓ ◆
x x0 x x2 2( b a )
w1 = dx =
a x1 x0 x1 x2 3
Z b✓ ◆✓ ◆
x x0 x x1 b a
w2 = dx = .
a x2 x0 x2 x1 6
In summary: 12
76.9618331. . . (Simpson)
73.4543644. . . (exact)
Simpson’s rule: 10
Z b
b a⇣ ⌘ 8
f ( x ) dx ⇡ f ( a) + 4 f ( 12 ( a + b)) + f (b) .
a 6
6
4
Simpson’s rule enjoys a remarkable feature: though it only approxi-
mates f by a quadratic, it integrates any cubic polynomial exactly! One 2
can verify this by directly applying Simpson’s rule to a generic cu-
bic polynomial. Write f ( x ) = ax3 + q( x ), where q 2 P2 . Let 0
Rb 0 2.5 5 7.5
x
10
I ( f ) = a f ( x ) dx and let I2 ( f ) denote the Simpson’s rule approx-
Figure 3.4: Simpson’s rule estimate of
imation. Then, by linearity of the integral, R 10
0 f ( x ) dx, shown in gray.
I ( f ) = aI ( x3 ) + I (q)
I2 ( f ) = aI2 ( x3 ) + I2 (q).
This error formula captures the fact that Simpson’s rule is exact
for cubics, since it features the fourth derivative f (4) (h ), two deriva-
tives greater than f 00 (h ) in the trapezoid rule bound, even though
the degree of the interpolant has only increased by one. Perhaps it is
helpful to visualize the exactness of Simpson’s rule for cubics. Fig-
ure 3.5 shows f ( x ) = x3 (blue) and its quadratic interpolant (red).
On the left, the area under f is colored gray: its area is the integral
we seek. On the right, the area under the interpolant is colored gray.
Accounting area below the x axis as negative, both integrals give an
identical value even though the functions are quite different. It is
remarkable that this is the case for all cubics.
Typically one does not see Newton–Cotes rules based on poly-
nomials of degree higher than two (i.e., Simpson’s rule). Because Integrating the cubic interpolant at
it can be fun to see numerical mayhem, we give an example to em- four uniformly spaced points is called
Simpson’s three-eighths rule.
phasize why high-degree Newton–Cotes rules can be a bad idea.
Recall that Runge’s function f ( x ) = 1/(1 + x2 ) gave a nice exam-
ple for which the polynomial interpolant at uniformly spaced points
over [ 5, 5] fails to converge uniformly to f . This fact suggests that
Newton–Cotes quadrature will also fail to converge as the degree of
the interpolant grows. The exact value of the integral we seek is
Z 5
1 1
dx = 2 tan (5) = 2.75680153 . . . .
5 1 + x2
Just as the interpolant at uniformly spaced points diverges, so too
does the Newton–Cotes integral. Figure 3.6 illustrates this diver-
gence, and shows that integrating the interpolant at Chebyshev
127
1.5 1.5
1 1
0.5 0.5
0 0
-0.5 -0.5
-1 -1
-1.5 -1.5
-1 0 1 2 -1 0 1 2
x x
10 1
over x 2 [ 5, 5].
10 0
5
Z 5
f ( x ) dx
10 -1
Che
bys
-2 hev p
10 oint
5
Z 5
10 -3
10 -4
1 8 16 24
n
This error analysis has an important consequence: the error for the
composite trapezoid rule is only O(h2 ), not the O(h3 ) we saw for the
usual trapezoid rule (in which case b a = h since n = 1).
Now use Theorem 3.3 to derive an error formula for the composite
Simpson’s rule, using the same approach as for the composite trape-
zoid rule.
h4
= (b a ) f (4) ( h )
180
12 12
73.2181469. . . (comp. trapezoid) 73.4610862. . . (comp. Simpson)
73.4543644. . . (exact) 73.4543644. . . (exact)
10 10
8 8
6 6
4 4
2 2
0 0
0 2.5 5 7.5 10 0 2.5 5 7.5 10
x x
Figure 3.7: Composite trapezoid rule
(left) and composite Simpson’s rule
3.2.4 Adaptive Quadrature (right).