Show that (1) the rectangle (midpoint) formula is exact
Show that (1) the rectangle (midpoint) formula is exact for $f(x)=ax+b$, and (2) the trapezoidal formula is exact for $f(x)=ax+b$.
Explanation of Method
Compute the exact value of $\int_{x_0}^{x_1}(ax+b)\,dx$ directly, then compute what each numerical rule (midpoint, trapezoidal) predicts for the same integral, and show the two expressions coincide term by term.
Step 1: Exact integral
With $h=x_1-x_0$:
\[I_{\text{exact}}=\int_{x_0}^{x_1}(ax+b)\,dx=\frac{a}{2}(x_1^2-x_0^2)+b(x_1-x_0)=h\left[\frac{a}{2}(x_0+x_1)+b\right].\]
Step 2: Midpoint rule
The midpoint is $x_m=(x_0+x_1)/2$, so $f(x_m)=\dfrac{a}{2}(x_0+x_1)+b$, and
\[I_{\text{mid}}=h\cdot f(x_m)=h\left[\frac{a}{2}(x_0+x_1)+b\right]=I_{\text{exact}}.\]
\[\boxed{I_{\text{exact}}=I_{\text{mid}}}\]
Step 3: Trapezoidal rule
\[I_{\text{trap}}=\frac{h}{2}\left[f(x_0)+f(x_1)\right]=\frac{h}{2}\left[a(x_0+x_1)+2b\right]=h\left[\frac{a}{2}(x_0+x_1)+b\right]=I_{\text{exact}}.\]
\[\boxed{I_{\text{exact}}=I_{\text{trap}}}\]
Step 4: Why both work
For a linear function, the midpoint value equals the average value of $f$ over the interval, and so does the average of the two endpoint values — both facts are special to linear (degree-1) functions, which is exactly why both rules recover the true area exactly, geometrically the area under a straight line is itself a trapezoid, matched exactly by either construction.
Step 5: Numerical check
For $f(x)=3x+2$ on $[1,5]$: $I_{\text{exact}}=44$; midpoint with $x_m=3$ gives $4\times f(3)=4\times11=44$; trapezoidal gives $2\times[f(1)+f(5)]=2\times[5+17]=44$. Both match exactly.
Result
Final answer:
\[\boxed{\int_{x_0}^{x_1}(ax+b)\,dx=h\,f\!\left(\frac{x_0+x_1}{2}\right)=\frac{h}{2}\left[f(x_0)+f(x_1)\right]}\]