Arc Length
How long is a curved path? This lesson defines the length of a curve as the limit of inscribed polygon lengths, derives the integral formula with the Mean Value Theorem, introduces the arc length function , and shows how code measures curves and walks along them at a steady speed.
Length as a limit of polygons
A ruler only measures straight segments, so we approximate. Split into pieces , put the points on the curve and join them with straight segments. The polygon's length is
Every chord is at most as long as the arc it cuts off (a straight line is the shortest path), so refining the partition can only make grow. Definition: the curve's length is as the largest piece shrinks to 0, when that limit exists. A curve with a finite length is called rectifiable.
The integral formula
Theorem. If is continuous on , the length of from to is
Proof sketch. Write and . By the Mean Value Theorem there is an in each piece with . Then
That is exactly a Riemann sum of the continuous function , so it converges to the integral. ∎
If the curve is easier as , swap the roles: . Both are cases of the symmetric memory aid , the Pythagorean theorem for an infinitesimal piece of curve.
Note: Arc length integrals are rarely elementary. The square root only simplifies when is a perfect square, which is why textbook examples are carefully chosen. In practice you integrate numerically, as in Approximate Integration.
Two curves that do simplify
For on , , so and
For the catenary (a hanging cable), , so the length from 0 to is . On that is .
import sympy as sp
x = sp.symbols("x", nonnegative=True)
def arc_length(f, a, b):
integrand = sp.sqrt(sp.simplify(1 + sp.diff(f, x) ** 2)) # simplify first: 1 + sinh² → cosh²
return sp.simplify(sp.integrate(integrand, (x, a, b)))
print("y = (2/3)x^(3/2) on [0, 3]:", arc_length(sp.Rational(2, 3) * x**sp.Rational(3, 2), 0, 3))
L = arc_length(sp.cosh(x), 0, sp.log(2))
print("y = cosh x on [0, ln 2]:", sp.simplify(L.rewrite(sp.exp)))y = (2/3)x^(3/2) on [0, 3]: 14/3
y = cosh x on [0, ln 2]: 3/4
Polygons converge to the integral
The parabola on has an exact length . The inscribed polygons approach it from below, and the error shrinks roughly by a factor of 4 each time doubles (it is ):
import numpy as np
from scipy.integrate import quad
f = lambda t: t**2
exact = (2 * np.sqrt(5) + np.arcsinh(2)) / 4
for n in [4, 8, 16, 32]:
xs = np.linspace(0, 1, n + 1)
Ln = np.sum(np.hypot(np.diff(xs), np.diff(f(xs))))
print(f"n={n:2d} polygon={float(Ln):.6f} error={float(exact - Ln):.2e}")
L, _ = quad(lambda t: np.sqrt(1 + (2 * t) ** 2), 0, 1)
print(f"quad: {L:.6f} exact: {float(exact):.6f}")n= 4 polygon=1.474280 error=4.66e-03
n= 8 polygon=1.477778 error=1.16e-03
n=16 polygon=1.478652 error=2.91e-04
n=32 polygon=1.478870 error=7.28e-05
quad: 1.478943 exact: 1.478943
The arc length function
Measuring from a fixed start , the arc length function is
is strictly increasing, so it has an inverse : "where am I after travelling distance ?" That inverse is what animation code needs.
In software
- Constant-speed motion along a path. Moving a sprite or camera with
x += speed·dtalong a curved track makes it rush through flat parts and crawl on steep ones, because equal steps in are unequal steps along the curve. The fix is arc-length reparameterisation: tabulate once, then invert it by interpolation (or Newton's method) each frame. Calculus with Parametric Curves does this for general paths and Bézier curves (Bézier curves). - Measuring polylines. GPS tracks, SVG paths and vector fonts store curves as many points; their length is the polygon sum from the example above.
- Dashed lines and textures on roads or ropes are spaced by arc length, not by parameter, so the dashes stay even.
import numpy as np
# Walk y = x^2 on [0, 2] at constant speed: invert s(x) with a lookup table
xs = np.linspace(0, 2, 2001)
seg = np.hypot(np.diff(xs), np.diff(xs**2))
s = np.concatenate([[0.0], np.cumsum(seg)])
total = float(s[-1])
print(f"total length ≈ {total:.4f}")
for frac in [0.25, 0.5, 0.75]:
x_at = float(np.interp(frac * total, s, xs))
print(f"{int(frac * 100)}% of the way: x = {x_at:.4f}")total length ≈ 4.6468
25% of the way: x = 0.8491
50% of the way: x = 1.3326
75% of the way: x = 1.6967
Half the distance is reached at , not at : the steep right part of the parabola is longer than its width suggests.
For a gentler first look, see Area Under and Between Curves in the survey course; arc length of parametric curves continues in Calculus with Parametric Curves.
Exercises
Exercise 1: A straight line
Use the formula to find the length of from to , and check it with the distance formula.
Answer
Solution
Exercise 2: An exact cubic-type curve
Find the length of on . Hint: is a perfect square.
Answer
Solution
import sympy as sp
x = sp.symbols("x", positive=True)
f = x**3 / 6 + 1 / (2 * x)
print(sp.integrate(sp.sqrt(sp.factor(1 + sp.diff(f, x) ** 2)), (x, 1, 2)))17/12
Exercise 3: Numerically only
The length of on has no elementary formula. Compute it to 6 decimals with scipy.integrate.quad.
Answer
Solution
, so (an elliptic integral).
import numpy as np
from scipy.integrate import quad
L, _ = quad(lambda t: np.sqrt(1 + np.cos(t) ** 2), 0, np.pi)
print(f"{L:.6f}")3.820198
Exercise 4: Arc length function of the catenary
For find measured from , then the where the arc length reaches 1.
Answer
;
Solution
Test yourself
Which step in the derivation of uses the Mean Value Theorem?
- Replacing by on each piece
- Showing the polygon lengths increase
- Taking the square root
- Swapping and
A sprite moves with x += speed·dt along . What goes wrong?
- Nothing, its speed is constant
- It moves faster along the curve where the curve is steep
- It moves slower where the curve is steep
- It leaves the curve
Why is the arc length function always invertible (for continuous)?
- Because is invertible
- Because
- Because , so is strictly increasing
- It is not always invertible