Multivariable calculus

Gradient of x^2 + y^2: Vector, Steps, and Geometry

For f(x, y) = x^2 + y^2 the gradient is the vector with components 2x and 2y, written grad f = (2x, 2y). At the point (3, 4) it equals (6, 8), a vector of length 10 pointing directly away from the origin. That is the compass direction in which this paraboloid climbs fastest.

f(x,y)=x2+y2f(x,y) = x^2 + y^2
f(x,y)=2x, 2y\nabla f(x,y) = \left\langle 2x,\ 2y \right\rangle
fx=2x\frac{\partial f}{\partial x} = 2x
fy=2y\frac{\partial f}{\partial y} = 2y

Differentiate once per variable, then stack the results

The gradient is not a new kind of derivative. It is the partial derivatives you already know, collected into one vector. Compute fx\frac{\partial f}{\partial x} with yy frozen, then fy\frac{\partial f}{\partial y} with xx frozen.

fx=x(x2+y2)=2x+0=2x\frac{\partial f}{\partial x} = \frac{\partial}{\partial x}\left(x^2 + y^2\right) = 2x + 0 = 2x

The y2y^2 term contributes nothing, because with yy held fixed it is just a number, and the derivative of a number is zero. Swapping roles gives the other component.

fy=y(x2+y2)=0+2y=2y\frac{\partial f}{\partial y} = \frac{\partial}{\partial y}\left(x^2 + y^2\right) = 0 + 2y = 2y

Now list them in variable order, xx first and yy second. That order is a convention, but it is the one every later formula assumes.

f(x,y)=2x, 2y\nabla f(x,y) = \left\langle 2x,\ 2y \right\rangle

At (3,4)(3,4) this evaluates to f(3,4)=6,8\nabla f(3,4) = \langle 6, 8\rangle, which has length 62+82=10\sqrt{6^2 + 8^2} = 10.

The mistake: giving the gradient a third component

The graph of ff is a paraboloid sitting in three dimensions, so students often write the gradient as a three-component vector, something like 2x,2y,1\langle 2x, 2y, -1\rangle, and try to make it point up the hillside in space.

The gradient of a function of two variables has exactly two components, one per input variable. It lives in the xyxy-plane, the floor plan, not on the surface. Read it as a set of walking directions: stand at (3,4)(3,4) on the floor and head in the direction 6,8\langle 6,8\rangle, and the surface above you rises as fast as it possibly can.

  • Number of components equals number of input variables, so two here.
  • f\nabla f is a vector, never a scalar. Writing f=2x+2y\nabla f = 2x + 2y loses the direction.
  • The vector 2x,2y,1\langle 2x, 2y, -1\rangle is a normal to the surface z=f(x,y)z = f(x,y), which is a different object with a different job.

What the vector says about this paraboloid

Notice that 2x,2y=2x,y\langle 2x, 2y\rangle = 2\langle x, y\rangle, so the gradient at any point is a positive multiple of the position vector. It points radially outward from the origin, and it gets longer the further out you go.

That matches the level curves. Setting f=cf = c gives x2+y2=cx^2 + y^2 = c, a circle of radius c\sqrt{c}, and a radial vector is perpendicular to every circle centred at the origin. The gradient is always perpendicular to the level curve through the point.

The magnitude carries the steepness. Walking from (3,4)(3,4) in the unit direction u=35,45\mathbf{u} = \left\langle \tfrac{3}{5}, \tfrac{4}{5}\right\rangle gives the directional derivative

Duf(3,4)=6,835,45=185+325=10=f(3,4)D_{\mathbf{u}}f(3,4) = \langle 6, 8\rangle \cdot \left\langle \tfrac{3}{5}, \tfrac{4}{5}\right\rangle = \tfrac{18}{5} + \tfrac{32}{5} = 10 = \left|\nabla f(3,4)\right|

No other unit direction beats 1010, which is exactly what it means for the gradient to point along steepest ascent.

Frequently asked questions

Where is the gradient of x^2 + y^2 the zero vector?

Only at the origin. Setting 2x=02x = 0 and 2y=02y = 0 forces x=0x = 0 and y=0y = 0. That single critical point is the bottom of the bowl, the global minimum with f(0,0)=0f(0,0) = 0.

Why does a surface in three dimensions have a two-component gradient?

Because ff takes two inputs. The gradient answers the question of which way to move in the input plane, and the input plane is two dimensional. The height is the output, not an input, so it gets no component of its own.