Areas and Distances
What is the area under a curve? For a rectangle the answer is , 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 be continuous on . Split into strips of equal width
and over each strip stand a rectangle whose height is the value of at some sample point :
| Sum | Sample point | Symbol |
|---|---|---|
| left | ||
| right | ||
| midpoint | ||
| lower / upper | where is smallest / largest on the strip | / |
Every choice satisfies .
Definition of area
Definition. The area of the region under , , for continuous , is
,
and for continuous this limit exists and is the same for every choice of sample points.
Why do all choices agree? On each strip varies by at most , the largest oscillation of over a strip of width . So . A continuous function on a closed interval is uniformly continuous, so as ; the upper and lower sums squeeze together, and every sum trapped between them has the same limit.
An exact limit
Area under on , with right endpoints. Here , :
using from Sigma Notation. SymPy does the same algebra:
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
overestimates for every because is increasing: the right endpoint is the highest point of each strip, so here.
Left, right and midpoint compared
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 ; the midpoint error shrinks like . It is also about half the error of the average (for 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 for time , it travels . 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 ).
A drone logs its speed every 2 seconds:
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 we cannot know the exact distance, but the true value lies between the lower and upper sums if we know '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 (), 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 on with and . Which is an overestimate?
Answer
(overestimate), (underestimate). The exact area is .
Solution
is decreasing, so the left endpoint is the highest point of each strip: is the upper sum.
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 for on using .
Answer
Solution
(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 s are 0, 4, 5, 5. Give left and right estimates of the distance.
Answer
Left , right .
Solution
Test yourself
For an increasing function on , the right sum is…
- the lower sum
- always exact
- always smaller than
- the upper sum
What does the area under a velocity–time graph () represent?
- Acceleration
- Average speed
- Distance travelled
- Time
Why do left, right and midpoint sums of a continuous function have the same limit?
- All of them are trapped between lower and upper sums, whose difference tends to 0
- They are equal for every
- Because is increasing
- Only the midpoint sum has a limit