Numerical Integration
Numerical Integration
under the straight line connecting f (a) and f (b). An estimate for the local trun-
2
cation error of a single application of the trapezoidal rule can be obtained using
Taylor series as
1 00
Et = − f (ξ)(b − a)3
12
where ξ is a value between a and b.
Example: Use the trapezoidal rule to numerically integrate
f (x) = 0.2 + 25x
from a = 0 to b = 2.
Solution: f (a) = f (0) = 0.2, and f (b) = f (2) = 50.2.
f (b) + f (a) 0.2 + 50.2
I = (b − a) = (2 − 0) × = 50.4
2 2
The true solution is
Z 2
f (x)dx = (0.2x + 12.5x2)|20 = (0.2 × 2 + 12.5 × 22) − 0 = 50.4
0
Because f (x) is a linear function, using the trapezoidal rule gets the exact solu-
tion.
Example: Use the trapezoidal rule to numerically integrate
f (x) = 0.2 + 25x + 3x2
3
from a = 0 to b = 2.
Solution: f (0) = 0.2, and f (2) = 62.2.
f (b) + f (a) 0.2 + 62.2
I = (b − a) = (2 − 0) × = 62.4
2 2
The true solution is
Z 2
f (x)dx = (0.2x + 12.5x2 + x3)|20 = (0.2 × 2 + 12.5 × 22 + 23) − 0 = 58.4
0
4
Multiple-application trapezoidal rule:
Using smaller integration interval can reduce the approximation error. We can
divide the integration interval from a to b into a number of segments and apply
the trapezoidal rule to each segment. Divide (a, b) into n segments of equal
width. Then
Z b Z x1 Z x2 Z xn
I= f (x)dx = f (x)dx + f (x)dx + . . . + f (x)dx
a x0 x1 xn−1