TExcelTAD
Home › Calculus in Depth › Applications of Double Integrals

Applications of Double Integrals

Whenever a quantity is spread over a flat region with a varying density, a double integral adds it up: the mass of a plate, the charge on a sheet, the probability that a random point lands in a set. This lesson develops mass and centre of mass, moments of inertia (the numbers a physics engine needs to spin a body correctly) and joint probability densities with expected values.

The survey course introduces double and triple integrals in Double and Triple Integrals.

The one-variable versions are in Applications to Physics and Engineering and Probability.

Mass and charge

A lamina is a thin plate occupying a region DD, with density ρ(x,y)\rho(x, y) in mass per unit area. A small piece of area ΔA\Delta A around (x,y)(x, y) has mass ≈ρ(x,y) ΔA\approx \rho(x, y)\,\Delta A, so the Riemann-sum argument gives

m=∬Dρ(x,y) dAm = \iint_D \rho(x, y)\,dA

The same formula with a charge density σ(x,y)\sigma(x, y) gives the total charge Q=∬Dσ dAQ = \iint_D \sigma\,dA; with a population density it gives a head count; with pixel brightness it gives total light.

Moments and centre of mass

The moments of the lamina about the axes are

Mx=∬Dy ρ(x,y) dA(about the x-axis)My=∬Dx ρ(x,y) dA(about the y-axis)\begin{aligned} M_x &= \iint_D y\,\rho(x, y)\,dA && \text{(about the } x\text{-axis)} \\ M_y &= \iint_D x\,\rho(x, y)\,dA && \text{(about the } y\text{-axis)} \end{aligned}

and the centre of mass is the point (xˉ,yˉ)(\bar{x}, \bar{y}) with

xˉ=Mym,yˉ=Mxm\bar{x} = \frac{M_y}{m}, \qquad \bar{y} = \frac{M_x}{m}

Physically, the lamina balances on a pin at (xˉ,yˉ)(\bar{x}, \bar{y}): the weighted average of positions, with weights ρ dA\rho\,dA. When ρ\rho is constant, the centre of mass is the centroid of DD, a purely geometric point, and the density cancels.

Tip: Use symmetry first. If DD and ρ\rho are both symmetric about a line, the centre of mass lies on that line, and one of the moments is zero without any computation.

Moments of inertia

The moment of inertia (second moment) about an axis measures how hard it is to start the lamina spinning about that axis. A mass mm at distance dd contributes md2m d^2, so

Ix=∬Dy2ρ dA,Iy=∬Dx2ρ dA,I0=∬D(x2+y2) ρ dA=Ix+IyI_x = \iint_D y^2 \rho\,dA, \qquad I_y = \iint_D x^2 \rho\,dA, \qquad I_0 = \iint_D (x^2 + y^2)\,\rho\,dA = I_x + I_y

I0I_0 is about the zz-axis through the origin (the perpendicular axis theorem: I0=Ix+IyI_0 = I_x + I_y for a flat body). The radius of gyration RR about an axis is defined by mR2=Im R^2 = I: the distance at which all the mass, concentrated, would have the same inertia.

Two standard results, for uniform bodies of mass mm:

Body (axis through the centre, perpendicular to the plate) II
disk of radius aa 12ma2\frac{1}{2} m a^2
rectangle w×hw \times h m(w2+h2)/12m (w^2 + h^2)/12
thin ring of radius aa ma2m a^2

The disk value comes from polar coordinates: with ρ=mπa2\rho = \frac{m}{\pi a^2}, I0=ρ∫02π∫0ar2⋅r dr dθ=ρ⋅2πa44=12ma2I_0 = \rho \int_0^{2\pi} \int_0^a r^2 \cdot r\,dr\,d\theta = \rho \cdot \frac{2\pi a^4}{4} = \frac{1}{2} m a^2. A disk spins up more easily than a ring of the same mass because its mass sits closer to the axis.

python · try it yourself
import sympy as sp

x, y = sp.symbols("x y")
# a triangular plate 0 ≤ x ≤ 1, 0 ≤ y ≤ 2 − 2x, heavier towards the right
rho = 1 + 3 * x + y
lims = [(y, 0, 2 - 2 * x), (x, 0, 1)]
m  = sp.integrate(rho, *lims)
My = sp.integrate(x * rho, *lims)
Mx = sp.integrate(y * rho, *lims)
I0 = sp.integrate((x**2 + y**2) * rho, *lims)
print("mass m          =", m)
print("centre of mass  =", (My / m, Mx / m))
print("centroid (ρ = 1)=", (sp.integrate(x, *lims), sp.integrate(y, *lims)))   # the area is 1
print("I0 about origin =", I0)
mass m          = 8/3
centre of mass  = (3/8, 11/16)
centroid (ρ = 1)= (1/3, 2/3)
I0 about origin = 12/5

The triangle has area 1, so the uniform centroid is the average of the vertices (0,0)(0, 0), (1,0)(1, 0), (0,2)(0, 2), namely (13,23)\left(\frac{1}{3}, \frac{2}{3}\right). The extra density to the right and upwards moves the centre of mass to (38,1116)=(0.375,0.6875)\left(\frac{3}{8}, \frac{11}{16}\right) = (0.375, 0.6875).

Joint probability densities

A pair of continuous random variables (X,Y)(X, Y) has a joint density p(x,y)p(x, y) if

P((X,Y)∈D)=∬Dp(x,y) dAfor every (reasonable) region DP((X, Y) \in D) = \iint_D p(x, y)\,dA \qquad \text{for every (reasonable) region } D

so p≥0p \ge 0 and ∬R2p dA=1\iint_{\mathbb{R}^2} p\,dA = 1. The probability is the "mass" of DD under the density pp. Expected values are the centre-of-mass formulas:

E[X]=∬x p(x,y) dA,E[Y]=∬y p(x,y) dA,E[g(X,Y)]=∬g(x,y) p(x,y) dAE[X] = \iint x\,p(x, y)\,dA, \qquad E[Y] = \iint y\,p(x, y)\,dA, \qquad E[g(X, Y)] = \iint g(x, y)\,p(x, y)\,dA

XX and YY are independent exactly when p(x,y)=pX(x) pY(y)p(x, y) = p_X(x)\,p_Y(y); then separable integrals split into products.

Example: which part fails first? Two components have independent exponential lifetimes with rates λ1=1\lambda_1 = 1 and λ2=2\lambda_2 = 2 per year, so p(x,y)=e−x⋅2e−2yp(x, y) = e^{-x} \cdot 2e^{-2y} for x,y≥0x, y \ge 0. The probability that the first fails first is the mass of the region y>xy > x:

P(X<Y)=∫0∞∫x∞2e−xe−2y dy dx=∫0∞e−xe−2x dx=13P(X < Y) = \int_0^{\infty} \int_x^{\infty} 2 e^{-x} e^{-2y}\,dy\,dx = \int_0^{\infty} e^{-x} e^{-2x}\,dx = \frac{1}{3}

In general P(X<Y)=λ1λ1+λ2P(X < Y) = \frac{\lambda_1}{\lambda_1 + \lambda_2}: this is why, in a queue or a race between exponential clocks, the faster clock wins with probability proportional to its rate.

python · try it yourself
import numpy as np
import sympy as sp

x, y = sp.symbols("x y", nonnegative=True)
pX, pY = sp.exp(-x), 2 * sp.exp(-2 * y)              # independent: p = pX * pY
print("total mass:", sp.integrate(pX, (x, 0, sp.oo)) * sp.integrate(pY, (y, 0, sp.oo)))
inner = sp.integrate(pY, (y, x, sp.oo))              # P(Y > x) = e^(-2x)
print("P(X < Y)  :", sp.integrate(pX * inner, (x, 0, sp.oo)))
# min(x, y) = x above the line y = x and y below it
above = sp.integrate(x * pX * inner, (x, 0, sp.oo))
below = sp.integrate(sp.integrate(y * pY, (y, 0, x)) * pX, (x, 0, sp.oo))
print("E[min]    :", sp.simplify(above + below))

rng = np.random.default_rng(3)
X = rng.exponential(1.0, 500_000)        # scale = 1/rate
Y = rng.exponential(0.5, 500_000)
print("simulated P(X < Y):", round(float(np.mean(X < Y)), 4), "  E[min]:", round(float(np.minimum(X, Y).mean()), 4))
total mass: 1
P(X < Y)  : 1/3
E[min]    : 1/3
simulated P(X < Y): 0.3319   E[min]: 0.3339

The minimum of independent exponentials is exponential with rate λ1+λ2=3\lambda_1 + \lambda_2 = 3, so E[min⁡]=13E[\min] = \frac{1}{3} as well: the double integral confirms it, split along the line y=xy = x where min⁡(x,y)\min(x, y) changes formula.

In software

  • Physics engines store each rigid body's mass, centre of mass and inertia (a tensor in 3D, a single number in 2D). Box2D computes them for a polygon by splitting it into triangles from a reference point and adding each triangle's exact integrals; getting II wrong makes bodies spin too easily or too sluggishly. See Rotational Dynamics.
  • Image moments. For a grayscale image I(x,y)I(x, y), m=∑Im = \sum I, the centroid is (∑xI/m,∑yI/m)\left(\sum xI/m, \sum yI/m\right), and the second moments give the orientation and elongation of a blob: discrete versions of exactly these integrals, used in object tracking and OpenCV's moments.
  • Monte Carlo expectations. E[g(X,Y)]E[g(X, Y)] for a complicated gg is estimated by averaging gg over simulated pairs, the probabilistic reading of "integral=area×average value\text{integral} = \text{area} \times \text{average value}" from the first lesson of this chapter. Reinforcement learning, Bayesian inference and risk models all rely on it.

Exercises

Exercise 1: Centre of mass of a square

A square plate [0,1]×[0,1][0, 1] \times [0, 1] has density ρ(x,y)=x\rho(x, y) = x. Find its mass and centre of mass.

Answer

m=12m = \frac{1}{2}, centre of mass (23,12)\left(\frac{2}{3}, \frac{1}{2}\right).

Solution
m=∬x dA=12⋅1=12My=∬x2 dA=13Mx=∬xy dA=12⋅12=14xˉ=1/31/2=23,yˉ=1/41/2=12\begin{aligned} m &= \iint x\,dA = \tfrac{1}{2} \cdot 1 = \tfrac{1}{2} \\ M_y &= \iint x^2\,dA = \tfrac{1}{3} \\ M_x &= \iint xy\,dA = \tfrac{1}{2} \cdot \tfrac{1}{2} = \tfrac{1}{4} \\ \bar{x} &= \frac{1/3}{1/2} = \frac{2}{3}, \qquad \bar{y} = \frac{1/4}{1/2} = \frac{1}{2} \end{aligned}

The density does not depend on yy and the square is symmetric about y=12y = \frac{1}{2}, so yˉ=12\bar{y} = \frac{1}{2} was predictable.

Exercise 2: Centroid of a half disk

Find the centroid of the uniform half disk x2+y2≤a2x^2 + y^2 \le a^2, y≥0y \ge 0.

Answer

(0,4a3π)≈(0,0.424a)\left(0, \frac{4a}{3\pi}\right) \approx (0, 0.424a).

Solution

By symmetry xˉ=0\bar{x} = 0. With ρ=1\rho = 1 the mass is the area πa22\frac{\pi a^2}{2}, and in polar coordinates

Mx=∫0π∫0a(rsin⁡θ) r dr dθ=2⋅a33yˉ=2a3/3πa2/2=4a3π\begin{aligned} M_x &= \int_0^{\pi} \int_0^a (r \sin\theta)\,r\,dr\,d\theta = 2 \cdot \frac{a^3}{3} \\ \bar{y} &= \frac{2a^3/3}{\pi a^2/2} = \frac{4a}{3\pi} \end{aligned}

Exercise 3: Normalise a density

p(x,y)=C(x+2y)p(x, y) = C(x + 2y) on [0,1]×[0,1][0, 1] \times [0, 1] and 0 elsewhere. Find CC, then P(X>Y)P(X > Y).

Answer

C=23C = \frac{2}{3}, P(X>Y)=49P(X > Y) = \frac{4}{9}.

Solution
∬(x+2y) dA=12+2⋅12=32  ⟹  C=23P(X>Y)=23∫01∫0x(x+2y) dy dx=23∫01(x2+x2) dx=23⋅23=49\begin{aligned} &\iint (x + 2y)\,dA = \tfrac{1}{2} + 2 \cdot \tfrac{1}{2} = \tfrac{3}{2} \implies C = \tfrac{2}{3} \\ &P(X > Y) = \tfrac{2}{3} \int_0^1 \int_0^x (x + 2y)\,dy\,dx = \tfrac{2}{3} \int_0^1 (x^2 + x^2)\,dx = \tfrac{2}{3} \cdot \tfrac{2}{3} = \tfrac{4}{9} \end{aligned}

Exercise 4: Inertia of a rectangle (code)

Use SymPy to compute I0I_0 about the centre for a uniform rectangle of width ww, height hh and mass mm, and confirm m(w2+h2)/12m(w^2 + h^2)/12.

Answer

I0=m(w2+h2)/12I_0 = m(w^2 + h^2)/12.

Solution

Place the centre at the origin, so −w/2≤x≤w/2-w/2 \le x \le w/2, −h/2≤y≤h/2-h/2 \le y \le h/2, and ρ=mwh\rho = \frac{m}{wh}.

python · try it yourself
import sympy as sp
x, y, w, h, m = sp.symbols("x y w h m", positive=True)
I0 = sp.integrate((x**2 + y**2) * m / (w * h), (x, -w / 2, w / 2), (y, -h / 2, h / 2))
print(sp.factor(I0), "| check:", sp.simplify(I0 - m * (w**2 + h**2) / 12))
m*(h**2 + w**2)/12 | check: 0

Exercise 5: A four-dimensional average (code)

The average distance between two independent uniform random points in the unit square is a 4D integral, with exact value 2+2+5ln⁡(1+2)15\frac{2 + \sqrt{2} + 5 \ln(1 + \sqrt{2})}{15}. Estimate it by Monte Carlo with 10610^6 pairs (seed 11) and compare.

Answer

Exact value ≈0.5214\approx 0.5214; the simulation gives 0.5213.

Solution

A grid with 30 points per axis would already need 304=810 00030^4 = 810\,000 evaluations for a crude estimate; Monte Carlo's error depends only on the number of samples.

python · try it yourself
import math
import numpy as np
rng = np.random.default_rng(11)
P, Q = rng.random((1_000_000, 2)), rng.random((1_000_000, 2))
d = np.linalg.norm(P - Q, axis=1)
print(round(float(d.mean()), 4), round((2 + math.sqrt(2) + 5 * math.log(1 + math.sqrt(2))) / 15, 4))
0.5213 0.5214

Test yourself

The centre of mass of a lamina is (xˉ,yˉ)=(\bar{x}, \bar{y}) = …

  1. (Mx/m,My/m)(M_x/m, M_y/m)
  2. (My/m,Mx/m)(M_y/m, M_x/m)
  3. (Iy/m,Ix/m)(I_y/m, I_x/m)
  4. (m/My,m/Mx)(m/M_y, m/M_x)

A uniform disk and a thin ring have the same mass mm and radius aa. Which has the larger moment of inertia about its centre?

  1. The disk
  2. They are equal
  3. The ring
  4. It depends on the material

If p(x,y)p(x, y) is a joint density, what must ∬ over the whole plane of p dA\iint \text{ over the whole plane of } p\,dA equal?

  1. 0
  2. 1
  3. The mean of XX
  4. It can be any positive number