Professional Documents
Culture Documents
W W L CHEN
c
This chapter originates from material used by the author at Imperial College, University of London, between 1981 and 1990.
It is available free to all individuals, on the understanding that it is not to be used for financial gain,
and may be downloaded and/or photocopied, with or without permission from the author.
However, this document may not be kept on any information storage and retrieval system without permission
from the author, unless such system is not accessible to any individuals other than its owners.
Chapter 11
NUMERICAL INTEGRATION
11.1. Introduction
In Chapters 9 and 10, we have discussed some analytic techniques for evaluating integrals. However,
many integrals that arise in science and engineering resist attack by even the most sophisticated analytic
techniques. In such instances, we may have to accept a rather poor and perhaps even not entirely
satisfactory second best, and attempt to make reasonable approximations by numerical techniques.
f (x) dx,
A
where the function f (x) is finite and continuous in the closed interval [A, B]. If we draw the curve
y = f (x), then the value of the integral is the same as the area bounded by the curve y = f (x) and the
lines y = 0, x = A and x = B (the reader should draw a diagram).
A first, and rather crude, approximation to the integral is to take the area of the trapezium with
vertices at the points (A, 0), (B, 0), (A, f (A)) and (B, f (B)). In other words, we take the approximation
Z B
1
(1)
f (x) dx (B A)(f (A) + f (B)).
2
A
In practice, however, we take more points than just A and B. Consider the dissection
A = x0 < x1 < . . . < xn = B
Chapter 11 : Numerical Integration
page 1 of 10
f (x) dx =
n Z
X
xi
f (x) dx.
xi1
i=1
Suppose now that we make a similar approximation as (1) in each of the subintervals, so that for every
i = 1, . . . , n, we have
Z
xi
f (x) dx
xi1
1
(xi xi1 )(f (xi1 ) + f (xi )).
2
f (x) dx
A
1X
(xi xi1 )(f (xi1 ) + f (xi )).
2 i=1
(2)
Suppose further that the lengths of all the subintervals are the same, so that
xi xi1 = h =
BA
n
for every i = 1, . . . , n.
h
(f (x0 ) + 2f (x1 ) + 2f (x2 ) + . . . + 2f (xn1 ) + f (xn )).
2
f (x) dx
A
1
dx.
x
Then f (x) = 1/x in the interval [1, 2]. If we take h = 1/2, then we have
x
f (x)
3
2
2
3
2
1
2
and so
Z
1
1
dx
x
4
4 1
1+ +
3 2
5
4
4
5
3
2
2
3
= 0.7083 (4dp).
f (x)
7
4
4
7
2
1
2
and so
Z
1
Chapter 11 : Numerical Integration
1
1
dx
x
8
8 4 8 1
1+ + + +
= 0.6970 (4dp).
5 3 7 2
page 2 of 10
f (x) dx,
A
where the function f (x) is finite and continuous in the closed interval [A, B].
Consider the point C = 21 (A + B), the midpoint in the interval [A, B] (the reader should draw a
diagram). We take the approximation
Z
f (x) dx (B A)f
A+B
2
.
(3)
Suppose that we divide the interval [A, B] into n subintervals by the dissection
A = x0 < x1 < . . . < xn = B,
and make a similar approximation as (3) in each of the subintervals, so that for every i = 1, . . . , n, we
have
Z xi
xi1 + xi
.
f (x) dx (xi xi1 )f
2
xi1
Then we have the approximation
Z
n
X
xi1 + xi
f (x) dx
(xi xi1 )f
.
2
i=1
(4)
Suppose further that the lengths of all the subintervals are the same, so that
xi xi1 = h =
BA
n
for every i = 1, . . . , n.
f (x) dx h
A
n
X
xi1 + xi
f
.
2
i=1
Z
1
1
dx.
x
Then f (x) = 1/x in the interval [1, 2]. If we take h = 1/2, then we have
x
f (x)
Chapter 11 : Numerical Integration
(1)
5
4
4
5
( 32 )
7
4
4
7
(2)
page 3 of 10
and so
2
Z
1
1
1
dx
x
2
4 4
+
5 7
= 0.6857 (4dp).
( 54 )
9
8
8
9
(1)
f (x)
11
8
8
11
( 32 )
13
8
8
13
( 74 )
15
8
8
15
(2)
and so
Z
1
1
dx
x
4
8
8
8
8
+
+
+
9 11 13 15
= 0.6912 (4dp).
f (x) dx,
A
where the function f (x) is finite and continuous in the closed interval [A, B].
In both the Trapezium rule and the Midpoint rule, a crude approximation to the area under the curve
is obtained by replacing the curve between x = A and x = B by a straight line segment; in other words,
a polynomial of degree 1. A natural extension of this idea is to replace the curve by a parabola; in other
words, a polynomial of degree 2, passing through the points (A, f (A)), (B, f (B)) and (C, f (C)), where
C = 21 (A + B).
Consider first the simple case A = H and B = H, so that C = 0. We wish to fit a parabola
p(x) = x2 + x +
through these points. Then
H 2 H + = f (H),
= f (0),
2
H + H + = f (H),
so that
f (H) 2f (0) + f (H)
,
2H 2
f (H) f (H)
=
,
2H
= f (0).
f (x) dx
H
(x2 + x + ) dx =
2
H
H 3 + 2H = (f (H) + 4f (0) + f (H)).
3
3
page 4 of 10
In general, if we wish to use this approximation over the interval [A, B], the above becomes
Z
f (x) dx
A
BA
6
f (A) + 4f
A+B
2
+ f (B) .
BA
n
for every i = 1, . . . , n.
f (x) dx
A
h
f (x0 ) + f (xn ) + 4
3
n1
X
f (xi ) + 2
n1
X
f (xi ) .
i=1
i even
i=1
i odd
This is called Simpsons rule for (n + 1) ordinates, where n is even. Note that the coefficients for
f (x0 ), f (x1 ), f (x2 ), . . . , f (xn )
are respectively
1, 4, 2, 4, 2, 4, 2, . . . , 4, 2, 4, 1.
Example 11.4.1. We wish to estimate the value of log 2 by a Simpson rule approximation to the integral
Z
1
dx.
x
Then f (x) = 1/x in the interval [1, 2]. If we take h = 1/2, hence 3 ordinates, then we have
x
f (x)
3
2
2
3
2
1
2
and so
Z
1
1
1
dx
x
6
1+
8 1
+
3 2
= 0.6944 (4dp).
f (x)
5
4
4
5
3
2
2
3
7
4
4
7
2
1
2
page 5 of 10
and so
Z
1
1
dx
x
12
1+
16 4 16 1
+ +
+
5
3
7
2
= 0.6933 (4dp).
BA
n
for every i = 1, . . . , n,
f (x) dx
Tn =
A
h
(f (x0 ) + 2f (x1 ) + 2f (x2 ) + . . . + 2f (xn1 ) + f (xn )).
2
Then
|Tn |
K(B A)3
K(B A)h2
=
,
12n2
12
where
K = max |f 00 (x)|.
x[A,B]
Furthermore, if f 00 (x) does not change sign in the interval [A, B], then Tn has the opposite sign to the
sign of f 00 (x) in this interval.
PROPOSITION 11B. Suppose that the function f (x) is finite and continuous in the closed interval
[A, B], and that the second derivative f 00 (x) exists for every x (A, B). Suppose further that the Midpoint
rule, applied to the dissection
A = x0 < x1 < . . . < xn = B
of [A, B] into n subintervals, where
xi xi1 = h =
Chapter 11 : Numerical Integration
BA
n
for every i = 1, . . . , n,
page 6 of 10
Mn =
A
n
X
xi1 + xi
f (x) dx h
.
f
2
i=1
Then
|Mn |
K(B A)3
K(B A)h2
=
,
2
24n
24
where
K = max |f 00 (x)|.
x[A,B]
Furthermore, if f 00 (x) does not change sign in the interval [A, B], then Mn has the same sign as the sign
of f 00 (x) in this interval.
Example 11.5.1. In our Trapezium and Midpoint rule approximation to log 2, we have used the function
f (x) = 1/x in the interval [1, 2]. Note that f 00 (x) = 2/x3 > 0 in this interval. It follows that Tn < 0
and Mn > 0. This means that our Trapezium rule estimates are over-estimates, and our Midpoint rule
estimates are under-estimates.
The corresponding result for Simpsons rule is somewhat different.
PROPOSITION 11C. Suppose that the function f (x) is finite and continuous in the closed interval
[A, B], and that the fourth derivative f 0000 (x) exists for every x (A, B). Suppose further that Simpsons
rule, applied to the dissection
A = x0 < x1 < . . . < xn = B
of [A, B] into n subintervals, where n is even and
xi xi1 = h =
BA
n
for every i = 1, . . . , n,
f (x) dx
Sn =
A
h
f (x0 ) + f (xn ) + 4
3
n1
X
f (xi ) + 2
i=1
i odd
n1
X
f (xi ) .
i=1
i even
Then
|Sn |
L(B A)5
L(B A)h4
=
,
180n4
180
where
L = max |f 0000 (x)|.
x[A,B]
Furthermore, if f 0000 (x) does not change sign in the interval [A, B], then Sn has the opposite sign to the
sign of f 0000 (x) in this interval.
Example 11.5.2. In our Simpson rule approximation to log 2, we have used the function f (x) = 1/x in
the interval [1, 2]. Note that f 0000 (x) = 24/x5 > 0 in this interval. It follows that Sn < 0. This means
that our estimates are over-estimates.
Chapter 11 : Numerical Integration
page 7 of 10
I=
f (x) dx.
A
Consider first of all the Trapezium rule. Suppose that f 00 (x) does not change sign in the interval
[A, B]. Suppose further that T (h) denotes the Trapezium rule approximation to I with a given h. Then
in view of Proposition 11A, we have
I T (h) CT (B A)h2 ,
where CT is a constant, so that
I T (h)
CT (B A).
h2
Repeating the same argument on the Trapezium rule approximation to I with h/2, we have
I T (h/2)
CT (B A).
(h/2)2
It follows that
I T (h/2)
I T (h)
,
h2
(h/2)2
so that I T (h) 4(I T (h/2)), whence
I
4T (h/2) T (h)
.
3
and
Hence
I
4(0.6970) (0.7083)
0.6932.
3
Consider next the Midpoint rule. Suppose that f 00 (x) does not change sign in the interval [A, B].
Suppose further that M (h) denotes the Midpoint rule approximation to I with a given h. Then in view
of Proposition 11B, we have
I M (h) CM (B A)h2 ,
where CM is a constant, so that
I M (h)
CM (B A).
h2
Repeating the same argument on the Midpoint rule approximation to I with h/2, we have
I M (h/2)
CM (B A).
(h/2)2
Chapter 11 : Numerical Integration
page 8 of 10
It follows that
I M (h/2)
I M (h)
,
h2
(h/2)2
so that I M (h) 4(I M (h/2)), whence
I
4M (h/2) M (h)
.
3
and
Hence
I
4(0.6912) (0.6857)
0.6930.
3
Consider finally Simpsons rule. Suppose that f 0000 (x) does not change sign in the interval [A, B].
Suppose further that S(h) denotes the Simpson rule approximation to I with a given h. Then in view
of Proposition 11C, we have
I S(h) CS (B A)h4 ,
where CS is a constant, so that
I S(h)
CS (B A).
h4
Repeating the same argument on the Simpson rule approximation to I with h/2, we have
I S(h/2)
CS (B A).
(h/2)4
It follows that
I S(h)
I S(h/2)
,
4
h
(h/2)4
so that I S(h) 16(I S(h/2)), whence
I
16S(h/2) S(h)
.
15
and
Hence
I
16(0.6933) (0.6944)
0.6932.
15
page 9 of 10
1
dx.
2
0 1+x
Find the Trapezium rule approximation with 2 intervals.
Find the Trapezium rule approximation with 4 intervals.
Find the Midpoint rule approximation with 2 intervals.
Find the Midpoint rule approximation with 4 intervals.
Discuss whether the estimates in (a)(d) are over-estimates or under-estimates. Justify your
assertions.
Find the Simpson rule approximation with 2 intervals.
Find the Simpson rule approximation with 4 intervals.
Use Richardson extrapolation on your results in (a)(d).
What number are we approximating?
page 10 of 10