Multivariable calculus

Gradient of the Gaussian Bump e^(-x^2-y^2)

For f(x, y) = e^(-x^2-y^2) the gradient is (-2x e^(-x^2-y^2), -2y e^(-x^2-y^2)), which is -2f times the position vector (x, y). It always points straight back toward the origin, where the bump peaks at height 1, and its length 2r e^(-r^2) is largest on the circle of radius 1 over root 2.

f(x,y)=ex2y2f(x,y) = e^{-x^{2}-y^{2}}
f=2ex2y2x,  y\nabla f = -2e^{-x^{2}-y^{2}}\left\langle x,\; y \right\rangle
fx=2xex2y2\frac{\partial f}{\partial x} = -2x\,e^{-x^{2}-y^{2}}
fy=2yex2y2\frac{\partial f}{\partial y} = -2y\,e^{-x^{2}-y^{2}}

Chain rule on the exponent

Let u=x2y2u = -x^{2}-y^{2}, so f=euf = e^{u}. The exponential is its own derivative, so each partial is eue^{u} times the matching partial of the exponent.

ux=2xfx=2xex2y2\frac{\partial u}{\partial x} = -2x \quad\Longrightarrow\quad \frac{\partial f}{\partial x} = -2x\,e^{-x^{2}-y^{2}}
uy=2yfy=2yex2y2\frac{\partial u}{\partial y} = -2y \quad\Longrightarrow\quad \frac{\partial f}{\partial y} = -2y\,e^{-x^{2}-y^{2}}

Notice that ex2y2e^{-x^{2}-y^{2}} is just ff again, so the whole gradient can be written as f=2fx,y\nabla f = -2f\left\langle x, y\right\rangle. Since f>0f > 0 everywhere, the sign of the gradient is entirely decided by the minus two.

Every arrow points home

The vector x,y\left\langle x, y\right\rangle points away from the origin, so 2fx,y-2f\left\langle x, y\right\rangle points toward it. The gradient gives the direction of fastest increase, and on a bump centred at the origin the fastest way up is always straight toward the summit. The picture and the algebra agree.

With r2=x2+y2r^{2} = x^{2}+y^{2}, the length of the gradient is a function of the radius alone.

f=2rer2\left|\nabla f\right| = 2r\,e^{-r^{2}}

That length is zero at the peak, grows outward, then collapses again. Setting its derivative 2er2(12r2)2e^{-r^{2}}(1 - 2r^{2}) to zero gives r=120.7071r = \frac{1}{\sqrt{2}} \approx 0.7071, where the slope is steepest at 2e1/20.8578\sqrt{2}\,e^{-1/2} \approx 0.8578. That circle is the visible rim of the bump.

Sample it at (1,0)(1, 0), where the gradient must point along the negative xx axis.

f(1,0)=2e,  00.7358,  0\nabla f(1,0) = \left\langle -\frac{2}{e},\; 0 \right\rangle \approx \left\langle -0.7358,\; 0 \right\rangle

The mistake: sign slips and a phantom product rule

Three wrong answers show up repeatedly, and each has a quick tell.

  • 2xex2y2,2yex2y2\left\langle 2x e^{-x^{2}-y^{2}}, 2y e^{-x^{2}-y^{2}}\right\rangle, with the minus sign lost. This claims the fastest way up is away from the peak, which is backwards.
  • 2xex2,2yey2\left\langle -2x e^{-x^{2}}, -2y e^{-y^{2}}\right\rangle, splitting the exponential. The exponent is a single sum, and ex2y2=ex2ey2e^{-x^{2}-y^{2}} = e^{-x^{2}}e^{-y^{2}} keeps both factors in both components.
  • Applying the product rule to 2x-2x and ex2y2e^{-x^{2}-y^{2}} while computing the first partial. That is second-derivative work; the first partial has no product to differentiate yet.

Fastest audit: at the origin the gradient must be 0,0\left\langle 0, 0 \right\rangle, because (0,0)(0,0) is the maximum. Every version above passes that. So test at (1,0)(1,0) instead, where the correct xx component is negative and the sign-slip version is positive.

Frequently asked questions

Where is ex2y2e^{-x^{2}-y^{2}} steepest?

On the circle x2+y2=12x^{2}+y^{2} = \frac{1}{2}, that is radius 120.7071\frac{1}{\sqrt{2}} \approx 0.7071. There the gradient has length 2e1/20.8578\sqrt{2}\,e^{-1/2} \approx 0.8578. Inside that circle the surface is flattening toward the peak, and outside it is flattening toward zero.

Why is the gradient parallel to the position vector?

Because ff depends only on r2=x2+y2r^{2} = x^{2}+y^{2}. Any radially symmetric function has circles as level curves, and the gradient must be perpendicular to those circles, which leaves only the radial direction x,y\left\langle x, y\right\rangle available, up to sign.