29. Surface integrals and flux
§12.1 integrated a scalar function along a curve, and §12.2 integrated a vector field along a curve to get work. §12.6 built surface area from dS=|\vec r_u\times\vec r_v|\,du\,dv. This lesson combines both earlier patterns with that new dS: a scalar surface integral (weighted surface area) and a vector surface integral called flux, measuring how much a field flows through a surface.
Surface integrals of scalar functions
\iint_Sf(x,y,z)\,dS=\iint_Df\big(\vec r(u,v)\big)\,|\vec r_u\times\vec r_v|\,du\,dv
This is §12.1's line integral, one dimension up, with §12.6's surface area element replacing arc length: setting f=1 recovers plain surface area, exactly the way §12.1's f=1 recovered plain arc length. The most common application is the mass of a curved shell with surface density f(x,y,z) — the direct two-dimensional-surface analogue of §12.1's curved-wire mass.
Flux: the surface integral of a vector field
For a vector field \vec F and a surface S with unit normal \hat n, the flux through S is:
\iint_S\vec F\cdot d\vec S=\iint_S\vec F\cdot\hat n\,dS=\iint_D\vec F\big(\vec r(u,v)\big)\cdot\big(\vec r_u\times\vec r_v\big)\,du\,dv
The middle expression is the key idea: at each point, only the component of \vec F perpendicular to the surface — pointing straight through it — contributes to flux; a component of \vec F lying flat within the surface contributes nothing, the same way §12.2's work integral only counted the component of a force along the direction of travel. The right-hand expression avoids computing \hat n and dS separately: \vec r_u\times\vec r_v already carries both the correct direction and the correct magnitude built in, since $\hat n\,dS=\frac{\vec r_u\times\vec r_v}{|\vec r_u\times\vec r_v|}\cdot|\vec r_u\times\vec r_v|\,du\,dv=(\vec r_u\times\vec r_v)\,du\,dv$ exactly.
Physical meaning: if \vec F is a fluid's velocity field, flux measures the net rate of volume flowing through S — positive if the net flow is in the direction \hat n points, negative if it's mostly opposite. This is the direct surface analogue of §12.2's circulation, and it will be the left-hand side of both §12.8's Stokes' theorem and §12.9's divergence theorem.
Orientation matters
Just as §12.2's line integral flipped sign under reversed direction, a flux integral flips sign under a reversed normal — choosing \hat n to point "outward" from a closed surface versus "inward" changes the sign of every flux computed across it. A surface must be orientable (have a consistent, continuous choice of normal direction across its entire extent) for flux to be well-defined at all — a subtlety this course won't dwell on, but worth knowing exists (the Möbius strip is the classic non-orientable surface, where no consistent normal choice is possible).
Doing it in Python
The flux of the radial field \vec F(x,y,z)=\langle x,y,z\rangle through a sphere of radius R — a classic computation, and a direct preview of §12.9's divergence theorem:
import sympy as sp
phi, theta, R = sp.symbols('phi theta R', positive=True)
r = sp.Matrix([
R * sp.sin(phi) * sp.cos(theta),
R * sp.sin(phi) * sp.sin(theta),
R * sp.cos(phi)
])
r_phi, r_theta = r.diff(phi), r.diff(theta)
normal = r_phi.cross(r_theta)
F = r # F(x,y,z) = <x,y,z>, evaluated on the surface is just r(phi,theta) itself
flux_integrand = sp.simplify(F.dot(normal))
print(f"F . (r_phi x r_theta) = {flux_integrand}")
flux = sp.integrate(sp.integrate(flux_integrand, (phi, 0, sp.pi)), (theta, 0, 2*sp.pi))
print(f"flux through the sphere = {sp.simplify(flux)}")
The mass of a hemispherical shell (radius R, upper half) with surface density f(x,y,z)=z — heavier toward the top:
import sympy as sp
phi, theta, R = sp.symbols('phi theta R', positive=True)
r = sp.Matrix([
R * sp.sin(phi) * sp.cos(theta),
R * sp.sin(phi) * sp.sin(theta),
R * sp.cos(phi)
])
r_phi, r_theta = r.diff(phi), r.diff(theta)
dS = sp.simplify(sp.sqrt(r_phi.cross(r_theta).dot(r_phi.cross(r_theta))))
density = r[2] # z-coordinate on the surface
mass = sp.integrate(sp.integrate(density * dS, (phi, 0, sp.pi/2)), (theta, 0, 2*sp.pi))
print(f"mass of the hemisphere shell = {sp.simplify(mass)}")
Confirming flux reverses sign under a reversed normal:
import sympy as sp
phi, theta = sp.symbols('phi theta', positive=True)
r = sp.Matrix([sp.sin(phi)*sp.cos(theta), sp.sin(phi)*sp.sin(theta), sp.cos(phi)])
r_phi, r_theta = r.diff(phi), r.diff(theta)
F = r
flux_outward = sp.integrate(sp.integrate(F.dot(r_phi.cross(r_theta)), (phi, 0, sp.pi)), (theta, 0, 2*sp.pi))
flux_inward = sp.integrate(sp.integrate(F.dot(r_theta.cross(r_phi)), (phi, 0, sp.pi)), (theta, 0, 2*sp.pi))
print(f"flux with r_phi x r_theta: {sp.simplify(flux_outward)}")
print(f"flux with r_theta x r_phi (reversed): {sp.simplify(flux_inward)}")
Worked example
Find the flux of \vec F(x,y,z)=\langle x,y,z\rangle through the sphere of radius R, using the outward normal.
Using §12.6's sphere parametrization and its already-computed cross product $\vec r_\varphi\times\vec r_\theta=\langle R^2\sin^2\varphi\cos\theta,\ R^2\sin^2\varphi\sin\theta,\ R^2\sin\varphi\cos\varphi\rangle$ (which points outward, away from the origin, for this parametrization):
On the surface, $\vec F=\vec r(\varphi,\theta)=\langle R\sin\varphi\cos\theta, R\sin\varphi\sin\theta,R\cos\varphi\rangle$ — the position vector itself.
\vec F\cdot(\vec r_\varphi\times\vec r_\theta)=R\sin\varphi\cos\theta\cdot R^2\sin^2\varphi\cos\theta+R\sin\varphi\sin\theta\cdot R^2\sin^2\varphi\sin\theta+R\cos\varphi\cdot R^2\sin\varphi\cos\varphi
=R^3\sin^3\varphi(\cos^2\theta+\sin^2\theta)+R^3\sin\varphi\cos^2\varphi=R^3\sin^3\varphi+R^3\sin\varphi\cos^2\varphi
=R^3\sin\varphi\big(\sin^2\varphi+\cos^2\varphi\big)=R^3\sin\varphi
\text{Flux}=\int_0^{2\pi}\int_0^\pi R^3\sin\varphi\,d\varphi\,d\theta=R^3\int_0^{2\pi}2\,d\theta=\boxed{4\pi R^3}
Sanity check. The radial field \langle x,y,z\rangle points directly outward everywhere, exactly aligned with the sphere's own outward normal at every point — so flux should be strongly positive, not accidentally cancelling anywhere, and it is. Notice also $4\pi R^3=3\cdot\left(\frac43\pi R^3\right)$, exactly 3 times the sphere's enclosed volume — no coincidence: §12.9's divergence theorem will show this flux equals \iiint_E\text{div}\,\vec F\,dV, and \text{div}\langle x,y,z\rangle=1+1+1=3 (§12.5), so 3\times\text{Volume}=3\cdot\frac43\pi R^3=4\pi R^3 — matching exactly, a preview of the theorem two lessons ahead. ✓
Your turn
1. Find the surface area (i.e. the surface integral with f=1) of a sphere of radius 2, using the formula from this lesson (should match §12.6's sphere-area result at R=2).
2. Explain, without recomputing, why the flux of \vec F(x,y,z)=\langle x,y,z\rangle through a sphere of radius 2R should be exactly 8 times the flux through a sphere of radius R (hint: think about how 4\pi R^3 scales).
3. True or false: flux measures the same physical quantity regardless of which direction the surface's normal vector is chosen to point.
Solutions
1. From §12.6, |\vec r_\varphi\times\vec r_\theta|=R^2\sin\varphi, so at R=2: 4\sin\varphi.
A=\int_0^{2\pi}\int_0^\pi4\sin\varphi\,d\varphi\,d\theta=4\cdot2\cdot2\pi=\boxed{16\pi}
— matching 4\pi(2)^2=16\pi directly, confirming §12.6's formula at a different radius.
2. Flux through a sphere of radius R is 4\pi R^3. Replacing R with 2R: 4\pi(2R)^3=4\pi\cdot8R^3=8\cdot(4\pi R^3) — exactly 8 times larger, purely because the formula scales with R^3, and doubling R cubes to a factor of 2^3=8. No new integral computation was needed — just tracking how the closed-form answer depends on R.
3. False. Reversing the normal direction flips the sign of the flux integral, exactly as reversing a line integral's direction flips its sign (§12.2). The magnitude of the physical flow through the surface is unaffected by this choice, but the signed number — which the flux integral literally computes — depends on which way \hat n was chosen to point, which is precisely why orientation must always be specified alongside a flux problem.
Check yourself in code
Find the flux of \vec F(x,y,z)=\langle x,y,z\rangle through the sphere of radius R, using the outward normal.
Print exactly this:
F . (r_phi x r_theta) = R**3*sin(phi)
flux = 4*pi*R**3
import sympy as sp
phi, theta, R = sp.symbols('phi theta R', positive=True)
r = sp.Matrix([
R * sp.sin(phi) * sp.cos(theta),
R * sp.sin(phi) * sp.sin(theta),
R * sp.cos(phi)
])
r_phi, r_theta = r.diff(phi), r.diff(theta)
normal = r_phi.cross(r_theta)
F = r
flux_integrand = sp.simplify(F.dot(normal))
print("F . (r_phi x r_theta) = ...")
flux = sp.integrate(sp.integrate(flux_integrand, (phi, 0, sp.pi)), (theta, 0, 2*sp.pi))
print("flux = ...")
import sympy as sp
phi, theta, R = sp.symbols('phi theta R', positive=True)
r = sp.Matrix([
R * sp.sin(phi) * sp.cos(theta),
R * sp.sin(phi) * sp.sin(theta),
R * sp.cos(phi)
])
r_phi, r_theta = r.diff(phi), r.diff(theta)
normal = r_phi.cross(r_theta)
F = r
flux_integrand = sp.simplify(F.dot(normal))
print(f"F . (r_phi x r_theta) = {flux_integrand}")
flux = sp.integrate(sp.integrate(flux_integrand, (phi, 0, sp.pi)), (theta, 0, 2*sp.pi))
print(f"flux = {sp.simplify(flux)}")
A scalar surface integral, \iint_Sf\,dS, weights §12.6's surface-area element by a function's value — the surface analogue of §12.1's curved- wire mass — while flux, $\iint_S\vec F\cdot d\vec S=\iint_D\vec F\cdot(\vec r_u\times\vec r_v)\,du\,dv$, measures how much of a vector field passes perpendicularly through a surface, using the cross product to supply both the correct normal direction and the correct area scaling at once. Like a line integral's direction-dependence in §12.2, flux depends on the surface's chosen orientation, flipping sign when the normal reverses.
Next: Stokes' theorem, which relates a vector field's circulation around a surface's boundary curve to the flux of its curl through the surface — the direct three-dimensional generalization of Green's theorem.