19. Center of mass and centroids
A see-saw with two riders balances at the point where their moments — mass times distance from the pivot — cancel. That single balancing idea, extended from a couple of point masses to a continuous distribution of mass spread over an interval or a region, is what this lesson builds, and once again it's an averaging problem the integral is built to solve.
Point masses: the discrete case
For point masses m_1,\ldots,m_n at positions x_1,\ldots,x_n, the center of mass is the weighted average position:
\bar x=\frac{\sum_im_ix_i}{\sum_im_i}=\frac{\text{total moment}}{\text{total mass}}
The numerator, \sum m_ix_i, is the moment — how much each mass contributes to tipping the system, scaled by how far it sits from the origin. A mass far from the origin has more leverage than the same mass close in, exactly as a see-saw rider farther from the pivot needs less weight to balance one sitting close.
A continuous rod
Replace point masses with a rod along [a,b] whose density (mass per unit length) is \rho(x). A tiny piece [x,x+dx] has mass dm=\rho(x)\,dx and moment x\,dm=x\rho(x)\,dx. Summing (integrating) both, then dividing:
\bar x=\frac{\displaystyle\int_a^bx\rho(x)\,dx}{\displaystyle\int_a^b\rho(x)\,dx}
The denominator is the rod's total mass; the numerator is its total moment. This is the discrete formula with sums replaced by integrals — the same limit-of-a-sum move behind every formula in this module.
The centroid of a plane region
A flat region (a lamina) of uniform density has a center of mass called its centroid — it depends only on the shape, not on any physical density value, since a constant density cancels out of the ratio. For the region under y=f(x) (above y=0) on [a,b], with area A:
\bar x=\frac1A\int_a^bx\,f(x)\,dx
For \bar y: each vertical strip is (to first order) a thin rectangle whose own center of mass sits at its midpoint height, \frac{f(x)}2, and whose mass is proportional to its area f(x)\,dx:
\bar y=\frac1A\int_a^b\frac{\big[f(x)\big]^2}{2}\,dx
Notice the exponent. \bar x weights by f(x) (the strip's mass); \bar y weights by \frac{[f(x)]^2}2 because that expression already bundles both the strip's mass and the fact that its own centroid sits at half its height. This squared term is structurally the disk-method integrand from §5.1 in disguise — both come from "a strip's contribution, weighted by something proportional to f(x)^2."
For a region between two curves, g(x)\le y\le f(x), the same idea generalizes exactly the way area (§5.0) and volume (§5.1) did:
A=\int_a^b\big[f(x)-g(x)\big]dx,\quad\bar x=\frac1A\int_a^bx\big[f(x)-g(x)\big]dx,\quad\bar y=\frac1A\int_a^b\frac{[f(x)]^2-[g(x)]^2}2dx
The Pappus connection
There's a payoff for computing a centroid: Pappus's theorem says the volume of a solid of revolution equals the area of the region times the distance its centroid travels when revolved:
V=2\pi\bar x\cdot A
(for revolution around the y-axis, region entirely at x\ge0). This is a genuine shortcut — once \bar x and A are known, §5.1 and §5.2's whole disk/washer/shell machinery collapses into one multiplication. It's also a nice check: compute a volume both ways and confirm they agree.
Doing it in Python
Center of mass of a rod with density \rho(x)=x+1 on [0,2]:
import sympy as sp
x = sp.Symbol('x')
rho = x + 1
M = sp.integrate(rho, (x, 0, 2))
moment = sp.integrate(x * rho, (x, 0, 2))
x_cm = moment / M
print(f"total mass = {M}")
print(f"total moment = {moment}")
print(f"center of mass x = {x_cm}")
The centroid of the region under y=x^2 on [0,2], both coordinates:
import sympy as sp
x = sp.Symbol('x')
f = x**2
A = sp.integrate(f, (x, 0, 2))
x_bar = sp.integrate(x * f, (x, 0, 2)) / A
y_bar = sp.integrate(f**2 / 2, (x, 0, 2)) / A
print(f"area = {A}")
print(f"x_bar = {x_bar}")
print(f"y_bar = {y_bar}")
Checking Pappus's theorem against the direct shell-method volume from §5.2, for this same region revolved around the y-axis:
import sympy as sp
x = sp.Symbol('x')
f = x**2
A = sp.integrate(f, (x, 0, 2))
x_bar = sp.integrate(x * f, (x, 0, 2)) / A
V_pappus = 2 * sp.pi * x_bar * A
V_shell = 2 * sp.pi * sp.integrate(x * f, (x, 0, 2))
print(f"Pappus: 2*pi*x_bar*A = {V_pappus}")
print(f"shell method directly = {V_shell}")
print(f"agree: {V_pappus == V_shell}")
Worked example
Find the centroid of the region under y=x^2 on [0,2].
A=\int_0^2x^2dx=\left[\frac{x^3}3\right]_0^2=\frac83
\bar x=\frac1A\int_0^2x\cdot x^2\,dx=\frac{3}{8}\int_0^2x^3dx=\frac38\left[\frac{x^4}4\right]_0^2=\frac38\cdot4=\boxed{\frac32}
\bar y=\frac1A\int_0^2\frac{(x^2)^2}2dx=\frac38\cdot\frac12\int_0^2x^4dx=\frac{3}{16}\left[\frac{x^5}5\right]_0^2=\frac3{16}\cdot\frac{32}5=\boxed{\frac65}
Sanity check. The region spans x\in[0,2] and, since the curve bulges outward toward x=2 (more area sits at larger x), the centroid should lie past the interval's midpoint of 1 — and \bar x=1.5 does. The region's height ranges from 0 to f(2)=4, and \bar y=1.2 sits well below the midheight of 2, which fits: most of the region's area is in the shorter part of the strips (near x=0, where f(x) is small), pulling the vertical balance point down. ✓
Your turn
1. Find the center of mass of a rod on [0,3] with constant density \rho(x)=5. (It should land exactly at the geometric midpoint — check that your formula confirms this for any constant density.)
2. Find \bar x for the region under y=\sqrt x on [0,4].
3. Using Pappus's theorem and your answer to problem 2 (you'll need the area too), find the volume of revolving that region around the y-axis — then check it against the shell-method formula from §5.2.
Solutions
1. M=\int_0^35\,dx=15, moment =\int_0^35x\,dx=5\left[\frac{x^2}2\right]_0^3=\frac{45}2:
\bar x=\frac{45/2}{15}=\boxed{\frac32}
— exactly the midpoint of [0,3]. In general, for constant density \rho, \bar x=\frac{\rho\int x\,dx}{\rho\int dx}=\frac{\int x\,dx}{\int dx}, and \rho cancels entirely — confirming that a uniform rod's balance point never depends on how much mass it carries, only on its shape.
2. A=\int_0^4\sqrt x\,dx=\left[\frac23x^{3/2}\right]_0^4=\frac23\cdot8=\frac{16}3.
\bar x=\frac{1}{16/3}\int_0^4x\sqrt x\,dx=\frac3{16}\int_0^4x^{3/2}dx=\frac3{16}\left[\frac25x^{5/2}\right]_0^4=\frac3{16}\cdot\frac{2}{5}\cdot32=\boxed{\frac{12}5}
3.
V=2\pi\bar x\cdot A=2\pi\cdot\frac{12}5\cdot\frac{16}3=2\pi\cdot\frac{192}{15}=\frac{384\pi}{15}=\frac{128\pi}5
Shell method directly: V=2\pi\int_0^4x\sqrt x\,dx=2\pi\int_0^4x^{3/2}dx=2\pi\left[\frac25x^{5/2}\right]_0^4=2\pi\cdot\frac{64}5=\boxed{\frac{128\pi}5}
— they match, confirming Pappus's theorem is exactly the shell-method integral in disguise, repackaged through the centroid.
Check yourself in code
Compute the total mass and center of mass of a rod on [0,2] with density \rho(x)=x+1, and the centroid (\bar x,\bar y) of the region under y=x^2 on [0,2].
Print exactly this:
rod: mass = 4, center of mass = 7/6
region under x^2 on [0,2]: x_bar = 3/2, y_bar = 6/5
import sympy as sp
x = sp.Symbol('x')
rho = x + 1
M = sp.integrate(rho, (x, 0, 2))
x_cm = sp.integrate(x * rho, (x, 0, 2)) / M
print("rod: mass = ..., center of mass = ...")
f = x**2
A = sp.integrate(f, (x, 0, 2))
x_bar = sp.integrate(x * f, (x, 0, 2)) / A
y_bar = sp.integrate(f**2 / 2, (x, 0, 2)) / A
print("region under x^2 on [0,2]: x_bar = ..., y_bar = ...")
import sympy as sp
x = sp.Symbol('x')
rho = x + 1
M = sp.integrate(rho, (x, 0, 2))
x_cm = sp.integrate(x * rho, (x, 0, 2)) / M
print(f"rod: mass = {M}, center of mass = {x_cm}")
f = x**2
A = sp.integrate(f, (x, 0, 2))
x_bar = sp.integrate(x * f, (x, 0, 2)) / A
y_bar = sp.integrate(f**2 / 2, (x, 0, 2)) / A
print(f"region under x^2 on [0,2]: x_bar = {x_bar}, y_bar = {y_bar}")
Center of mass is a weighted average — \bar x=\frac{\int x\,dm}{\int dm} — built from the same discrete-sum-to-integral limit as every other formula in this module, with "moment" playing the role area and volume played before. For a planar region, \bar y carries a factor of \frac12 because each strip's own centroid sits at its midpoint height, and Pappus's theorem — V=2\pi\bar x A — shows that the centroid isn't just a curiosity: it's the shell-method volume integral, repackaged as a single multiplication.
Next: another kind of average — not of position, but of a function's value itself — and the theorem guaranteeing that average is actually achieved somewhere on the interval.