4.11 Trapezoidal Rule
4.11 Trapezoidal Rule
4.11 Trapezoidal Rule
11 Trapezoidal Rule
If n = 1 (one panel), as illustrated in Figure 6.2, we have l0 = (x − x1)/(x0 − x1) = −(x − b)/ h. Therefore,
(6.3)
which is known as the trapezoidal rule. It represents the area of the trapezoid in Figure 6.2.
is the area of the region between f(x) and the straight-line interpolant, as indicated in Figure 6.2. It can be obtained by integrating the interpolation error in Eq. (3.3):
(6.4)
In practice, the trapezoidal rule is applied in a piecewise fashion. Figure 6.3 shows the region (a, b) divided into n panels, each of width h. The function f(x) to be integrated is
approximated by a straight line in each panel. From the trapezoidal rule, we obtain for the approximate area of a typical (ith) panel,
b
Hence the total area, representing ∫ f (x) dx, is
(6.5)
where ξi lies in (xi, xi+1). Hence the truncation error in Eq. (6.5) is
(a)
But
where f¯'' is the arithmetic mean of the second derivatives. If f''(x) is continuous, there must be a point ξ in (a, b) at which f''(ξ) = f¯'', enabling us to write
(6.6)
It would be incorrect to conclude from Eq. (6.6) that E = ch2 (c being a constant), because f''(ξ) is not entirely independent of h. A deeper analysis of the error shows that if f(x)
and its derivatives are finite in (a, b), then
(6.7)
Let Ik be the integral evaluated with the composite trapezoidal rule using 2k−1 panels. Note that if k is increased by one, the number of panels is doubled. Using the notation
H=b−a
k = 1 (one panel):
(6.8)
k = 2 (two panels):
(6.9a)
which is the recursive trapezoidal rule. Observe that the summation contains only the new nodes that were created when the number of panels was doubled. Therefore, the
computation of the sequence I1, I2, I3, . . . , Ik from Eqs. (6.8) and (6.9) involves the same amount of algebra as the calculation of Ik directly from Eq. (6.5). The advantage of
using the recursive trapezoidal rule is that it allows us to monitor convergence and terminate the process when the difference between Ik−1 and Ik becomes sufficiently small. A
form of Eq. (6.9a) that is easier to remember is
(6.9b)
where h = H/n is the width of each panel.
Illustrative Example:
π
Evaluate the bounds on ∫ sin(x)dx with the composite trapezoidal rule using (1) 8 panels; and (2) 16 panels.
Solution of Part (1). With eight panels there are nine nodes spaced at h = π/8. The abscissas of the nodes are xi = iπ/8, i = 0, 1, . . . , 8. From Eq. (6.5) we get
where 0 < ξ < π. Because we do not know the value of ξ, we cannot evaluate E, but we can determine its bounds:
π
Therefore, I + Emin < ∫ sin(x)dx < I + Emax, or
0
The exact integral is, of course, 2.
Solution of Part (2). The new nodes created by the doubling of panels are located at the midpoints of the old panels. Their abscissas are
and the bounds on the error become (note that E is quartered when h is halved)
Reference:
Kiusalaas, J. (2013). Numerical Methods in Engineering with Python 3. USA: Cambridge University Press.