Chapter 18
25 min read
Section 158 of 353

Applications of Double Integrals

Multiple Integrals

Learning Objectives

By the end of this section, you will be able to:

  1. Compute areas of planar regions using double integrals by integrating the constant function 1
  2. Calculate volumes under surfaces and between surfaces using double integration
  3. Find mass, center of mass, and moments of laminas (thin flat plates) with variable density
  4. Compute moments of inertia and understand their physical significance in rotational dynamics
  5. Determine surface area of surfaces defined by z=f(x,y)z = f(x,y)
  6. Apply double integrals to probability, computing probabilities from joint density functions
  7. Connect these concepts to machine learning, including expected values, feature averaging, and integration over parameter spaces

The Big Picture: From Abstraction to Reality

"Double integrals transform abstract mathematical regions into measurable physical quantities—area, volume, mass, and probability."

In the previous sections, we learned how to compute double integrals over rectangular and general regions. But why do we care about these calculations? The power of double integrals lies in their applications—they provide the mathematical machinery to compute quantities that matter in physics, engineering, probability, and machine learning.

Each application follows the same pattern: we identify a quantity that can be broken into infinitesimal pieces, express each piece as a function times dAdA, and then integrate to get the total. Whether we are computing the mass of a thin plate, the volume of a solid, or the probability of an event, the underlying principle is the same.

Why Applications Matter

Double integrals appear throughout science and engineering:

  • Physics: Mass distributions, moments of inertia, center of mass, gravitational fields
  • Engineering: Structural analysis, fluid flow, heat distribution
  • Probability: Expected values, marginal distributions, joint probabilities
  • Computer Graphics: Texture mapping, surface area, radiosity calculations
  • Machine Learning: Feature averaging, kernel methods, Bayesian integration

Historical Context

The applications of double integrals emerged alongside the development of calculus itself. Isaac Newton and Gottfried Leibniz both understood that integration could compute areas and volumes, but the systematic treatment of multiple integrals came later.

Leonhard Euler (1707-1783) made extensive use of double integrals in mechanics and probability. His work on the rotation of rigid bodies required computing moments of inertia—quantities that depend on the distribution of mass relative to an axis.

Joseph-Louis Lagrange (1736-1813) developed the mathematical foundations of mechanics, where double and triple integrals appear constantly. His "Analytical Mechanics" treats the motion of extended bodies using integral calculus throughout.

In probability theory, Pierre-Simon Laplace (1749-1827) and Carl Friedrich Gauss (1777-1855) used double integrals to study two-dimensional probability distributions. The bivariate normal distribution, so important in statistics and machine learning, requires double integration for almost every calculation.


Area of a Region

The simplest application of double integrals: computing the area of a planar region. The idea is straightforward—if we integrate the constant function 1 over a region DD, we count up all the infinitesimal area elements:

Area by Double Integration

Area(D)=D1dA=Ddxdy\text{Area}(D) = \iint_D 1 \, dA = \iint_D dx \, dy

This might seem trivial, but it gives us a powerful tool: we can compute areas of regions that would be difficult to find by other methods. The same double integral machinery we use for more complex functions works for the constant function.

For a Type I region (vertical slices) with axba \le x \le b and g1(x)yg2(x)g_1(x) \le y \le g_2(x):

Area=abg1(x)g2(x)dydx=ab[g2(x)g1(x)]dx\text{Area} = \int_a^b \int_{g_1(x)}^{g_2(x)} dy \, dx = \int_a^b [g_2(x) - g_1(x)] \, dx

This recovers the familiar formula for area between curves!

Interactive: Area Visualizer

Explore how double integration computes the area of various regions. Watch how we sum up the widths of horizontal strips (Type II) or vertical strips (Type I):

Area of a Region by Double Integration

The area of a planar region D equals the double integral of 1 over D: Area = \u222c_D 1 dA

x² + y² ≤ R²
xy

Area Formula

∬_D 1 \, dA = ∫_{-R}^{R} ∫_{-√(R²-y²)}^{√(R²-y²)} dx \, dy = πR²
Exact Area: πR²

Understanding the Visualization

  • The green boundary shows the region D
  • Blue strips represent horizontal slices at each y-value
  • For each y, we integrate from x = g\u2081(y) to x = g\u2082(y)
  • Then we integrate these strips from y = c to y = d
  • Area = ∫_c^d [∫_g₁(y)^g₂(y) dx] dy = ∫_c^d (g₂(y) - g₁(y)) dy

Volume Under a Surface

When f(x,y)0f(x, y) \ge 0, the double integral gives the volume of the solid region between the surface z=f(x,y)z = f(x, y) and the xy-plane, bounded laterally by the region DD:

Volume Under a Surface

V=Df(x,y)dAV = \iint_D f(x, y) \, dA

Each element f(x,y)dAf(x,y) \, dA is a thin column of height f(x,y)f(x,y) and base dAdA

This is the natural generalization of the single-variable integral formula for area under a curve. Where a single integral sums infinitesimal rectangles of height f(x)f(x) and width dxdx, a double integral sums infinitesimal rectangular prisms of height f(x,y)f(x,y) and base area dAdA.

Signed Volume

When f(x,y)f(x,y) takes negative values, the double integral gives signed volume: regions where f<0f < 0 contribute negatively. To find the total volume of solid between the surface and xy-plane regardless of sign, integrate f(x,y)|f(x,y)|.

Interactive: Volume Visualizer

Explore the volume under various surfaces. Toggle the Riemann columns to see how we approximate the volume with rectangular prisms:

Volume Under a Surface

V = \u222c_D f(x,y) dA where f(x,y) \u2265 0 is the height above the xy-plane

Current Function

z = 1 - x² - y² over x² + y² ≤ 1
Exact Volume: π/2
V = \u222b\u222b_D f(x,y) dA

Volume as Double Integral

The volume under a surface z = f(x,y) over a region D in the xy-plane is:

V = ∬_D f(x,y) dA = lim_(n→∞) ΣΣ f(x*_ij, y*_ij) ΔA

Toggle "Show Riemann Columns" to see the rectangular prisms that approximate the volume. As we use more and thinner columns, the approximation becomes exact.


Mass and Density

Consider a thin flat plate (a lamina) occupying a region DD in the xy-plane. If the density at each point is ρ(x,y)\rho(x, y) (mass per unit area), then the total mass is:

Mass of a Lamina

M=Dρ(x,y)dAM = \iint_D \rho(x, y) \, dA

Each element dm=ρ(x,y)dAdm = \rho(x,y) \, dA is the mass of an infinitesimal piece

For a uniform lamina where ρ(x,y)=ρ\rho(x,y) = \rho is constant, the mass simplifies to M=ρArea(D)M = \rho \cdot \text{Area}(D). But for non-uniform density, we must integrate.


Center of Mass

The center of mass (or centroid for uniform density) is the point (xˉ,yˉ)(\bar{x}, \bar{y}) where we could balance the lamina on a pin. It is computed using the first moments:

Center of Mass Formulas

First moment about y-axis:My=Dxρ(x,y)dAM_y = \iint_D x \, \rho(x, y) \, dA
First moment about x-axis:Mx=Dyρ(x,y)dAM_x = \iint_D y \, \rho(x, y) \, dA
xˉ=MyM,yˉ=MxM\bar{x} = \frac{M_y}{M}, \quad \bar{y} = \frac{M_x}{M}

Notation

The confusing notation (MyM_y uses xx and vice versa) comes from physics: the moment about the y-axis measures how far mass is from the y-axis, which depends on the x-coordinate.

Interactive: Mass and Center of Mass

Explore how density distribution affects mass and center of mass. See how non-uniform density shifts the center of mass away from the geometric center:

Mass and Center of Mass of a Lamina

For a flat plate with variable density \u03c1(x,y): M = \u222c_D \u03c1 dA, and center of mass (\u0305x, \u0305y) where \u0305x = (1/M)\u222c x\u03c1 dA

ρ(x,y) = 1 on x² + y² ≤ 1
xyCOM

Computed Values

Total Mass:
3.1111
Center of Mass:
(-0.000, -0.000)
Expected COM:
(0.000, 0.000)

Key Formulas

Mass: M = \u222c_D \u03c1(x,y) dA
First Moment (x): M_y = \u222c_D x \u03c1(x,y) dA
First Moment (y): M_x = \u222c_D y \u03c1(x,y) dA
Center of Mass: (\u0305x, \u0305y) = (M_y/M, M_x/M)

The orange dot shows computed COM, the dashed circle shows the theoretical value. Color intensity shows density (darker = less dense, brighter = more dense).


Moments of Inertia

The moment of inertia measures how difficult it is to rotate an object about a given axis. It depends not just on total mass, but on how that mass is distributed relative to the axis. Mass far from the axis contributes more because it has a larger lever arm.

Moments of Inertia

About x-axis:
Ix=Dy2ρdAI_x = \iint_D y^2 \rho \, dA
About y-axis:
Iy=Dx2ρdAI_y = \iint_D x^2 \rho \, dA
Polar (about origin):
I0=D(x2+y2)ρdAI_0 = \iint_D (x^2 + y^2) \rho \, dA

The perpendicular axis theorem for laminas states:

I0=Ix+IyI_0 = I_x + I_y

This makes sense geometrically: the squared distance from the origin is the sum of squared distances from the two coordinate axes.

ShapeI_xI_yI_0
Disk (radius R, uniform)πR⁴/4πR⁴/4πR⁴/2
Rectangle (a × b)ab³/12a³b/12ab(a²+b²)/12
Right triangle (legs a, b)ab³/12a³b/12ab(a²+b²)/12

Interactive: Moments of Inertia

Explore how distance from the axis affects the moment of inertia. Notice how mass far from the axis (brighter regions) contributes more:

Moment of Inertia of a Lamina

I = \u222c_D r\u00b2 \u03c1 dA, where r is the distance from the axis of rotation

xy

Computed Moments

I_x (about x-axis):
0.8180
I_y (about y-axis):
0.8180
I_0 (polar moment):
1.6360
Exact I_0: πR⁴/2 = π/2
Note: I_0 = I_x + I_y (perpendicular axis theorem)

Moment of Inertia Formulas

About x-axis:
I_x = \u222c_D y\u00b2 \u03c1 dA
About y-axis:
I_y = \u222c_D x\u00b2 \u03c1 dA
Polar (about origin):
I_0 = \u222c_D (x\u00b2+y\u00b2) \u03c1 dA

Color intensity shows r\u00b2: brighter elements are farther from the axis and contribute more to the moment of inertia.


Surface Area

To find the surface area of a surface z=f(x,y)z = f(x, y) over a region DD, we need to account for how the surface "stretches" relative to its projection onto the xy-plane.

Consider a small patch of the surface. When projected onto the xy-plane, it covers area dAdA. But the actual surface area is larger because the surface is tilted. The ratio depends on the partial derivatives fxf_x and fyf_y:

Surface Area Formula

S=D1+(fx)2+(fy)2dAS = \iint_D \sqrt{1 + \left(\frac{\partial f}{\partial x}\right)^2 + \left(\frac{\partial f}{\partial y}\right)^2} \, dA

The factor 1+fx2+fy2\sqrt{1 + f_x^2 + f_y^2} is the magnitude of the normal vector to the surface

The derivation comes from computing the cross product of the tangent vectors:

Tangent vectors: rx=(1,0,fx)\vec{r}_x = (1, 0, f_x), ry=(0,1,fy)\vec{r}_y = (0, 1, f_y)
Normal vector: rx×ry=(fx,fy,1)\vec{r}_x \times \vec{r}_y = (-f_x, -f_y, 1)
Surface element: dS=rx×rydA=1+fx2+fy2dAdS = |\vec{r}_x \times \vec{r}_y| \, dA = \sqrt{1 + f_x^2 + f_y^2} \, dA

Interactive: Surface Area

Visualize how the surface area element varies across the surface. Toggle tangent patches to see the local tangent planes and normal vectors:

Surface Area via Double Integration

S = \u222c_D \u221a(1 + (f_x)\u00b2 + (f_y)\u00b2) dA for z = f(x,y)

Surface Area

z = x² + y² over x² + y² ≤ 1
Computed:5.336
Exact:π(5√5 - 1)/6 ≈ 5.33

Surface Area Formula Derivation

For a surface z = f(x,y), we approximate with tangent plane patches. Each patch has area:

dS = |∂r/∂x × ∂r/∂y| dA = √(1 + f_x² + f_y²) dx dy

Toggle "Show Tangent Patches" to see the local tangent planes and normal vectors. The color intensity shows the surface area element magnitude - steeper regions are brighter because they contribute more area per unit xy-area.


Probability Applications

In probability theory, double integrals compute probabilities for continuous bivariate distributions. If f(x,y)f(x, y) is a joint probability density function (PDF), then:

Probability from Joint PDF

P((X,Y)R)=Rf(x,y)dAP((X, Y) \in R) = \iint_R f(x, y) \, dA

The probability that the random vector (X, Y) falls in region R

Key properties of joint PDFs:

  • Non-negativity: f(x,y)0f(x, y) \ge 0 everywhere
  • Normalization: f(x,y)dA=1\iint_{-\infty}^{\infty} f(x, y) \, dA = 1
  • Marginal PDF: fX(x)=f(x,y)dyf_X(x) = \int_{-\infty}^{\infty} f(x, y) \, dy
  • Expected value: E[g(X,Y)]=g(x,y)f(x,y)dAE[g(X, Y)] = \iint g(x, y) f(x, y) \, dA
QuantityFormula
E[X]∫∫ x f(x,y) dA
E[Y]∫∫ y f(x,y) dA
E[XY]∫∫ xy f(x,y) dA
Var(X)E[X²] - (E[X])²
Cov(X,Y)E[XY] - E[X]E[Y]

Interactive: Joint Probability

Explore different joint probability distributions and see how integrating over different regions changes the probability:

Probability from Joint PDF

P(event) = \u222c_R f(x,y) dA where f(x,y) is the joint probability density

xy1010

Probability Calculation

P(Region R):1.0000
= \u222c_R f(x,y) dA \u2248 1.000000
f(x,y) = 1 for 0 ≤ x,y ≤ 1
f_X(x) = 1 for 0 ≤ x ≤ 1

Key Properties of Joint PDFs

Normalization:
∬_(-∞)^(∞) ∬_(-∞)^(∞) f(x,y) dA = 1
Non-negativity:
f(x,y) ≥ 0 for all x, y
Marginal PDF of X:
f_X(x) = ∫_(-∞)^(∞) f(x,y) dy
Probability:
P((X,Y) ∈ R) = ∬_R f(x,y) dA

Bright green = region being integrated (higher density = brighter).Purple = outside integration region. The orange dashed box shows the integration bounds.


Machine Learning Connections

Double integral applications appear throughout machine learning:

1. Expected Values and Loss Functions

The expected loss over a data distribution is a double (or higher) integral:

L(θ)=E(x,y)p(x,y)[(θ;x,y)]=(θ;x,y)p(x,y)dxdy\mathcal{L}(\theta) = E_{(x,y) \sim p(x,y)}[\ell(\theta; x, y)] = \iint \ell(\theta; x, y) \, p(x, y) \, dx \, dy

This is why we use empirical risk minimization: we approximate the integral with a sum over training samples.

2. Bayesian Integration

In Bayesian inference, we often need to integrate over parameter space:

p(yx)=p(yx,θ)p(θ)dθp(y|x) = \iint p(y|x, \theta) \, p(\theta) \, d\theta

This predictive distribution integrates out the parameters, averaging predictions over all possible parameter values weighted by their posterior probability.

3. Kernel Methods and Inner Products

In kernel methods, we work with inner products in function space:

f,g=f(x,y)g(x,y)dxdy\langle f, g \rangle = \iint f(x, y) \, g(x, y) \, dx \, dy
ML ConceptDouble Integral Role
Expected loss∫∫ L(θ;x,y) p(x,y) dA
Posterior predictive∫ p(y|x,θ) p(θ|D) dθ
Marginal likelihood∫ p(D|θ) p(θ) dθ
Feature averagingE[f(X,Y)] = ∫∫ f p(x,y) dA
Gaussian process predictionsIntegration against GP posterior

Python Implementation

Let's implement the key applications in Python:

Mass, Center of Mass, and Moments

Physical Applications
🐍double_integral_applications.py
4Area by Double Integration

For a Type II region (horizontal slices), we integrate the width f_upper(y) - f_lower(y) from y_min to y_max. This is equivalent to the double integral of 1 over the region.

16Volume Under Surface

Volume = ∬_D f(x,y) dA. We discretize the domain into a grid and sum f(x,y) × ΔA for each cell. This is the 2D analogue of Riemann sums.

33Center of Mass

First compute total mass M = ∬ ρ dA, then the moments M_y = ∬ xρ dA and M_x = ∬ yρ dA. The center of mass is (M_y/M, M_x/M).

53Moments of Inertia

I_x measures resistance to rotation about the x-axis (uses y²), I_y about the y-axis (uses x²). The polar moment I_0 = I_x + I_y by the perpendicular axis theorem.

72Characteristic Function

We define density as 1 inside the disk and 0 outside. This indicator function approach works with any region—the integration naturally excludes points outside.

87 lines without explanation
1import numpy as np
2from scipy import integrate
3
4def double_integral_area(f_lower, f_upper, y_min, y_max, n=1000):
5    """
6    Compute area of region bounded by x = f_lower(y), x = f_upper(y)
7    from y = y_min to y = y_max.
8
9    Area = integral from y_min to y_max of [f_upper(y) - f_lower(y)] dy
10    """
11    y = np.linspace(y_min, y_max, n)
12    width = f_upper(y) - f_lower(y)
13    area = np.trapz(width, y)
14    return area
15
16def volume_under_surface(f, x_bounds, y_bounds, nx=100, ny=100):
17    """
18    Compute volume under z = f(x,y) over rectangular region.
19
20    Volume = double integral of f(x,y) dA
21    """
22    x = np.linspace(x_bounds[0], x_bounds[1], nx)
23    y = np.linspace(y_bounds[0], y_bounds[1], ny)
24    dx = x[1] - x[0]
25    dy = y[1] - y[0]
26
27    X, Y = np.meshgrid(x, y)
28    Z = f(X, Y)
29
30    volume = np.sum(Z) * dx * dy
31    return volume
32
33def center_of_mass_2d(rho, x_bounds, y_bounds, nx=100, ny=100):
34    """
35    Compute center of mass of a lamina with density rho(x,y).
36
37    x_bar = (1/M) * integral of x * rho(x,y) dA
38    y_bar = (1/M) * integral of y * rho(x,y) dA
39    """
40    x = np.linspace(x_bounds[0], x_bounds[1], nx)
41    y = np.linspace(y_bounds[0], y_bounds[1], ny)
42    dx = x[1] - x[0]
43    dy = y[1] - y[0]
44
45    X, Y = np.meshgrid(x, y)
46    R = rho(X, Y)
47
48    mass = np.sum(R) * dx * dy
49    moment_x = np.sum(X * R) * dx * dy
50    moment_y = np.sum(Y * R) * dx * dy
51
52    return {
53        'mass': mass,
54        'x_bar': moment_x / mass,
55        'y_bar': moment_y / mass
56    }
57
58def moment_of_inertia(rho, x_bounds, y_bounds, axis='origin', nx=100, ny=100):
59    """
60    Compute moment of inertia of a lamina.
61
62    axis='x': I_x = integral of y^2 * rho dA
63    axis='y': I_y = integral of x^2 * rho dA
64    axis='origin': I_0 = integral of (x^2 + y^2) * rho dA = I_x + I_y
65    """
66    x = np.linspace(x_bounds[0], x_bounds[1], nx)
67    y = np.linspace(y_bounds[0], y_bounds[1], ny)
68    dx, dy = x[1] - x[0], y[1] - y[0]
69
70    X, Y = np.meshgrid(x, y)
71    R = rho(X, Y)
72
73    if axis == 'x':
74        return np.sum(Y**2 * R) * dx * dy
75    elif axis == 'y':
76        return np.sum(X**2 * R) * dx * dy
77    else:  # origin
78        return np.sum((X**2 + Y**2) * R) * dx * dy
79
80# Example: Compute properties of uniform unit disk
81def uniform_disk(x, y):
82    """Density = 1 inside unit disk, 0 outside"""
83    return np.where(x**2 + y**2 <= 1, 1.0, 0.0)
84
85# Center of mass of uniform disk (should be at origin)
86result = center_of_mass_2d(uniform_disk, [-1, 1], [-1, 1])
87print(f"Mass: {result['mass']:.4f} (expected: π ≈ 3.1416)")
88print(f"Center of mass: ({result['x_bar']:.4f}, {result['y_bar']:.4f})")
89
90# Moment of inertia of unit disk
91I_0 = moment_of_inertia(uniform_disk, [-1, 1], [-1, 1], axis='origin')
92print(f"Polar moment I_0: {I_0:.4f} (expected: π/2 ≈ 1.5708)")

Probability Applications

Probability with Double Integrals
🐍probability_applications.py
5Joint Probability Integration

P((X,Y) ∈ R) = ∬_R f(x,y) dA. We use scipy&apos;s dblquad for accurate numerical integration of the joint PDF over any rectangular region.

21Marginal Distribution

f_X(x) = ∫_{-∞}^{∞} f(x,y) dy. The marginal PDF &apos;integrates out&apos; the other variable, collapsing the joint distribution to a single variable.

29Expected Values via Double Integration

E[g(X,Y)] = ∬ g(x,y)f(x,y) dA. This formula computes expectations of any function of the random variables, including covariance: Cov(X,Y) = E[XY] - E[X]E[Y].

56Bivariate Normal Distribution

The bivariate normal is defined by means μ_x, μ_y, standard deviations σ_x, σ_y, and correlation ρ. The exponent contains a quadratic form involving all these parameters.

69 lines without explanation
1import numpy as np
2from scipy import stats
3from scipy.integrate import dblquad
4
5def joint_probability(pdf, x_range, y_range):
6    """
7    Compute P((X,Y) in region) by integrating joint PDF.
8
9    pdf: joint probability density function f(x,y)
10    x_range, y_range: tuples (min, max) for integration
11    """
12    result, error = dblquad(
13        pdf,
14        y_range[0], y_range[1],  # y limits
15        lambda y: x_range[0],    # x lower limit
16        lambda y: x_range[1]     # x upper limit
17    )
18    return result, error
19
20def marginal_pdf_x(joint_pdf, y_support, x_value, n=1000):
21    """
22    Compute marginal PDF of X: f_X(x) = integral of f(x,y) dy
23    """
24    y = np.linspace(y_support[0], y_support[1], n)
25    integrand = np.array([joint_pdf(x_value, yi) for yi in y])
26    return np.trapz(integrand, y)
27
28def expected_value_xy(joint_pdf, x_support, y_support, func='x'):
29    """
30    Compute E[g(X,Y)] = integral of g(x,y) * f(x,y) dA
31
32    func: 'x' for E[X], 'y' for E[Y], 'xy' for E[XY], 'x2' for E[X²]
33    """
34    if func == 'x':
35        g = lambda x, y: x
36    elif func == 'y':
37        g = lambda x, y: y
38    elif func == 'xy':
39        g = lambda x, y: x * y
40    elif func == 'x2':
41        g = lambda x, y: x**2
42    else:
43        raise ValueError(f"Unknown function: {func}")
44
45    integrand = lambda y, x: g(x, y) * joint_pdf(x, y)
46    result, _ = dblquad(
47        integrand,
48        x_support[0], x_support[1],
49        lambda x: y_support[0],
50        lambda x: y_support[1]
51    )
52    return result
53
54# Example: Bivariate normal distribution
55mu_x, mu_y = 0, 0
56sigma_x, sigma_y = 1, 1
57rho = 0.5  # correlation coefficient
58
59def bivariate_normal(x, y):
60    """Joint PDF of bivariate normal with correlation rho"""
61    z = ((x - mu_x)/sigma_x)**2 - 2*rho*((x - mu_x)/sigma_x)*((y - mu_y)/sigma_y) + ((y - mu_y)/sigma_y)**2
62    norm = 2 * np.pi * sigma_x * sigma_y * np.sqrt(1 - rho**2)
63    return np.exp(-z / (2*(1 - rho**2))) / norm
64
65# Probability that X > 0 AND Y > 0 (first quadrant)
66prob, err = joint_probability(bivariate_normal, (0, 5), (0, 5))
67print(f"P(X > 0, Y > 0) = {prob:.4f} (expected: {0.25 + np.arcsin(rho)/(2*np.pi):.4f})")
68
69# Expected values
70E_X = expected_value_xy(bivariate_normal, (-5, 5), (-5, 5), 'x')
71E_XY = expected_value_xy(bivariate_normal, (-5, 5), (-5, 5), 'xy')
72print(f"E[X] = {E_X:.4f} (expected: 0)")
73print(f"E[XY] = {E_XY:.4f} (expected: ρ = {rho})")

Surface Area Computation

Surface Area Calculation
🐍surface_area.py
4Surface Area Formula

S = ∬_D √(1 + (∂f/∂x)² + (∂f/∂y)²) dA. The factor √(1 + f_x² + f_y²) is the magnitude of the normal vector to the surface, accounting for how much the surface &apos;stretches&apos; relative to its projection.

13Region Masking

For non-rectangular regions (like disks), we use a characteristic function that returns 0 outside the region. This effectively restricts the integration domain.

30Paraboloid Example

For z = x² + y², we have f_x = 2x and f_y = 2y. The surface area over the unit disk has a known closed form: π(5√5 - 1)/6 ≈ 5.33.

41Hemisphere Boundary

The hemisphere z = √(1 - x² - y²) has a singularity at the boundary (r = 1) where the surface becomes vertical. We integrate over a slightly smaller disk to avoid numerical issues.

63 lines without explanation
1import numpy as np
2from scipy.integrate import dblquad
3
4def surface_area(f, f_x, f_y, x_bounds, y_bounds, region=None):
5    """
6    Compute surface area of z = f(x,y) over a region.
7
8    S = integral of sqrt(1 + f_x^2 + f_y^2) dA
9
10    f: function z = f(x,y)
11    f_x, f_y: partial derivatives
12    region: optional function (x,y) -> bool for non-rectangular regions
13    """
14    def integrand(y, x):
15        if region is not None and not region(x, y):
16            return 0.0
17        dzdx = f_x(x, y)
18        dzdy = f_y(x, y)
19        return np.sqrt(1 + dzdx**2 + dzdy**2)
20
21    result, error = dblquad(
22        integrand,
23        x_bounds[0], x_bounds[1],
24        lambda x: y_bounds[0],
25        lambda x: y_bounds[1]
26    )
27    return result, error
28
29# Example 1: Paraboloid z = x² + y² over unit disk
30f = lambda x, y: x**2 + y**2
31f_x = lambda x, y: 2*x
32f_y = lambda x, y: 2*y
33disk = lambda x, y: x**2 + y**2 <= 1
34
35area, err = surface_area(f, f_x, f_y, [-1, 1], [-1, 1], disk)
36exact = np.pi * (5*np.sqrt(5) - 1) / 6
37print(f"Paraboloid surface area: {area:.4f} (exact: {exact:.4f})")
38
39# Example 2: Hemisphere z = sqrt(1 - x² - y²)
40def hemisphere_area():
41    f = lambda x, y: np.sqrt(np.maximum(0, 1 - x**2 - y**2))
42
43    # Partial derivatives (handle boundary carefully)
44    def f_x(x, y):
45        val = 1 - x**2 - y**2
46        return -x / np.sqrt(val) if val > 0.01 else 0
47
48    def f_y(x, y):
49        val = 1 - x**2 - y**2
50        return -y / np.sqrt(val) if val > 0.01 else 0
51
52    # Use smaller disk to avoid singularity at boundary
53    disk = lambda x, y: x**2 + y**2 <= 0.99
54
55    area, err = surface_area(f, f_x, f_y, [-1, 1], [-1, 1], disk)
56    return area
57
58hemisphere = hemisphere_area()
59print(f"Hemisphere surface area: {hemisphere:.4f} (exact: 2π ≈ {2*np.pi:.4f})")
60
61# Example 3: Saddle z = x² - y² over unit square
62f = lambda x, y: x**2 - y**2
63f_x = lambda x, y: 2*x
64f_y = lambda x, y: -2*y
65
66area, err = surface_area(f, f_x, f_y, [-1, 1], [-1, 1])
67print(f"Saddle surface area over [-1,1]²: {area:.4f}")

Test Your Understanding

Test Your Understanding

Question 1 of 8

To find the area of a region D in the xy-plane using a double integral, which integrand should you use?


Summary

Double integrals transform abstract mathematical computation into concrete physical and probabilistic quantities. The key applications covered in this section are:

ApplicationFormulaIntegrand
AreaA = ∬_D 1 dA1
VolumeV = ∬_D f(x,y) dAf(x,y) (height)
MassM = ∬_D ρ(x,y) dAρ(x,y) (density)
Center of mass̅x = M_y/M, ̅y = M_x/Mxρ, yρ
Moment of inertia I_xI_x = ∬_D y²ρ dAy²ρ
Moment of inertia I_yI_y = ∬_D x²ρ dAx²ρ
Surface areaS = ∬_D √(1+f_x²+f_y²) dA√(1+f_x²+f_y²)
ProbabilityP(R) = ∬_R f(x,y) dAf(x,y) (joint PDF)
Expected valueE[g] = ∬ g(x,y)f(x,y) dAg(x,y)f(x,y)

Key Takeaways

  1. Unifying pattern: All applications follow the same structure—integrate an appropriate function over a region
  2. Physical interpretation: The integrand represents what we are accumulating (height, mass, probability, etc.)
  3. Moments measure distribution: First moments give center of mass; second moments give moment of inertia
  4. Surface area uses derivatives: The factor 1+fx2+fy2\sqrt{1 + f_x^2 + f_y^2} accounts for surface tilt
  5. ML ubiquity: Expected values, Bayesian marginalization, and many other ML concepts are fundamentally double integrals
The Power of Double Integral Applications:
"From areas and volumes to mass distributions and probabilities—double integrals provide the mathematical bridge between calculus and the physical world."
Coming Up Next: In the next section, we extend to three dimensions with Triple Integrals. You'll learn to compute volumes and masses of solid regions, where the setup mirrors what we've done here but with an additional dimension of integration.
Loading comments...