Gaussian integral (source code)

= Gaussian integral
{c}
{title2=$\int_{-\infty}^{\infty}e^{-x^2}\,dx=\sqrt\pi$}
{wiki}

The <Gaussian integral> gives the exact area under a <Gaussian function>. For a positive <real number> $a$,
$$
\boxed{I(a)=\int_{-\infty}^{\infty}e^{-ax^2}\,dx=\sqrt{\frac\pi a}.}
$$
This is a finite <improper integral> over the whole <real line>. For example, $I(1)=\sqrt\pi\approx1.772454$ and $I(4)=\sqrt\pi/2\approx0.886227$. Increasing $a$ from one to four narrows the curve and halves its area, while its height at zero stays one. The <change of variables> $u=\sqrt a\,x$ explains the factor $a^{-1/2}$.

\Image[/gaussian-integral-width-and-area.png]
{title=Narrower Gaussian curves have less area unless their height is adjusted}
{description=Left: the full-line areas of $e^{-x^2}$ and $e^{-4x^2}$ are $\sqrt\pi$ and $\sqrt\pi/2$. Right: multiplication by $\sqrt{a/\pi}$ makes both areas one. Shading shows the plotted finite interval; the stated areas refer to the whole <real line>.}

The useful consequence is an exact normalization. For $a>0$ and any real center $\mu$,
$$
p_a(x)=\sqrt{\frac a\pi}\,e^{-a(x-\mu)^2},\qquad
\int_{\mathbb R}p_a(x)\,dx=1.
$$
This is a <probability density function> for a <normal distribution> with <expected value> $\mu$ and <variance> $1/(2a)$. A narrower <probability density function> must be taller to keep total <probability> one. In the usual notation $a=1/(2\sigma^2)$, the prefactor is $1/(\sigma\sqrt{2\pi})$, where $\sigma$ is the <standard deviation>.

The same area calculation makes the one-dimensional <heat kernel>
$$
K(x,t)=\frac1{\sqrt{4\pi Dt}}e^{-x^2/(4Dt)},\qquad D>0,\quad t>0,
$$
integrate to one in $x$, with $D$ the <diffusion coefficient>. A spreading <Gaussian function> can therefore preserve total mass while its height falls. This links the <Gaussian integral> with both the <normal distribution> and the <diffusion equation>.

Finite intervals lead to the <error function>, rather than this single constant:
$$
\operatorname{erf}(z)=\frac2{\sqrt\pi}\int_0^z e^{-u^2}\,du,\qquad
\int_{-R}^{R}e^{-ax^2}\,dx
=\sqrt{\frac\pi a}\operatorname{erf}(\sqrt a\,R),\quad R\ge0.
$$
The complementary tail is described by the <complementary error function>. These definitions and their real-axis limits are given in the NIST reference. <NIST Digital Library of Mathematical Functions/7.2 Definitions>[NIST Digital Library of Mathematical Functions, §7.2, equations 7.2.1–7.2.4]{ref}

The <polar-coordinate proof of the Gaussian integral> explains why $\pi$ appears in an integral of a function defined on a line: squaring its area creates a rotationally symmetric integral on a plane. Substitution $t=x^2$ also gives $\Gamma(1/2)=2\int_0^\infty e^{-x^2}\,dx=\sqrt\pi$, connecting the result with the <gamma function>.