Why this matters for simulation: Total mass in a region is ∭ρ dV — the starting point of every conservation law.
By the end of this lesson you can…
Interpret a double or triple integral as the limit of a Riemann sum of value × tiny area (or volume), and estimate one by hand with the midpoint rule.
Evaluate double and triple integrals as iterated integrals, set up limits for non-rectangular regions, and reverse the order of integration using Fubini's theorem.
Derive the area element $dA = r\,dr\,d\theta$ geometrically and use polar, cylindrical and spherical coordinates to integrate over round regions.
Change variables in a multiple integral with the absolute Jacobian determinant, and explain it as local area scaling.
Compute mass, center of mass and other total quantities of a density field over a region.
Implement midpoint-rule and Monte Carlo integration in two dimensions and compare how their errors shrink.
Open any grid-based fluid solver, Stam’s included, and you’ll find a density array rho[j, i]: so many kilograms of smoke per square meter in each cell. How much smoke is in the whole tank? You multiply each cell’s density by the cell’s area and add everything up. That sum, value times tiny area added over a region, is a double integral in disguise. Make the cells smaller and smaller and the sum becomes exact. In 3D, with volumes instead of areas, it becomes a triple integral.
This lesson extends the Calc II integral to functions of several variables, the kind you met as scalar fields in 2.1 Functions of Several Variables & Partial Derivatives. Two ideas carry everything. First, a multiple integral is defined as a sum over tiny pieces but computed as a stack of ordinary single integrals (Fubini’s theorem). Second, when the region is round and you bend your grid to fit it, each tiny piece gets stretched, and the stretch factor is the Jacobian determinant. That’s the area-scaling idea from 1.4 Determinants as Volume Scaling, now applied point by point. Conservation of mass, the flux integrals of 2.9 Line Integrals, Circulation & Flux and the divergence theorem all start from here.
▶ VideoDouble integrals: columns under a surface, slices, and Fubinicaptions only
Transcript
In this lesson we learn to add things up over a whole region: area, volume, and the total mass of fluid in a box.
Remember Calc two. To integrate a function of one variable, you chop the interval into thin strips, add up height times width, and let the strips shrink.
Now the function depends on two inputs, x and y. Its graph is a surface hanging over the x y plane. Here is a dome above the square from zero to two in both directions.
Question: what is the volume of the solid between the floor square and the surface?
Same trick as before. Chop the floor into small rectangles. Over each one, build a column whose height is the function at the rectangle's midpoint.
Each column has volume height times base area: f at the midpoint, times delta x, times delta y. Adding the four columns gives five point five.
Now refine. Four by four, eight by eight, sixteen by sixteen. The columns hug the surface more and more closely, and the sum settles down.
The limit of these sums is the double integral of f over the region R. For our dome it is sixteen thirds, about five point three three.
Notice the pattern. A double integral is just a giant sum of value times tiny area. Keep that sentence in mind, because it is exactly what a computer does.
But how do we compute the exact value? Slice the solid with a plane where x is held fixed. The slice is a flat region, and its area is an ordinary one variable integral in y.
Call that slice area A of x. As x moves from zero to two, the slice sweeps through the whole solid.
Stack up the slices: integrate A of x from zero to two. That is an iterated integral, an inner integral in y, then an outer integral in x. It gives exactly sixteen thirds.
You could just as well slice the other way, holding y fixed. Fubini's theorem says both orders give the same answer, for any continuous function on a rectangle.
That is the whole strategy for double integrals: think of a sum over tiny pieces, but compute it as two single integrals, one inside the other.
The height does not have to be a height. If f is a density, say kilograms of smoke per square meter, then value times area is mass, and the double integral is the total mass in the region.
A fluid solver stores density on exactly this kind of grid, and its total mass is this sum. Next, we will see what happens when the region is round, and the grid has to bend.
Double integrals as Riemann sums
Recall the single-variable picture. To integrate g(x) over [a,b] you cut the interval into pieces of width Δx, pick a sample point xi in each, and add g(xi)Δx. The integral is the limit as the pieces shrink.
Now let f(x,y) be a function of two variables and R a rectangle [a,b]×[c,d] in the xy-plane. Cut [a,b] into m pieces of width Δx and [c,d] into n pieces of width Δy. That chops R into mn small rectangles Rij, each of area ΔA=ΔxΔy. Pick a sample point (xi∗,yj∗) in each and form the double Riemann sum
Sm,n=i=1∑mj=1∑nf(xi∗,yj∗)ΔA.
The symbol dA stands for “a tiny bit of area”. There are several useful ways to read the result:
Volume. If f≥0, each term f(xi∗,yj∗)ΔA is the volume of a thin column with base Rij and height f. The integral is the volume of the solid under the surface z=f(x,y) and above R. This is the picture in the video.
Area. With f=1 the sum just adds up cell areas, so ∬R1dA=area(R).
Total amount. If f=ρ is a density (mass per unit area, heat per unit area, people per square kilometer), each term is the amount in one cell, and the integral is the total amount in R.
Average. The average value of f over R is fˉ=area(R)1∬RfdA.
The usual properties carry over: the integral is linear (∬(af+bg)=a∬f+b∬g), it’s additive over regions that don’t overlap, and if f≤g everywhere, then ∬f≤∬g.
Worked example: a midpoint sum by hand
Estimate the volume under the dome f(x,y)=2−4x2+y2 over R=[0,2]×[0,2] using a 2×2 grid with midpoints.
The cells are unit squares, so ΔA=1. Their midpoints are (0.5,0.5), (1.5,0.5), (0.5,1.5) and (1.5,1.5), where
So S=(1.875+1.375+1.375+0.875)⋅1=5.5. We’ll soon see that the exact answer is 16/3≈5.333. With only four evaluations, that’s already within about 3%. With a 4×4 grid the estimate is 5.375, and with 8×8 it’s 5.344. The error drops by a factor of about 4 each time the grid spacing halves.
Iterated integrals and Fubini’s theorem
The definition is a limit of sums, and nobody wants to evaluate that directly. The way out is the slicing argument from the video.
Fix a value of x and slice the solid with the vertical plane at that x. The slice is a flat region under the curve y↦f(x,y) for c≤y≤d, and its area is an ordinary integral in y, with x treated as a constant:
A(x)=∫cdf(x,y)dy.
If we cut the solid into thin slabs of thickness dx, each slab has volume of about A(x)dx. Adding the slabs gives
∬RfdA=∫abA(x)dx=∫ab(∫cdf(x,y)dy)dx.
This is an iterated integral: an inner integral (in y, holding x fixed) inside an outer integral (in x). The inner integral is exactly “partial integration”, the reverse of the partial derivative ∂/∂y.
In the Riemann sum, slicing is nothing more than adding the terms column by column. First add over j for a fixed i, then add the column totals over i. A finite double sum can be added in either order. Fubini’s theorem says the same is true in the limit.
When the integrand factors as g(x)h(y) and the region is a rectangle, the double integral splits into a product: (∫016x2dx)(∫02ydy)=2⋅2=4.
✅ Concept check
What is the average value of $f(x,y) = 6x^2 y$ over $R = [0,1]\times[0,2]$?
Why: The average is $\frac{1}{\text{area}}\iint_R f\,dA = \frac{4}{2} = 2$.
Regions that aren’t rectangles
Most regions aren’t rectangles. The fix is to let the inner limits depend on the outer variable.
A region is type I (vertically simple) if it can be described as
D={(x,y):a≤x≤b,g1(x)≤y≤g2(x)},
that is, every vertical line crosses it in a single segment. Then
∬DfdA=∫ab∫g1(x)g2(x)f(x,y)dydx.
A type II region has c≤y≤d and h1(y)≤x≤h2(y), and you integrate in x first. Many regions are both. Regions that are neither can be cut into pieces that are.
Worked example: a triangle, both ways
Compute ∬DxydA where D is the triangle with vertices (0,0), (1,0), (1,1).
Sketch: the triangle sits below the line y=x, above the x-axis, and left of x=1.
Type I. A vertical line at x enters at y=0 and leaves at y=x:
∫01∫0xxydydx=∫01x⋅2x2dx=81.
Type II. A horizontal line at height y enters at x=y (on the diagonal) and leaves at x=1:
∫01∫y1xydxdy=∫01y⋅21−y2dy=21(21−41)=81.✓
✅ Concept check
Reverse the order of integration: $\int_0^1\!\int_0^{x} f(x,y)\,dy\,dx = \;?$
Why: Swapping the order means re-describing the same region, never just swapping the limits around.
✏️ Pen & paperAn integral you can only do backwards●●○
Evaluate ∫01∫x1ey2dydx.
(The function ey2 has no elementary antiderivative, so the inner integral can’t be done as written.)
Show worked solution
The region is 0≤x≤1, x≤y≤1: the triangle with vertices (0,0), (0,1), (1,1), lying above the diagonal. Described horizontally, a line at height y∈[0,1] runs from x=0 to x=y. So
The inner integral in x just produced a factor y, which is exactly what makes the substitution u=y2 work. Reversing the order of integration is a real tool, not just a curiosity.
Polar coordinates
▶ VideoBending the grid: polar coordinates and the Jacobian determinantcaptions only
Transcript
A rectangular grid is perfect for rectangles. But nature loves round things: pipes, jets, vortices, stars.
Try to cover a disk with little squares. Around the edge you get a jagged staircase: some squares stick out, some gaps are missed. It converges, but slowly.
Instead, describe each point by its distance r from the center and its angle theta. Lines of constant r are circles, lines of constant theta are rays. Together they form a polar grid that fits the disk perfectly.
Here is the key observation. Both highlighted cells have the same change in r and the same change in theta, but the outer one is much bigger.
Zoom in on one cell. Its radial side has length d r. Its curved side is an arc of a circle of radius r, and arc length is radius times angle: r d theta.
When the cell is tiny it is almost a rectangle, so its area is d r times r d theta. That extra factor of r is the price of bending the grid.
Check it on the disk. Integrate r from zero to capital R, giving R squared over two, then theta from zero to two pi. Out comes pi R squared, exactly.
Here is the same idea as a map. On the left is an honest rectangle of r and theta values. Every cell has the same size, d r by d theta.
The polar map, x equals r cosine theta, y equals r sine theta, bends that rectangle into the disk. Cells near r equal zero get crushed, cells far out get stretched.
How much does each cell's area get multiplied by? Zoom in far enough and any smooth map looks linear. Its matrix is the Jacobian, the matrix of partial derivatives.
And from Module one, a linear map scales area by its determinant. For polar coordinates the determinant is r. That is the r in r d r d theta, now derived instead of drawn.
This works for any change of variables. Write the region in new coordinates u and v, and multiply the integrand by the absolute value of the Jacobian determinant.
In three dimensions it is the same story with volume. Cylindrical coordinates add a height z, so d V is r d r d theta d z. Spherical coordinates give rho squared sine phi.
So: a multiple integral is a sum of value times tiny volume, and when you bend the grid, the Jacobian determinant tells you how big each tiny volume really is.
Next lesson, we put a vector at every point and follow the flow: vector fields and streamlines.
Round regions fit badly into rectangular grids. The boundary becomes a staircase and the limits involve awkward square roots like y=±R2−x2. Polar coordinates describe a point by its distance r from the origin and its angle θ:
x=rcosθ,y=rsinθ,r2=x2+y2.
A disk of radius R becomes the “rectangle” 0≤r≤R, 0≤θ≤2π in the (r,θ) variables. But the area element changes.
Deriving dA=rdrdθ
Cut the plane along circles r=const (spaced Δr apart) and rays θ=const (spaced Δθ apart). A typical cell is a piece of an annulus. Its two straight sides have length Δr. Its curved sides are arcs, and arc length is radius times angle, so the arc at radius r has length rΔθ. When the cell is small it’s almost a rectangle, with area
ΔA≈(Δr)(rΔθ)=rΔrΔθ.
For an exact check, the cell between radii r0 and r0+Δr is the fraction Δθ/2π of an annulus, with area 2Δθ[(r0+Δr)2−r02]=rˉΔrΔθ, where rˉ=r0+Δr/2 is the midpoint radius. So the formula is exact if you evaluate r at the midpoint. Taking the limit gives:
∬Df(x,y)dA=∬D′f(rcosθ,rsinθ)rdrdθ.
The factor r says that cells far from the origin are bigger. That’s the “stretching” you saw in the video, where equal (r,θ) boxes near the center are crushed and those near the rim are stretched.
Worked examples
Area of a disk.∫02π∫0Rrdrdθ=2π⋅2R2=πR2.
A paraboloid-shaped integrand. Over the disk r≤2,
∬(x2+y2)dA=∫02π∫02r2⋅rdrdθ=2π⋅424=8π≈25.13.
In Cartesian coordinates you would face ∫−22∫−4−x24−x2(x2+y2)dydx, which can be done but is painful.
The Gaussian integral. This is one of the most famous tricks in mathematics. Let I=∫−∞∞e−x2dx, an integral with no elementary antiderivative. Square it and use Fubini (on ever larger squares, which is fine because the integrand is positive):
So I=π. The factor r is what makes e−r2 integrable in closed form. This integral normalizes the bell curve and is the backbone of the heat-equation solution in 9.9 Infinite Domains & the Fourier Transform.
◆ InteractiveRiemann sums over a region: Cartesian vs. polar vs. Monte Carlo
Loading simulation…
Things to try in the explorer:
With the disk and f=1, compare Cartesian and Polar at the same n. The polar midpoint sum gives 4π to machine precision (the midpoint radius makes each cell’s area exact). The Cartesian estimate wobbles, because its error comes from cells straddling the boundary, and on the log–log plot it falls only like N−1/2 to N−3/4 instead of N−1.
Switch to the rectangle and the roles reverse: now the Cartesian grid fits perfectly and the polar grid has the staircase problem.
Change the sample point to lower corner on the rectangle with f=x2+y2. The error now falls like N−1/2 (first order in h) instead of N−1.
Choose Monte Carlo and press Resample several times. The estimate jumps around, but its error shrinks like N−1/2 on average no matter what shape the region is.
✅ Concept check
Why does the polar area element contain the extra factor $r$?
✅ Concept check
Compute $\iint_D (x^2 + y^2)\,dA$ over the unit disk $D$ (radius 1). Give a decimal.
Polar coordinates are one example of a general move. Suppose a map T(u,v)=(x(u,v),y(u,v)) sends a simple region S in the uv-plane one-to-one onto the region D we care about. A tiny rectangle in the uv-plane with sides Δu and Δv gets mapped to a small curved quadrilateral. How big is it?
So the tiny rectangle becomes, to first order, a parallelogram spanned by the columns J(Δu,0) and J(0,Δv). From 1.4 Determinants as Volume Scaling, a linear map multiplies areas by the absolute value of its determinant:
ΔAxy≈∣detJ∣ΔuΔv.
Add up over all the cells and let them shrink.
Polar check. With x=rcosθ and y=rsinθ,
detJ=det[cosθsinθ−rsinθrcosθ]=rcos2θ+rsin2θ=r.
The geometric argument and the determinant agree. Note the absolute value. Orientation doesn’t matter for area, so if the map flips orientation (detJ<0), you still count positive area.
Worked example: a tilted square
Compute ∬D(x+y)2dA where D is the square bounded by the lines x+y=0, x+y=2, x−y=0, x−y=2.
The boundary lines suggest u=x+y and v=x−y, which turn D into the square S=[0,2]×[0,2]. Solving for x and y gives x=2u+v and y=2u−v, so
Sanity check: with f=1 the same computation gives area =21⋅4=2, and D is indeed a square of side 2.
✅ Concept check
The map $x = 2u + v$, $y = u + 3v$ sends the unit square $[0,1]^2$ in the $uv$-plane to a parallelogram. What is the parallelogram's area?
Why: $\det\begin{bmatrix}2 & 1\\ 1 & 3\end{bmatrix} = 6 - 1 = 5$. For a linear map the Jacobian is constant, so area = $5 \times 1$.
Triple integrals
Everything goes up one dimension. For f(x,y,z) on a box B=[a,b]×[c,d]×[p,q], cut B into tiny boxes of volume ΔV=ΔxΔyΔz, form ∑f(xi∗,yj∗,zk∗)ΔV, and take the limit:
Fubini still holds, and any of the six orders works for a continuous f on a box. You can’t draw a graph of f in 4D, so don’t try to picture “hypervolume”. Think of f as a density filling the solid, and of the integral as the total amount inside. With f=1, the triple integral is the volume of the solid.
For a general solid E, the limits nest. The innermost limits can depend on both outer variables, the middle ones on the outermost variable, and the outermost limits are constants.
Worked example: a tetrahedron
Find the volume of the solid x,y,z≥0, x+y+z≤1.
For a given (x,y), z runs from 0 up to the slanted plane z=1−x−y. The “shadow” of the solid on the xy-plane is the triangle x,y≥0, x+y≤1:
That’s one sixth of the unit cube, which matches the “one third base times height” formula for a pyramid (31⋅21⋅1).
Cylindrical and spherical coordinates
Cylindrical: polar plus height
Use polar coordinates in the xy-plane and keep z:
x=rcosθ,y=rsinθ,z=z,dV=rdrdθdz.
The Jacobian matrix is block-diagonal (polar block, then a 1 for z), so its determinant is r. Geometrically, a cylindrical cell is a polar cell of area rdrdθ, extruded to height dz. Use cylindrical coordinates for anything with an axis of symmetry: pipes, jets, tornadoes, rotating tanks.
Worked example: a non-uniform cylinder. A cylinder of radius a and height H is filled with fluid whose density increases away from the axis: ρ=ρ0(1+r2/a2). Its mass is
That’s 1.5 times the mass of a uniform cylinder with density ρ0. This makes sense: most of the volume is far from the axis, where the density is highest.
Spherical: distance and two angles
Describe a point by its distance ρ from the origin, its angle φ down from the positive z-axis (0≤φ≤π), and its azimuth θ around the z-axis:
x=ρsinφcosθ,y=ρsinφsinθ,z=ρcosφ.
(Physicists often swap the names θ and φ. Always check the convention.)
The volume element, geometrically. A spherical cell has three nearly perpendicular edges:
radially: dρ;
along a meridian (changing φ): an arc of radius ρ, length ρdφ;
along a circle of latitude (changing θ): that circle has radius ρsinφ (the distance to the z-axis), so the arc length is ρsinφdθ.
Multiplying the three edges gives
dV=ρ2sinφdρdφdθ.
The 3×3 Jacobian determinant gives the same answer (Problem 4 below asks you to verify it). The sinφ says cells near the poles are thin slivers. The ρ2 says shells far out are big.
The center of mass is a density-weighted average of position, and the same formulas work in 2D with dA. Swap “mass” for any other quantity and the pattern holds: total heat is ∭ρcpTdV, total kinetic energy is ∭21ρ∣u∣2dV, and total momentum is ∭ρudV (one integral per component).
Worked example: centroid of a half-disk
Find the center of mass of the upper half-disk x2+y2≤R2, y≥0, with uniform density.
By symmetry xˉ=0. The area is πR2/2. In polar coordinates the half-disk is 0≤r≤R, 0≤θ≤π:
The next cell does exactly that for a smoke puff on a grid:
🐍 PythonTotal mass and center of mass of a smoke puff on a grid
⌘/Ctrl + Enter
Numerical integration in several dimensions
There are two ways to compute ∬DfdA on a computer.
Grid (midpoint) rules. Cover the region with cells and add f(midpoint)×area. You already know the error: O(h2) when the grid fits the region, which means O(N−2/d) for N evaluations in d dimensions. A curved boundary on a Cartesian grid spoils this, since the staircase error is O(h). That’s one reason to choose coordinates that fit the geometry, and one reason fluid codes care so much about how boundaries cut through cells (10.11 2D Grids, Boundary Conditions & Staggered (MAC) Grids).
Monte Carlo. Enclose D in a box B of known area ∣B∣. Throw N uniformly random points pk into B and use
∬DfdA≈N∣B∣k=1∑Nf(pk)1D(pk),
where 1D is 1 inside D and 0 outside. This is the box area times the average of f⋅1D. By the central limit theorem the error is random with typical size σ/N, where σ is the standard deviation of ∣B∣f1D. The key point is that N−1/2 doesn’t depend on the dimension. In 2D, Monte Carlo loses badly to the midpoint rule (N−1/2 vs N−1). In 10D the midpoint rule’s N−1/5 is worse than Monte Carlo, and a grid with just 10 points per axis already needs 1010 evaluations. That is the curse of dimensionality, and it’s why statistical physics, radiative transfer and path tracing all use Monte Carlo.
✅ Concept check
A Monte Carlo estimate with $N = 10^4$ samples has an error of about $0.02$. Roughly how many samples do you need to get the error down to $0.002$?
Why: Monte Carlo is slow but dimension-independent: every extra decimal digit costs 100 times more samples.
Now implement both methods, plus a polar-grid computation of a disk’s area.
🧪 Coding exerciseExercise: midpoint rule, Monte Carlo, and a disk in polar✓ passed
⌘/Ctrl + Enter
💡 For the midpoint rule, x = a + (np.arange(n) + 0.5) * hx and similarly for y; np.meshgrid gives all midpoints. For Monte Carlo, x = rng.uniform(xmin, xmax, N). The polar area doesn't depend on theta, so the theta sum just multiplies by nt * dtheta = 2π.
With working integrators, measure the convergence rates and watch the curse of dimensionality appear:
🐍 PythonMidpoint vs. Monte Carlo: error against number of evaluations
⌘/Ctrl + Enter
Practice problems
✏️ Pen & paperSetting up and evaluating●○○
Evaluate ∬R(x+2y)dA over R=[0,2]×[1,3].
Find the area of the region between y=x2 and y=2x with a double integral.
Show worked solution
Inner integral in y: ∫13(x+2y)dy=[xy+y2]13=(3x+9)−(x+1)=2x+8. Outer integral: ∫02(2x+8)dx=4+16=20. Check by averages: the area is 4 and the average of x+2y is 1+2⋅2=5, so the integral is 20. ✓
The curves meet where x2=2x, at x=0 and x=2. Between them 2x≥x2 (try x=1: 2>1). So the area is ∫02∫x22xdydx=∫02(2x−x2)dx=4−38=34.
✏️ Pen & paperA planet's mass●●○
A planet of radius R has density that falls off linearly from the center: ρ=ρ0(1−ρr/R), where ρr is the distance from the center (we write ρr to avoid a clash with the density’s symbol).
Find its total mass M.
Compare it with a uniform planet of the same radius and central density ρ0.
Show worked solution
Use spherical coordinates. The density depends only on the distance s=ρr, so the angular integrals give ∫02π∫0πsinφdφdθ=4π:
M=4πρ0∫0R(1−Rs)s2ds=4πρ0(3R3−4R3)=3πρ0R3.
A uniform planet has mass 34πρ0R3, so this one has a quarter of that mass. Most of a ball’s volume is near the surface (the s2 in dV), and that’s exactly where this density is small.
✏️ Pen & paperElliptical region by change of variables●●○
Compute the area of the ellipse a2x2+b2y2≤1, and then ∬E(a2x2+b2y2)dA over it.
Show worked solution
Let x=au, y=bv. The ellipse becomes the unit disk u2+v2≤1, and
∂(u,v)∂(x,y)=det[a00b]=ab.
Area:∬diskabdudv=ab⋅π=πab.
Second integral:∬disk(u2+v2)abdudv. In polar coordinates on the unit disk this is ab∫02π∫01r3drdθ=ab⋅2π.
The answer combines two changes of variables: a linear stretch (Jacobian ab) followed by polar coordinates (Jacobian r).
✏️ Pen & paperThe spherical volume element from the Jacobian●●●
Verify that ∂(ρ,φ,θ)∂(x,y,z)=ρ2sinφ for spherical coordinates. Then use it to find the volume of the “ice-cream cone” bounded below by the cone φ=π/4 and above by the sphere ρ=1.
Show worked solution
The columns of J are the partial derivatives with respect to ρ, φ and θ:
(The (3,2) entry −ρsinφ carries cofactor sign −1, so the two signs cancel and that term enters with a plus.) Since 0≤φ≤π, sinφ≥0, and the absolute value is ρ2sinφ.
A fluid parcel occupying a region D0 is carried by a steady flow for time t. Over that time, the flow moves the point (x0,y0) to (x,y)=(x0et,y0e−t) (a “strain” flow that stretches along x and squeezes along y).
Compute the Jacobian determinant ∂(x,y)/∂(x0,y0). What happens to the area of any parcel?
Dye with density ρ0(x0,y0) is carried along without any mixing, so each bit of dye keeps its mass. Show that the dye’s density at time t is ρ(x,y)=ρ0(xe−t,yet), and that the total dye mass is unchanged.
Show worked solution
J=[et00e−t], so detJ=ete−t=1. Every parcel keeps its area. It is stretched along x and squeezed along y into a long thin shape, but the two effects exactly cancel in area. This flow is incompressible (its velocity field (x,−y) has zero divergence; see 2.7 Divergence: Sources & Sinks).
A small patch dA0 around (x0,y0) holds mass ρ0dA0. It’s carried to a patch of area dA=∣detJ∣dA0=dA0 around (x,y), so the density there is ρ0(x0,y0) with x0=xe−t and y0=yet. The total mass at time t, after the change of variables (x,y)=T(x0,y0), is
It’s unchanged because ∣detJ∣=1. For a compressible flow, detJ=1, and the density has to change by the factor 1/∣detJ∣ to keep the mass fixed. That’s the Lagrangian form of conservation of mass.
Key Takeaways
A multiple integral is the limit of a Riemann sum: add (value of f) × (tiny area or volume) over the region. Read it as volume, area (f=1), total amount (when f is a density), or, after dividing by the size, an average.
Fubini’s theorem lets you compute it as iterated single integrals in any order. For non-rectangular regions the inner limits are functions of the outer variables. Sketch the region and draw a typical line through it.
Polar coordinates: dA=rdrdθ, because a cell’s curved side has length rdθ. Cylindrical: dV=rdrdθdz. Spherical: dV=ρ2sinφdρdφdθ.
Change of variables: dxdy=∣detJ∣dudv. The Jacobian determinant is the local area (or volume) scaling factor of the map, which is the determinant idea from Module 1 applied point by point.
Mass is ∭ρdV and the center of mass is the density-weighted average of position. The same pattern gives total heat, momentum and energy.
On a computer, the midpoint rule has error O(h2) if the grid fits the region, but a staircase boundary drops it to O(h). Monte Carlo converges like N−1/2 in any dimension.
Every conservation law in fluid dynamics starts as “the rate of change of ∭VρdV equals flux through the boundary”, and finite-volume solvers conserve mass by keeping that Riemann sum exact.
Finished this lesson?
Mark it complete to track your progress (saved in this browser). Reading every section does this for you.