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 3 of 5

ConceptLesson 4.7.3 in Level 4, Multivariable calculus and optimisation. About 30 minutes.

Polar coordinates and the Gaussian integral

Polar coordinates

A point of the plane can be given by its distance rr from the origin and its angle θ\theta from the positive xx-axis. The point at angle θ\theta on the unit circle is (cos⁡θ,sin⁡θ)(\cos\theta, \sin\theta) (lesson 1.7.1), so the point at distance rr is rr times it.

Rule: Polar coordinates

x=rcos⁡θ,y=rsin⁡θr=x2+y2\begin{gathered} x = r\cos\theta, \quad y = r\sin\theta \\[4pt] r = \sqrt{x^2 + y^2} \end{gathered}

r≥0r \ge 0 is a distance; θ\theta is in radians. The angle is found with math.atan2(y, x) (practice set 1.7.4), which looks at the signs of both coordinates. These are the modulus and argument of x+iyx + iy (lesson 1.7.3).

The point (1,1)(1, 1) has r=2≈1.414214r = \sqrt{2} \approx 1.414214 and θ=π4\theta = \frac{\pi}{4}. The point (−1,1)(-1, 1) has the same rr but θ=3π4≈2.356194\theta = \frac{3\pi}{4} \approx 2.356194, in the second quarter of the plane. The point (0,−2)(0, -2) has r=2r = 2 and θ=−π2\theta = -\frac{\pi}{2}; adding 2π2\pi gives the same point.

Two cases need care. Adding 2π2\pi to θ\theta does not move the point, so a full turn is θ\theta from 0 to 2π2\pi or from −π-\pi to π\pi, not both. And the origin has r=0r = 0 and no angle.

Try it

math.hypot(x, y) is x2+y2\sqrt{x^2 + y^2}. The loop prints rr, θ\theta and θ\theta in degrees for the three points above.

The last line goes back: rcos⁡θr\cos\theta and rsin⁡θr\sin\theta rebuild (−1,1)(-1, 1).

⌘/Ctrl + Enter runs the cell

The polar cell: dA=r dr dθdA = r\,dr\,d\theta

Polar coordinates are a map from the (r,θ)(r, \theta) plane to the (x,y)(x, y) plane, as in lesson 4.7.2. A small rectangle in (r,θ)(r, \theta), from rr to r+drr + dr and from θ\theta to θ+dθ\theta + d\theta, lands on a piece of a ring.

That piece has two straight sides of length drdr along the rays. Its other two sides are arcs, and an arc of angle dθd\theta on a circle of radius rr has length r dθr\,d\theta (lesson 1.7.1). So its area is about r dr dθr\,dr\,d\theta: the further out, the bigger the cell.

Equal cells in the (r,θ)(r, \theta) plane land on pieces of rings. The cell from r=2.5r = 2.5 to 3 has 2.2 times the area of the cell from r=1r = 1 to 1.5. That is the ratio of their middle radii, 2.75 and 1.25.

The exact area of the piece of ring is the difference of two sectors, 12((r+dr)2−r2)dθ=(r+dr2)dr dθ\frac{1}{2}\left((r + dr)^2 - r^2\right)d\theta = \left(r + \frac{dr}{2}\right)dr\,d\theta. Divided by the cell's area in (r,θ)(r, \theta), dr dθdr\,d\theta, it tends to rr as the cell shrinks:

dr=dθdr = d\theta0.10.010.001
area ratio at r=2r = 22.052.0052.0005
area ratio at r=0.5r = 0.50.550.5050.5005

The Jacobian of lesson 4.7.2 gives the same scale. With x=rcos⁡θx = r\cos\theta and y=rsin⁡θy = r\sin\theta,

J=(cos⁡θ−rsin⁡θsin⁡θrcos⁡θ)det⁡J=rcos⁡2θ+rsin⁡2θ=r\begin{gathered} J = \begin{pmatrix} \cos\theta & -r\sin\theta \\ \sin\theta & r\cos\theta \end{pmatrix} \\[4pt] \det J = r\cos^2\theta + r\sin^2\theta = r \end{gathered}

by the identity cos⁡2θ+sin⁡2θ=1\cos^2\theta + \sin^2\theta = 1 of lesson 1.7.1.

Rule: Integrals in polar coordinates

dA=r dr dθ∬Rf dA=∬f(rcos⁡θ,rsin⁡θ) r dr dθ\begin{gathered} dA = r\,dr\,d\theta \\[4pt] \iint_R f\,dA \\ = \iint f(r\cos\theta, r\sin\theta)\,r\,dr\,d\theta \end{gathered}

The extra rr is the area scale det⁡J\det J. The limits describe RR in rr and θ\theta, with θ\theta covering the region once.

Try it

SymPy builds the Jacobian and simplifies its determinant to rr.

The loop prints the exact area of a small piece of ring, divided by dr dθdr\,d\theta, at r=2r = 2 and r=0.5r = 0.5.

⌘/Ctrl + Enter runs the cell

Discs, rings and wedges

A disc of radius aa about the origin is the polar rectangle 0≤r≤a0 \le r \le a, 0≤θ≤2π0 \le \theta \le 2\pi. Its area comes out as it should:

∫02π∫0ar dr dθ=2π⋅a22=πa2\int_0^{2\pi} \int_0^a r\,dr\,d\theta = 2\pi \cdot \frac{a^2}{2} = \pi a^2

A ring 1≤r≤21 \le r \le 2 has area 2π⋅4−12=3π≈9.4247782\pi \cdot \frac{4 - 1}{2} = 3\pi \approx 9.424778. For a function of x2+y2x^2 + y^2, polar coordinates turn it into a function of rr alone. Over the unit disc,

∬(x2+y2) dA=∫02π∫01r2⋅r dr dθ=2π⋅14=π2\begin{aligned} \iint (x^2 + y^2)\,dA &= \int_0^{2\pi} \int_0^1 r^2 \cdot r\,dr\,d\theta \\ &= 2\pi \cdot \frac{1}{4} = \frac{\pi}{2} \end{aligned}

That is about 1.570796. Without the factor rr the answer would be 2π3\frac{2\pi}{3}, which is wrong.

A wedge uses part of a turn. The right half of the disc of radius 2, where x≥0x \ge 0, is −π2≤θ≤π2-\frac{\pi}{2} \le \theta \le \frac{\pi}{2}.

There ∬x dA=∫−π/2π/2cos⁡θ dθ⋅∫02r2 dr=2⋅83=163\iint x\,dA = \int_{-\pi/2}^{\pi/2} \cos\theta\,d\theta \cdot \int_0^2 r^2\,dr = 2 \cdot \frac{8}{3} = \frac{16}{3}, a product as in lesson 4.7.1. Over the whole disc the two halves cancel and ∬x dA=0\iint x\,dA = 0.

When polar coordinates do not help

Polar coordinates suit discs, rings and wedges centred at the origin, and functions of x2+y2x^2 + y^2. They make other regions harder.

In the square [0,1]×[0,1][0, 1] \times [0, 1], rr runs out to the edge x=1x = 1, which is r=1cos⁡θr = \frac{1}{\cos\theta} for θ≤π4\theta \le \frac{\pi}{4}. Beyond that it runs out to y=1y = 1, so there are two pieces with awkward limits. For a square, keep xx and yy.

Try it

SymPy computes the disc and the ring, then x2+y2x^2 + y^2 over the unit disc with and without the factor rr. The third line integrates xx over the half disc and the whole disc.

dblquad checks π2\frac{\pi}{2} twice: in xx and yy, with yy from −1−x2-\sqrt{1 - x^2} to 1−x2\sqrt{1 - x^2}, and in polar coordinates.

⌘/Ctrl + Enter runs the cell

Where the Gaussian integral comes from

Lesson 2.6.3 stated ∫−∞∞e−x2 dx=π\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi} without proof. The curve e−x2e^{-x^2} has no antiderivative made of familiar functions, so the fundamental theorem cannot find this area. A double integral can.

Call the area II. The idea is to work out I2I^2 instead: as a double integral over the whole plane, it can be done in polar coordinates.

  1. 1
    I2=∫−∞∞e−x2 dx⋅∫−∞∞e−y2 dyI^2 = \int_{-\infty}^{\infty} e^{-x^2}\,dx \cdot \int_{-\infty}^{\infty} e^{-y^2}\,dy
  2. 2
    I2=∬R2e−(x2+y2) dAI^2 = \iint_{\mathbb{R}^2} e^{-(x^2 + y^2)}\,dA
  3. 3
    I2=∫02π∫0∞e−r2 r dr dθI^2 = \int_0^{2\pi} \int_0^{\infty} e^{-r^2}\,r\,dr\,d\theta
  4. 4
    ∫0∞r e−r2 dr=[−12e−r2]0∞=12\int_0^{\infty} r\,e^{-r^2}\,dr = \left[-\tfrac{1}{2}e^{-r^2}\right]_0^{\infty} = \frac{1}{2}
  5. 5
    I2=2π⋅12=π,I=πI^2 = 2\pi \cdot \frac{1}{2} = \pi, \qquad I = \sqrt{\pi}

The factor rr from the polar cell is what makes it work. In one variable e−x2e^{-x^2} has no antiderivative; in two, the area element brings in the rr that r e−r2r\,e^{-r^2} needs.

Rule: The Gaussian integral

∬R2e−(x2+y2) dA=π∫−∞∞e−x2 dx=π\begin{gathered} \iint_{\mathbb{R}^2} e^{-(x^2 + y^2)}\,dA = \pi \\[4pt] \int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi} \end{gathered}

The double integral is π\pi by polar coordinates, and it is the square of the single integral. Every integral here is improper (lesson 2.6.3); making each step exact over the whole plane is a job for the Proof Gym.

Checking it with numbers

Over a disc of radius bb, the same steps give π(1−e−b2)\pi\left(1 - e^{-b^2}\right). Over the square [−b,b]×[−b,b][-b, b] \times [-b, b], the product rule gives (∫−bbe−x2 dx)2\left(\int_{-b}^{b} e^{-x^2}\,dx\right)^2: the square of lesson 2.6.3's table. At b=1b = 1 that is 1.4936482=2.2309851.493648^2 = 2.230985.

The square contains the disc of radius bb and lies inside the disc of radius 2 b\sqrt{2}\,b, which passes through its corners. The integrand is positive, so the square's volume is squeezed between the two discs' volumes.

The volume under e−(x2+y2)e^{-(x^2 + y^2)} over the square [−b,b]2[-b, b]^2 stays between its volumes over the two discs. As bb grows, all three close in on π\pi.

bb1234
disc of radius bb1.9858653.0840523.1412053.141592
square [−b,b]2[-b, b]^22.2309853.112273.1414543.141593
disc of radius 2 b\sqrt{2}\,b2.7164243.1405393.1415933.141593

All three settle on π≈3.141593\pi \approx 3.141593, so I2=πI^2 = \pi, and I=π≈1.772454I = \sqrt{\pi} \approx 1.772454, the number lesson 2.6.3 found numerically.

Try it

Each line prints bb and the three volumes: the disc formula, the square of quad's one-dimensional integral, and the larger disc.

The last lines take the whole plane: SymPy gives pi, and so does dblquad with infinite limits, up to rounding.

⌘/Ctrl + Enter runs the cell

The bell in two dimensions

The same steps work for e−(x2+y2)/2e^{-(x^2 + y^2)/2}. In polar coordinates the inner integral is ∫0∞r e−r2/2 dr=1\int_0^{\infty} r\,e^{-r^2/2}\,dr = 1, so

∬R2e−(x2+y2)/2 dA=2π\iint_{\mathbb{R}^2} e^{-(x^2 + y^2)/2}\,dA = 2\pi

Its square root, 2π≈2.506628\sqrt{2\pi} \approx 2.506628, is ∫−∞∞e−x2/2 dx\int_{-\infty}^{\infty} e^{-x^2/2}\,dx, the number lesson 2.6.3 found by substitution. Dividing by 2π2\pi gives the surface φ(x)φ(y)=12πe−(x2+y2)/2\varphi(x)\varphi(y) = \frac{1}{2\pi}e^{-(x^2 + y^2)/2}, with φ\varphi the standard normal density, and it has volume 1. Case study 4.7.5 reads that surface as the joint density of two independent normal returns.

Try it

SymPy finds the volume under e−(x2+y2)/2e^{-(x^2 + y^2)/2} in polar coordinates, then ∫e−x2/2 dx\int e^{-x^2/2}\,dx squared.

The last line integrates φ(x)φ(y)\varphi(x)\varphi(y) over the plane with dblquad.

⌘/Ctrl + Enter runs the cell

Common mistakes

  1. Keep the rr. dA=r dr dθdA = r\,dr\,d\theta, not dr dθdr\,d\theta: ∬(x2+y2) dA\iint (x^2 + y^2)\,dA over the unit disc is π2\frac{\pi}{2}, not 2π3\frac{2\pi}{3}.
  2. A full turn is 2π2\pi. θ\theta from 0 to π\pi covers only the upper half; from 0 to 4π4\pi it covers the disc twice.
  3. A ring of radii aa and bb has area π(b2−a2)\pi(b^2 - a^2), not π(b−a)2\pi(b - a)^2.
  4. Find the angle with atan2. yx\frac{y}{x} is the same for (1,1)(1, 1) and (−1,−1)(-1, -1); the quadrant decides the angle (practice set 1.7.4). And rr is never negative.
  5. Use polar coordinates for round regions, centred at the origin. A square has awkward limits in rr and θ\theta.
  6. e−x2e^{-x^2} has no antiderivative, but r e−r2r\,e^{-r^2} does. The Gaussian integral works only through the double integral, where the area element supplies the rr.

Polar coordinates and the Gaussian integral

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

  • Polar coordinates: x=rcos⁡θx = r\cos\theta, y=rsin⁡θy = r\sin\theta, r=x2+y2r = \sqrt{x^2 + y^2}, with θ\theta from atan2(y, x).
  • The area element is dA=r dr dθdA = r\,dr\,d\theta: a polar cell has sides drdr and r dθr\,d\theta, and det⁡J=r\det J = r.
  • Discs, rings and wedges centred at the origin are rectangles in (r,θ)(r, \theta): a disc has area πa2\pi a^2, a ring π(b2−a2)\pi(b^2 - a^2).
  • ∬R2e−(x2+y2) dA=π\iint_{\mathbb{R}^2} e^{-(x^2 + y^2)}\,dA = \pi in polar coordinates, and it is the square of ∫−∞∞e−x2 dx\int_{-\infty}^{\infty} e^{-x^2}\,dx, which is therefore π\sqrt{\pi}.
  • ∬e−(x2+y2)/2 dA=2π\iint e^{-(x^2 + y^2)/2}\,dA = 2\pi, so φ(x)φ(y)\varphi(x)\varphi(y) has volume 1.

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.

  • 18.02SC Multivariable Calculus

    MIT OpenCourseWare. Course.

    Lectures and problem sets on partial derivatives, optimisation and multiple integrals.