Introduction to The Trapezoid Rule
While there are many integrals that we can calculate explicitly, there are many others that we cannot. For example, it is impossible to evaluate
That is to say, it can be proved mathematically that no closed-form antiderivative can be written down for the function e ^{− x 2} . Nevertheless, (*) is one of the most important integrals in all of mathematics, for it is the Gaussian probability distribution integral that plays such an important role in statistics and probability.
Thus we need other methods for getting our hands on the value of an integral. One method would be to return to the original definition, that is to the Riemann sums. If we need to know the value of
then we can approximate this value by a Riemann sum
A more accurate approximation could be attained with a finer approximation:
or
The trouble with these “numerical approximations” is that they are calculationally expensive: the degree of accuracy achieved compared to the number of calculations required is not attractive.
Fortunately, there are more accurate and more rapidly converging methods for calculating integrals with numerical techniques. We shall explore some of these in the present section.
It should be noted, and it is nearly obvious to say so, that the techniques of this section require the use of a computer. While the Riemann sum (**) could be computed by hand with some considerable effort, the Riemann sum (*) is all but infeasible to do by hand. Many times one wishes to approximate an integral by the sum of a thousand terms (if, perhaps, five decimal places of accuracy are needed). In such an instance, use of a high-speed digital computer is virtually mandatory.
The Trapezoid Rule
The method of using Riemann sums to approximate an integral is sometimes called “the method of rectangles.” It is adequate, but it does not converge very quickly and it begs more efficient methods. In this subsection we consider the method of approximating by trapezoids.
Let f be a continuous function on an interval [ a, b ] and consider a partition P = {x _{0}, x _{1},..., x _{k}} of the interval. As usual, we take x _{0} = a and x _{k} = b. We also assume that the partition is uniform.
In the method of rectangles we consider a sum of the areas of rectangles. Figure 8.44 shows one rectangle, how it approximates the curve, and what error is made in this particular approximation. The rectangle gives rise to a “triangular” error region (the difference between the true area under the curve and the area of the rectangle). We put quotation marks around the word “triangular” since the region in question is not a true triangle but instead is a sort of curvilinear triangle. If we instead approximate by trapezoids, as in Fig. 8.45 (which, again, shows just one region), then at least visually the errors seem to be much smaller.
Fig. 8.44
Fig. 8.45
In fact, letting Δ x = x _{j} − x _{j −1} as usual, we see that the first trapezoid in the figure has area [ f ( x _{0} ) + f ( x _{1} )] · Δ x /2. The second has area [ f ( x _{1} ) + f ( x _{2} )] · Δ x /2, and so forth. In sum, the aggregate of the areas of all the trapezoids is
It is known that, if the second derivative of f on the interval [ a, b ] does not exceed M then the approximation given by the sum (†) is accurate to within
[By contrast, the accuracy of the method of rectangles is generally not better than where N is an upper bound for the first derivative of f .
We see that the method of trapezoids introduces an extra power of ( b − a ) in the numerator of the error estimate and, perhaps more importantly, an extra factor of k in the denominator.]
Example 1
Calculate the integral
to two decimal places of accuracy.
Solution 1
We first calculate that if f ( x ) = e ^{− x 2} then f″ ( x ) = (4 x ^{2} − 2) e ^{− x 2} and therefore | f″ ( x )| ≤ 2 = M for 0 ≤ x ≤ 1. In order to control the error, and to have two decimal places of accuracy, we need to have
Rearranging this inequality gives
Obviously k = 6 will do.
So we will use the partition P = {0, 1/6, 1/3, 1/2, 2/3, 5/6, 1}. The corresponding trapezoidal sum is
Some tedious but feasible calculation yields then that
We may use a computer algebra utility like Mathematica or Maple to calculate the integral exactly (to six decimal places) to equal 0.746824. We thus see that the answer we obtained with the Trapezoid Rule is certainly accurate to two decimal places. It is not accurate to three decimal places.
It should be noted that Maple and Mathematica both use numerical techniques, like the ones being developed in this section, to calculate integrals. So our calculations merely emulate what these computer algebra utilities do so swiftly and so well.
You Try It : How fine a partition would we have needed to use if we wanted four decimal places of accuracy in the last example? If you have some facility with a computer, use the Trapezoid Rule with that partition and confirm that your answer agrees with Mathematica’s answer to four decimal places.
Example 2
Use the Trapezoid Rule with k = 4 to estimate
Solution 2
Of course we could calculate this integral precisely by hand, but the point here is to get some practice with the Trapezoid Rule. We calculate
A bit of calculation reveals that
Now if we take f (x) = 1/(1 + x ^{2} ) then f″ ( x ) = (6 x ^{2} − 2)/(1 + x ^{2} ) ^{3}. Thus, on the interval [0, 1], we have that | f″ ( x )| ≤ 4 = M . Thus the error estimate for the Trapezoid Rule predicts accuracy of
This suggests accuracy of one decimal place.
Now we know that the true and exact value of the integral is arctan 1 ≈ 0.78539816.... Thus our Trapezoid Rule approximation is good to one, and nearly to two, decimal places—better than predicted.
Find practice problems and solutions for these concepts at: Applications of the Integral Practice Test.