multivariable calc25 min

Triple Integrals

Integrate functions of three variables over solid regions to compute volumes, masses, and averages in 3D

0/9Not Started

Why This Matters

Double integrals sum a function over a flat region. But the real world is three-dimensional. To find the mass of a solid object with varying density, the total charge in a 3D volume, or the average temperature inside a room, you need a triple integral. It sums f(x, y, z) over a solid region in space.

A volume integral is simply a triple integral where f = 1, giving the volume of the solid. For more complex regions -- spheres, cylinders, cones -- Cartesian coordinates lead to ugly limits. That is where cylindrical and spherical coordinates shine. They align with the geometry of the problem and simplify both the limits and the integrand. The trade-off is a Jacobian factor (r for cylindrical, rho^2 sin(phi) for spherical) that you must include.

Define Terms

Visual Model

Solid Region E3D bounded volume
f(x, y, z)Integrand
Inner: integrate zFix x, y; vary z
Middle: integrate yFix x; vary y
Outer: integrate xVary x over bounds
ResultSingle number
Cylindrical(r, theta, z)
Spherical(rho, phi, theta)
Jacobian Factorr or rho^2 sin(phi)

The full process at a glance. Click Start tour to walk through each step.

A triple integral evaluates f(x,y,z) over a 3D solid. Choose Cartesian, cylindrical, or spherical coordinates based on the geometry.

Code Example

Code
// Triple integral: approximate volume and mass of a solid
// Region: unit sphere x^2 + y^2 + z^2 at most 1
// f(x, y, z) = 1 for volume, or density function for mass

function tripleIntegralBox(fn, n) {
  // Bounding box: [-1, 1]^3
  const dx = 2.0 / n;
  let sum = 0;
  for (let i = 0; i < n; i++) {
    const x = -1 + (i + 0.5) * dx;
    for (let j = 0; j < n; j++) {
      const y = -1 + (j + 0.5) * dx;
      for (let k = 0; k < n; k++) {
        const z = -1 + (k + 0.5) * dx;
        // Only include points inside the sphere
        if (x * x + y * y + z * z <= 1) {
          sum += fn(x, y, z) * dx * dx * dx;
        }
      }
    }
  }
  return sum;
}

// Volume of unit sphere: exact = 4*pi/3 = 4.1888
console.log("Volume (n=20):", tripleIntegralBox((x,y,z) => 1, 20).toFixed(4));
console.log("Volume (n=50):", tripleIntegralBox((x,y,z) => 1, 50).toFixed(4));
console.log("Exact: 4*pi/3 =", (4 * Math.PI / 3).toFixed(4));

// Mass with density rho(x,y,z) = x^2 + y^2 + z^2
// Exact: integral of r^2 * r^2*sin(phi) dr dphi dtheta
// = integral 0 to 1 of r^4 dr * integral 0 to pi of sin(phi) dphi * 2pi
// = (1/5)(2)(2pi) = 4pi/5 = 2.5133
console.log("Mass (n=50):", tripleIntegralBox((x,y,z) => x*x+y*y+z*z, 50).toFixed(4));
console.log("Exact: 4*pi/5 =", (4*Math.PI/5).toFixed(4));

Interactive Experiment

Try these exercises:

  • Compute the volume of a cube of side 2 using the triple integral with f = 1. You should get exactly 8.
  • Approximate the volume of a cylinder of radius 1 and height 2 (centered on the z-axis). Compare to the exact answer pi * r^2 * h = 2*pi.
  • Increase n from 10 to 20 to 40. How does the error change? Is the convergence rate what you expect for a midpoint rule?
  • Compute the average value of f(x,y,z) = z over the unit sphere. The average is the integral of f divided by the volume.
  • Try computing the moment of inertia: integrate (x^2 + y^2) over the unit sphere for a uniform density. This gives I_z.

Quick Quiz

Coding Challenge

Volume by Triple Riemann Sum

Write a function called `approxVolume` that takes n (grid divisions per axis) and approximates the volume of the solid defined by x^2 + y^2 at most 1 and z between 0 and 2 - x^2 - y^2 (a paraboloid cap over a disk). Use the bounding box [-1, 1] x [-1, 1] x [0, 2] with midpoint Riemann sums. Return the result rounded to 4 decimal places as a string. The exact answer is 3*pi/2 = 4.7124.

Loading editor...

Real-World Usage

Triple integrals solve 3D problems across science and engineering:

  • Mechanical engineering: Computing the mass, center of mass, and moments of inertia of 3D objects with non-uniform density requires triple integrals over the solid.
  • Electromagnetism: The total charge in a volume with charge density rho(x,y,z) is the triple integral of rho over the volume. Gauss law relates this to the electric flux.
  • Fluid dynamics: The total amount of a substance (heat, pollutant, dye) in a volume of fluid is computed by integrating the concentration over the 3D region.
  • Medical imaging: CT scans reconstruct a 3D density function. Integrating this density over regions of interest measures tissue mass or detects anomalies.
  • Astrophysics: Computing the gravitational potential at a point requires integrating the mass density over the entire volume of the celestial body.

Connections