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 [latex]f\left(x\right)[/latex] over an interval [latex]\left[a,b\right][/latex] may be viewed as an estimate of [latex]{\displaystyle\int }_{a}^{b}f\left(x\right)dx[/latex]. Recall that a Riemann sum of a function [latex]f\left(x\right)[/latex] over an interval [latex]\left[a,b\right][/latex] is obtained by selecting a partition

[latex]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[/latex]

 

and a set

[latex]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[/latex].

 

The Riemann sum corresponding to the partition [latex]P[/latex] and the set [latex]S[/latex] is given by [latex]\displaystyle\sum _{i=1}^{n}f\left({x}_{i}^{*}\right)\Delta {x}_{i}[/latex], where [latex]\Delta {x}_{i}={x}_{i}-{x}_{i - 1}[/latex], 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, [latex]{m}_{i}[/latex], of each subinterval in place of [latex]{x}_{i}^{*}[/latex]. Formally, we state a theorem regarding the convergence of the midpoint rule as follows.

The Midpoint Rule


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

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

 

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

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

This figure is a graph of a non-negative function in the first quadrant. The function increases and decreases. The quadrant is divided into a grid. Beginning on the x-axis at the point labeled a = x sub 0, there are rectangles shaded whose heights are approximately the height of the curve. The x-axis is scaled by increments of msub1, x sub 1, m sub 2, x sub 2, m sub 3, x sub 3, m sub 4 and b = x sub 4.

Figure 1. The midpoint rule approximates the area between the graph of [latex]f\left(x\right)[/latex] and the x-axis by summing the areas of rectangles with midpoints that are points on [latex]f\left(x\right)[/latex].

Example: Using the Midpoint Rule with [latex]{M}_{4}[/latex]

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

Example: Using the Midpoint Rule with [latex]{M}_{6}[/latex]

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

try it

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

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.

This figure is a graph of a non-negative function in the first quadrant. The function increases and decreases. The quadrant is divided into a grid. Beginning on the x-axis at the point labeled a = x sub 0, there are trapezoids shaded whose heights are approximately the height of the curve. The x-axis is scaled by increments of a = x sub 0, x sub 1, x sub 2, x sub 3, and b = x sub 4.

Figure 2. Trapezoids may be used to approximate the area under a curve, hence approximating the definite integral.

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 [latex]\Delta x[/latex]. First, recall that the area of a trapezoid with a height of h and bases of length [latex]{b}_{1}[/latex] and [latex]{b}_{2}[/latex] is given by [latex]\text{Area}=\frac{1}{2}h\left({b}_{1}+{b}_{2}\right)[/latex]. We see that the first trapezoid has a height [latex]\Delta x[/latex] and parallel bases of length [latex]f\left({x}_{0}\right)[/latex] and [latex]f\left({x}_{1}\right)[/latex]. Thus, the area of the first trapezoid in Figure 2 is

[latex]\frac{1}{2}\Delta x\left(f\left({x}_{0}\right)+f\left({x}_{1}\right)\right)[/latex].

 

The areas of the remaining three trapezoids are

[latex]\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)[/latex].

 

Consequently,

[latex]{\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)[/latex].

 

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

[latex]{\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)[/latex].

 

Generalizing, we formally state the following rule.

The Trapezoidal Rule


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

[latex]{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)[/latex].

 

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

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

[latex]{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[/latex].

 

That is, [latex]{L}_{n}[/latex] and [latex]{R}_{n}[/latex] 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.

This figure has two graphs, both of the same non-negative function in the first quadrant. The function increases and decreases. The quadrant is divided into a grid. The first graph, beginning on the x-axis at the point labeled a = x sub 0, there are trapezoids shaded whose heights are approximately the height of the curve. The x-axis is scaled by increments of a = x sub 0, xsub1, x sub 2, x sub 3, and b = x sub 4. The second graph has on the x-axis at the point labeled a = x sub 0. There are rectangles shaded whose heights are approximately the height of the curve. The x-axis is scaled by increments of m sub 1, x sub 1, m sub 2, x sub 2, m sub 3, x sub 3, m sub 4 and b = x sub 4.

Figure 3. The trapezoidal rule tends to be less accurate than the midpoint rule.

Example: Using the Trapezoidal Rule

Use the trapezoidal rule to estimate [latex]{\displaystyle\int }_{0}^{1}{x}^{2}dx[/latex] 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.

You can view the transcript for this segmented clip of “3.6.1” here (opens in new window).

try it

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