Numerical Integration
Numerical Integration
There
Z b are two situations in which it is impossible to find the exact value of a definite integral
f (x) dx.
a
1. The first situation is when it impossible to find the antiderivative of f . For example,
it is impossible to evaluate the following integrals exactly:
Z 1 Z 1√
x2
e dx, 1 + x3 dx
0 −1
2. The second situation arises when the function is determined from a scientific experiment
through instrument readings or collected data. There may be no formula for the
function.
In both cases we need to find approximate values of definite integrals. In this section we
shall discuss some of these different approximation/numerical techniques.
We approximate the area under the curve by summing up the areas of the trapezoids. This
is called the Trapezoidal Rule.
Z b
b−a
f (x) dx ≈ [(f (x0 ) + f (x1 )) + (f (x1 ) + f (x2 )) +
a 2n
· · · + (f (xn−1 ) + f (xn ))]
b−a
= [f (x0 ) + 2f (x1 ) + 2f (x2 ) + · · · + 2f (xn−1 ) + f (xn )]
2n
b−a
≈ [f (x0 ) + 2(f (x1 ) + f (x2 ) + · · · + f (xn−1 )) + f (xn )]
2n
Trapezoidal Rule:
Z b
h
f (x) dx = [f (x0 ) + 2(f (x1 ) + f (x2 ) + · · · + f (xn−1 )) + f (xn )]
a 2
b−a
where h = n
Z 4
Example 11.2.1. Use Trapezoidal Rule to approximate the integral x2 dx with (a) n = 4
0
(b) n = 8
Solution:
4−0
(a) h = 4
= 1. So we have
Z 4
1
x2 dx ≈ [f (0) + 2[f (1) + f (2) + f (3)] + f (4)]
0 2
1
= [0 + 2(1 + 4 + 9) + 16]
2
≈ 22 sq. units
4−0
(b) h = 8
= 21 . So we have
Z 4
0.5
x2 dx ≈ [f (0) + 2[f (0.5) + f (1) + f (1.5) + f (2)] + f (2.5)
0 2
+f (3) + f (3.5)] + f (4)]
1
= [0 + 2[0.25 + 1 + 2.25 + 4 + 6.25 + 9 + 12.25] + 16]
4
1 1
= [0 + 2(35) + 16] = · 86
4 4
≈ 21.5 sq. units
Z 4 3 4
2 x 64
Check that the exact area is x dx = = = 21.33
0 3 0 3
Midpoint Rule:
Z b
x0 + x1 x1 + x2 xn−1 + xn
f (x) dx = h f +f + ··· + f
a 2 2 2
b−a
where x0 = a, xn = b h = n
Z 2
1
Example 11.2.2. Use the Midpoint Rule with n = 5 to approximate dx.
1 x
Solution:
With a = 1 and b = 2, we have h = 2−15
= 0.2
Z 2
1 1 + 1.2 1.2 + 1.4 1.4 + 1.6
dx ≈ 0.2 f +f +f +
1 x 2 2 2
1.6 + 1.8 1.8 + 2
f +f
2 2
≈ 0.2 [f (1.1) + f (1.3) + f (1.5) + f (1.7) + f (1.9)]
1 1 1 1 1
≈ 0.2 + + + +
1.1 1.3 1.5 1.7 1.9
≈ 0.691908
We compute the error in Trapezoidal and Midpoint approximations. We work out Example
11.2.2 using Trapezoidal Rule with n = 5. Here h = 2−1
5
= 0.2
Z 2
1 0.2
dx ≈ [f (1) + 2[f (1.2) + f (1.4) + f (1.6) + f (1.8)] + f (2)]
1 x 2
1 2 2 2 2 1
= 0.1 + + + + +
1 1.2 1.4 1.6 1.8 2
≈ 0.695635
Z 2
1
The exact area is dx = ln x|21 = ln 2 = 0.693147 · · · .
1 x
The error in Trapezoidal and Midpoint approximations for n = 5 are:
n Tn Mn ET EM
5 0.695635 0.691908 -0.002488 0.001239
10 0.693771 0.692835 -0.000624 0.000312
20 0.693303 0.693069 -0.000156 0.000078
Table 1 shows the trend in the errors from the approximation of the integral of Example
11.2.2 as we increase the value of n. The following can be deduced from the table:
1. As n increases, the accuracy of the approximation increases
Exercise 11.2.1. Use the Trapezoidal and Midpoint Rules with the specified values of n
below Z
2√ Z 1
1. 3
x − 1 dx; n = 10 2. sin(x3 ) dx; n = 10
1 0
Z 2 Z 4 √
1 t
3. dx; n=8 4. e sin t dt; n=8
0 1 + x6 0
Z 4 √ Z 6
5. ln x dx; n=6 6. ln(x3 + 2) dx; n = 10
1 4
If yi = f (xi ), then P (xi , yi ) is the point on the curve lying above xi . A typical parabola
passes through three consecutive points Pi , Pi+1 and Pi+2 .
Simpson’s Rule:
Z b
h
f (x) dx = [f (x0 ) + 4f (x1 ) + 2f (x2 ) + 4f (x3 ) + 2f (x4 ) + · · ·
a 3
+2f (xn−2 ) + 4f (xn−1 ) + f (xn )]
b−a
where h = n
Z 2
1
Example 11.2.3. Use Simpson’s Rule with n = 10 to approximate dx.
1 x
Solution:
h = 2−1
10
= 0.1. Thus,
Z 2
1 0.1
dx = [f (1) + 4f (1.1) + 2f (1.2) + 4f (1.3) + · · · + 2f (1.8)
1 x 3
+4f (1.9) + f (2)]
0.1 1 4 2 4 2 4 2 4 2
= + + + + + + + +
3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8
4 1
+ +
1.9 2
≈ 0.693150
Note 11.2.1. Notice that Simpson’s Rule give us a much better approximation (S10 ≈
0.693150) to the true value of the integral (0.693147 · · · ) than Trapezoidal (T10 ≈ 0.693771)
or the Midpoint Rule (M10 ≈ 0.692835)
Z 1
x
Exercise 11.2.2. 1. Use Simpson’s Rule with n = 10 to approximate ee dx.
−1
2. The speedometer reading (v) on a car was observed at 1-minute intervals and recorded
in the following chart. Use Simpson’s Rule to estimate the distance traveled by the car.
t (min) 0 1 2 3 4 5 6 7 8 9 10
v(mkm/h) 40 42 45 49 52 54 56 57 57 55 56
References
[1] S. P. Hurd D. F. Wright and B. D. New. Essential Calculus. Hawkes learning System,
Charleston, SC, U.S.A, 2 edition, 2008.
[2] E. J. Purcell D. Verberg and S. E. Rigdon. Calculus. Pearson Prentice Hall, upper Saddle
River, New Jersey, NJ, U.S.A, 9 edition, 2007.
[4] L. Ron and H. E. Bruce. Calculus. Cengage Learning, 11 edition, 2017, ISBN-13: 978-
1337275347.
[5] J. Stewart. Calculus. CENGAGE Learning, Belmont, CA, U.S.A, 8 edition, 2016.