← All posts

The Gaussian integral, in one line of polar coordinates

This post shows how articles look: serif body text for long reading, inline formulas such as e−x2e^{-x^2}, and display equations that sit on their own line. Everything is ordinary LaTeX inside a Markdown file.

We want the value of

I=∫−∞∞e−x2 dx. I = \int_{-\infty}^{\infty} e^{-x^2}\,dx.

The function has no elementary antiderivative, so the usual trick is to square the integral and treat it as a double integral over the plane:

I2=∫−∞∞ ⁣∫−∞∞e−(x2+y2) dx dy. I^2 = \int_{-\infty}^{\infty}\!\int_{-\infty}^{\infty} e^{-(x^2+y^2)}\,dx\,dy.

Switching to polar coordinates

With x=rcos⁡θx = r\cos\theta, y=rsin⁡θy = r\sin\theta and dx dy=r dr dθdx\,dy = r\,dr\,d\theta, the integrand only depends on rr:

I2=∫02π ⁣∫0∞e−r2 r dr dθ=2π⋅12=π. I^2 = \int_{0}^{2\pi}\!\int_{0}^{\infty} e^{-r^2}\, r\,dr\,d\theta = 2\pi \cdot \tfrac{1}{2} = \pi.

So I=πI = \sqrt{\pi}. Code blocks look like this:

import numpy as np
from scipy.integrate import quad

val, err = quad(lambda x: np.exp(-x**2), -np.inf, np.inf)
print(val, np.sqrt(np.pi))  # 1.7724538509 1.7724538509

Quotes and asides get a quiet left rule in the accent color.

Aligned equations work too:

∇⋅E=ρε0∇×B=μ0J+μ0ε0∂E∂t \begin{aligned} \nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \\ \nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0 \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \end{aligned}

Footnotes are supported as well.1


  1. Formulas are rendered once at build time, so pages stay fast and work without JavaScript. ↩︎