y=ex2y = e^{-x^2}

The Gaussian Function y=ex2y = e^{-x^2}

y=ex2y = e^{-x^2} substitutes u=x2u = -x^2 into the exponent of eue^u, tracing a symmetric bell curve. As the kernel of the normal distribution in statistics it is one of the most important functions there is, appearing throughout probability and statistics and on into physics and signal processing.

Domain and range

It is defined for every real xx. Since x20-x^2 \le 0 we have 0<ex210 < e^{-x^2} \le 1, so the range is (0,1](0, 1].

  • The domain is all real numbers
  • The range is (0,1](0, 1]
  • The maximum is 11, at x=0x = 0
  • There is no minimum; the lower bound 00 is never reached

The further xx moves from the origin the smaller the value, but the exponential takes only positive values, so it never becomes zero.

Symmetry

Since f(x)=e(x)2=ex2=f(x)f(-x) = e^{-(-x)^2} = e^{-x^2} = f(x), the function is even and its graph is symmetric about the yy-axis. It pairs with y=xex2y = xe^{-x^2}, which carries the same exponent and is odd, symmetric about the origin.

Monotonicity and extremum

The chain rule gives the derivative.

f(x)=ex2ddx(x2)=2xex2\begin{align*} f'(x) &= e^{-x^2} \cdot \frac{d}{dx}(-x^2) \\ &= -2x\,e^{-x^2} \end{align*}

Since ex2>0e^{-x^2} > 0 the sign is decided by 2x-2x alone: the function increases for x<0x < 0 and decreases for x>0x > 0. It therefore attains its maximum at the peak (0,1)(0, 1), and there is no local minimum.

Inflection points

The product rule gives the second derivative.

f(x)=(4x22)ex2f''(x) = (4x^2 - 2)\,e^{-x^2}

It vanishes at x=±12±0.707x = \pm \dfrac{1}{\sqrt{2}} \approx \pm 0.707, where the value is y=e1/20.607y = e^{-1/2} \approx 0.607. Those are the shoulders of the bell, where the curve turns from concave down to concave up.

How fast it decays

As x±x \to \pm\infty we have x2-x^2 \to -\infty and hence ex20e^{-x^2} \to 0, so the xx-axis, the line y=0y = 0, is a horizontal asymptote. Because the exponent carries a square, the decay is far faster than that of exe^{-x}.

xxy=ex2y = e^{-x^2}
0011
0.50.50.77880.7788
110.36790.3679
1.51.50.10540.1054
220.01830.0183
330.00012340.0001234

Full width at half maximum

A common measure of the spread of the bell is the width at which the value falls to half its maximum, the full width at half maximum. Solving ex2=12e^{-x^2} = \dfrac{1}{2} gives x=±ln2x = \pm\sqrt{\ln 2}, so the width is as follows.

2ln21.66512\sqrt{\ln 2} \approx 1.6651

The Gaussian integral

Although it has no elementary antiderivative, the integral over the whole line has a closed form1.

ex2dx=π\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi}

The standard proof squares it and moves the resulting double integral to polar coordinates.

I2=e(x2+y2)dxdy=02π0er2rdrdθ=2π12=π\begin{align*} I^2 &= \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} e^{-(x^2 + y^2)}\,dx\,dy \\ &= \int_0^{2\pi} \int_0^{\infty} e^{-r^2} r\,dr\,d\theta \\ &= 2\pi \cdot \frac{1}{2} = \pi \end{align*}

Since I>0I > 0 we get I=πI = \sqrt{\pi}. The version with a coefficient, eax2dx=πa\int_{-\infty}^{\infty} e^{-ax^2}\,dx = \sqrt{\dfrac{\pi}{a}} for a>0a > 0, follows the same way.

The antiderivative and the error function

The indefinite integral cannot be written with elementary functions, so the error function is defined as follows3.

erf(x)=2π0xet2dt\operatorname{erf}(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2}\,dt

With it the antiderivative takes this form.

ex2dx=π2erf(x)+C\int e^{-x^2}\,dx = \frac{\sqrt{\pi}}{2}\operatorname{erf}(x) + C

Relation to the normal distribution

The density of the standard normal distribution has the following form.

φ(t)=12πet2/2\varphi(t) = \frac{1}{\sqrt{2\pi}} e^{-t^2/2}

Putting t=2xt = \sqrt{2}\,x turns et2/2e^{-t^2/2} into ex2e^{-x^2}. The density is thus the Gaussian function stretched horizontally by a factor of 2\sqrt{2} and normalized so that the total area is 112.

QuantityGaussian functionStandard normal
Formulaex2e^{-x^2}12πet2/2\dfrac{1}{\sqrt{2\pi}}e^{-t^2/2}
Maximum1112π0.3989\dfrac{1}{\sqrt{2\pi}} \approx 0.3989
Position of the
inflection points
±12\pm\dfrac{1}{\sqrt{2}}±1\pm 1
Total areaπ\sqrt{\pi}11

Moments

Being even, all of its odd moments vanish. The even ones are given by a formula using the double factorial.

x2nex2dx=(2n1)!!2nπ\int_{-\infty}^{\infty} x^{2n} e^{-x^2}\,dx = \frac{(2n-1)!!}{2^n}\sqrt{\pi}
n=1n = 1π2\dfrac{\sqrt{\pi}}{2}
n=2n = 23π4\dfrac{3\sqrt{\pi}}{4}
n=3n = 315π8\dfrac{15\sqrt{\pi}}{8}

Fourier transform

The Fourier transform of a Gaussian is again a Gaussian.

ex2eikxdx=πek2/4\int_{-\infty}^{\infty} e^{-x^2} e^{-ikx}\,dx = \sqrt{\pi}\,e^{-k^2/4}

The narrower the original, the wider the transform. That trade-off recurs wherever width and spread cannot both be small at once, from the uncertainty principle of quantum mechanics to the window functions of signal processing.

The heat equation

The fundamental solution of the heat equation ut=uxxu_t = u_{xx} is a Gaussian as well.

u(x,t)=14πtex2/(4t)u(x, t) = \frac{1}{\sqrt{4\pi t}}\,e^{-x^2/(4t)}

As t0+t \to 0^{+} it concentrates at the origin, and as time passes it widens and flattens. Heat placed at a single point spreading out is exactly the widening of the bell.

Taylor expansion

Substituting u=x2u = -x^2 into the series for eue^{u} gives an expansion that converges for every real number.

ex2=n=0(1)nx2nn!e^{-x^2} = \sum_{n=0}^{\infty} \frac{(-1)^n x^{2n}}{n!}

That no odd powers appear is how evenness shows up on the side of the series.

Numerical computation

Since the antiderivative is not elementary, the area over a concrete interval is found by numerical integration. Computing the interval [0,3][0, 3] with the trapezoidal rule goes as follows.

function gaussian(x: number): number {
	return Math.exp(-x * x)
}

function trapezoid(from: number, to: number, count: number): number {
	const step = (to - from) / count

	let total = (gaussian(from) + gaussian(to)) / 2

	for (let index = 1; index < count; index++) {
		total += gaussian(from + index * step)
	}

	return total * step
}

The result is 0.88620.8862, matching π20.8862\dfrac{\sqrt{\pi}}{2} \approx 0.8862 almost exactly, because the contribution beyond x=3x = 3 is already negligible.

History

In Theoria Motus of 1809, Gauss derived the following form as the most probable distribution of observational error.

φ(Δ)=hπeh2Δ2\varphi(\Delta) = \frac{h}{\sqrt{\pi}}\,e^{-h^2\Delta^2}

De Moivre reached the curve as an approximation to the binomial distribution, and Gauss and Laplace established it as the distribution of error2. The view of it as the curve at the center of the theory of errors was settled from there.

Applications

  • The distribution of measurement error, that is the normal distribution
  • The fundamental solution of the heat equation
  • Blurring in image processing, the Gaussian filter
  • The RBF kernel in the kernel methods of machine learning
  • The ground state of the harmonic oscillator in quantum mechanics
  1. Gaussian integral, Wikipedia
  2. Normal distribution, Wikipedia
  3. Error Functions, Dawson's and Fresnel Integrals, NIST Digital Library of Mathematical Functions