Areas from a table of values
Tonight's idea
Often you know a function only at a few points: a speed every two seconds, a river's depth every metre. The area under the graph still matters: it is the distance travelled, or the river's cross-section.
Take equally spaced values \(y_0, y_1, \ldots, y_n\), a step \(h\) apart. Join neighbours with straight lines. Each strip is a trapezium of area \(\tfrac{h}{2}(y_k + y_{k+1})\). Add the strips:
Trapezium rule. Area \(\approx \dfrac{h}{2}\big(y_0 + 2y_1 + 2y_2 + \cdots + 2y_{n-1} + y_n\big)\).
Straight lines cut the corners of a curved graph. A parabola can bend, so put one through each three neighbouring points. The area under it, across two strips, is \(\tfrac{h}{3}(y_0 + 4y_1 + y_2)\). Add these two strips at a time (so \(n\) must be even):
Simpson's rule. Area \(\approx \dfrac{h}{3}\big(y_0 + 4y_1 + 2y_2 + 4y_3 + \cdots + 4y_{n-1} + y_n\big)\).
The weights run 1, 4, 2, 4, …, 2, 4, 1. Halve the step and the trapezium error divides by about 4. Simpson's divides by about 16.
Watch one: the area under \(y = x^4\) from 0 to 1
The exact area is \(\tfrac15 = 0.2\), so we can see the errors. Use \(h = 0.25\).
| \(x\) | 0 | 0.25 | 0.5 | 0.75 | 1 |
|---|---|---|---|---|---|
| \(y = x^4\) | 0 | 0.0039 | 0.0625 | 0.3164 | 1 |
Trapezium: \(\tfrac{0.25}{2}\big(0 + 2(0.0039 + 0.0625 + 0.3164) + 1\big) = 0.2207\). Error \(0.0207\).
Simpson: \(\tfrac{0.25}{3}\big(0 + 4(0.0039) + 2(0.0625) + 4(0.3164) + 1\big) = 0.2005\). Error \(0.0005\): the same five numbers, forty times closer.
The demo at mathdetours.com/demos/riemann.html uses rectangles, not trapezia: left, right and midpoint sums, with a table as \(n\) doubles. The trapezium rule is the average of its left and right columns.
Your turn
- A car's speed is read every 2 seconds. Use the trapezium rule to estimate how far it travels in the 8 seconds.
time (s) 0 2 4 6 8 speed (m/s) 0 7 10 12 12 - Estimate the same distance with Simpson's rule. Which estimate is larger, and why would you expect that for a graph that bends this way?
- Go back to \(y = x^4\) from 0 to 1, but with \(h = 0.5\): just the values \(0,\ 0.0625,\ 1\). Find both estimates and both errors. Compare with the errors for \(h = 0.25\) above. By what factor did each error shrink?
- Use Simpson's rule with \(h = 1\) on \(y = x^3\) from 0 to 2. The exact area is 4. The parabola through the three points is \(y = 3x^2 - 2x\), which is not the cubic. Factorise \(x^3 - (3x^2 - 2x)\) and explain why Simpson's rule is still exactly right.
Stretch: Simpson from two trapezium estimates
Suppose the trapezium estimate with step \(h\) is off by \(E\). Then with step \(2h\) it is off by about \(4E\). Which combination of the two estimates cancels the error? Show that for three values \(y_0, y_1, y_2\) your combination is exactly Simpson's rule.
Answers
- \(\tfrac{2}{2}\big(0 + 2(7 + 10 + 12) + 12\big) = 70\) m.
- \(\tfrac{2}{3}\big(0 + 4(7) + 2(10) + 4(12) + 12\big) = \tfrac23 \times 108 = 72\) m. Simpson's is larger. The graph bends downwards, so it lies above the straight lines joining its points, and the trapezium rule falls short.
- Trapezium: \(\tfrac{0.5}{2}(0 + 2(0.0625) + 1) = 0.2813\), error \(0.0813\). Simpson: \(\tfrac{0.5}{3}(0 + 4(0.0625) + 1) = 0.2083\), error \(0.0083\). Halving the step took the trapezium error from \(0.0813\) to \(0.0207\), a factor of about 3.9, and Simpson's from \(0.0083\) to \(0.0005\), a factor of 16.
- \(\tfrac13\big(0 + 4(1) + 8\big) = 4\), exactly right. The gap between the curves is \(x^3 - 3x^2 + 2x = x(x - 1)(x - 2)\). It is positive between 0 and 1 and negative between 1 and 2, and the two pieces are mirror images: put \(x = 1 + t\) and it becomes \(t^3 - t\), which changes sign when \(t\) does. So the cubic's extra area on the left is cancelled exactly on the right. The same happens for every cubic, so Simpson's rule is exact for cubics.
Stretch. Write \(T_h\) and \(T_{2h}\) for the two estimates. Then \(4T_h - T_{2h}\) has error about \(4E - 4E = 0\) and counts the area three times, so use \(\tfrac13(4T_h - T_{2h})\). For three values, \(T_h = \tfrac h2(y_0 + 2y_1 + y_2)\) and \(T_{2h} = h(y_0 + y_2)\), so \(\tfrac13(4T_h - T_{2h}) = \tfrac h3(2y_0 + 4y_1 + 2y_2 - y_0 - y_2) = \tfrac h3(y_0 + 4y_1 + y_2)\).