[go: up one dir, main page]

0% found this document useful (0 votes)
236 views8 pages

4.11 Trapezoidal Rule

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 8

4.

11 Trapezoidal Rule

Figure 6.2. Trapezoidal rule.

If n = 1 (one panel), as illustrated in Figure 6.2, we have l0 = (x − x1)/(x0 − x1) = −(x − b)/ h. Therefore,

Also l1 = (x − x0)/(x1 − x0) = (x − a)/ h, so that

Substitution in Eq. (6.2a) yields

(6.3)

which is known as the trapezoidal rule. It represents the area of the trapezoid in Figure 6.2.

The error in the trapezoidal rule

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)

Composite Trapezoidal Rule


Figure 6.3. Composite trapezoidal rule.

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)

which is the composite trapezoidal rule.

The truncation error in the area of a panel is – see Eq. (6.4) —

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

Therefore, Eq. (a) becomes

(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

E = c1h2 + c2h4 + c3h6 + . . .

(6.7)

Recursive Trapezoidal Rule

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

Eq. (6.5) yields the following results for k = 1, 2, and 3.

k = 1 (one panel):

I1 = [f(a) + f(b)] H/2

(6.8)

k = 2 (two panels):

We can now see that for arbitrary k>1 we have

(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

The error is given by Eq. (6.6):

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

xj = π/16 + jπ/8 = (1 + 2j)π/16, j = 0, 1, . . . , 7

Using the recursive trapezoidal rule in Eq. (6.9b), we get

and the bounds on the error become (note that E is quartered when h is halved)

Emin = 0, Emax = 0.040 37/4 = 0.010 09. Hence

Reference:

Kiusalaas, J. (2013). Numerical Methods in Engineering with Python 3. USA: Cambridge University Press.

You might also like