Chapter 5 · Techniques of Integration

5.4 Numerical Integration

When no antiderivative is available — or all you have is a table of measurements — approximate the integral, and know how big the error can be.

Every technique in this chapter so far finds an antiderivative and then applies the Fundamental Theorem of Calculus. But many perfectly ordinary integrals have no antiderivative that can be written with the usual functions: $\displaystyle\int_0^1e^{-x^2}dx$ (central to statistics), $\displaystyle\int_0^2\sqrt{1+x^3}\,dx$, or the arc length of an ellipse. And very often in practice there is no formula at all — only a table of measurements: a car's speed every ten seconds, a river's depth every two metres, a patient's drug level every hour.

In all of these cases we approximate the integral by a weighted sum of function values. This is numerical integration, and it is what your calculator and every engineering software package actually do when you ask for a definite integral. The two questions that matter are: which weighted sum gives the most accuracy for the least work, and how large can the error be? This section answers both.

The Midpoint and Trapezoidal Rules

Divide $[a,b]$ into $n$ subintervals of equal width $\Delta x=\dfrac{b-a}{n}$ with endpoints $x_i=a+i\,\Delta x$ ($i=0,1,\dots,n$), and let $m_i=\tfrac12(x_{i-1}+x_i)$ be the midpoint of the $i$-th subinterval. Recall from Calculus I that a Riemann sum uses one height per subinterval. Two choices are much better than left or right endpoints.

📘 Definition 5.3 — Midpoint and trapezoidal rules
For $f$ defined on $[a,b]$, with $\Delta x$, $x_i$ and $m_i$ as above: $$M_n=\Delta x\left[f(m_1)+f(m_2)+\cdots+f(m_n)\right]\qquad\text{(midpoint rule)},$$ $$T_n=\frac{\Delta x}{2}\left[f(x_0)+2f(x_1)+2f(x_2)+\cdots+2f(x_{n-1})+f(x_n)\right]\qquad\text{(trapezoidal rule)}.$$ $M_n$ adds rectangles whose heights are taken at the midpoints. $T_n$ joins neighbouring points of the graph by straight lines and adds the areas of the resulting trapezoids; it is the average of the left and right Riemann sums, so interior points are counted twice and the end points once.
✏️ Example 1 — The midpoint rule
Use $M_4$ to approximate $\displaystyle\int_1^2\frac1x\,dx$, and compare with the exact value $\ln2\approx0.693147$.
Set up $\Delta x=\dfrac{2-1}{4}=0.25$; subintervals $[1,1.25],[1.25,1.5],[1.5,1.75],[1.75,2]$ with midpoints $1.125,\ 1.375,\ 1.625,\ 1.875$.
Compute $$M_4=0.25\left(\frac1{1.125}+\frac1{1.375}+\frac1{1.625}+\frac1{1.875}\right)=0.25\,(0.888889+0.727273+0.615385+0.533333)\approx0.691220.$$
Error $\ln2-M_4\approx0.693147-0.691220=0.001927$. With just four function values we are already correct to two decimal places. The approximation is a little too small: $1/x$ is concave up.
✏️ Example 2 — The trapezoidal rule
Use $T_4$ to approximate the same integral $\displaystyle\int_1^2\frac1x\,dx$.
Values $\Delta x=0.25$; $f(1)=1$, $f(1.25)=0.8$, $f(1.5)=0.666667$, $f(1.75)=0.571429$, $f(2)=0.5$.
Compute $$T_4=\frac{0.25}{2}\Big[1+2(0.8)+2(0.666667)+2(0.571429)+0.5\Big]=0.125\times5.576190\approx0.697024.$$
Compare $\ln2-T_4\approx-0.003877$: too large this time, and the error is about twice the midpoint error, with the opposite sign. This pattern ($E_T\approx-2E_M$) holds for smooth functions and is the key to Simpson's rule.
⚠️ Analysis — why the midpoint rule beats the trapezoid

For a concave-up function (like $1/x$) every chord lies above the curve, so each trapezoid over-counts: $T_n$ is too big. The midpoint rectangle has the same area as the trapezoid formed by the tangent line at the midpoint, and tangent lines of a concave-up function lie below it, so $M_n$ is too small. In short:

if $f''\gt0$ on $[a,b]$, then $\ M_n\lt\displaystyle\int_a^bf(x)\,dx\lt T_n$; $\quad$ if $f''\lt0$, the inequalities reverse.

Because a tangent line hugs the curve more closely than a chord does, the midpoint error is roughly half the trapezoid error. The trapezoidal rule is still widely used because it needs only the values at the grid points — exactly what a table of measurements provides.

Simpson's Rule

Both rules above replace $f$ by straight-line pieces. We can do much better by fitting a parabola through each set of three consecutive points $(x_{i-1},y_{i-1})$, $(x_i,y_i)$, $(x_{i+1},y_{i+1})$. A short calculation (integrate the quadratic through the three points, placing the middle one at $x=0$) shows that the area under the parabola through three equally spaced points with spacing $h$ is $\dfrac h3\left(y_{i-1}+4y_i+y_{i+1}\right)$. Adding these areas over pairs of subintervals gives Simpson's rule.

📘 Definition 5.4 — Simpson's rule
Let $n$ be even, $\Delta x=\dfrac{b-a}{n}$ and $y_i=f(x_i)$. Then $$S_n=\frac{\Delta x}{3}\Big[y_0+4y_1+2y_2+4y_3+2y_4+\cdots+2y_{n-2}+4y_{n-1}+y_n\Big].$$ The coefficients follow the pattern $1,4,2,4,2,\dots,2,4,1$. Equivalently, $S_{2n}=\dfrac{2M_n+T_n}{3}$ — a weighted average that cancels the leading errors of $M_n$ and $T_n$ (since $E_T\approx-2E_M$).
✏️ Example 3 — Simpson's rule
Use $S_4$ to approximate $\displaystyle\int_1^2\frac1x\,dx$.
Compute Same five values as Example 2, with weights $1,4,2,4,1$: $$S_4=\frac{0.25}{3}\Big[1+4(0.8)+2(0.666667)+4(0.571429)+0.5\Big]=\frac{8.319048}{12}\approx0.693254.$$
Error $\ln2-S_4\approx-0.000107$. The same five function values that gave $T_4$ an error of $0.0039$ now give an error about $36$ times smaller.
Check $M_2=0.5\left(\tfrac1{1.25}+\tfrac1{1.75}\right)\approx0.685714$ and $T_2=0.25\left(1+2\cdot\tfrac1{1.5}+0.5\right)\approx0.708333$, so $\dfrac{2M_2+T_2}{3}\approx0.693254=S_4$. ✓
Interactive 1 — Midpoint vs Trapezoid vs Simpson

Choose a function and a rule. The shaded shapes are what the rule really integrates: rectangles (midpoint), trapezoids (trapezoidal) or parabolic arches over pairs of subintervals (Simpson). Play steps through $n=2,4,6,\dots,24$; watch how fast each error shrinks. All three approximations and errors are always shown so you can compare.

$n$ and $\Delta x$—
$M_n$ (error)—
$T_n$ (error)—
$S_n$ (error)—
exact value—

How Big Is the Error?

In real problems we do not know the exact value — that is why we are approximating! So we need a guaranteed upper bound on the error, computed from information about $f$ alone. First, two ways to measure error.

📘 Definition 5.5 — Absolute and relative error
If $A$ approximates a quantity whose exact value is $I\ne0$, the absolute error is $|I-A|$ and the relative error is $\dfrac{|I-A|}{|I|}$ (often given as a percentage). We write $E_M=I-M_n$, $E_T=I-T_n$, $E_S=I-S_n$ for the signed errors of the three rules.

An error of $0.01$ m is excellent when measuring a 400 m track and useless when machining a 2 cm part; the relative error captures that difference.

📐 Theorem 5.8 — Error bounds for the midpoint and trapezoidal rules
Suppose $f''$ is continuous on $[a,b]$ and $K$ is a constant with $|f''(x)|\le K$ for all $x$ in $[a,b]$. Then $$|E_M|\le\frac{K(b-a)^3}{24n^2}\qquad\text{and}\qquad|E_T|\le\frac{K(b-a)^3}{12n^2}.$$
📐 Theorem 5.9 — Error bound for Simpson's rule
Suppose $f^{(4)}$ is continuous on $[a,b]$ and $|f^{(4)}(x)|\le K$ for all $x$ in $[a,b]$. Then, for even $n$, $$|E_S|\le\frac{K(b-a)^5}{180n^4}.$$ In particular $S_n$ is exact for every polynomial of degree $\le3$, because then $f^{(4)}=0$.

Read the powers of $n$: doubling $n$ divides the midpoint and trapezoid bounds by $2^2=4$, but the Simpson bound by $2^4=16$. Interactive 2 shows that the actual errors follow exactly these rates.

🧭 Choosing $n$ to meet a tolerance $\varepsilon$
  1. Compute $f''$ (for $M$, $T$) or $f^{(4)}$ (for $S$) and check it is continuous on $[a,b]$.
  2. Find a value $K$ with $|f''|\le K$ (or $|f^{(4)}|\le K$) on the whole interval — any valid upper bound works; it need not be the smallest.
  3. Solve "bound $\le\varepsilon$" for $n$, then round up to the next integer (to the next even integer for Simpson).
✏️ Example 4 — How many subintervals?
How large must $n$ be to guarantee that $M_n$, $T_n$ and $S_n$ approximate $\displaystyle\int_1^2\frac{dx}{x}$ to within $10^{-4}$?
Bound $f''$ $f(x)=x^{-1}$, $f''(x)=2x^{-3}$, continuous on $[1,2]$ and decreasing, so $|f''(x)|\le2=K$.
Trapezoid $\dfrac{2\cdot1^3}{12n^2}\le10^{-4}\iff n^2\ge\dfrac{10^4}{6}\approx1666.7\iff n\ge40.8$. Take $n=41$.
Midpoint $\dfrac{2}{24n^2}\le10^{-4}\iff n^2\ge833.3\iff n\ge28.9$. Take $n=29$.
Simpson $f^{(4)}(x)=24x^{-5}$, so $|f^{(4)}|\le24=K$ on $[1,2]$. $\dfrac{24}{180n^4}\le10^{-4}\iff n^4\ge1333.3\iff n\ge6.04$. The next even integer is $n=8$.
Compare Simpson needs $9$ function values; the trapezoidal rule needs $42$. Also, for $n=4$ the bounds are $|E_T|\le\frac{1}{96}\approx0.0104$ and $|E_S|\le\frac{24}{180\cdot256}\approx0.00052$ — true, but pessimistic: the actual errors were $0.0039$ and $0.00011$.
✏️ Example 5 — An integral with no elementary antiderivative
Approximate $\displaystyle\int_0^1e^{-x^2}dx$ with $S_4$, bound the error, and give the absolute and relative errors using the accurate value $0.746824$.
Values $\Delta x=0.25$: $y_0=1$, $y_1=e^{-0.0625}\approx0.939413$, $y_2=e^{-0.25}\approx0.778801$, $y_3=e^{-0.5625}\approx0.569783$, $y_4=e^{-1}\approx0.367879$.
Simpson $$S_4=\frac{0.25}{3}\Big[1+4(0.939413)+2(0.778801)+4(0.569783)+0.367879\Big]=\frac{8.962265}{12}\approx0.746855.$$
Bound $f^{(4)}(x)=\left(16x^4-48x^2+12\right)e^{-x^2}$ is continuous, and on $[0,1]$ its largest absolute value is $12$ (at $x=0$). So $|E_S|\le\dfrac{12\cdot1^5}{180\cdot4^4}\approx0.00026$.
Errors Absolute error $|0.746824-0.746855|\approx3.1\times10^{-5}$ — well inside the bound. Relative error $\approx\dfrac{3.1\times10^{-5}}{0.7468}\approx4.2\times10^{-5}$, i.e. about $0.004\%$.
Interactive 2 — Error vs $n$ on a Log–Log Plot

Horizontal axis: $\log_{10}n$ (so $1$ means $n=10$, $2$ means $n=100$). Vertical axis: $\log_{10}|\text{error}|$. On these axes an error that behaves like $C/n^p$ is a straight line of slope $-p$: midpoint and trapezoid fall with slope $-2$, Simpson with slope $-4$ until it hits the computer's rounding floor near $10^{-16}$. Choose a tolerance to see the smallest $n$ that each rule actually needs.

$n$—
$|E_M|$ · ratio $E(n/2)/E(n)$—
$|E_T|$ · ratio—
$|E_S|$ · ratio—
smallest $n$ meeting the tolerance (M / T / S)—

Integrating Tabulated Data

When $f$ is known only at equally spaced points — measurements from a sensor, a logbook or a survey — the trapezoidal and Simpson's rules apply directly to the table. (The midpoint rule needs values between the grid points, so it is used only when the data happen to include them.) Error bounds are no longer available, since we cannot differentiate a table, but comparing $T_n$ with $S_n$ gives a practical feel for the accuracy: when they agree closely, both are probably good.

✏️ Example 6 — Distance from a speed log
A rescue boat leaves the harbour and its speed is logged every 10 seconds:
$t$ (s)0102030405060
$v$ (m/s)03.25.67.18.08.48.6
Estimate the distance travelled in the first minute.
Model $v\ge0$, so distance $=\displaystyle\int_0^{60}v(t)\,dt$. The table gives $n=6$ subintervals with $\Delta t=10$ s.
Trapezoid $T_6=\dfrac{10}{2}\Big[0+2(3.2+5.6+7.1+8.0+8.4)+8.6\Big]=5\times73.2=366$ m.
Simpson $n=6$ is even: $S_6=\dfrac{10}{3}\Big[0+4(3.2)+2(5.6)+4(7.1)+2(8.0)+4(8.4)+8.6\Big]=\dfrac{10}{3}(110.6)\approx368.7$ m.
Interpret The two estimates differ by under $1\%$, so the boat travelled about $368$ m. (The speed curve is concave down, so we expect the trapezoids to under-estimate slightly — and $T_6\lt S_6$ agrees.) Using only the readings at $10,30,50$ s as midpoints of $20$-second intervals gives $M_3=20(3.2+7.1+8.4)=374$ m, a rougher estimate because $\Delta t$ is twice as large.

Exercises

I
Compute the approximations. Give answers to six decimal places where appropriate.
  • 1 $M_4$ for $\displaystyle\int_0^2x^3\,dx$
  • 2 $T_4$ for $\displaystyle\int_0^2x^3\,dx$
  • 3 $S_4$ for $\displaystyle\int_0^2x^3\,dx$. Compare parts 1–3 with the exact value and explain the result for $S_4$.
  • 4 $T_4$ for $\displaystyle\int_0^{\pi}\sin x\,dx$
  • 5 $M_4$ for $\displaystyle\int_0^{\pi}\sin x\,dx$
  • 6 $S_4$ for $\displaystyle\int_0^{\pi}\sin x\,dx$
  • 7 $S_6$ for $\displaystyle\int_0^3\frac{dx}{1+x^2}$, and compare with the exact value $\tan^{-1}3$.
  • 8 $T_6$ for $\displaystyle\int_1^4\ln x\,dx$, and compare with the exact value $4\ln4-3$.
1 $\Delta x=0.5$, midpoints $0.25,0.75,1.25,1.75$: $M_4=0.5(0.015625+0.421875+1.953125+5.359375)=0.5(7.75)=3.875$.
2 $T_4=0.25\Big[0+2(0.125+1+3.375)+8\Big]=0.25(17)=4.25$.
3 $S_4=\dfrac{0.5}{3}\Big[0+4(0.125)+2(1)+4(3.375)+8\Big]=\dfrac{24}{6}=4$. The exact value is $\int_0^2x^3dx=4$: $M_4$ is $0.125$ too small, $T_4$ is $0.25$ too large (again $E_T=-2E_M$), and $S_4$ is exact because $f^{(4)}=0$ for a cubic (Theorem 5.9).
4 $\Delta x=\pi/4$: $T_4=\dfrac{\pi}{8}\Big[0+2\left(\tfrac{\sqrt2}{2}+1+\tfrac{\sqrt2}{2}\right)+0\Big]=\dfrac{\pi}{8}(2+2\sqrt2)\approx1.896119$.
5 Midpoints $\tfrac{\pi}{8},\tfrac{3\pi}{8},\tfrac{5\pi}{8},\tfrac{7\pi}{8}$: $M_4=\dfrac{\pi}{4}(0.382683+0.923880+0.923880+0.382683)\approx2.052344$.
6 $S_4=\dfrac{\pi}{12}\Big[0+4(0.707107)+2(1)+4(0.707107)+0\Big]=\dfrac{\pi}{12}(7.656854)\approx2.004560$. (Exact: $2$.)
7 $\Delta x=0.5$; $y=1,\ 0.8,\ 0.5,\ 0.307692,\ 0.2,\ 0.137931,\ 0.1$. $S_6=\dfrac{0.5}{3}\Big[1+4(0.8)+2(0.5)+4(0.307692)+2(0.2)+4(0.137931)+0.1\Big]\approx1.247082$, while $\tan^{-1}3\approx1.249046$: error $\approx0.0020$.
8 $\Delta x=0.5$; $\ln$ of $1,1.5,\dots,4$: $0,\ 0.405465,\ 0.693147,\ 0.916291,\ 1.098612,\ 1.252763,\ 1.386294$. $T_6=0.25\Big[0+2(4.366278)+1.386294\Big]\approx2.529713$; exact $4\ln4-3\approx2.545177$. $T_6$ is too small because $\ln x$ is concave down.
II
Errors and error bounds.
  • 1 Find the absolute and relative errors of $T_4$ in Exercise I.4.
  • 2 Use Theorem 5.8 to bound the error of $T_4$ for $\displaystyle\int_0^{\pi}\sin x\,dx$. Is the actual error within the bound?
  • 3 Use Theorem 5.9 to bound the error of $S_4$ for $\displaystyle\int_0^{\pi}\sin x\,dx$, and compare with the actual error.
  • 4 How large must $n$ be for $T_n$ to approximate $\displaystyle\int_0^2e^x\,dx$ to within $0.001$?
  • 5 How large must $n$ be for $S_n$ to approximate $\displaystyle\int_0^2e^x\,dx$ to within $0.001$?
  • 6 How large must $n$ be for $M_n$ to approximate $\displaystyle\int_1^3\frac{dx}{x}$ to within $0.0005$?
  • 7 How large must $n$ be for $S_n$ to approximate $\displaystyle\int_0^1e^{-x^2}dx$ to within $10^{-6}$? (Use $K=12$ from Example 5.)
  • 8 Conceptual. Without computing anything, put $M_4$, $T_4$ and $\displaystyle\int_0^1e^x\,dx$ in increasing order. Then check with a calculator.
1 Absolute error $|2-1.896119|\approx0.103881$; relative error $\approx\dfrac{0.103881}{2}\approx0.0519$, about $5.2\%$.
2 $f''=-\sin x$ is continuous with $|f''|\le1=K$: $|E_T|\le\dfrac{\pi^3}{12\cdot16}\approx0.1615$. The actual error $0.1039$ is within the bound. ✓
3 $f^{(4)}=\sin x$, $K=1$: $|E_S|\le\dfrac{\pi^5}{180\cdot256}\approx0.00664$. Actual: $|2-2.004560|\approx0.00456$. ✓
4 $f''=e^x\le e^2=K$ on $[0,2]$: $\dfrac{e^2\cdot8}{12n^2}\le0.001\iff n^2\ge4926.0\iff n\ge70.19$. Take $n=71$.
5 $f^{(4)}=e^x\le e^2$: $\dfrac{e^2\cdot32}{180n^4}\le0.001\iff n^4\ge1313.6\iff n\ge6.02$. Next even integer: $n=8$.
6 $f''=2/x^3\le2$ on $[1,3]$: $\dfrac{2\cdot2^3}{24n^2}=\dfrac{2}{3n^2}\le0.0005\iff n^2\ge1333.3\iff n\ge36.5$. Take $n=37$.
7 $\dfrac{12}{180n^4}\le10^{-6}\iff n^4\ge66\,667\iff n\ge16.07$. Next even integer: $n=18$.
8 $e^x$ is concave up ($f''=e^x\gt0$), so $M_4\lt\int_0^1e^xdx\lt T_4$. Check: $M_4\approx1.713815$, exact $e-1\approx1.718282$, $T_4\approx1.727222$. ✓
III
Tabulated data. Use the trapezoidal rule and Simpson's rule unless told otherwise.
  • 1 Hydrology. The depth of a 12 m wide river, measured every 2 m from one bank to the other, is $0,\ 1.2,\ 2.1,\ 2.8,\ 2.5,\ 1.4,\ 0$ m. Estimate the cross-sectional area.
  • 2 Energy. The power drawn by an office building, measured every 2 hours from 08:00 to 20:00, is $40,\ 52,\ 70,\ 85,\ 80,\ 64,\ 48$ kW. Estimate the energy used, in kWh.
  • 3 Drone flight. A delivery drone's speed is logged every 5 s for 40 s: $0,\ 4,\ 7,\ 9,\ 10,\ 10,\ 9,\ 6,\ 2$ m/s. Estimate the distance flown.
  • 4 Using only the readings at $t=5,15,25,35$ s in part 3 as midpoints, estimate the distance with $M_4$.
  • 5 Use your Simpson estimate from part 3 to find the drone's average speed over the 40 s.
  • 6 Pharmacology. A patient's plasma drug concentration (mg/L), measured every hour for 6 hours after a dose, is $0,\ 4.2,\ 5.8,\ 5.1,\ 3.9,\ 2.8,\ 2.0$. The area under this curve (AUC) measures total drug exposure. Estimate it.
Check: trapezoids and Simpson's parabolas drawn through the data
$n$, $\Delta x$—
trapezoidal $T_n$—
Simpson $S_n$—
difference—
1 $\Delta x=2$, $n=6$. $T_6=\dfrac22\Big[0+2(1.2+2.1+2.8+2.5+1.4)+0\Big]=20$ m². $S_6=\dfrac23\Big[0+4(1.2)+2(2.1)+4(2.8)+2(2.5)+4(1.4)+0\Big]=\dfrac23(30.8)\approx20.53$ m².
2 $\Delta t=2$ h, $n=6$. $T_6=1\cdot\Big[40+2(52+70+85+80+64)+48\Big]=790$ kWh. $S_6=\dfrac23\Big[40+4(52)+2(70)+4(85)+2(80)+4(64)+48\Big]=\dfrac23(1192)\approx794.7$ kWh.
3 $\Delta t=5$ s, $n=8$. $T_8=2.5\Big[0+2(4+7+9+10+10+9+6)+2\Big]=2.5(112)=280$ m. $S_8=\dfrac53\Big[0+4(4)+2(7)+4(9)+2(10)+4(10)+2(9)+4(6)+2\Big]=\dfrac53(170)\approx283.3$ m.
4 Four intervals of width $10$ s: $M_4=10(4+9+10+6)=290$ m.
5 Average speed $=\dfrac{1}{40}\displaystyle\int_0^{40}v\,dt\approx\dfrac{283.3}{40}\approx7.08$ m/s.
6 $\Delta t=1$ h. $T_6=\tfrac12\Big[0+2(4.2+5.8+5.1+3.9+2.8)+2.0\Big]=\tfrac12(45.6)=22.8$ mg·h/L. $S_6=\tfrac13\Big[0+4(4.2)+2(5.8)+4(5.1)+2(3.9)+4(2.8)+2.0\Big]=\tfrac13(69.8)\approx23.27$ mg·h/L.
IV
Theory and challenge.
  • 1 Compute $M_2$ and $T_2$ for $\displaystyle\int_1^2\frac{dx}{x}$ and verify that $\dfrac{2M_2+T_2}{3}=S_4$ (Example 3).
  • 2 Compute $S_2$ for $\displaystyle\int_0^2\left(x^3-2x+1\right)dx$ and show that it equals the exact value. Which theorem predicts this?
  • 3 For a smooth function, $T_{10}$ has error $0.004$ and $S_{10}$ has error $3.2\times10^{-5}$. Estimate the errors of $T_{20}$ and $S_{20}$.
  • 4 Compute $T_4$ for $\displaystyle\int_0^1\sqrt x\,dx$ and its actual error. Can Theorem 5.8 be used to bound this error? Explain.
  • 5 Use $S_4$ on $\displaystyle\int_1^3\frac{dx}{x}$ to estimate $\ln3$. How many correct decimal places do you get?
1 $M_2=0.5\left(\tfrac1{1.25}+\tfrac1{1.75}\right)\approx0.685714$; $T_2=0.25\left(1+\tfrac{2}{1.5}+0.5\right)\approx0.708333$. $\dfrac{2(0.685714)+0.708333}{3}\approx0.693254=S_4$. ✓ (Indeed, the three formulas use exactly the same five points with the same weights.)
2 $\Delta x=1$: $S_2=\tfrac13\big[f(0)+4f(1)+f(2)\big]=\tfrac13[1+4(0)+5]=2$. Exact: $\Big[\tfrac{x^4}{4}-x^2+x\Big]_0^2=4-4+2=2$. Theorem 5.9: $f^{(4)}=0$ for a cubic, so the error bound is $0$.
3 Doubling $n$ divides trapezoid errors by about $4$ and Simpson errors by about $16$: $E_{T_{20}}\approx0.001$, $E_{S_{20}}\approx2\times10^{-6}$.
4 $T_4=0.125\Big[0+2(0.5+0.707107+0.866025)+1\Big]\approx0.643283$; exact $\tfrac23$, error $\approx0.0234$. Theorem 5.8 does not apply: $f''(x)=-\tfrac14x^{-3/2}$ is not continuous on $[0,1]$ and is unbounded near $0$, so no $K$ exists. (The rule still works, but more slowly than $1/n^2$.)
5 $\Delta x=0.5$: $S_4=\tfrac{0.5}{3}\Big[1+4\left(\tfrac1{1.5}\right)+2\left(\tfrac12\right)+4\left(\tfrac1{2.5}\right)+\tfrac13\Big]=\tfrac16(6.6)=1.1$. Since $\ln3\approx1.098612$, the error is $0.0014$: two correct decimal places.
🔬 Research–Teaching NexusResearch-tutored · optional, about 30 minutes

Research question. How much electrical energy does a rooftop solar system produce on a clear day — and how much does the answer depend on how often the power is logged?

Why it matters. Solar inverters log power output at fixed intervals; energy (kWh) is the integral of power (kW) over time. Utilities, homeowners and researchers in sunny regions from the Gulf to Australia use exactly these numerical rules to turn logs into energy totals and payback estimates.

What to do.

  1. Sample log (hourly, 06:00–18:00, kW): $0,\ 0.3,\ 1.1,\ 2.0,\ 2.8,\ 3.3,\ 3.5,\ 3.3,\ 2.8,\ 2.0,\ 1.1,\ 0.3,\ 0$.
  2. Estimate the day's energy with $T_{12}$ and $S_{12}$.
  3. Now pretend you only logged every 2 hours (use every second value): recompute $T_6$ and $S_6$. Which rule is less sensitive to the coarser logging?
  4. Find a real hourly log (many inverters publish one, or use an online solar-irradiance data set for your city) and repeat.

Tools: Spreadsheet or Python; optionally an online solar data portal.

Hand in: A half-page note: your four estimates, which you trust most and why, and one source of error that no numerical rule can fix.

Going further. Cloudy days give jagged logs. Does Simpson's rule still beat the trapezoidal rule when the data are not smooth? Test it.

Instructor note: for the sample log $T_{12}=22.5$ kWh and $S_{12}\approx22.47$ kWh; with 2-hour logging $T_6=22.6$ kWh and $S_6\approx22.67$ kWh — both rules move by only about $0.1$–$0.2$ kWh because this clear-day curve is smooth. Measurement noise and the inverter's own averaging cannot be removed by any rule.

🧪 Self-check quiz

0/5 correct

Q1. Simpson's rule $S_n$ requires $n$ to be…

Q2. If $f''(x)\gt0$ on $[a,b]$, then…

Q3. Doubling $n$ in the trapezoidal rule divides the error bound by…

Q4. Simpson's rule gives the exact value for every polynomial of degree up to…

Q5. $T_2$ for $\displaystyle\int_0^2x^2\,dx$ equals…