Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 68 ยท Multivariable Calculus

Double and Triple Integrals

Learn double and triple integrals: iterated integrals, changing the order, polar, cylindrical and spherical coordinates, with sympy and scipy dblquad examples.

A single integral adds up thin slices along a line. A double integral adds up tiny patches of area over a region of the plane, and a triple integral adds up tiny blocks of volume inside a solid. They compute mass from a density, volume under a surface, the total charge on a plate, the moment of inertia of a wheel and the probability that two random quantities land in a region.

The good news is that you never have to learn a completely new technique. Every multiple integral is computed as a sequence of ordinary integrals, one variable at a time. What is new is choosing the limits correctly and picking a coordinate system that fits the shape. If integration still feels rusty, review The Integral as Accumulated Change and Applications of Integrals.

Double integrals as volume

Given a surface z = f(x, y) above a region R of the xy-plane, the volume between the region and the surface is

V = double integral over R of f(x, y) dA.

Slice the region into small rectangles with area dA = dx * dy; the column above each has volume about f(x, y) dA. Adding up all columns gives the integral. When f = 1, the integral is simply the area of R.

Fubini's theorem says that for a continuous f you can compute it as an iterated integral, integrating the inside variable first with the other held constant, then the outside one:

integral from x=a to b of ( integral from y=g1(x) to g2(x) of f(x, y) dy ) dx.

The inner limits may depend on the outer variable, but the outer limits must be plain numbers. The inner integral is a function of the outer variable alone.

flowchart LR
    R["Region R in the plane"] --> L["Choose an order:<br/>dy dx or dx dy"]
    L --> I["Inner integral<br/>(limits may depend on outer variable)"]
    I --> O["Outer integral<br/>(constant limits)"]
    O --> V["A number: volume, mass, area ..."]

An iterated integral turns one hard two-dimensional sum into two easy one-dimensional ones.

A first iterated integral

Integrate f(x, y) = x*y over the region between the curves y = x**2 and y = x, for 0 <= x <= 1. In this region x**2 <= y <= x.

Python An iterated integral with sympy

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The answer is 1/24. Notice that the inner integral was taken with x held as a constant, and produced x**3/2 - x**5/2, an ordinary function of x.

Changing the order of integration

The same region can be described in the other direction. Looking at the picture, for a fixed y between 0 and 1, x runs from the line (x = y) to the parabola (x = sqrt(y)), because y = x**2 means x = sqrt(y). So

integral from y=0 to 1 of ( integral from x=y to sqrt(y) of x*y dx ) dy.

Sketch the region before you swap, and read the new limits off the sketch. Switching the order is not only a check: sometimes one order is easy and the other is impossible. For e^(y**2) over a triangle, only one order has an elementary answer.

Python Swap the order and check with scipy

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Pay attention to dblquad. Its function takes the inner variable first, so the call lambda yy, xx: ... matches an integral with y inside and x outside. The limits for y can be functions of x. A mismatched argument order is the most common bug when using it.

Polar coordinates

When a region is a disk, a ring or a wedge, Cartesian limits are awkward. Polar coordinates x = r cos(theta), y = r sin(theta) fit those shapes naturally, with r the distance from the origin and theta the angle. The crucial change is the area element:

dA = r dr dtheta.

The extra factor r is the Jacobian: a patch at distance r is wider than one near the centre, because arcs get longer as you move outward. Forgetting this r is the single most common mistake in polar integrals.

Polar coordinates let you evaluate the famous Gaussian integral. The one-dimensional integral of e^(-x**2) has no elementary antiderivative, but its square is a double integral of e^(-(x**2 + y**2)) = e^(-r**2) over the whole plane, and in polar form it is easy.

Python Polar coordinates: the Gaussian integral and a paraboloid

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The paraboloid z = 4 - x**2 - y**2 meets the plane z = 0 on the circle r = 2, which fixes the limits. The result is 8*pi, about 25.1327.

Triple integrals

For a solid region E and a function f(x, y, z), the triple integral โˆญ f dV adds up f times volume. With f = 1 it gives the volume of the solid; with f as a density it gives the mass; with f = x**2 + y**2 it is the moment of inertia about the z axis (for unit density). Computation is the same idea again: three nested one-variable integrals, each limit may depend on the variables outside it.

Three coordinate systems cover almost every case.

System Variables Volume element dV Good for
Cartesian x, y, z dx dy dz boxes, planes
Cylindrical r, theta, z r dr dtheta dz cylinders, cones, paraboloids
Spherical rho, phi, theta rho**2 sin(phi) drho dphi dtheta balls, spheres, cones from the origin

In spherical coordinates rho is the distance from the origin, phi is the angle down from the positive z axis (0 to pi), and theta is the angle around the axis (0 to 2*pi). The conversions are x = rho sin(phi) cos(theta), y = rho sin(phi) sin(theta), z = rho cos(phi). As in polar coordinates, the extra factors in dV come from the Jacobian.

Python Cylindrical and spherical triple integrals

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The moment of inertia divided by the mass is 2/5 * R**2, the textbook value for a solid sphere. The cone has volume 8*pi/3, which matches the formula (1/3) * pi * radius**2 * height with radius 2 and height 2.

Numerical triple integrals with scipy

When a region or integrand has no closed form, scipy.integrate.tplquad computes the triple integral numerically. It follows the same inner-first convention as dblquad: the function takes (z, y, x), and each inner limit can be a function of the outer variables. Check the ball volume in Cartesian coordinates, where the limits are less pleasant.

Python tplquad: volume of a unit ball

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The numeric and exact values agree to about six digits. Compared with the one-line spherical integral above, it is a strong argument for choosing the coordinates that fit the shape.

To decide on coordinates, ask which symmetry the problem has. Circles and x**2 + y**2 suggest polar or cylindrical; x**2 + y**2 + z**2 suggests spherical. Then write the limits in words ("r from 0 to the cone, theta all the way around") before writing symbols.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the area element dA in polar coordinates?

    A small polar patch at distance r has radial width dr and arc length r dtheta, so its area is r dr dtheta. Forgetting the factor r is a very common error.
  2. 2. In an iterated integral, which limits must be plain numbers?

    The inner limits may depend on the outer variable, but the outer limits cannot depend on anything: the final result must be a number.
  3. 3. In scipy's dblquad(func, a, b, gfun, hfun), which variable comes first in func(...)?

    dblquad calls func(y, x) with the inner variable first. The limits a, b belong to x, and gfun(x), hfun(x) to y.
  4. 4. What is the volume element in spherical coordinates?

    The Jacobian of the spherical transformation is rho^2 sin(phi). The form r dr dtheta dz is the cylindrical element.
  5. 5. Why is the Gaussian integral of e^(-x^2) over all reals computed by squaring it?

    The product of two copies of the integral is a double integral of e^(-(x^2+y^2)) = e^(-r^2) over the plane, and with the extra factor r the polar form can be integrated exactly. The result is pi, so the original integral is sqrt(pi).

Summary

  • A double integral adds f dA over a region; with f = 1 it is the area.
  • By Fubini's theorem, compute it as iterated integrals: inner limits can depend on outer variables, outer limits are numbers.
  • Sketch the region to swap the order; read the new limits from the picture.
  • Polar: dA = r dr dtheta. Cylindrical: dV = r dr dtheta dz. Spherical: dV = rho**2 sin(phi) drho dphi dtheta.
  • sympy.integrate(f, (inner), (outer)) gives exact answers; dblquad and tplquad give numeric checks, inner variable first.
  • Pick the coordinates that match the symmetry of the shape.

Next: Vector Calculus: Divergence, Curl, Line Integrals.