TExcelTAD
Home › Calculus in Depth › Triple Integrals

Triple Integrals

A triple integral adds up a quantity spread through a solid: mass from a density, charge from a charge density, probability from a joint density of three variables. It is defined by Riemann sums over little boxes, and computed, thanks to Fubini's theorem, as three nested one-variable integrals. The hard part is almost always the limits: describing the solid correctly.

The survey version is Multiple Integrals; two-variable groundwork is in Double Integrals over General Regions.

Definition over a box

Let B=[a,b]×[c,d]×[r,s]B = [a, b] \times [c, d] \times [r, s] and ff continuous on BB. Divide BB into l⋅m⋅nl \cdot m \cdot n sub-boxes BijkB_{ijk} of volume ΔV=Δx Δy Δz\Delta V = \Delta x\,\Delta y\,\Delta z, pick a sample point (x∗,y∗,z∗)(x^*, y^*, z^*) in each, and form

∭Bf(x,y,z) dV=lim⁡l,m,n→∞∑i∑j∑kf(xijk∗,yijk∗,zijk∗) ΔV\iiint_B f(x, y, z)\,dV = \lim_{l, m, n \to \infty} \sum_i \sum_j \sum_k f(x^*_{ijk}, y^*_{ijk}, z^*_{ijk})\,\Delta V

The limit exists for every continuous ff (and for bounded ff whose discontinuities lie on finitely many smooth surfaces).

Fubini's theorem (3D). If ff is continuous on BB, the triple integral equals any of the six iterated integrals, for example

∭Bf dV=∫rs∫cd∫abf(x,y,z) dx dy dz\iiint_B f\,dV = \int_r^s \int_c^d \int_a^b f(x, y, z)\,dx\,dy\,dz

Work from the inside out: integrate in xx with yy, zz held fixed, then in yy, then in zz.

General regions

A solid EE is type 1 if it lies between two surfaces over a region DD in the xyxy-plane:

E={(x,y,z):(x,y)∈D, u1(x,y)≤z≤u2(x,y)}∭Ef dV=∬D[∫u1(x,y)u2(x,y)f(x,y,z) dz]dA\begin{aligned} E &= \{(x, y, z) : (x, y) \in D,\ u_1(x, y) \le z \le u_2(x, y)\} \\ \iiint_E f\,dV &= \iint_D \left[ \int_{u_1(x,y)}^{u_2(x,y)} f(x, y, z)\,dz \right] dA \end{aligned}

and DD is then described as a type I or type II plane region. Types 2 and 3 are the same with the roles of the variables permuted (project onto the yzyz- or xzxz-plane instead).

Recipe.

  1. Sketch EE. Find the "floor" and "ceiling" surfaces in one variable.
  2. Project EE onto the plane of the other two variables to get DD; find DD's boundary by eliminating the variable (for example, setting floor=ceiling\text{floor} = \text{ceiling}).
  3. Describe DD with constant outer limits.

Example: a tetrahedron

EE is bounded by the coordinate planes and the plane x+y/2+z/3=1x + y/2 + z/3 = 1, so its vertices are (0,0,0)(0, 0, 0), (1,0,0)(1, 0, 0), (0,2,0)(0, 2, 0), (0,0,3)(0, 0, 3). Integrate f=zf = z:

0≤x≤1,0≤y≤2(1−x),0≤z≤3(1−x−y/2)∭Ez dV=∫01∫02(1−x)∫03(1−x−y/2)z dz dy dx\begin{aligned} &0 \le x \le 1, \quad 0 \le y \le 2(1 - x), \quad 0 \le z \le 3(1 - x - y/2) \\[1ex] &\iiint_E z\,dV = \int_0^1 \int_0^{2(1-x)} \int_0^{3(1-x-y/2)} z\,dz\,dy\,dx \end{aligned}

The volume is ∭E1 dV=16⋅1⋅2⋅3=1\iiint_E 1\,dV = \frac{1}{6} \cdot 1 \cdot 2 \cdot 3 = 1, and the integral of zz equals (volume)⋅(average z)=1⋅34=34(\text{volume}) \cdot (\text{average } z) = 1 \cdot \frac{3}{4} = \frac{3}{4} (the centroid of a tetrahedron is the average of its vertices, so zˉ=34\bar{z} = \frac{3}{4}).

python · try it yourself
import sympy as sp

x, y, z = sp.symbols("x y z")
lim = [(z, 0, 3 * (1 - x - y / 2)), (y, 0, 2 * (1 - x)), (x, 0, 1)]
print("volume     :", sp.integrate(1, *lim))
print("∭ z dV     :", sp.integrate(z, *lim))
print("∭ xyz dV   :", sp.integrate(x * y * z, *lim))

# the same volume in another order: dx dz dy
lim2 = [(x, 0, 1 - y / 2 - z / 3), (z, 0, 3 * (1 - y / 2)), (y, 0, 2)]
print("volume, order dx dz dy:", sp.integrate(1, *lim2))
volume     : 1
∭ z dV     : 3/4
∭ xyz dV   : 1/20
volume, order dx dz dy: 1

Changing the order

Six orders are possible, and the projection picture changes with each one. For the solid bounded by the parabolic cylinder y=x2y = x^2 and the planes z=0z = 0, z=1−yz = 1 - y (so 0≤y≤10 \le y \le 1):

dz dy dx:−1≤x≤1,x2≤y≤1,0≤z≤1−ydx dz dy:0≤y≤1,0≤z≤1−y,−y≤x≤ydx dy dz:0≤z≤1,0≤y≤1−z,−y≤x≤y\begin{aligned} &dz\,dy\,dx\text{:} && -1 \le x \le 1, && x^2 \le y \le 1, && 0 \le z \le 1 - y \\ &dx\,dz\,dy\text{:} && 0 \le y \le 1, && 0 \le z \le 1 - y, && -\sqrt{y} \le x \le \sqrt{y} \\ &dx\,dy\,dz\text{:} && 0 \le z \le 1, && 0 \le y \le 1 - z, && -\sqrt{y} \le x \le \sqrt{y} \end{aligned}

All three give volume 815\frac{8}{15}. Choosing a good order can turn an impossible inner integral into an easy one, just as in two variables.

Applications

With a density ρ(x,y,z)\rho(x, y, z) (mass per unit volume):

Quantity Formula
volume V=∭E1 dVV = \iiint_E 1\,dV
mass m=∭Eρ dVm = \iiint_E \rho\,dV
moments Myz=∭xρ dVM_{yz} = \iiint x\rho\,dV, Mxz=∭yρ dVM_{xz} = \iiint y\rho\,dV, Mxy=∭zρ dVM_{xy} = \iiint z\rho\,dV
centre of mass (xˉ,yˉ,zˉ)=(Myz,Mxz,Mxy)/m(\bar{x}, \bar{y}, \bar{z}) = (M_{yz}, M_{xz}, M_{xy})/m
moment of inertia about the zz-axis Iz=∭(x2+y2) ρ dVI_z = \iiint (x^2 + y^2)\,\rho\,dV
probability P((X,Y,Z)∈E)=∭EfXYZ dVP((X, Y, Z) \in E) = \iiint_E f_{XYZ}\,dV for a joint density

Monte Carlo in three dimensions

An iterated integral with nn sample points per axis costs n3n^3 evaluations, and the cost grows like ndn^d in dd dimensions. Monte Carlo integration draws NN random points in a box of volume VBV_B and estimates ∭Ef dV≈VB⋅mean⁡(f⋅1E)\iiint_E f\,dV \approx V_B \cdot \operatorname{mean}(f \cdot \mathbf{1}_E); its error shrinks like 1N\frac{1}{\sqrt{N}} whatever the dimension. In 3D, grids still win for smooth integrands (the example below integrates a 0–1 indicator, which slows both methods down); in 10 or 100 dimensions (as in physics, finance and Bayesian ML) Monte Carlo is the only practical option.

python · try it yourself
import numpy as np

rng = np.random.default_rng(7)
# volume of E = {x² + y² ≤ z ≤ 2 − x² − y²}, exactly π
N = 400_000
P = rng.uniform([-1, -1, 0], [1, 1, 2], size=(N, 3))
s = P[:, 0]**2 + P[:, 1]**2
inside = (s <= P[:, 2]) & (P[:, 2] <= 2 - s)
box = 2 * 2 * 2
est = box * inside.mean()
se = box * inside.std() / np.sqrt(N)
print(f"Monte Carlo volume ≈ {est:.4f} ± {se:.4f}   (exact π = {np.pi:.4f})")

# grid: midpoint rule with n points per axis
for n in [10, 40, 160]:
    c = (np.arange(n) + 0.5) / n
    X, Y, Z = np.meshgrid(2 * c - 1, 2 * c - 1, 2 * c, indexing="ij")
    S = X**2 + Y**2
    print(f"grid n={n:3d} ({n**3:>8,} points): {box * np.mean((S <= Z) & (Z <= 2 - S)):.4f}")
Monte Carlo volume ≈ 3.1436 ± 0.0062   (exact π = 3.1416)
grid n= 10 (   1,000 points): 3.2000
grid n= 40 (  64,000 points): 3.1310
grid n=160 (4,096,000 points): 3.1408

The exact value: the two paraboloids meet where s=1s = 1, and the height between them is 2−2r22 - 2r^2, so V=∫02π∫01(2−2r2) r dr dθ=2π⋅12=πV = \int_0^{2\pi} \int_0^1 (2 - 2r^2)\,r\,dr\,d\theta = 2\pi \cdot \frac{1}{2} = \pi.

In software

  • Physics engines need a rigid body's mass, centre of mass and inertia tensor, which are triple integrals of a density over the body. For meshes, engines compute them exactly by splitting the solid into tetrahedra from a reference point (each tetrahedron's integrals have closed forms like the example above). See Rotation Dynamics.
  • Volume rendering (medical CT, clouds and smoke in games) integrates density along rays; the total absorbed light is a line integral through a 3D field, and voxel grids store the field.
  • Probabilistic ML needs integrals of joint densities to normalise and marginalise; when the dimension is high, Monte Carlo and MCMC replace iterated integrals.

Exercises

Exercise 1: A box

Evaluate ∭Bxy2z3 dV\iiint_B x y^2 z^3\,dV over B=[0,1]×[0,2]×[0,1]B = [0, 1] \times [0, 2] \times [0, 1].

Answer

13\frac{1}{3}.

Solution

The integrand is a product of a function of xx, one of yy and one of zz, and the region is a box, so the integral factors:

∫01x dx⋅∫02y2 dy⋅∫01z3 dz=12⋅83⋅14=824=13\int_0^1 x\,dx \cdot \int_0^2 y^2\,dy \cdot \int_0^1 z^3\,dz = \frac{1}{2} \cdot \frac{8}{3} \cdot \frac{1}{4} = \frac{8}{24} = \frac{1}{3}

Exercise 2: Set up and evaluate

Find the volume of the solid in the first octant under the surface z=4−x2z = 4 - x^2 and bounded by the plane x+y=2x + y = 2.

Answer

203≈6.667\frac{20}{3} \approx 6.667.

Solution

Floor z=0z = 0, ceiling z=4−x2z = 4 - x^2 (positive for 0≤x<20 \le x < 2). The shadow is the triangle 0≤x≤20 \le x \le 2, 0≤y≤2−x0 \le y \le 2 - x.

V=∫02∫02−x∫04−x2dz dy dx=∫02(4−x2)(2−x) dx=∫02(8−4x−2x2+x3) dx=16−8−163+4=203\begin{aligned} V &= \int_0^2 \int_0^{2-x} \int_0^{4-x^2} dz\,dy\,dx = \int_0^2 (4 - x^2)(2 - x)\,dx \\ &= \int_0^2 (8 - 4x - 2x^2 + x^3)\,dx = 16 - 8 - \frac{16}{3} + 4 = \frac{20}{3} \end{aligned}

Exercise 3: Centroid

Find the centroid of the solid bounded by y=x2y = x^2, z=0z = 0 and z=1−yz = 1 - y (the solid of the "Changing the order" section, volume 815\frac{8}{15}).

Answer

(xˉ,yˉ,zˉ)=(0,37,27)(\bar{x}, \bar{y}, \bar{z}) = \left(0, \frac{3}{7}, \frac{2}{7}\right).

Solution

xˉ=0\bar{x} = 0 by symmetry (the solid is symmetric under x→−xx \to -x).

∭y dV=∫−11∫x21y(1−y) dy dx=835yˉ=8/358/15=37∭z dV=∫−11∫x21(1−y)22 dy dx=16105zˉ=16/1058/15=27\begin{aligned} \iiint y\,dV &= \int_{-1}^{1} \int_{x^2}^{1} y(1 - y)\,dy\,dx = \frac{8}{35} && \bar{y} = \frac{8/35}{8/15} = \frac{3}{7} \\ \iiint z\,dV &= \int_{-1}^{1} \int_{x^2}^{1} \frac{(1 - y)^2}{2}\,dy\,dx = \frac{16}{105} && \bar{z} = \frac{16/105}{8/15} = \frac{2}{7} \end{aligned}
python · try it yourself
import sympy as sp
x, y, z = sp.symbols("x y z")
lim = [(z, 0, 1 - y), (y, x**2, 1), (x, -1, 1)]
V = sp.integrate(1, *lim)
print(V, [sp.integrate(v, *lim) / V for v in (x, y, z)])
8/15 [0, 3/7, 2/7]

Exercise 4: Monte Carlo probability (code)

XX, YY, ZZ are independent and uniform on [0,1][0, 1]. Find P(X+Y+Z≤1)P(X + Y + Z \le 1) exactly as a triple integral, then estimate it with 200 000 seeded random points.

Answer

Exactly 16≈0.1667\frac{1}{6} \approx 0.1667 (the volume of the corner tetrahedron); the simulation gives about 0.166.

Solution

The joint density is 1 on the unit cube, so the probability is the volume of {x,y,z≥0, x+y+z≤1}=∫01∫01−x∫01−x−ydz dy dx=16\{x, y, z \ge 0,\ x + y + z \le 1\} = \int_0^1 \int_0^{1-x} \int_0^{1-x-y} dz\,dy\,dx = \frac{1}{6}.

python · try it yourself
import numpy as np
rng = np.random.default_rng(3)
P = rng.random((200_000, 3))
print(round(float(np.mean(P.sum(axis=1) <= 1)), 4), round(1 / 6, 4))
0.1666 0.1667

Test yourself

How many different orders of integration exist for a triple integral?

  1. 3
  2. 6
  3. 9
  4. 8

For a type 1 solid u1(x,y)≤z≤u2(x,y)u_1(x, y) \le z \le u_2(x, y) over DD, the inner integral is taken with respect to…

  1. xx
  2. yy
  3. zz
  4. any variable

Why is Monte Carlo preferred over grid (iterated) quadrature for integrals in 50 dimensions?

  1. It is exact
  2. Its error decreases like 1N\frac{1}{\sqrt{N}} regardless of dimension, while a grid needs n50n^{50} points
  3. It needs no random numbers
  4. Grids cannot handle continuous functions