The Gaussian Integral

Published January 15, 2023 • more posts

Original by u/AlgebraPad

Recently, I saw this video showing a proof of the Gaussian integral, set to DNCE's Cake By The Ocean. It's pretty slick—I recommend watching with sound on. This inspired me to create a blogpost explaining what's being shown here.

We start with the Gaussian integral:

+ex2dx\int_{-\infty}^{+\infty} e^{-x^2}\,dx

It's called the Gaussian integral because it's the integral of the Gaussian function, f(x)=ex2f(x) = e^{-x^2}. This function is pretty important, and shows up in a ton of different domains like physics, statistics, and signal processing. You're probably familiar with its graph:

graph of gaussian function

This function has an interesting property: while the indefinite integral of f(x)f(x) cannot be written using elementary functions, the definite integral over (,)(-\infty, \infty) can be solved analytically. This is what we will be exploring today.

The video starts by equating the integral to

((+ex2dx)2)12\left(\left(\int_{-\infty}^{+\infty} e^{-x^2}\,dx\right)^2\right)^\frac12

This allows us to rewrite the expression as an integral of two variables:

(+ex2dx+ey2dy)12\left(\int_{-\infty}^{+\infty} e^{-x^2}\,dx \int_{-\infty}^{+\infty} e^{-y^2}\,dy \right)^\frac12

+ex2\int_{-\infty}^{+\infty}e^{-x^2} converges, so we can treat this as a case of an integral multiplied by a constant with respect to yy. Thus, we have

(+(+ex2dx)ey2dy)12\left(\int_{-\infty}^{+\infty} \left(\int_{-\infty}^{+\infty}e^{-x^2}\,dx\right) e^{-y^2}\,dy \right)^\frac12

ey2e^{-y^2} does not vary with respect to xx, so we can move it into the inner integral, yielding

(++ex2ey2dxdy)12\left(\int_{-\infty}^{+\infty} \int_{-\infty}^{+\infty} e^{-x^2} e^{-y^2}\,dx\,dy\right)^\frac12

or just

(R2e(x2+y2)d(x,y))12\left(\iint_{\R^2} e^{-(x^2+y^2)} d(x,y)\right)^\frac12

That x2+y2x^2+y^2 tips us off that the next step will be to convert the integral to polar coordinates. To do so, we replace xx and yy with ρcosθ\rho\cos\theta and ρsinθ\rho\sin\theta, and our bounds of integration become ρ[0,)\rho \in [0, \infty) and θ[0,2π]\theta \in [0, 2\pi]

(R+×[0,2π]e((ρcosθ)2+(ρsinθ)2)d(x,y)d(ρ,θ)d(ρ,θ))12\left(\iint_{\R^+ \times [0,2\pi]} e^{-\left((\rho\cos\theta)^2 + (\rho\sin\theta)^2 \right)} \left|\frac{d(x,y)}{d(\rho,\theta)}\right| d(\rho, \theta) \right)^\frac12

Since we've changed the variables of integration, the differential is now given by the determinant of the Jacobian matrix.

(R+×[0,2π]e((ρcosθ)2+(ρsinθ)2)(ρx(ρ,θ)θx(ρ,θ)ρy(ρ,θ)θy(ρ,θ))d(ρ,θ))12\left(\iint_{\R^+ \times [0,2\pi]} e^{-\left((\rho\cos\theta)^2 + (\rho\sin\theta)^2 \right)} \left|\begin{pmatrix}\frac{\partial}{\partial\rho} x(\rho, \theta) & \frac{\partial}{\partial\theta} x(\rho, \theta) \\[0.7em] \frac{\partial}{\partial\rho} y(\rho, \theta) & \frac{\partial}{\partial\theta} y(\rho, \theta)\end{pmatrix}\right| d(\rho, \theta) \right)^\frac12

From here, we can do a number of things to simplify the expression:

This leaves us with

(002πeρ2(cosθρsinθsinθρcosθ)dθdρ)12\left(\int_0^\infty \int_0^{2\pi} e^{-\rho^2} \cdot \left|\begin{pmatrix}\cos\theta &-\rho\sin\theta \\ \sin\theta &\quad\rho\cos\theta\end{pmatrix}\right| \,d\theta \,d\rho\right)^\frac12

allowing us to evaluate the determinant:

(002πeρ2(ρcos2θ+ρsin2θ)dθdρ)12\left(\int_0^\infty \int_0^{2\pi} e^{-\rho^2} \cdot (\rho\cos^2\theta + \rho\sin^2\theta) \,d\theta \,d\rho\right)^\frac12

eρ2e^{-\rho^2} does not vary with respect to θ\theta, so we can move it to the outer integral, giving

(0eρ202πρ(cos2θ+sin2θ)dθdρ)12\left(\int_0^\infty e^{-\rho^2} \int_0^{2\pi} \rho\left(\cos^2\theta + \sin^2\theta\right) \,d\theta \,d\rho\right)^\frac12

or just

(0eρ202πρdθdρ)12\left(\int_0^\infty e^{-\rho^2} \int_0^{2\pi} \rho\,d\theta\,d\rho\right)^\frac12

Moving ρ\rho to the outer integral yields

(0ρeρ202πdθdρ)12\left(\int_0^\infty \rho e^{-\rho^2} \int_0^{2\pi} d\theta\,d\rho\right)^\frac12

Finally, we simplify the inner integral…

(0ρeρ22πdρ)12\left(\int_0^\infty \rho e^{-\rho^2} 2\pi \,d\rho\right)^\frac12

…and evaluate.

(2π0ρeρ2dρ)12=(2π(12)0(2ρ)eρ2dρ)12=(π[eρ2]0)12=(π[ee0])12=(π[01])12=(π)12=π \begin{align*} \left(2\pi \int_0^\infty \rho e^{-\rho^2} d\rho\right)^\frac12 &= \\ \left(2\pi \left(-\frac12\right) \int_0^\infty (-2\rho) e^{-\rho^2} d\rho\right)^\frac12 &= \\ \left(-\pi \left[e^{-\rho^2}\right]_0^\infty\right)^\frac12 &= \\ \left(-\pi [e^{-\infty} - e^0]\right)^\frac12 &= \\ \left(-\pi [0 - 1]\right)^\frac12 &= \\ \left(\pi\right)^\frac12 &= \\ \sqrt{\pi} \end{align*}