# Definite Integrals, Part 2: The Composite Trapezoid and Midpoint Rules

## Contents

# 23. Definite Integrals, Part 2: The Composite Trapezoid and Midpoint Rules#

**References:**

Section 5.2.4 of Sauer

Section 4.4 of Burden&Faires

## 23.1. Introduction#

The “elementary” integral approximations of the definite integral

seen in the previous section the Trapzoid Rule

and the Midpoint Rule

are of course of very low accuracy in themselves. They are however central building blocks for various more accurate methods and also for some good methods for numerical solution of differential equations.

The basic strategy for improving accuracy is to derive the domain of integration \([a, b]\) into numerous smaller intervals, and use these rules on each such sub-interval: the *composite* rules.

In turn, the most straightforward way to do this is to use \(n\) sub-intervals of equal width \(h = (b-a)/n\), so that the sub-interval endpoints are \(x_0 = a + ih\), \(0 \leq i \leq n\): that is

sub-intervals \([x_{i-1}, x_i]\), \(1 \leq i \leq n\) separated by the nodes.

### 23.1.1. The Composite Midpoint Rule#

Using the Midpoint Rule on each interval and summing gives a formula that could be familiar:

This is a *Riemann Sum* as used in the definition of the defnite integral; possibly the best and natural one in most situations, by using the midpoints of each interval.
The theory of definite integrals also guarantees that \(M_n \to I\) as \(n \to \infty\) so long as the function \(f\) is continuous — the next question for us will be “how fast?*

### 23.1.2. The Composite Trapezoid Rule#

Using the Tapezoid Rule on each interval instead gives

This is also a Riemann sum, with intervals if length \(h/2\) at each end, using value at teh ends of thos intervals, and the rest of width \(h\), with the Midpoint Rule used. So again, we know that \(T_n \to I\) as \(n \to \infty\) and next want to know “how fast?*

### 23.1.3. Accuracy and Error Formulas#

In brief, the errors for ech of rhese rules is the sum of the errors for each of the pieces; I will just state them for now.

Firstly,

This can be rewitten as

and as we will see, this sum can have each \(f''(\xi_i)\) replace by an “average value” \(f''(\xi_i)\), \(\xi \in[a, b]\):

and the most important conclusion for now is that

Similarly,

again with \(\xi \in[a, b]\), but note well: these two \(\xi\) values are probably not the same!

## 23.2. Cancelling Some Error Terms: The Composite Simpson’s Rule#

Ignoring the \(\xi\) values being different, this suggests again that we can cancel some of the errors wi ha weighted average:

Indeed we will see that the main, \(O(h^2)\), errors cancel out, and also due to symmetry, the error is even in \(h\), so that

The name is because this is the *Composite Simpson’s Rule*, and the interleaving of the different \(x\) values used by \(M_n\) and \(T_n\) means that is uses \(2n+1\) nodes, and so \(2n\) sub-intervals.

### 23.2.1. The Missing Step: A Generalized Mean Value Theorem#

A key step in getting more useful error formulas for approximations of integrals is the following result:

**Theorem**

For any continuous function \(f\) on an interval \([a, b]\) and any collection of points \(x_i \in [a,b]\), \(1 \leq i \leq n\), there is a point \(\xi \in [a,b]\) for which

That is, the value of the function at \(c\) is the average of its values at those other points.

*Proof:*

The proof is rather similar to that of Theorme 3 in th previos section; essenrial repaltin teh interal tehr by a sum here:

*As \(f\) is continuous on the closed, bounded interval \([a, b]\), the Extreme Value Theorem from calculus says that \(f\) has a minimum \(L\) and a maximum \(H\) on this interval.
Each of the values \(f(x_i)\) is in interval \([L, H]\) so their average is also:*

*The Mean Value Theorem then says that \(f\) attains this mean value for some \(\xi \in [L, H]\).*

### 23.2.2. Completing the derivation of the error formulas for these composite rules#

I will spell this out for the Composite Trapezoid Rule; it works very similarly for the “midpoint” case.

First, break the exact integral up as

Similarly,

where each \(T^{(i)}\) is the Trapezoid Rule approximation of \(I^{(i)}\):

The error in \(T_n\) is the sum of the errors in each piece:

Now we can use the above mean value result (with \(f''\) in place of \(f\)) to replace the last sum above by \(n f''(\xi)\), some \(\xi \in [a, b]\), so that as claimed,

using \(h n = b-a\).

### 23.2.3. Another error formula, useful for Richardson Extrapolation#

Starting from

note that the sum in the second version is a Riemann sum for approximating the integral

so it seems that

A virtue of this form is that now we have a good chance of evaluating the coefficient of \(h^2\), so this given a “practical error formula” when \(f'(x)\) is known.

Another useful fact (not proven in these notes) is that the error for the basic Trapezoid rule can be computed with the help of Taylor’s Theorem in a series:

(where \(B_2 = 1/12\) as seen above).

Putting the higher power terms into the above argument one can get

so that

The last form is the setup for Richardson extrapolation —
and the previous one with a succession of “big-O” terms is the setup for *repeated* Richardson extrapolation,
to get a succession of approximations with errors \(O(h^2)\), then \(O(h^4)\), then \(O(h^6)\), and so on:
Definite Integrals, Part 4: Romberg Integration

There are similar formulas for the Composite Midpoint Rule, like

but we will see why the Composite Trapezoid Rule is far more useful for Richardson extrapolation.

## 23.3. Appendix: The Composite Left-hand Endpoint Rule, and its Error#

The Composite Left-hand Endpoint Rule with \(n\) sub-intervals of equal width \(h = (b-a)/n\) is

To study its errors, start as with the Compound Trapezoid Rule: break the integral up as

and the approximation as

where each \(L^{(i)}\) is the Left-hand Endpoint Rule approximation of \(I^{(i)}\):

Then the error in \(L_n\) is again the sum of the errors in each piece:

The Generalized Mean Value Theorem — now with \(f'\) in place of \(f\) — allows us to replace the last sum above by \(n f'(\xi)\), some \(\xi \in [a, b]\), so that as claimed,

**Aside:** As with the Composite Trapezoid Rule, one can also get

This work is licensed under Creative Commons Attribution-ShareAlike 4.0 International