23. Line integrals of scalar functions
§9.5 built arc length, \int|\vec r'(t)|\,dt, by summing tiny straight segments along a curve. Weight each segment not just by its length but by a scalar function's value there, and the result is a line integral — the natural way to compute a total quantity, like the mass of a bent wire, that's spread unevenly along a curve rather than along a straight interval the way §5.5's rod was.
Definition
For a scalar function f(x,y) and a curve C parametrized by \vec r(t)=\langle x(t),y(t)\rangle for t\in[a,b]:
\int_Cf(x,y)\,ds=\int_a^bf\big(x(t),y(t)\big)\,|\vec r'(t)|\,dt
This is arc length (§9.5) with a weight inserted: setting f=1 everywhere recovers \int_C1\,ds=\int_a^b|\vec r'(t)|\,dt, exactly §9.5's arc-length formula, with no weighting at all. The general case multiplies each infinitesimal arc-length piece ds=|\vec r'(t)|\,dt by f's value at that point before summing — precisely the "weight each tiny piece, then integrate" pattern behind every application in Module 5, applied here to a curved path instead of a straight interval.
Mass of a wire
If a thin wire is bent into the shape of curve C, with linear density (mass per unit length) f(x,y) varying along its length, the total mass is
M=\int_Cf(x,y)\,ds
— the direct curved-path generalization of §5.5's straight-rod mass formula M=\int_a^b\rho(x)\,dx. A denser stretch of wire contributes more to the total exactly the way a denser stretch of rod did; the only new ingredient is that "how far you've moved" is now measured by arc length along a (possibly curved) path, using |\vec r'(t)| to convert.
Independence from parametrization and direction
A line integral of a scalar function has a property worth stating explicitly, because it will contrast sharply with §12.2's vector-field line integral: \int_Cf\,ds gives the same value regardless of which parametrization is used to trace C, and regardless of which direction the curve is traced. This makes sense physically — the mass of a wire doesn't depend on which end you start measuring from, or how quickly you imagine walking along it; only the wire's shape and density matter. (This follows formally from §6.1's observation that arc length itself doesn't depend on parametrization speed, only on the path traced.)
Doing it in Python
The mass of a semicircular wire, \vec r(t)=\langle\cos t,\sin t\rangle for t\in[0,\pi], with linear density f(x,y)=1+y (heavier toward the top):
import sympy as sp
t = sp.Symbol('t')
x, y = sp.cos(t), sp.sin(t)
speed = sp.simplify(sp.sqrt(sp.diff(x, t)**2 + sp.diff(y, t)**2))
print(f"speed |r'(t)| = {speed}")
f = 1 + y
mass = sp.integrate(f * speed, (t, 0, sp.pi))
print(f"mass of the wire = {mass}")
Confirming that setting f=1 recovers ordinary arc length:
import sympy as sp
t = sp.Symbol('t')
x, y = sp.cos(t), sp.sin(t)
speed = sp.sqrt(sp.diff(x, t)**2 + sp.diff(y, t)**2)
arc_length = sp.integrate(speed, (t, 0, sp.pi))
mass_with_f_1 = sp.integrate(1 * speed, (t, 0, sp.pi))
print(f"arc length (section 9.5 formula): {arc_length}")
print(f"line integral with f=1: {mass_with_f_1}")
print(f"match: {arc_length == mass_with_f_1}")
Confirming parametrization-independence — the same curve, traced twice as fast, gives an identical line integral:
import sympy as sp
t, s = sp.symbols('t s')
# original: r(t) = (cos t, sin t), t in [0, pi]
x1, y1 = sp.cos(t), sp.sin(t)
speed1 = sp.sqrt(sp.diff(x1, t)**2 + sp.diff(y1, t)**2)
f = 1 + y1
result1 = sp.integrate(f * speed1, (t, 0, sp.pi))
# reparametrized: same curve, traced twice as fast, r(s) = (cos(2s), sin(2s)), s in [0, pi/2]
x2, y2 = sp.cos(2*s), sp.sin(2*s)
speed2 = sp.sqrt(sp.diff(x2, s)**2 + sp.diff(y2, s)**2)
f2 = 1 + y2
result2 = sp.integrate(f2 * speed2, (s, 0, sp.pi/2))
print(f"original parametrization: {result1}")
print(f"faster parametrization: {result2}")
print(f"match: {result1 == result2}")
Worked example
Find the mass of a wire bent into the shape of the semicircle \vec r(t)=\langle\cos t,\sin t\rangle, t\in[0,\pi], with density f(x,y)=1+y.
\vec r'(t)=\langle-\sin t,\cos t\rangle,\qquad|\vec r'(t)|=\sqrt{\sin^2t+\cos^2t}=1
(the standard unit-circle constant speed, from §6.1's own worked example).
M=\int_0^\pi(1+\sin t)\cdot1\,dt=\int_0^\pi1\,dt+\int_0^\pi\sin t\,dt=\pi+\Big[-\cos t\Big]_0^\pi=\pi+\big(1-(-1)\big)
=\boxed{\pi+2}
Sanity check. With no weighting at all (f=1), this semicircular wire's plain arc length would be exactly \pi (half the circumference of a unit circle, 2\pi(1)). The actual mass, \pi+2\approx5.14, is noticeably larger than \pi\approx3.14 — consistent with the density f=1+y always being at least 1 (since y=\sin t\ge0 throughout the upper semicircle) and often larger, so the weighted total should indeed exceed the unweighted arc length. ✓
Your turn
1. Find the mass of a straight wire along \vec r(t)=\langle t,0\rangle for t\in[0,4], with density f(x,y)=3+x.
2. Set up (don't necessarily evaluate by hand) the line integral for the mass of a wire along the helix \vec r(t)=\langle\cos t,\sin t,t\rangle for t\in[0,2\pi] (from §9.5), with density f(x,y,z)=z.
3. True or false: tracing the same curve in the opposite direction changes the value of \int_Cf\,ds.
Solutions
1. \vec r'(t)=\langle1,0\rangle, |\vec r'(t)|=1.
M=\int_0^4(3+t)\,dt=\left[3t+\frac{t^2}2\right]_0^4=12+8=\boxed{20}
(Check against §5.5: this is exactly a straight rod with density \rho(x)=3+x on [0,4] — the same formula, since a line integral along a straight path is an ordinary single-variable integral, with the speed factor |\vec r'(t)|=1 doing nothing.)
2. From §9.5, |\vec r'(t)|=\sqrt2 for this helix (constant speed). z(t)=t, so f(x(t),y(t),z(t))=t.
M=\int_0^{2\pi}t\cdot\sqrt2\,dt
3. False. As the concept section stated, \int_Cf\,ds is independent of both parametrization and direction — reversing direction is a special case of reparametrizing the same underlying curve, and arc length (the quantity ds ultimately reduces to) has no notion of "forward" or "backward" built into it. This will contrast directly with §12.2's line integral of a vector field, where direction genuinely does flip the sign of the result.
Check yourself in code
Find the mass of a wire along the semicircle $\vec r(t)=\langle\cos t,\sin t\rangle$, t\in[0,\pi], with density f(x,y)=1+y.
Print exactly this:
speed = 1
mass = 2 + pi
import sympy as sp
t = sp.Symbol('t')
x, y = sp.cos(t), sp.sin(t)
speed = sp.simplify(sp.sqrt(sp.diff(x, t)**2 + sp.diff(y, t)**2))
print("speed = ...")
f = 1 + y
mass = sp.integrate(f * speed, (t, 0, sp.pi))
print("mass = ...")
import sympy as sp
t = sp.Symbol('t')
x, y = sp.cos(t), sp.sin(t)
speed = sp.simplify(sp.sqrt(sp.diff(x, t)**2 + sp.diff(y, t)**2))
print(f"speed = {speed}")
f = 1 + y
mass = sp.integrate(f * speed, (t, 0, sp.pi))
print(f"mass = {mass}")
A scalar line integral, \int_Cf\,ds=\int_a^bf(x(t),y(t))|\vec r'(t)|\,dt, weights §9.5's arc-length integrand by a function's value along the path — the curved-path analogue of §5.5's rod-mass formula, computing the mass of a bent wire with variable density. It shares a key property with ordinary arc length: the result depends only on the curve's shape, never on which parametrization traces it or which direction it's walked.
Next: a genuinely different kind of line integral — one that integrates a vector field along a curve instead of a scalar function, and where direction of travel changes the answer.