Integration and numerical methods: area and the trapezoidal rule

IB Math AI · Calculus

Integration as accumulated change

If $f'(t)$ is a rate, then $\displaystyle\int_{a}^{b}f'(t)\,dt=f(b)-f(a)$ is the total change between $t=a$ and $t=b$. This single sentence answers most AI integration questions: litres flowed in, extra cost incurred, distance covered.

$$\int x^{n}\,dx=\frac{x^{n+1}}{n+1}+c\ (n\ne-1),\qquad \int e^{kx}\,dx=\frac{e^{kx}}{k}+c$$

Area between two curves

$$A=\int_{a}^{b}\bigl(y_{\text{tren}}-y_{\text{duoi}}\bigr)\,dx$$

The limits come from solving $y_1=y_2$. Subtracting in the wrong order gives the negative of the area.

The trapezoidal rule

$$\int_{a}^{b}y\,dx\approx\frac{h}{2}\Bigl(y_{0}+2(y_{1}+y_{2}+\cdots+y_{n-1})+y_{n}\Bigr),\qquad h=\frac{b-a}{n}$$

With $n$ strips there are $n+1$ ordinates. The two end ordinates appear once; every interior ordinate appears twice, because it is shared by two strips.

This is the only method available when the data is a table of measurements and no formula exists — which is precisely the AI situation.

Over- or under-estimate

Where the curve is concave up, each chord lies above the curve and the rule overestimates. Where it is concave down, the rule underestimates. Doubling the number of strips divides the error by roughly $4$.

h = 0,5 · sáu dải trên [0 ; 3] 0 3 tổng 6 hình thang = 7,395 tích phân thật = 7,341 y = √(1 + x³) lõm lên trên cả khoảng
This figure explains by eye something the formula does not say: the trapezoidal rule gives a result larger than the true integral when the curve is concave up. The top of each blue strip is a chord joining two points on the curve. Because the red curve is concave up, it sags below every one of its chords, so the part between the chord and the curve is area that has been counted in excess; six small excesses add up to $7.395-7.341=0.054$. If the curve were concave down, every chord would lie below the curve and the trapezoidal rule would give an underestimate. Note three details readable directly from the figure. First, there are seven ordinates but six strips; being off by one here is the most common error when building the table. Second, the two end ordinates belong to only one strip so are counted once, while the five middle ordinates belong to two strips so are doubled; that is the origin of the formula $\frac{h}{2}\left(y_0+2(y_1+\cdots+y_{5})+y_6\right)$. Third, the strips on the right are as wide as those on the left but much taller, so the error piles up toward the steep part of the curve.

Worked example: the trapezoidal rule on a real table of measurements

The velocity of a car is recorded every $2$ seconds for the first $10$ seconds.

$t$ (s)$0$$2$$4$$6$$8$$10$
$v$ (m/s)$0$$7.5$$13.2$$17.1$$19.4$$20.5$

Estimate the distance the car travels, and say whether that estimate is an overestimate or an underestimate of the true distance.

Solution

Step 1: count the strips and ordinates. There are $6$ ordinates so $5$ strips, and $h=2$ s. This is where an off-by-one error most often occurs: $6$ data points do not give $6$ strips.

Step 2: apply the formula. The first and last ordinates are $0$ and $20.5$; the four interior ordinates are $7.5;\ 13.2;\ 17.1;\ 19.4$ with sum $57.2$.

$$s\approx\frac{2}{2}\Bigl(0+2(57.2)+20.5\Bigr)=1\times(114.4+20.5)=134.9\ \text{m}$$

Step 3: overestimate or underestimate. Look at the sequence of velocities: the successive increases are $7.5;\ 5.7;\ 3.9;\ 2.3;\ 1.1$, decreasing, so the velocity graph is concave down. For a concave-down curve, the chord lies below the curve, so the trapezoidal rule gives an underestimate of the true distance.

Why this problem can only be solved numerically: the problem does not give a formula for $v(t)$ and there is no way to find one. This is the default situation in AI, and also the reason the trapezoidal rule is in the syllabus.

Three common errors, all giving reasonable-looking numbers. Forgetting to multiply by $\dfrac{h}{2}$ and multiplying by $h$ only: you get $269.8$ m, double. Forgetting to double the interior ordinates: you get $\dfrac{2}{2}(0+57.2+20.5)=77.7$ m. Adding all the ordinates directly and multiplying by $h$: you get $2(77.7)=155.4$ m; this is in fact a right-hand rectangle sum, which always overestimates when the function is increasing.

Worked example: area between two curves and accumulated quantity

(a) Calculate the area of the region bounded by $y=x(4-x)$ and $y=x$.

(b) Water flows into a tank at a rate $r(t)=4+0.6t^{2}$ liters per minute, for $0\le t\le 5$. Calculate the amount of water that flows in during the first $5$ minutes.

Solution

(a) Step 1: find the limits by solving for the intersections.

$$x(4-x)=x\;\Longrightarrow\;4x-x^{2}=x\;\Longrightarrow\;3x-x^{2}=0\;\Longrightarrow\;x(3-x)=0$$

So $x=0$ and $x=3$. Note that you must not divide both sides by $x$: doing so loses the solution $x=0$ and with it one of the limits.

Step 2: decide which curve is on top. Test $x=1$: the parabola gives $y=3$, the line gives $y=1$. The parabola is on top.

$$A=\int_{0}^{3}\bigl[(4x-x^{2})-x\bigr]dx=\int_{0}^{3}(3x-x^{2})\,dx=\left[\frac{3x^{2}}{2}-\frac{x^{3}}{3}\right]_{0}^{3}$$$$A=\frac{27}{2}-9=13.5-9=4.5$$

If you get $-4.5$ you subtracted in the wrong order; area is never negative.

(b) The rate is in liters per minute, so its integral over time gives the number of liters:

$$V=\int_{0}^{5}(4+0.6t^{2})\,dt=\left[4t+0.2t^{3}\right]_{0}^{5}=20+0.2(125)=20+25=45\ \text{liters}$$

Reasonableness check. The rate runs from $r(0)=4$ to $r(5)=19$ liters/min. If the rate stayed at $4$ throughout you would get $20$ liters; if it stayed at $19$ throughout you would get $95$ liters. The answer $45$ lies between those two bounds, and leans toward the low side because the rate is small for most of the time, exactly as the shape of a quadratic suggests.

The two typical wrong answers are exactly the two bounds just mentioned: $19$ liters (confusing the final rate with the total amount) and $95$ liters (multiplying the final rate by the time). Both result from forgetting that the rate is changing.

Common mistake

Trap number one, and the most expensive: counting the strips wrongly by one. A table with $n+1$ ordinates has $n$ strips, and $h=\dfrac{b-a}{n}$, not divided by the number of ordinates. Six measurements spaced $2$ seconds apart give $5$ strips, not $6$. Trap number two: forgetting to multiply by $\dfrac{h}{2}$, or forgetting to double the interior ordinates. These two errors give a result double or about half the correct answer, and both are reasonable numbers so they do not reveal themselves. How to prevent it: write the formula first, circle the group $2(y_1+\cdots+y_{n-1})$ separately, and only then substitute. Trap number three: answering “overestimate or underestimate” by feel. The answer is right only when you can state the concavity: concave up means overestimate, concave down means underestimate, and a table of successive differences tells you the concavity at once without a derivative. Trap number four: subtracting in the wrong order when computing the area between two curves. A negative answer is the sign, but if the problem asks only for the magnitude many students take the absolute value and carry on without noticing the two curves swap roles in the middle of the interval; when the two curves cross several times, the interval must be split. Trap number five: confusing the rate at the final moment with the total accumulated amount. The value $r(5)=19$ is liters per minute at the fifth minute, while the total is $45$ liters; the units tell the two apart immediately.

Key takeaway

Integration in AI always answers the question “how much in total”: accumulating a rate over time, or accumulating a height across a width. When there is a formula, take the antiderivative or use the calculator; when there is only a table of measurements, use the trapezoidal rule, and always add a sentence about whether the result is an overestimate or an underestimate, because that is the mark the calculator cannot earn for you.

← Differentiation in context: rates of change, tangents and optimisation · All IB Math AI lessons · Practice IB Math AI questions (free, instant scoring) · Kinematics and differential equations: Euler's method →