Topic 13.2: Composite-Trapezoidal Rule (Examples)

Contents Previous Chapter Start of Chapter Previous Topic Introduction Notes Theory HOWTO Examples Engineering Error Questions Matlab Maple Next Topic Next Chapter

Example 1.

Approximate the integral of f(x) = x3 on the interval [1, 2] with four subintervals.

First, h = (2 - 1)/4 = 0.25, and thus we calculate:

½⋅(f(1) + 2⋅(f(1.25) + f(1.5) + f(1.75)) + f(2))⋅0.25
= ½⋅(13 + 2⋅(1.253 + 1.53 + 1.753) + 23)⋅0.25 = 3.796875

If we double the number of intervals, that is, eight, we set h = (2 - 1)/8 = 0.125, and thus we calculate:

½⋅(f(1)+2⋅(f(1.125)+f(1.25)+f(1.375)+f(1.5)+f(1.625)+f(1.75)+f(1.875))+f(2))⋅0.125
= ½⋅(13+2⋅(1.1253+1.253+1.3753+1.53+1.6253+1.753+1.8753)+23)⋅0.25 = 3.76171875

The second approximation is much closer to the correct answer of 3.75.

Example 2

Find the integral of the function f(x) = e-xsin(x) on the interval [0, 3], with N = 10 and εstep = 0.001. In this case, the initial width is h = 3.0 and therefore T0 = 0.010539. The subsequent iterations are shown in Table 1.

Table 1. The composite-trapezoidal rule applied to f(x) = e-xsin(x).

nTn − 1Tn|Tn - Tn − 1|
10.0105390.339130.33
20.33913 0.472560.13
30.47256 0.508810.036
40.50881 0.518040.0092
50.51804 0.520360.0023
60.52036 0.520940.00058

Thus, our approximation to the integral is 0.52094 which has an absolute error of 0.00019 (or relative error of less than 0.04%) when compared to the correct five digit approximation 0.52113.

Copyright ©2005 by Douglas Wilhelm Harder. All rights reserved.