SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 4.7.1 Double integralsConcept · 35 min
      2. 4.7.2 Change of variables and the JacobianConcept · 35 min
      3. 4.7.3 Polar coordinates and the Gaussian integralConcept · 30 min
      4. 4.7.4 Practice set: multiple integralsPractice set · 25 min
      5. 4.7.5 Case study: joint densities and Monte Carlo integrationCase study · 35 min

Level 4, Multivariable calculus and optimisation 4.7 Multiple integrals Lesson 2 of 5

ConceptLesson 4.7.2 in Level 4, Multivariable calculus and optimisation. About 35 minutes.

Change of variables and the Jacobian

New coordinates for a region

Some regions are awkward in xx and yy but simple in other coordinates. A map (u,v)↦(x,y)(u, v) \mapsto (x, y) gives each point of a uvuv-plane a point of the xyxy-plane. If it sends a rectangle SS onto the region RR, an integral over RR can be worked out over SS instead.

One correction is needed. A small cell of area du dvdu\,dv in the uvuv-plane does not land on a cell of the same area. So each cell must carry the factor by which the map stretches or shrinks area near it.

A linear map

Take the map x=3u+vx = 3u + v, y=u+2vy = u + 2v. In matrix form it is x=Au\mathbf{x} = A\mathbf{u} with

A=(3112)A = \begin{pmatrix} 3 & 1 \\ 1 & 2 \end{pmatrix}

the matrix of lesson 3.4.1. It sends the unit square S=[0,1]×[0,1]S = [0, 1] \times [0, 1] to the parallelogram PP with corners (0,0)(0, 0), (3,1)(3, 1), (4,3)(4, 3) and (1,2)(1, 2). Since det⁡A=3⋅2−1⋅1=5\det A = 3 \cdot 2 - 1 \cdot 1 = 5, it multiplies every area by 5 (lesson 3.4.1).

The map with matrix AA sends a grid of squares to a grid of parallelograms. Every cell's area is multiplied by det⁡A=5\det A = 5, so PP has area 5.

So a Riemann sum (lesson 4.7.1) over PP can use the images of the uvuv cells. A cell at (u,v)(u, v) lands near the point (3u+v,u+2v)(3u + v, u + 2v) and has area 5 du dv5\,du\,dv:

∬Pf(x,y) dA=∫01∫01f(3u+v, u+2v)⋅5 du dv\begin{gathered} \iint_P f(x, y)\,dA \\ = \int_0^1 \int_0^1 f(3u + v,\ u + 2v)\cdot 5\,du\,dv \end{gathered}

For f(x,y)=xf(x, y) = x this gives ∬Px dA=5∫01∫01(3u+v) du dv=5(32+12)=10\iint_P x\,dA = 5\int_0^1 \int_0^1 (3u + v)\,du\,dv = 5\left(\frac{3}{2} + \frac{1}{2}\right) = 10. Without the factor 5 you would get 2.

The same numbers come from a plain grid in xx and yy, with no map at all. Cover the box [0,4]×[0,3][0, 4] \times [0, 3] with small squares and keep those whose midpoint lies in PP, edges included:

squares per unit length101001000
area of PP5.15.015.001
∬Px dA\iint_P x\,dA10.210.0210.002

The squares cut by the edges make this slow: the error shrinks only in step with the square's width. But both rows settle on 5 and 10.

Try it

The first line integrates over the unit square with SymPy: the area of PP, then ∬Px dA\iint_P x\,dA with the factor det⁡A\det A and without it.

Then the grid check, one row of squares at a time. A midpoint is in PP when its (u,v)(u, v) lies in the unit square; by the inverse of lesson 3.2.3, u=2x−y5u = \frac{2x - y}{5} and v=3y−x5v = \frac{3y - x}{5}. Measuring xx and yy in grid steps, i and j, keeps the test exact for points on the edges.

⌘/Ctrl + Enter runs the cell

Rule: Change of variables, linear map

∬Rf(x,y) dA=∬Sf(x(u,v),y(u,v)) ∣det⁡A∣ du dv\begin{gathered} \iint_R f(x, y)\,dA \\ = \iint_S f(x(u, v), y(u, v))\,\lvert \det A \rvert\,du\,dv \end{gathered}

Here x=Au\mathbf{x} = A\mathbf{u} sends SS onto RR. Each uvuv cell lands on a cell ∣det⁡A∣\lvert \det A \rvert times as large, so dA=∣det⁡A∣ du dvdA = \lvert \det A \rvert\,du\,dv.

New variables given in terms of xx and yy

Often the region comes as lines in xx and yy. Take the region RR where 0≤x+y≤20 \le x + y \le 2 and 0≤x−y≤20 \le x - y \le 2: a square turned through 45°, with corners (0,0)(0, 0), (1,1)(1, 1), (2,0)(2, 0) and (1,−1)(1, -1). In the new variables u=x+yu = x + y and v=x−yv = x - y it becomes the square S=[0,2]×[0,2]S = [0, 2] \times [0, 2].

Here the formulas go the other way: they give (u,v)(u, v) from (x,y)(x, y). That map has matrix (111−1)\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}, with determinant −2-2. The map back from (u,v)(u, v) to (x,y)(x, y) is its inverse, with determinant 1−2=−12\frac{1}{-2} = -\frac{1}{2} (lesson 3.4.1).

The minus sign only says the map flips the plane over. The area scale is ∣−12∣=12\left\lvert -\frac{1}{2} \right\rvert = \frac{1}{2}. So the area of RR is 12×4=2\frac{1}{2} \times 4 = 2, and

∬R(x+y)2 dA=∫02∫02u2⋅12 du dv=12⋅83⋅2=83\begin{aligned} \iint_R (x + y)^2\,dA &= \int_0^2 \int_0^2 u^2 \cdot \tfrac{1}{2}\,du\,dv \\ &= \tfrac{1}{2} \cdot \tfrac{8}{3} \cdot 2 = \tfrac{8}{3} \end{aligned}

Rule: Going the other way

area scale=1∣det⁡M∣\begin{gathered} \text{area scale} = \frac{1}{\lvert \det M \rvert} \end{gathered}

If the new variables are given in terms of the old ones, with matrix MM, the map back from (u,v)(u, v) to (x,y)(x, y) has determinant 1det⁡M\frac{1}{\det M}. Always take the absolute value: an area cannot be negative.

Try it

SymPy finds both determinants, then the integral over the square SS.

dblquad (lesson 4.7.1) checks it directly over the turned square. That needs two pieces: for xx from 0 to 1, yy runs from −x-x to xx; for xx from 1 to 2, from x−2x - 2 to 2−x2 - x.

⌘/Ctrl + Enter runs the cell

A non-linear map

Now take the map x=ux = u, y=uvy = uv. Read backwards, v=yxv = \frac{y}{x} is the slope of the line from the origin to the point. So the map describes each point by its xx and the slope of its ray, a cousin of the distance and angle of lesson 4.7.3.

It sends the unit square SS onto the triangle TT where 0≤y≤x≤10 \le y \le x \le 1. Each line u=u = constant lands on a vertical segment from (u,0)(u, 0) to (u,u)(u, u), of length uu. Each line v=v = constant lands on the ray y=vxy = vx.

The map x=ux = u, y=uvy = uv sends the square onto a triangle. Cells near u=0u = 0 are squeezed towards the origin; near u=1u = 1 they keep most of their area. Each cell's area is multiplied by the uu at its centre.

So the area scale changes from point to point. Measure it on a small cell [u0,u0+h]×[v0,v0+h][u_0, u_0 + h] \times [v_0, v_0 + h].

Its image is a trapezoid with vertical sides of lengths u0hu_0 h and (u0+h)h(u_0 + h)h, a distance hh apart, so its area is h2(u0+h2)h^2\left(u_0 + \frac{h}{2}\right). Divide by the cell's area h2h^2:

side hh0.10.010.001
area ratio at u0=0.5u_0 = 0.50.550.5050.5005
area ratio at u0=0.25u_0 = 0.250.30.2550.2505

As the cell shrinks, the ratio settles on u0u_0: the local area scale at that point.

The Jacobian matrix

A small step dudu in uu moves the point by (∂x∂u,∂y∂u)du\left(\frac{\partial x}{\partial u}, \frac{\partial y}{\partial u}\right)du, the partial derivatives of lesson 4.1.2. A small step dvdv moves it by (∂x∂v,∂y∂v)dv\left(\frac{\partial x}{\partial v}, \frac{\partial y}{\partial v}\right)dv. Close up, the curved grid looks straight, and a small cell lands on the parallelogram with these two sides.

Rule: Jacobian matrix

J=(∂x∂u∂x∂v∂y∂u∂y∂v)local area scale=∣det⁡J∣\begin{gathered} J = \begin{pmatrix} \dfrac{\partial x}{\partial u} & \dfrac{\partial x}{\partial v} \\[8pt] \dfrac{\partial y}{\partial u} & \dfrac{\partial y}{\partial v} \end{pmatrix} \\[6pt] \text{local area scale} = \lvert \det J \rvert \end{gathered}

The columns are where small steps in uu and in vv take the point. By lesson 3.4.1, the parallelogram they span has area ∣det⁡J∣ du dv\lvert \det J \rvert\,du\,dv.

For a linear map, J=AJ = A at every point. Lesson 4.2.2 meets the same matrix in the chain rule.

For x=ux = u, y=uvy = uv:

J=(10vu),det⁡J=uJ = \begin{pmatrix} 1 & 0 \\ v & u \end{pmatrix}, \qquad \det J = u

That is the u0u_0 the table found. Along the edge u=0u = 0 the determinant is 0: the whole edge lands on the single point (0,0)(0, 0). An edge has no area, so this does no harm.

Rule: Change of variables

∬Rf(x,y) dx dy=∬Sf(x(u,v),y(u,v)) ∣det⁡J∣ du dv\begin{gathered} \iint_R f(x, y)\,dx\,dy \\ = \iint_S f(x(u, v), y(u, v))\,\lvert \det J \rvert\,du\,dv \end{gathered}

The map must send SS onto RR, covering each point of RR once. Change three things together: the function (put in x(u,v)x(u, v) and y(u,v)y(u, v)), the region (SS instead of RR) and the area (∣det⁡J∣ du dv\lvert \det J \rvert\,du\,dv instead of dx dydx\,dy).

Example. Average the slope yx\frac{y}{x} over the triangle TT. With the map, yx=v\frac{y}{x} = v and dA=u du dvdA = u\,du\,dv:

∬Tyx dA=∫01∫01v⋅u dv du=12⋅12=14\iint_T \frac{y}{x}\,dA = \int_0^1 \int_0^1 v \cdot u\,dv\,du = \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{4}

The direct way agrees: ∫01∫0xyx dy dx=∫01x2 dx=14\int_0^1 \int_0^x \frac{y}{x}\,dy\,dx = \int_0^1 \frac{x}{2}\,dx = \frac{1}{4}. Without the factor uu the answer would be 12\frac{1}{2}. The area of TT is ∫01∫01u du dv=12\int_0^1 \int_0^1 u\,du\,dv = \frac{1}{2}, so the average slope, the integral divided by the area, is 14÷12=12\frac{1}{4} \div \frac{1}{2} = \frac{1}{2}.

Try it

SymPy builds JJ with .jacobian and takes its determinant. Then the integral of yx\frac{y}{x} through the map, without the factor uu, and directly; dblquad agrees.

The loop measures the area ratio of small cells at u0=0.5u_0 = 0.5 and 0.250.25. cell_area splits the image into two triangles, each half the absolute determinant of two edge vectors (lesson 3.4.1).

⌘/Ctrl + Enter runs the cell

Folds, flips and one variable

A flip is fine. The map (u,v)↦(v,u)(u, v) \mapsto (v, u) swaps the axes, a mirror image with det⁡J=−1\det J = -1. Areas are unchanged, which is why the rule takes ∣det⁡J∣\lvert \det J \rvert.

A fold is not. The map x=u2x = u^2, y=vy = v sends [−1,1]×[0,1][-1, 1] \times [0, 1] onto the unit square twice over: u=0.5u = 0.5 and u=−0.5u = -0.5 land on the same point. Here ∣det⁡J∣=∣2u∣\lvert \det J \rvert = \lvert 2u \rvert, and ∫01∫−11∣2u∣ du dv=2\int_0^1 \int_{-1}^{1} \lvert 2u \rvert\,du\,dv = 2, though the unit square has area 1. A map that covers RR twice counts its area twice.

One variable. Substitution (lesson 2.6.1) is the same rule with a 1×11 \times 1 Jacobian: x=g(u)x = g(u) gives dx=g′(u) dudx = g'(u)\,du. For x=2u+1x = 2u + 1, which takes [0,1][0, 1] to [1,3][1, 3], ∫13x2 dx=∫01(2u+1)2⋅2 du=263\int_1^3 x^2\,dx = \int_0^1 (2u + 1)^2 \cdot 2\,du = \frac{26}{3}.

In one variable a falling gg needs no absolute value: the new limits run backwards, and swapping them fixes the sign (lesson 2.6.1). A region in the plane has no such order, so the rule uses ∣det⁡J∣\lvert \det J \rvert instead.

Try it

The determinants of the flip and the fold, then the fold's double count.

The last line checks the substitution x=2u+1x = 2u + 1 both ways.

⌘/Ctrl + Enter runs the cell

Lesson 4.7.3 applies the rule to polar coordinates, where det⁡J=r\det J = r. Case study 4.7.5 uses a linear map to turn independent normal draws into correlated returns. Lesson 5.6.1 uses the rule for functions of random variables.

Common mistakes

  1. Keep the area factor. ∬Px dA\iint_P x\,dA is 5×2=105 \times 2 = 10, not 2: every du dvdu\,dv becomes ∣det⁡J∣ du dv\lvert \det J \rvert\,du\,dv.
  2. Use the right map's determinant. If uu and vv are given in terms of xx and yy, the factor is 1∣det⁡M∣\frac{1}{\lvert \det M \rvert}: 12\frac{1}{2} for u=x+yu = x + y, v=x−yv = x - y, not 2.
  3. Take the absolute value. A determinant of −12-\frac{1}{2} is an area scale of 12\frac{1}{2}.
  4. Change the region too. The limits must describe SS in uu and vv, not RR.
  5. For a non-linear map, det⁡J\det J depends on the point. It stays inside the integral: ∬Tyx dA=∫01∫01v u dv du\iint_T \frac{y}{x}\,dA = \int_0^1\int_0^1 v\,u\,dv\,du.
  6. The map must cover RR once. x=u2x = u^2 on [−1,1][-1, 1] folds, and counts every area twice.

Change of variables

0 of 12 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
How to type answers
  • Powers with ^: x^7, 2^(1/3), a^-2.
  • Multiply with * or by writing side by side: 3x^2, 2(x+1).
  • ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
  • Your first answer to each question is saved: it counts towards your score and brings the question back for review.
  • Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.

Summary card

  • A map (u,v)↦(x,y)(u, v) \mapsto (x, y) sends small cells to small cells; the area scale near a point is ∣det⁡J∣\lvert \det J \rvert, with JJ the matrix of partial derivatives ∂x∂u,∂x∂v,∂y∂u,∂y∂v\frac{\partial x}{\partial u}, \frac{\partial x}{\partial v}, \frac{\partial y}{\partial u}, \frac{\partial y}{\partial v}.
  • Change of variables: ∬Rf dx dy=∬Sf(x(u,v),y(u,v)) ∣det⁡J∣ du dv\iint_R f\,dx\,dy = \iint_S f(x(u, v), y(u, v))\,\lvert \det J \rvert\,du\,dv, with the map covering RR once.
  • A linear map x=Au\mathbf{x} = A\mathbf{u} has J=AJ = A everywhere: every area is multiplied by ∣det⁡A∣\lvert \det A \rvert.
  • If uu and vv are given in terms of xx and yy by a matrix MM, the factor is 1∣det⁡M∣\frac{1}{\lvert \det M \rvert}. The sign of a determinant only records a flip.
  • For a non-linear map the scale changes from point to point: x=ux = u, y=uvy = uv has det⁡J=u\det J = u.
  • In one variable the rule is substitution, dx=g′(u) dudx = g'(u)\,du.

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.

  • Multiple Integrals

    Paul's Online Notes. Notes.

    Double and triple integrals, polar coordinates and change of variables.