---
title: Change of variables and the Jacobian
heading: Choosing coordinates that fit the shape
eyebrow: A9 · Lesson 19 · Change of variables
xp: 40
---

::: hook
An elliptical waveguide, a tilted parallelogram of copper, a probability spread that's stretched along one axis: integrating over these in plain $x$ and $y$ is painful. Choose coordinates that fit the shape and the region becomes a square or a disk. The price is one factor, the **Jacobian**, which says how much the new coordinates stretch area. You've already met two: the $r$ in polar coordinates and the $|\det A|$ of A7.
:::

::: play
- Stretching the unit disk by $a$ along $x$ and $b$ along $y$ makes an ellipse. The map is $x = au$, $y = bv$.
- The readouts compare the ellipse's area with the disk's area times the stretch factor $ab$.
- Every small patch of the disk is stretched by the same factor, so the whole area is too.
:::
:::

```sim plot
view: complex
range: 4
slider: a = 0.5..3.5 step 0.1 = 3
slider: b = 0.5..3.5 step 0.1 = 1.5
curve: cos(u) + j*sin(u) | over: u = 0..2*pi | dashed | label: unit disk
curve: a*cos(u) + j*b*sin(u) | over: u = 0..2*pi | color: ch2 | label: ellipse
readout: Jacobian ab = a*b | digits: 3
readout: ellipse area = pi*a*b | digits: 4
```

::: predict
## The map $x = 3u$, $y = 2v$ sends the unit disk to an ellipse. What is the ellipse's area?

- [ ] $\pi$
- [ ] $5\pi$
- [x] $6\pi$
- [ ] $9\pi$

::: reveal
$6\pi$. The map stretches every area by $|\det| = 3 \times 2 = 6$, the Jacobian, so the disk's area $\pi$ becomes $6\pi$. In general an ellipse with semi-axes $a$ and $b$ has area $\pi ab$.
:::
:::

::: nameit
## The Jacobian

For a change of variables $x = x(u, v)$, $y = y(u, v)$, the **Jacobian determinant** is

$$J = \frac{\partial(x, y)}{\partial(u, v)} = \begin{vmatrix}x_u & x_v\\y_u & y_v\end{vmatrix}$$

and areas transform as $dA = |J|\,du\,dv$:

$$\iint_Rf(x, y)\,dx\,dy = \iint_Sf(x(u, v), y(u, v))\,|J|\,du\,dv$$

where $S$ is the region in the $u, v$ plane that maps to $R$. Near each point the map is nearly linear (lesson 6), and a linear map scales areas by its determinant.

## Familiar cases

| Coordinates | Jacobian |
|---|---|
| Linear, $\begin{bmatrix}x\\y\end{bmatrix} = A\begin{bmatrix}u\\v\end{bmatrix}$ | $\lvert\det A\rvert$ |
| Polar | $r$ |
| Cylindrical | $r$ |
| Spherical $(r, \theta, \varphi)$ | $r^2\sin\varphi$ |

In one dimension it's the $\frac{dx}{du}$ of ordinary substitution.

## Choosing the substitution

Look at the boundaries. If they're $x + y = $ const and $x - y = $ const, use $u = x + y$, $v = x - y$. If they're ellipses, scale to circles. If the integrand has $x^2 + y^2$, go polar. You often have $u$ and $v$ in terms of $x$ and $y$; then $J = 1\big/\frac{\partial(u, v)}{\partial(x, y)}$.
:::

::: example
## Find the area of the ellipse $\frac{x^2}{a^2} + \frac{y^2}{b^2} \le 1$.

::: solution
1. **Stretch a disk.** With $x = au$, $y = bv$ the region becomes the unit disk $u^2 + v^2 \le 1$.
2. **Jacobian.**
   $$\begin{aligned} J &= \begin{vmatrix}a & 0\\0 & b\end{vmatrix} \\ &= ab \end{aligned}$$
3. **Area.**
   $$\begin{aligned} A &= \iint ab\,du\,dv \\ &= ab \times \pi \end{aligned}$$

**Answer:** the ellipse's area is $\pi ab$.
:::
:::

::: example
## Evaluate $\iint(x + y)\,dA$ over the square with corners $(0, 0)$, $(1, 1)$, $(2, 0)$, $(1, -1)$.

::: solution
1. **Choose the new variables.** Its sides lie on $x + y = 0, 2$ and $x - y = 0, 2$, so let $u = x + y$ and $v = x - y$, each from 0 to 2.
2. **Jacobian.**
   $$\begin{aligned} \frac{\partial(u, v)}{\partial(x, y)} &= \begin{vmatrix}1 & 1\\1 & -1\end{vmatrix} \\ &= -2 \end{aligned}$$
   so $|J| = \frac{1}{2}$.
3. **Integrate.**
   $$\begin{aligned} &\int_0^2\int_0^2u\cdot\tfrac{1}{2}\,du\,dv \\ &= \tfrac{1}{2}\cdot 2\cdot 2 \\ &= 2 \end{aligned}$$

**Answer:** the integral is 2.
:::
:::

::: example
## Find the area of the region $0 \le x + y \le 2$, $0 \le x - y \le 1$, and $\iint(x + y)\,dA$ over it.

::: solution
1. **Change variables.** With $u = x + y$ and $v = x - y$, the region is the rectangle $[0, 2] \times [0, 1]$.
2. **Jacobian.**
   $$\begin{aligned} \frac{\partial(u, v)}{\partial(x, y)} &= \det\begin{bmatrix}1 & 1\\1 & -1\end{bmatrix} \\ &= -2 \end{aligned}$$
   so $dA = \frac12du\,dv$.
3. **Area.**
   $$2 \times 1 \times \tfrac12 = 1$$
4. **The integral.**
   $$\begin{aligned} &\iint(x + y)\,dA \\ &= \int_0^1\int_0^2u \cdot \tfrac12\,du\,dv \\ &= \tfrac12 \cdot 2 \\ &= 1 \end{aligned}$$

**Answer:** the area is 1, and $\iint(x + y)\,dA = 1$ over it.
:::
:::

::: check
given: a = 2 | 3; b = 1 | 4
answer: a*b

## What is the Jacobian of $x = \given{a}u$, $y = \given{b}v$?

::: right
Right. $\begin{vmatrix}a & 0\\0 & b\end{vmatrix} = ab$ = {answer}.
:::

::: misses
- [a + b] It's a determinant: multiply the stretches.
- [any] Not yet. $x_uy_v - x_vy_u$.
:::
:::

::: check
given: a = 2 | 5; b = 1 | 3
answer: pi*a*b
tolerance: 0.5%

## What is the area of the ellipse with semi-axes {a} and {b}?

::: right
Right. $\pi ab$ = {answer}.
:::

::: misses
- [pi*(a + b)/2] Areas scale by the product of the stretches.
- [pi*a^2] That's a circle of radius $a$.
- [any] Not yet. Map the unit disk with Jacobian $ab$.
:::
:::

::: check
given: p = 2 | 3; q = 1 | -1; r = 1 | 4; s = 3 | 2
answer: abs(p*s - q*r)

## By what factor does $x = \given{p}u + \given{q}v$, $y = \given{r}u + \given{s}v$ scale areas?

::: right
Right. $|ps - qr|$ = {answer}.
:::

::: misses
- [p*s + q*r] The determinant subtracts the cross term.
- [any] Not yet. $|\det|$ of the coefficient matrix.
:::
:::

::: check
given: r = 2 | 3; phi = 30 | 45
answer: r^2*sin(phi*pi/180)
tolerance: 0.5%

## What is the spherical Jacobian $r^2\sin\varphi$ at $r$ = {r}, $\varphi$ = {phi}°? (It's how much volume a small $dr\,d\theta\,d\varphi$ box has there.)

::: right
Right. {answer}.
:::

::: misses
- [r*sin(phi*pi/180)] Spherical coordinates scale volume by $r^2\sin\varphi$.
- [r^2] Include $\sin\varphi$: boxes near the poles are thinner.
- [any] Not yet. $r^2\sin\varphi$.
:::
:::

::: check
given: a = 1 | 2; b = 3 | 2; c = 2 | 5
answer: 4*pi*a*b*c/3
tolerance: 0.5%

## What is the volume of the ellipsoid with semi-axes {a}, {b} and {c}?

::: right
Right. Scaling the unit ball by $a$, $b$, $c$ multiplies its volume $\frac{4}{3}\pi$ by $abc$: {answer}.
:::

::: misses
- [4*pi*a*b*c] The unit ball has volume $\frac{4}{3}\pi$.
- [any] Not yet. Jacobian $abc$ times the unit ball's volume.
:::
:::

::: check
given: k = 1 | 2 | 3
answer: 2*k^3

## Evaluate $\iint(x + y)\,dA$ over the square with corners $(0, 0)$, $(\given{k}, \given{k})$, $(2\given{k}, 0)$, $(\given{k}, -\given{k})$.

::: right
Right. With $u = x + y$, $v = x - y$ from 0 to $2k$ and $|J| = \frac{1}{2}$: $\frac{1}{2}\cdot\frac{(2k)^2}{2}\cdot 2k = 2k^3$ = {answer}.
:::

::: misses
- [4*k^3] Include $|J| = \frac{1}{2}$.
- [any] Not yet. Change to $u = x + y$, $v = x - y$.
:::
:::

::: check
kind: parts
given: a = 2 | 3; b = 1 | 4

## The ellipse $\frac{x^2}{\given{a}^2} + \frac{y^2}{\given{b}^2} \le 1$ maps to the unit disk with $x = au$, $y = bv$.

::: part
answer: a*b
tolerance: 0.5%

### What is the Jacobian $\left|\frac{\partial(x, y)}{\partial(u, v)}\right|$?

::: misses
- [a + b] It's a determinant: $\det\begin{bmatrix}a & 0\\0 & b\end{bmatrix}$.
- [any] Compute the determinant.
:::
:::

::: part
answer: pi*a*b
tolerance: 0.5%

### What is the ellipse's area?

::: misses
- [any] $ab$ times the unit disk's area.
:::
:::
:::

::: check
kind: derivation
vars: r = 0.1..3, t = 0..6

## Find the Jacobian of polar coordinates, $x = r\cos t$, $y = r\sin t$.

::: step
answer: cos(t)*r*cos(t) + r*sin(t)*sin(t)

### What is $x_ry_t - x_ty_r$, written out?
:::

::: step
answer: r

### Simplify.
:::

::: right
Right. $dA = r\,dr\,d\theta$: the factor $r$ is the Jacobian.
:::
:::

::: explain
## Why does a change of variables need the absolute value of the Jacobian determinant?

::: model
Close to any point, a smooth change of variables acts like a linear map, and a linear map multiplies small areas by the size of its determinant (A7). So a little patch $du\,dv$ in the new coordinates corresponds to an area $|J|\,du\,dv$ in the old ones. Integrating adds up $f$ times these true areas. The sign of $J$ only says whether the map flips orientation, like a mirror; area is never negative, so we take the absolute value.
:::
:::

::: practice

::: check
given: r = 2..20 int
answer: r

## What is the polar Jacobian at $r$ = {r}?

::: misses
- [1] Patches farther out are bigger: $J = r$.
- [any] $\frac{\partial(x, y)}{\partial(r, \theta)} = r$.
:::
:::

::: check
given: a = 2 | 4; b = 3 | 5
answer: 4*a*b
tolerance: 0.5%

## What is the area of the rectangle $|x| \le \given{a}$, $|y| \le \given{b}$, found by scaling the square $|u|, |v| \le 1$?

::: misses
- [a*b] The square $|u|, |v| \le 1$ has area 4.
- [any] Jacobian $ab$ times 4.
:::
:::

::: check
given: d = -8 | -6 | -5 | -3 | -2 | -1.5
answer: abs(d)

## A linear map has determinant {d}. By what factor does it scale areas?

::: misses
- [d] Area scales by the size of the determinant.
- [any] $|\det|$.
:::
:::
:::
