The trapezoidal rule
Approximating a definite integral with the trapezoidal rule using equally spaced function values, and using concavity to decide whether the estimate is too big or too small.
Some integrals can't be done with a primitive, such as $\displaystyle\int_0^1 \sqrt{1 + x^3}\,dx$. And often there is no formula at all, only measurements: a flow rate read every two hours, or a river's depth measured every metre. The trapezoidal rule estimates the area from a few function values.
One trapezium
Join the two end points of the curve with a straight line. The region under the line is a trapezium with parallel sides $f(a)$ and $f(b)$ and width $b - a$.
Several subintervals
One trapezium is usually crude. Split $a \le x \le b$ into $n$ equal subintervals of width $h = \dfrac{b - a}{n}$, and add the trapezia. Every inside value is the right side of one trapezium and the left side of the next, so it is counted twice.
Remember it as "ends once, middles twice". With $n$ subintervals there are $n + 1$ function values.
Use the trapezoidal rule with $4$ subintervals to estimate $\displaystyle\int_1^3 \dfrac1x\,dx$, correct to four decimal places.
The exact answer turns out to be $\ln 3 \approx 1.0986$ (Chapter 5), so the estimate is a little too big. The next part explains why.
Water flows into a dam. The flow rate $R$ (in ML per hour) is measured every $2$ hours:
| $t$ (h) | $0$ | $2$ | $4$ | $6$ | $8$ |
| $R$ | $0$ | $30$ | $45$ | $40$ | $20$ |
Estimate the total volume that flowed in over the $8$ hours.
Too big or too small?
Each trapezium has a straight top. If the curve is concave up, it sags below every chord, so the trapezia include extra area: the rule overestimates. If the curve is concave down, it bulges above every chord, and the rule underestimates.
The shaded region is the trapezoidal estimate of the integral from 0 to 2.
Is the estimate too big or too small, and where can you see the extra area? Increase $n$ until the error is below $0.01$. How many subintervals did you need?
Lorenz curves and the Gini coefficient
Economists measure inequality with a Lorenz curve. Its $x$-value is a fraction of the population, from the poorest up, and its $y$-value is the fraction of total income that group earns. It runs from $(0, 0)$ to $(1, 1)$. If everyone earned the same, it would be the line of equality $y = x$. Real Lorenz curves sag below that line.
The area under $y = x$ is $\tfrac12$, which is where the formula comes from. $G = 0$ means perfect equality; values near $1$ mean a few people earn almost everything.
Survey data give these points on a Lorenz curve. Estimate the Gini coefficient using the trapezoidal rule.
| poorest fraction $x$ | $0$ | $0.2$ | $0.4$ | $0.6$ | $0.8$ | $1$ |
| income share $L$ | $0$ | $0.05$ | $0.15$ | $0.3$ | $0.55$ | $1$ |
A Lorenz curve is concave up, so the trapezoidal estimate of the area under it is a little too big, which makes this Gini estimate a little too small.
Your turn
Estimate $\displaystyle\int_0^1 \sqrt{1 + x^2}\,dx$ with $2$ subintervals, to two decimal places.
Show the working
$h = 0.5$, and the values are $1$, $\sqrt{1.25} \approx 1.1180$ and $\sqrt2 \approx 1.4142$. Estimate $= 0.25(1 + 2 \times 1.1180 + 1.4142) \approx 1.16$.
Use one trapezium to estimate $\displaystyle\int_0^2 x^2\,dx$.
$\dfrac{2 - 0}{2}(0 + 4) = 4$.
Use $4$ subintervals to estimate $\displaystyle\int_0^2 x^2\,dx$.
$h = 0.5$, values $0, 0.25, 1, 2.25, 4$. $0.25(0 + 2 \times 3.5 + 4) = 0.25 \times 11 = 2.75$.
The exact value of $\displaystyle\int_0^2 x^2\,dx$ is $\tfrac83$. The estimate $2.75$ is too big because:
On a concave up curve the straight tops of the trapezia sit above the curve, adding extra area.
Find $h$ when the trapezoidal rule is used on $1 \le x \le 4$ with $6$ subintervals.
$h = \dfrac{4 - 1}{6} = 0.5$.
The trapezoidal rule with $n$ subintervals uses how many function values?
Each subinterval has two ends, and neighbours share one, so there are $n + 1$ values.
Estimate $\displaystyle\int_1^3 \dfrac1x\,dx$ with $4$ subintervals, to four decimal places.
$0.25\left(1 + 2\left(\tfrac23 + \tfrac12 + \tfrac25\right) + \tfrac13\right) = 0.25 \times 4.4667 \approx 1.1167$.
A flow rate (ML/h) is $0, 30, 45, 40, 20$ at $t = 0, 2, 4, 6, 8$ hours. Estimate the total flow in ML.
$h = 2$: $\dfrac22\big(0 + 2(30 + 45 + 40) + 20\big) = 230 + 20 = 250$.
A Lorenz curve is modelled by $L(x) = x^2$. Find the Gini coefficient, to two decimal places.
$G = 1 - 2\displaystyle\int_0^1 x^2\,dx = 1 - \tfrac23 = \tfrac13 \approx 0.33$.
Exam style: Lorenz curve data are $L = 0, 0.05, 0.15, 0.3, 0.55, 1$ at $x = 0, 0.2, 0.4, 0.6, 0.8, 1$. Use the trapezoidal rule to estimate the Gini coefficient.
Area $\approx 0.1\big(0 + 2(1.05) + 1\big) = 0.31$. $G \approx 1 - 0.62 = 0.38$.
Exam style: the trapezoidal estimate of $\displaystyle\int_0^2 x^2\,dx$ with $n$ subintervals has error $\dfrac{4}{3n^2}$. Find the least $n$ that makes the error less than $0.01$.
$\dfrac{4}{3n^2} \lt 0.01$ gives $n^2 \gt 133.3$, so $n \gt 11.5$ and $n = 12$.
Coaching Centre