Midpoint and Trapezoidal Rules

Two ways to approximate an integral that beat an endpoint sum, worked on one integral, with the concavity rule for which way each estimate errs.

The two lessons before this one computed integrals exactly, as limits of Riemann sums. Most integrals do not yield to that. Many functions in an applied problem arrive as a table of measurements with no formula, so an approximation is all there is.
Both rules below are as cheap to compute as an endpoint sum and much more accurate. The first is a Riemann sum with a particular choice of sample point. The second gives up rectangles altogether.

The Midpoint Rule

Take the height of each rectangle at the midpoint of its subinterval rather than at an end.
It is a Riemann sum like any other, so the definition of the definite integral already covers it.

A midpoint estimate

Approximate the integral of 1x\frac{1}{x} from 11 to 33 using four subintervals.
131xdx\int_{1}^{3} \frac{1}{x}\,dx
The width is Δx=314=12\Delta x = \frac{3-1}{4} = \frac{1}{2}, so the subintervals are [1,1.5][1, 1.5], [1.5,2][1.5, 2], [2,2.5][2, 2.5] and [2.5,3][2.5, 3], and their midpoints are 1.251.25, 1.751.75, 2.252.25 and 2.752.75.
M₄: four rectangles whose heights are read at 1.25, 1.75, 2.25 and 2.75.
Each height is the reciprocal of its midpoint, so
M4=12(11.25+11.75+12.25+12.75)=12(45+47+49+411)1.0898.\begin{aligned} M_4 &= \tfrac{1}{2}\left(\frac{1}{1.25} + \frac{1}{1.75} + \frac{1}{2.25} + \frac{1}{2.75}\right) \\[8pt] &= \tfrac{1}{2}\left(\frac{4}{5} + \frac{4}{7} + \frac{4}{9} + \frac{4}{11}\right) \approx 1.0898. \end{aligned}
The exact value of this integral is ln31.0986\ln 3 \approx 1.0986, which the Fundamental Theorem of Calculus will produce later in this unit. The estimate is low by about 0.0090.009. Each rectangle crosses the curve, and gives up more on the left of its midpoint than it gains on the right.

The Trapezoidal Rule

A rectangle has a flat top, and the curve above it does not. Joining the two endpoint heights by a straight segment follows the curve far more closely, and turns each subinterval's region into a trapezoid.
T₄: the same four subintervals, each capped by the chord joining its endpoint heights.
A trapezoid lying on its side, with parallel sides f(xi1)f(x_{i-1}) and f(xi)f(x_i) a distance Δx\Delta x apart, has area
[f(xi1)+f(xi)2](ban).\left[\frac{f(x_{i-1}) + f(x_i)}{2}\right]\left(\frac{b-a}{n}\right).
Now add the nn of them. Every interior height belongs to two trapezoids, once as a right end and once as a left end. It therefore arrives with a coefficient of 22, while the two outer heights keep a coefficient of 11:
Area=(ban)[f(x0)+f(x1)2++f(xn1)+f(xn)2]=(ba2n)[f(x0)+f(x1)+f(x1)+f(x2)++f(xn1)+f(xn)]=(ba2n)[f(x0)+2f(x1)+2f(x2)++2f(xn1)+f(xn)].\begin{aligned} \text{Area} &= \left(\frac{b-a}{n}\right)\left[\frac{f(x_0) + f(x_1)}{2} + \cdots + \frac{f(x_{n-1}) + f(x_n)}{2}\right] \\[8pt] &= \left(\frac{b-a}{2n}\right)\bigl[f(x_0) + f(x_1) + f(x_1) + f(x_2) + \cdots + f(x_{n-1}) + f(x_n)\bigr] \\[8pt] &= \left(\frac{b-a}{2n}\right)\bigl[f(x_0) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(x_n)\bigr]. \end{aligned}
The coefficients are 1,2,2,,2,11, 2, 2, \ldots, 2, 1. Counting them is the usual place to drop a point: there are n+1n + 1 heights for nn subintervals.

The same integral, by trapezoids

The five partition points are 11, 1.51.5, 22, 2.52.5 and 33, with heights 11, 23\frac{2}{3}, 12\frac{1}{2}, 25\frac{2}{5} and 13\frac{1}{3}. Here ba2n=28=14\frac{b-a}{2n} = \frac{2}{8} = \frac{1}{4}, so
T4=14[1+2(23)+2(12)+2(25)+13]=14(6715)=67601.1167.\begin{aligned} T_4 &= \tfrac{1}{4}\left[1 + 2\left(\tfrac{2}{3}\right) + 2\left(\tfrac{1}{2}\right) + 2\left(\tfrac{2}{5}\right) + \tfrac{1}{3}\right] \\[8pt] &= \tfrac{1}{4}\left(\tfrac{67}{15}\right) = \tfrac{67}{60} \approx 1.1167. \end{aligned}
So the two rules straddle the answer: M41.0898M_4 \approx 1.0898 sits below ln31.0986\ln 3 \approx 1.0986, and T41.1167T_4 \approx 1.1167 sits above it. That is not an accident of this integral.

Which way each estimate errs

The chord of a concave-up arc lies above the arc, so every trapezoid overshoots and TnT_n comes out too big.
The midpoint case needs one more step. Tilt the rectangle's flat top about the midpoint. That adds on one side exactly what it removes on the other. The rectangle therefore has the same area as the trapezoid capped by the tangent line at that point. A tangent to a concave-up arc lies below it, so MnM_n comes out too small.
Our example is the first case. 1x\frac{1}{x} is concave up on [1,3][1, 3], and the midpoint estimate came in low, the trapezoid estimate high. A concave-down curve flips both pictures: chord below, tangent above.
On a concave-down curve every chord dips below the graph, so the trapezoid estimate falls short.
One more thing the numbers show. The midpoint estimate missed by about 0.0090.009, the trapezoid estimate by about 0.0180.018. The midpoint error is roughly half the size and falls on the other side of the answer, and that holds for smooth functions generally. The cruder-looking rule is the better one.

Equal widths, and when there are none

The Trapezoidal Rule's tidy 1,2,2,,2,11, 2, 2, \ldots, 2, 1 pattern comes from every subinterval having the same width, so the common factor can be pulled out front. An AP question supplying a table of measured values usually spaces them unevenly, and then the rule does not apply.
Compute each trapezoid's area on its own width and add them up. The rule was only a shortcut for doing exactly that.
The same goes for the whole construction. Equal widths have been a convenience all along. They were never a requirement. For an integrable function the limit does not depend on the partition or on the sample points. Left, right, midpoint and trapezoid all arrive at one number.