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 and continuous on . Divide into sub-boxes of volume , pick a sample point in each, and form
The limit exists for every continuous (and for bounded whose discontinuities lie on finitely many smooth surfaces).
Fubini's theorem (3D). If is continuous on , the triple integral equals any of the six iterated integrals, for example
Work from the inside out: integrate in with , held fixed, then in , then in .
General regions
A solid is type 1 if it lies between two surfaces over a region in the -plane:
and 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 - or -plane instead).
Recipe.
- Sketch . Find the "floor" and "ceiling" surfaces in one variable.
- Project onto the plane of the other two variables to get ; find 's boundary by eliminating the variable (for example, setting ).
- Describe with constant outer limits.
Example: a tetrahedron
is bounded by the coordinate planes and the plane , so its vertices are , , , . Integrate :
The volume is , and the integral of equals (the centroid of a tetrahedron is the average of its vertices, so ).
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 and the planes , (so ):
All three give volume . Choosing a good order can turn an impossible inner integral into an easy one, just as in two variables.
Applications
With a density (mass per unit volume):
| Quantity | Formula |
|---|---|
| volume | |
| mass | |
| moments | , , |
| centre of mass | |
| moment of inertia about the -axis | |
| probability | for a joint density |
Monte Carlo in three dimensions
An iterated integral with sample points per axis costs evaluations, and the cost grows like in dimensions. Monte Carlo integration draws random points in a box of volume and estimates ; its error shrinks like 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.
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 , and the height between them is , so .
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 over .
Answer
.
Solution
The integrand is a product of a function of , one of and one of , and the region is a box, so the integral factors:
Exercise 2: Set up and evaluate
Find the volume of the solid in the first octant under the surface and bounded by the plane .
Answer
.
Solution
Floor , ceiling (positive for ). The shadow is the triangle , .
Exercise 3: Centroid
Find the centroid of the solid bounded by , and (the solid of the "Changing the order" section, volume ).
Answer
.
Solution
by symmetry (the solid is symmetric under ).
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)
, , are independent and uniform on . Find exactly as a triple integral, then estimate it with 200 000 seeded random points.
Answer
Exactly (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 .
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?
- 3
- 6
- 9
- 8
For a type 1 solid over , the inner integral is taken with respect to…
- any variable
Why is Monte Carlo preferred over grid (iterated) quadrature for integrals in 50 dimensions?
- It is exact
- Its error decreases like regardless of dimension, while a grid needs points
- It needs no random numbers
- Grids cannot handle continuous functions