## The Midpoint and Trapezoidal Rules

### Learning Outcomes

• Approximate the value of a definite integral by using the midpoint and trapezoidal rules

## The Midpoint Rule

Earlier in this text we defined the definite integral of a function over an interval as the limit of Riemann sums. In general, any Riemann sum of a function $f\left(x\right)$ over an interval $\left[a,b\right]$ may be viewed as an estimate of ${\displaystyle\int }_{a}^{b}f\left(x\right)dx$. Recall that a Riemann sum of a function $f\left(x\right)$ over an interval $\left[a,b\right]$ is obtained by selecting a partition

$P=\left\{{x}_{0},{x}_{1},{x}_{2}, \ldots,{x}_{n}\right\},\text{ where }a={x}_{0}<{x}_{1}<{x}_{2}<\cdots <{x}_{n}=b$

and a set

$S=\left\{{x}_{1}^{*},{x}_{2}^{*},\ldots ,{x}_{n}^{*}\right\},\text{ where }{x}_{i - 1}\le {x}_{i}^{*}\le {x}_{i}\text{ for all }i$.

The Riemann sum corresponding to the partition $P$ and the set $S$ is given by $\displaystyle\sum _{i=1}^{n}f\left({x}_{i}^{*}\right)\Delta {x}_{i}$, where $\Delta {x}_{i}={x}_{i}-{x}_{i - 1}$, the length of the ith subinterval.

The midpoint rule for estimating a definite integral uses a Riemann sum with subintervals of equal width and the midpoints, ${m}_{i}$, of each subinterval in place of ${x}_{i}^{*}$. Formally, we state a theorem regarding the convergence of the midpoint rule as follows.

### The Midpoint Rule

Assume that $f\left(x\right)$ is continuous on $\left[a,b\right]$. Let n be a positive integer and $\Delta x=\frac{b-a}{n}$. If $\left[a,b\right]$ is divided into $n$ subintervals, each of length $\Delta x$, and ${m}_{i}$ is the midpoint of the ith subinterval, set

${M}_{n}=\displaystyle\sum _{i=1}^{n}f\left({m}_{i}\right)\Delta x$.

Then $\underset{n\to \infty }{\text{lim}}{M}_{n}={\displaystyle\int }_{a}^{b}f\left(x\right)dx$.

As we can see in Figure 1, if $f\left(x\right)\ge 0$ over $\left[a,b\right]$, then $\displaystyle\sum _{i=1}^{n}f\left({m}_{i}\right)\Delta x$ corresponds to the sum of the areas of rectangles approximating the area between the graph of $f\left(x\right)$ and the x-axis over $\left[a,b\right]$. The graph shows the rectangles corresponding to ${M}_{4}$ for a nonnegative function over a closed interval $\left[a,b\right]$.

### Example: Using the Midpoint Rule with ${M}_{4}$

Use the midpoint rule to estimate ${\displaystyle\int }_{0}^{1}{x}^{2}dx$ using four subintervals. Compare the result with the actual value of this integral.

### Example: Using the Midpoint Rule with ${M}_{6}$

Use ${M}_{6}$ to estimate the length of the curve $y=\frac{1}{2}{x}^{2}$ on $\left[1,4\right]$.

### try it

Use the midpoint rule with $n=2$ to estimate ${\displaystyle\int }_{1}^{2}\frac{1}{x}dx$.

## The Trapezoidal Rule

We can also approximate the value of a definite integral by using trapezoids rather than rectangles. In Figure 2, the area beneath the curve is approximated by trapezoids rather than by rectangles.

The trapezoidal rule for estimating definite integrals uses trapezoids rather than rectangles to approximate the area under a curve. To gain insight into the final form of the rule, consider the trapezoids shown in Figure 2. We assume that the length of each subinterval is given by $\Delta x$. First, recall that the area of a trapezoid with a height of h and bases of length ${b}_{1}$ and ${b}_{2}$ is given by $\text{Area}=\frac{1}{2}h\left({b}_{1}+{b}_{2}\right)$. We see that the first trapezoid has a height $\Delta x$ and parallel bases of length $f\left({x}_{0}\right)$ and $f\left({x}_{1}\right)$. Thus, the area of the first trapezoid in Figure 2 is

$\frac{1}{2}\Delta x\left(f\left({x}_{0}\right)+f\left({x}_{1}\right)\right)$.

The areas of the remaining three trapezoids are

$\frac{1}{2}\Delta x\left(f\left({x}_{1}\right)+f\left({x}_{2}\right)\right),\frac{1}{2}\Delta x\left(f\left({x}_{2}\right)+f\left({x}_{3}\right)\right),\text{and}\frac{1}{2}\Delta x\left(f\left({x}_{3}\right)+f\left({x}_{4}\right)\right)$.

Consequently,

${\displaystyle\int }_{a}^{b}f\left(x\right)dx\approx \frac{1}{2}\Delta x\left(f\left({x}_{0}\right)+f\left({x}_{1}\right)\right)+\frac{1}{2}\Delta x\left(f\left({x}_{1}\right)+f\left({x}_{2}\right)\right)+\frac{1}{2}\Delta x\left(f\left({x}_{2}\right)+f\left({x}_{3}\right)\right)+\frac{1}{2}\Delta x\left(f\left({x}_{3}\right)+f\left({x}_{4}\right)\right)$.

After taking out a common factor of $\frac{1}{2}\Delta x$ and combining like terms, we have

${\displaystyle\int }_{a}^{b}f\left(x\right)dx\approx \frac{1}{2}\Delta x\left(f\left({x}_{0}\right)+2f\left({x}_{1}\right)+2f\left({x}_{2}\right)+2f\left({x}_{3}\right)+f\left({x}_{4}\right)\right)$.

Generalizing, we formally state the following rule.

### The Trapezoidal Rule

Assume that $f\left(x\right)$ is continuous over $\left[a,b\right]$. Let n be a positive integer and $\Delta x=\frac{b-a}{n}$. Let $\left[a,b\right]$ be divided into $n$ subintervals, each of length $\Delta x$, with endpoints at $P=\left\{{x}_{0},{x}_{1},{x}_{2}\ldots ,{x}_{n}\right\}$. Set

${T}_{n}=\frac{1}{2}\Delta x\left(f\left({x}_{0}\right)+2f\left({x}_{1}\right)+2f\left({x}_{2}\right)+\cdots +2f\left({x}_{n - 1}\right)+f\left({x}_{n}\right)\right)$.

Then, $\underset{n\to \text{+}\infty }{\text{lim}}{T}_{n}={\displaystyle\int }_{a}^{b}f\left(x\right)dx$.

Before continuing, let’s make a few observations about the trapezoidal rule. First of all, it is useful to note that

${T}_{n}=\frac{1}{2}\left({L}_{n}+{R}_{n}\right)\text{where}{L}_{n}=\displaystyle\sum _{i=1}^{n}f\left({x}_{i - 1}\right)\Delta x\text{and}{R}_{n}=\displaystyle\sum _{i=1}^{n}f\left({x}_{i}\right)\Delta x$.

That is, ${L}_{n}$ and ${R}_{n}$ approximate the integral using the left-hand and right-hand endpoints of each subinterval, respectively. In addition, a careful examination of Figure 3 leads us to make the following observations about using the trapezoidal rules and midpoint rules to estimate the definite integral of a nonnegative function. The trapezoidal rule tends to overestimate the value of a definite integral systematically over intervals where the function is concave up and to underestimate the value of a definite integral systematically over intervals where the function is concave down. On the other hand, the midpoint rule tends to average out these errors somewhat by partially overestimating and partially underestimating the value of the definite integral over these same types of intervals. This leads us to hypothesize that, in general, the midpoint rule tends to be more accurate than the trapezoidal rule.

### Example: Using the Trapezoidal Rule

Use the trapezoidal rule to estimate ${\displaystyle\int }_{0}^{1}{x}^{2}dx$ using four subintervals.

Watch the following video to see the worked solution to Example: Using the Trapezoidal Rule

For closed captioning, open the video on its original page by clicking the Youtube logo in the lower right-hand corner of the video display. In YouTube, the video will begin at the same starting point as this clip, but will continue playing until the very end.

### try it

Use the trapezoidal rule with $n=2$ to estimate ${\displaystyle\int }_{1}^{2}\frac{1}{x}dx$.