Chapter 8
Integral Calculus and Its Uses





8.3 Numerical Approximation of Integrals

8.3.2 The Midpoint and Trapezoidal Rules

In the discussions of Activity 1 and Activity 2 we ignored a better idea staring us in the face. We observed that the errors for RHS and LHS are approximately equal with opposite signs; i.e., the value of the integral lies roughly halfway between these two approximations. Let's average the two sums and use that average as a new approximation to the integral.

As in Activity 4, we write the left-hand sums and right-hand sums in the form

RHS = [ f ( x 1 ) + f ( x 2 )   +   ⋅⋅⋅   +   f ( x n - 1 ) + f ( x n ) ] Δ x ;
LHS = [ f ( x 0 ) + f ( x 1 ) + ⋅⋅⋅ + f ( x n - 2 ) + f ( x n - 1 )       ] Δ x .

Now we add column by column and divide by \(2\) to find that the average of LHS and RHS is

LHS + RHS 2 = [ f ( x 0 ) + f ( x 1 ) 2 + f ( x 1 ) + f ( x 2 ) 2 + ⋅⋅⋅ + f ( x n - 1 ) + f ( x n ) 2 ] Δ x .

If you have already calculated LHS and RHS, you don't need a new formula to average them - just add and divide by \(2\). But if you are starting from scratch, the right-hand side of this equation reveals both a way to calculate the average and an interesting fact about it: It is also a sum of terms, and the terms themselves (after factoring out \(\Delta x\)) are averages of the \(y\)-coordinates that were summed in LHS and RHS. In the notation of moments and centers of mass, this formula can be rewritten

LHS + RHS 2 = ( y ¯ 1 + y ¯ 2 + ⋅⋅⋅ + y ¯ n - 1 + y ¯ n ) Δ x .

This suggests another good idea: Instead of averaging \(y\)-coordinates, why not average \(x\)-coordinates? That is, instead of calculating function values at the endpoints (\(x_0\), \(x_1,\,x_2\), and so on), why not calculate them at the midpoints (\(\bar{x}_1,\,\bar{x}_2,\,\bar{x}_3\), and so on)? This leads to an approximating sum for the definite integral that has the obvious name Midpoint Rule and the equally obvious abbreviation MR:

MR = [ f ( x ¯ 1 ) + f ( x ¯ 2 ) + ⋅⋅⋅ + f ( x ¯ n - 1 ) + f ( x ¯ n ) ] Δ x ,

where, for each \(k\) from \(1\) to \(n\), \(\bar{x}_k=\frac{x_{k-1}+x_k}{2}\). The average of left and right sums has a less obvious name and abbreviation: For reasons we will explore in Problem 2, it is called the Trapezoidal Rule, abbreviated TR. Thus

TR = ( y ¯ 1 + y ¯ 2 + ⋅⋅⋅ + y ¯ n - 1 + y ¯ n ) Δ x ,

where, for each \(k\) from \(1\) to \(n\), \(\bar{y}_k=\frac{f(x_{k-1})+f(x_k)}{2}\).

Now that we have two new ideas for approximating integrals, how good are they? In Table 3 we show the values for MR and TR that correspond to the entries of Table 2 - same function, same interval, same values of \(n\).

Table 3   Approximations to \(\displaystyle\int_1^{\,3} \frac{1}{x} dx = \ln(3) \approx 1.098612288668\)
\(n\) Midpoint Rule (MR) Trapezoid Rule (TR) Error in MR Error in TR
  10    1.097142    1.101562    -0.00147    0.00295
  100    1.09859748    1.09864192    -0.0000148    0.0000296
  1000    1.0986121405    1.0986125850    -0.000000148    0.000000296

Activity 5

  1. What patterns do you observe in the error columns of Table 3? Consider, in particular, how the errors decrease as \(n\) increases, which method underestimates and which overestimates, and how the MR errors are related to the TR errors.

  2. For this particular integral, how big does \(n\) have to be to achieve six-decimal-place accuracy with MR? with TR?

Comment 1Comment on Activity 5

sum animation Animation  The pop-up animation illustrates geometrically how the Midpoint Rule "fills in" the region between the graph of \(f(x)\) and the \(x\)-axis as \(n\) increases. In order to have enough steps to see the progression, we double \(n\) at each step instead of multiplying by \(10\). Up to \(64\) steps, you can still see slight differences between the rectangular approximations and the curve, but the "positive" and "negative" differences roughly balance each other. We explore the significance of this balancing in Problems 3 and 4. Our similar animation for the Trapezoidal Rule is on the Problems page with Problem 2.

Now we're getting somewhere! Sums with \(1000\) terms are easily evaluated by a computer - that's where our table entries came from. On the other hand, you might have a little trouble getting such sums from a calculator. When you calculate an integral on a calculator, you can probably tell from the speed of operation of the calculator's integral key that it isn't adding that many terms. The programmers are using (at least) one more good idea.

Go to Back One Page Go Forward One Page

Contents for Chapter 8