Calculus with Parametric Curves
Once a curve is given as , , the usual questions of calculus (slopes, areas, lengths) have answers written entirely in terms of . This lesson derives those formulas, proves the arc-length formula from inscribed polygons, and uses arc length to solve a practical problem: moving an object along a curve at constant speed, as game cameras and path followers must.
Start with Curves Defined by Parametric Equations if parametric curves are new.
Tangents
Suppose and are differentiable and near . Then is strictly monotone there, so it has a differentiable inverse and, locally, is a function of : . The chain rule gives , hence
- Horizontal tangent: and .
- Vertical tangent: and .
- If both vanish, the point needs a closer look (it may be a cusp, as for the cycloid).
The second derivative is the derivative of with respect to , so the same rule applies again:
import sympy as sp
t = sp.symbols("t", real=True)
x, y = t**2 - 3*t, t**3 - 3*t
dydx = sp.simplify(y.diff(t) / x.diff(t))
d2 = sp.factor(sp.simplify(dydx.diff(t) / x.diff(t)))
print("dy/dx =", dydx)
print("d2y/dx2 =", d2)
print("horizontal tangents at t =", sp.solve(y.diff(t), t))
print("vertical tangent at t =", sp.solve(x.diff(t), t),
"point", (x.subs(t, sp.Rational(3, 2)), y.subs(t, sp.Rational(3, 2))))
print("slope at t = 2:", dydx.subs(t, 2))dy/dx = 3*(t**2 - 1)/(2*t - 3)
d2y/dx2 = 6*(t**2 - 3*t + 1)/(2*t - 3)**3
horizontal tangents at t = [-1, 1]
vertical tangent at t = [3/2] point (-9/4, -9/8)
slope at t = 2: 9
The curve is concave up exactly where is positive. Here the sign can change at the roots of the numerator (inflection points) and at , the vertical tangent, where the curve turns back in .
Areas
If the curve is traced once as goes from to , substituting , into gives
The orientation matters: if decreases as increases, the integral comes out negative and you take its absolute value (or swap the limits). For a closed curve traced once anticlockwise, , a special case of Green's theorem.
Arc length
Theorem. If and are continuous on and the curve is traversed exactly once, its length is
Proof sketch. Split into pieces at and join the points by straight segments. The length of the curve is defined as the limit of the polygon lengths as the pieces shrink. By the mean value theorem, and for some points , in the -th piece, so
This is almost a Riemann sum for ; the two sample points differ, but because and are uniformly continuous on the closed interval, the difference vanishes in the limit. ∎
The integrand is the speed, so length is the integral of speed: distance travelled. If the curve is traversed twice, the integral counts it twice, which is why "traversed once" matters. The length does not depend on which once-through parametrisation you use (a change of variables in the integral shows it). For graphs the formula reduces to from Arc Length.
import sympy as sp
th, r = sp.symbols("theta r", positive=True)
x, y = r * (th - sp.sin(th)), r * (1 - sp.cos(th))
area = sp.integrate(y * x.diff(th), (th, 0, 2 * sp.pi))
print("area under one arch:", sp.simplify(area))
speed = sp.sqrt(sp.simplify(x.diff(th)**2 + y.diff(th)**2))
print("speed:", speed, " = 2r·sin(θ/2) on [0, 2π]")
length = sp.integrate(2 * r * sp.sin(th / 2), (th, 0, 2 * sp.pi))
print("length of one arch:", length)area under one arch: 3*pi*r**2
speed: r*sqrt(2 - 2*cos(theta)) = 2r·sin(θ/2) on [0, 2π]
length of one arch: 8*r
One cycloid arch has area , three times the rolling circle, and length , a rational multiple of with no , which Christopher Wren proved in 1658.
In software: constant-speed motion along a curve
A game camera on a spline, a train on a track or a UI element following a Bézier path is usually given as for . Advancing at a constant rate does not give constant speed: varies, so the object speeds up and slows down. The fix is arc-length reparameterisation:
- Compute the arc-length function . It is strictly increasing when the speed is positive.
- Invert it: for a desired distance , find .
- Move by distance, not by parameter: at time , place the object at .
The curve has speed exactly 1, since . Engines approximate step 1 with a lookup table of cumulative chord lengths and do step 2 with binary search plus linear interpolation.
import numpy as np
P = np.array([[0, 0], [1, 3], [4, 3], [5, 0]], float) # cubic Bézier controls
def bez(t):
t = np.asarray(t)[:, None]
return ((1-t)**3 * P[0] + 3*(1-t)**2*t * P[1] + 3*(1-t)*t**2 * P[2] + t**3 * P[3])
# lookup table: t samples and cumulative chord length
ts = np.linspace(0, 1, 2001)
pts = bez(ts)
s = np.concatenate([[0], np.cumsum(np.linalg.norm(np.diff(pts, axis=0), axis=1))])
L = s[-1]
print(f"curve length ≈ {L:.4f}")
def t_of_s(target): # invert s(t) by interpolation in the table
return np.interp(target, s, ts)
steps = 8
uniform_t = bez(np.linspace(0, 1, steps + 1))
uniform_s = bez(t_of_s(np.linspace(0, L, steps + 1)))
seg = lambda q: np.round(np.linalg.norm(np.diff(q, axis=0), axis=1), 3).tolist()
print("step lengths, equal t:", seg(uniform_t))
print("step lengths, equal s:", seg(uniform_s))curve length ≈ 7.1906
step lengths, equal t: [1.087, 0.925, 0.813, 0.755, 0.755, 0.813, 0.925, 1.087]
step lengths, equal s: [0.897, 0.896, 0.894, 0.892, 0.892, 0.894, 0.896, 0.897]
With equal steps the object covers about 45% more ground per frame near the ends of this curve than in the middle. With equal arc-length steps every frame covers the same arc length; the printed straight-line chords differ only in the third decimal because a chord is slightly shorter than its arc where the curve bends more.
Exercises
Exercise 1: Tangent to an ellipse
Find the slope and the point of tangency on , at .
Answer
Slope at the point .
Solution
Exercise 2: An exact arc length
Find the length of , for .
Answer
Solution
import sympy as sp
t = sp.symbols("t", nonnegative=True)
L = sp.integrate(sp.sqrt((2*t)**2 + (3*t**2)**2), (t, 0, 1))
print(sp.simplify(L), round(float(L), 4))-8/27 + 13*sqrt(13)/27 1.4397
Exercise 3: Area of an ellipse
Use with , , , to find the area enclosed by the ellipse.
Answer
Solution
The minus sign appears because the parametrisation runs anticlockwise (along the top half decreases), so the area is .
Exercise 4: Half-way along a parabola
On the path , , find the parameter value at which an object moving at constant speed has covered half the length. Use a lookup table as in the lesson.
Answer
Total length ; half-way is at , not at .
Solution
; the exact total is . Because speed grows with , the first half of the distance takes more than half the parameter range.
import numpy as np
ts = np.linspace(0, 1, 100001)
speed = np.sqrt(1 + 4 * ts**2)
s = np.concatenate([[0], np.cumsum((speed[1:] + speed[:-1]) / 2 * np.diff(ts))])
print(f"L = {s[-1]:.6f}, exact {np.sqrt(5)/2 + np.arcsinh(2)/4:.6f}")
print(f"t at half length = {np.interp(s[-1] / 2, s, ts):.4f}")L = 1.478943, exact 1.478943
t at half length = 0.6107
Test yourself
For , , where is the tangent vertical?
- Where and
- Where and
- Where
- Where
Which formula gives for a parametric curve?
A camera moves along a Bézier path by increasing at a constant rate, but its speed varies. What fixes it?
- Increasing the frame rate
- Reparameterising by arc length: build an table and invert it
- Normalising the control points
- Using a quadratic Bézier