TExcelTAD
Home › Calculus in Depth › Areas and Distances

Areas and Distances

What is the area under a curve? For a rectangle the answer is base×height\text{base} \times \text{height}, but a curved region has no such formula. This lesson defines area as a limit of rectangle sums, computes one such limit exactly with summation formulas, and shows that the same sums turn a velocity record into a distance travelled. The gentler version is Riemann Sums.

Approximating with rectangles

Let f≥0f \ge 0 be continuous on [a,b][a, b]. Split [a,b][a, b] into nn strips of equal width

Δx=b−an,xi=a+i Δx(i=0,1,…,n)\Delta x = \frac{b - a}{n}, \qquad x_i = a + i\,\Delta x \quad (i = 0, 1, \ldots, n)

and over each strip [xi−1,xi][x_{i-1}, x_i] stand a rectangle whose height is the value of ff at some sample point xi∗x_i^*:

Sum Sample point Symbol
left xi∗=xi−1x_i^* = x_{i-1} LnL_n
right xi∗=xix_i^* = x_i RnR_n
midpoint xi∗=xi−1+xi2x_i^* = \frac{x_{i-1} + x_i}{2} MnM_n
lower / upper where ff is smallest / largest on the strip sns_n / SnS_n

Every choice satisfies sn≤∑f(xi∗) Δx≤Sns_n \le \sum f(x_i^*)\,\Delta x \le S_n.

Definition of area

Definition. The area AA of the region under y=f(x)y = f(x), a≤x≤ba \le x \le b, for continuous f≥0f \ge 0, is

A=lim⁡n→∞∑i=1nf(xi∗) ΔxA = \lim_{n \to \infty} \sum_{i=1}^{n} f(x_i^*)\,\Delta x,

and for continuous ff this limit exists and is the same for every choice of sample points.

Why do all choices agree? On each strip ff varies by at most ωn\omega_n, the largest oscillation of ff over a strip of width Δx\Delta x. So Sn−sn≤ωn(b−a)S_n - s_n \le \omega_n (b - a). A continuous function on a closed interval is uniformly continuous, so ωn→0\omega_n \to 0 as n→∞n \to \infty; the upper and lower sums squeeze together, and every sum trapped between them has the same limit.

An exact limit

Area under f(x)=x2+1f(x) = x^2 + 1 on [0,2][0, 2], with right endpoints. Here Δx=2/n\Delta x = 2/n, xi=2i/nx_i = 2i/n:

Rn=∑i=1n[(2in)2+1]⋅2n=8n3∑i2+2n⋅n=8n3⋅n(n+1)(2n+1)6+2=43(1+1n)(2+1n)+2→43⋅2+2=143as n→∞\begin{aligned} R_n &= \sum_{i=1}^{n} \left[\left(\frac{2i}{n}\right)^2 + 1\right] \cdot \frac{2}{n} = \frac{8}{n^3} \sum i^2 + \frac{2}{n} \cdot n \\ &= \frac{8}{n^3} \cdot \frac{n(n + 1)(2n + 1)}{6} + 2 \\ &= \frac{4}{3}\left(1 + \frac{1}{n}\right)\left(2 + \frac{1}{n}\right) + 2 \quad \to \quad \frac{4}{3} \cdot 2 + 2 = \frac{14}{3} \quad \text{as } n \to \infty \end{aligned}

using ∑i2=n(n+1)(2n+1)6\sum i^2 = \frac{n(n + 1)(2n + 1)}{6} from Sigma Notation. SymPy does the same algebra:

python · try it yourself
import sympy as sp

i, n = sp.symbols('i n', integer=True, positive=True)
R_n = sp.summation(((2*i/n)**2 + 1) * 2/n, (i, 1, n))
print("R_n =", sp.factor(sp.simplify(R_n)))
print("limit:", sp.limit(R_n, n, sp.oo))
for k in (4, 40, 400):
    print(f"R_{k} =", R_n.subs(n, k), "≈", round(float(R_n.subs(n, k)), 6))
R_n = 2*(7*n**2 + 6*n + 2)/(3*n**2)
limit: 14/3
R_4 = 23/4 ≈ 5.75
R_40 = 1907/400 ≈ 4.7675
R_400 = 187067/40000 ≈ 4.676675

RnR_n overestimates for every nn because x2+1x^2 + 1 is increasing: the right endpoint is the highest point of each strip, so Rn=SnR_n = S_n here.

Left, right and midpoint compared

python · try it yourself
import numpy as np
import matplotlib.pyplot as plt

f = lambda x: x**2 + 1
a, b, exact = 0.0, 2.0, 14 / 3
for n in (4, 16, 64):
    x = np.linspace(a, b, n + 1); dx = (b - a) / n
    L, R = float(np.sum(f(x[:-1])) * dx), float(np.sum(f(x[1:])) * dx)
    M = float(np.sum(f((x[:-1] + x[1:]) / 2)) * dx)
    print(f"n = {n:2}: L = {L:.5f}  R = {R:.5f}  M = {M:.5f}   errors {L - exact:+.4f} {R - exact:+.4f} {M - exact:+.5f}")

n = 6; x = np.linspace(a, b, n + 1); mid = (x[:-1] + x[1:]) / 2
plt.figure(figsize=(6, 4))
plt.bar(mid, f(mid), width=(b - a) / n, alpha=0.35, edgecolor="k", label="midpoint rectangles, n = 6")
xs = np.linspace(a, b, 200); plt.plot(xs, f(xs), "C3", label="y = x² + 1")
plt.legend(); plt.grid(alpha=0.3)
n =  4: L = 3.75000  R = 5.75000  M = 4.62500   errors -0.9167 +1.0833 -0.04167
n = 16: L = 4.42188  R = 4.92188  M = 4.66406   errors -0.2448 +0.2552 -0.00260
n = 64: L = 4.60449  R = 4.72949  M = 4.66650   errors -0.0622 +0.0628 -0.00016

The left and right errors shrink like 1/n1/n; the midpoint error shrinks like 1/n21/n^2. It is also about half the error of the average (L+R)/2(L + R)/2 (for n=4n = 4 that average is off by +0.0833, the midpoint by −0.0417), with the opposite sign. That observation is the seed of the error bounds in Approximate Integration.

The distance problem

If an object moves at constant velocity vv for time Δt\Delta t, it travels v⋅Δtv \cdot \Delta t. If velocity changes, chop time into short intervals, treat velocity as constant on each, and add: a Riemann sum. In the limit, distance = area under the velocity curve (for v≥0v \ge 0).

A drone logs its speed every 2 seconds:

python · try it yourself
t = [0, 2, 4, 6, 8, 10, 12]
v = [0.0, 3.1, 5.8, 7.2, 6.5, 4.0, 1.2]          # m/s
dt = 2
left = sum(v[:-1]) * dt
right = sum(v[1:]) * dt
print(f"left estimate  = {left:.1f} m")
print(f"right estimate = {right:.1f} m")
print(f"average (trapezoid) = {(left + right) / 2:.1f} m")
left estimate  = 53.2 m
right estimate = 55.6 m
average (trapezoid) = 54.4 m

Without the formula for v(t)v(t) we cannot know the exact distance, but the true value lies between the lower and upper sums if we know vv's monotonicity on each interval. The average of left and right is the trapezoid rule.

In software

  • Rasterising and coverage: anti-aliasing estimates the area of a pixel covered by a shape by sampling sub-pixel points, a 2-D Riemann sum.
  • Telemetry: energy use from power readings (W×s=J\text{W} \times \text{s} = \text{J}), data transferred from bandwidth samples, and distance from a GPS speed log are all Riemann sums over logged samples.
  • Monte Carlo: when sample points are random instead of on a grid, the sum becomes Monte Carlo integration, the method used in path-tracing renderers.

Exercises

Exercise 1: Four rectangles

Estimate the area under f(x)=1/xf(x) = 1/x on [1,3][1, 3] with L4L_4 and R4R_4. Which is an overestimate?

Answer

L4=77/60≈1.2833L_4 = 77/60 \approx 1.2833 (overestimate), R4=19/20=0.95R_4 = 19/20 = 0.95 (underestimate). The exact area is ln⁡3≈1.0986\ln 3 \approx 1.0986.

Solution
Δx=0.5,grid 1,1.5,2,2.5,3L4=0.5⋅(1+23+12+25)=0.5⋅7730=7760R4=0.5⋅(23+12+25+13)=0.5⋅5730=1920\begin{aligned} &\Delta x = 0.5, \quad \text{grid } 1, 1.5, 2, 2.5, 3 \\ &L_4 = 0.5 \cdot \left(1 + \tfrac{2}{3} + \tfrac{1}{2} + \tfrac{2}{5}\right) = 0.5 \cdot \tfrac{77}{30} = \tfrac{77}{60} \\ &R_4 = 0.5 \cdot \left(\tfrac{2}{3} + \tfrac{1}{2} + \tfrac{2}{5} + \tfrac{1}{3}\right) = 0.5 \cdot \tfrac{57}{30} = \tfrac{19}{20} \end{aligned}

1/x1/x is decreasing, so the left endpoint is the highest point of each strip: L4L_4 is the upper sum.

python · try it yourself
from fractions import Fraction as F
import math
xs = [F(1) + F(k, 2) for k in range(5)]
L = sum(1 / x for x in xs[:-1]) / 2
R = sum(1 / x for x in xs[1:]) / 2
print(L, R, float(L), float(R), round(math.log(3), 4))
77/60 19/20 1.2833333333333334 0.95 1.0986

Exercise 2: An exact limit

Compute lim⁡Rn\lim R_n for f(x)=3xf(x) = 3x on [0,4][0, 4] using ∑i=n(n+1)2\sum i = \frac{n(n + 1)}{2}.

Answer
Solution
Δx=4/n,xi=4i/nRn=∑3(4in)(4n)=48n2⋅n(n+1)2=24(1+1n)→24\begin{aligned} &\Delta x = 4/n, \quad x_i = 4i/n \\ &R_n = \sum 3\left(\frac{4i}{n}\right)\left(\frac{4}{n}\right) = \frac{48}{n^2} \cdot \frac{n(n + 1)}{2} = 24\left(1 + \frac{1}{n}\right) \to 24 \end{aligned}

(The region is a triangle with base 4 and height 12: area 24.)

Exercise 3: Distance from a log

A runner's speeds (m/s) at t=0,10,20,30t = 0, 10, 20, 30 s are 0, 4, 5, 5. Give left and right estimates of the distance.

Answer

Left 90 m90\ \text{m}, right 140 m140\ \text{m}.

Solution
left=10⋅(0+4+5)=90right=10⋅(4+5+5)=140\begin{aligned} \text{left} &= 10 \cdot (0 + 4 + 5) = 90 \\ \text{right} &= 10 \cdot (4 + 5 + 5) = 140 \end{aligned}

Test yourself

For an increasing function on [a,b][a, b], the right sum RnR_n is…

  1. the lower sum
  2. always exact
  3. always smaller than LnL_n
  4. the upper sum

What does the area under a velocity–time graph (v≥0v \ge 0) represent?

  1. Acceleration
  2. Average speed
  3. Distance travelled
  4. Time

Why do left, right and midpoint sums of a continuous function have the same limit?

  1. All of them are trapped between lower and upper sums, whose difference tends to 0
  2. They are equal for every nn
  3. Because ff is increasing
  4. Only the midpoint sum has a limit