18. Mass, moments, centroids, and joint densities

📖 Reading · 9 min
💡 Every code box below is live — edit it and hit Run.

§5.5 built center of mass for a flat region of uniform density, using a single integral because the region's shape alone determined the answer. Let density vary from point to point across a two-dimensional region, and a single integral is no longer enough — this lesson rebuilds mass, moment, and center of mass with §11.0's double integral, and closes with a second application built from the exact same formulas: joint probability densities.

Mass of a lamina with variable density

For a flat plate (lamina) occupying region R, with density (mass per unit area) \rho(x,y) varying across the plate, a tiny piece of area dA has mass \rho(x,y)\,dA. Summing over the whole region:

M=\iint_R\rho(x,y)\,dA

This is §5.5's rod-mass formula, M=\int\rho(x)\,dx, extended from one dimension to two — the same "density times infinitesimal size, summed" idea, now integrated over an area instead of a length.

Moments and center of mass

The moment about the x-axis, M_x, weights each piece of mass by its distance from the x-axis (i.e., by its y-coordinate); the moment about the y-axis, M_y, weights by distance from the y-axis (its x-coordinate):

M_x=\iint_Ry\,\rho(x,y)\,dA\qquad M_y=\iint_Rx\,\rho(x,y)\,dA

The center of mass is the balance point, moment divided by total mass — exactly §5.5's discrete-to-continuous averaging idea, one more time:

\bar x=\frac{M_y}M\qquad\bar y=\frac{M_x}M

Notice which moment produces which coordinate: \bar x (an x-coordinate) comes from M_y (weighted by x), and \bar y comes from M_x — a naming convention that trips up almost everyone the first time, worth memorizing deliberately rather than guessing.

A uniform-density lamina recovers §5.5's original centroid formulas exactly: if \rho(x,y)=k (constant), it factors out of every integral, and \bar x=\frac{\iint x\,dA}{\iint dA} — the plain geometric centroid, with no reference to density left at all, matching §5.5's lamina formulas precisely.

Doing it in Python

Mass and center of mass of a lamina over the region between y=x^2 and y=1, with density \rho(x,y)=y (denser near the top):

import sympy as sp

x, y = sp.symbols('x y')
rho = y

M = sp.integrate(sp.integrate(rho, (y, x**2, 1)), (x, -1, 1))
M_x = sp.integrate(sp.integrate(y * rho, (y, x**2, 1)), (x, -1, 1))
M_y = sp.integrate(sp.integrate(x * rho, (y, x**2, 1)), (x, -1, 1))

x_bar = M_y / M
y_bar = M_x / M

print(f"mass M = {M}")
print(f"M_x = {M_x}, M_y = {M_y}")
print(f"center of mass: ({x_bar}, {y_bar})")

Confirming that constant density recovers §5.5's plain geometric centroid, for the same region:

import sympy as sp

x, y = sp.symbols('x y')

# constant density -- should give the same x_bar as section 5.5's method
area = sp.integrate(sp.integrate(1, (y, x**2, 1)), (x, -1, 1))
M_y_const = sp.integrate(sp.integrate(x, (y, x**2, 1)), (x, -1, 1))
x_bar_const = M_y_const / area
print(f"x_bar with constant density = {x_bar_const}")
print("(zero, by the left-right symmetry of this region -- a useful sanity check)")

A joint probability density: verifying it integrates to 1, and computing a probability directly as a double integral:

import sympy as sp

x, y = sp.symbols('x y')
f = 6 * x * y**2   # a joint density on the unit square [0,1]x[0,1]

total = sp.integrate(sp.integrate(f, (y, 0, 1)), (x, 0, 1))
print(f"total probability (should be 1): {total}")

# P(0 <= X <= 0.5, 0 <= Y <= 1)
prob = sp.integrate(sp.integrate(f, (y, 0, 1)), (x, 0, sp.Rational(1,2)))
print(f"P(X <= 0.5) = {prob}")

Worked example

Find the mass and center of mass of the lamina over the region bounded by y=x^2 and y=1, with density \rho(x,y)=y.

The region: -1\le x\le1, x^2\le y\le1.

M=\int_{-1}^1\int_{x^2}^1y\,dy\,dx=\int_{-1}^1\left[\frac{y^2}2\right]_{x^2}^1dx=\int_{-1}^1\frac{1-x^4}2dx

=\frac12\left[x-\frac{x^5}5\right]_{-1}^1=\frac12\left[\left(1-\frac15\right)-\left(-1+\frac15\right)\right]=\frac12\cdot\frac85=\boxed{\frac45}

M_y=\int_{-1}^1\int_{x^2}^1xy\,dy\,dx=\int_{-1}^1x\cdot\frac{1-x^4}2dx=0

(the integrand x(1-x^4) is odd, integrated over the symmetric interval [-1,1] — zero by symmetry, §4.7's technique)

M_x=\int_{-1}^1\int_{x^2}^1y^2\,dy\,dx=\int_{-1}^1\left[\frac{y^3}3\right]_{x^2}^1dx=\int_{-1}^1\frac{1-x^6}3dx=\frac13\left[x-\frac{x^7}7\right]_{-1}^1=\frac13\cdot\frac{12}7=\frac47

\bar x=\frac{M_y}M=\frac0{4/5}=\boxed0\qquad\bar y=\frac{M_x}M=\frac{4/7}{4/5}=\frac45\cdot\frac54=\boxed{\frac57}

Sanity check. \bar x=0 matches the region's left-right symmetry about the y-axis exactly — no computation could have given anything else, since the region and the density \rho=y are both symmetric under x\to-x. And \bar y=\frac57\approx0.714 sits in the upper portion of the region (which spans y\in[0,1] at its widest), consistent with the density \rho=y weighting the top of the region more heavily — pulling the balance point up from where a uniform-density centroid would sit. ✓

Your turn

1. Find the mass of a lamina over the square [0,1]\times[0,1] with density \rho(x,y)=x+y.

2. Find \bar x for the lamina in problem 1 (you'll need M_y).

3. True or false: for a joint probability density f(x,y), the "center of mass" formulas \bar x=\iint xf\,dA, \bar y=\iint yf\,dA compute the same thing as E[X] and E[Y] from §5.7's single-variable expected value.

Solutions

1.

M=\int_0^1\int_0^1(x+y)\,dy\,dx=\int_0^1\left[xy+\frac{y^2}2\right]_0^1dx=\int_0^1\left(x+\frac12\right)dx=\left[\frac{x^2}2+\frac x2\right]_0^1=\boxed1

2.

M_y=\int_0^1\int_0^1x(x+y)\,dy\,dx=\int_0^1\left[x^2y+\frac{xy^2}2\right]_0^1dx=\int_0^1\left(x^2+\frac x2\right)dx=\left[\frac{x^3}3+\frac{x^2}4\right]_0^1=\frac13+\frac14=\frac7{12}

\bar x=\frac{M_y}M=\frac{7/12}1=\boxed{\frac7{12}}

3. True. Since a joint density already satisfies \iint f\,dA=1 (the "total mass" is automatically 1, exactly as §5.7 noted for the single-variable case), $\bar x=\frac{M_y}M=\frac{\iint xf\,dA}1=\iint xf\,dA$ — identical to the direct expected-value formula. Just as §5.7 showed a probability density is a mass distribution with total mass 1 and expected value equal to its centroid, a joint density is a two-dimensional mass distribution with the identical relationship, one dimension up.

Check yourself in code

Find the mass and center of mass of the lamina over the region bounded by y=x^2 and y=1, with density \rho(x,y)=y.

Print exactly this:

mass = 4/5
center of mass = (0, 5/7)
import sympy as sp

x, y = sp.symbols('x y')
rho = y

M = sp.integrate(sp.integrate(rho, (y, x**2, 1)), (x, -1, 1))
print("mass = ...")

M_x = sp.integrate(sp.integrate(y * rho, (y, x**2, 1)), (x, -1, 1))
M_y = sp.integrate(sp.integrate(x * rho, (y, x**2, 1)), (x, -1, 1))
x_bar = M_y / M
y_bar = M_x / M
print("center of mass = ...")
import sympy as sp

x, y = sp.symbols('x y')
rho = y

M = sp.integrate(sp.integrate(rho, (y, x**2, 1)), (x, -1, 1))
print(f"mass = {M}")

M_x = sp.integrate(sp.integrate(y * rho, (y, x**2, 1)), (x, -1, 1))
M_y = sp.integrate(sp.integrate(x * rho, (y, x**2, 1)), (x, -1, 1))
x_bar = M_y / M
y_bar = M_x / M
print(f"center of mass = ({x_bar}, {y_bar})")

Mass, M=\iint_R\rho\,dA, and the moments M_x, M_y that weight each piece of mass by its distance from an axis, extend §5.5's rod formulas to a full two-dimensional lamina — with the naming convention that \bar x comes from M_y (and vice versa) worth remembering deliberately. Setting \rho constant collapses everything back to §5.5's plain geometric centroid, and the exact same integrals, reinterpreted, compute expected value for a joint probability density — the two-variable sibling of §5.7's single-density lesson.

Next: extending the double integral one more dimension, to triple integrals over solid regions in space.