Multivariable calculus

Gradient of xy: Why It Is (y, x) and Not (x, y)

For f(x, y) = xy the gradient is (y, x). The components come out swapped: differentiating in x leaves the y factor behind, and differentiating in y leaves the x factor behind. At the point (2, 3) the gradient is (3, 2), not (2, 3).

f(x,y)=xyf(x,y) = xy
f(x,y)=y, x\nabla f(x,y) = \left\langle y,\ x \right\rangle
fx=y\frac{\partial f}{\partial x} = y
fy=x\frac{\partial f}{\partial y} = x

Freeze one variable and the other becomes a coefficient

Hold yy fixed. Then f=yxf = y \cdot x is a constant multiple of xx, and the derivative of a constant multiple of xx is that constant.

fx=x(yx)=y\frac{\partial f}{\partial x} = \frac{\partial}{\partial x}\left(y \cdot x\right) = y

Hold xx fixed instead. Now f=xyf = x \cdot y is a constant multiple of yy, and the same reasoning applies.

fy=y(xy)=x\frac{\partial f}{\partial y} = \frac{\partial}{\partial y}\left(x \cdot y\right) = x
f(x,y)=y, x\nabla f(x,y) = \left\langle y,\ x \right\rangle

So f(2,3)=3,2\nabla f(2,3) = \langle 3, 2\rangle. It is worth saying out loud: the xx-component is yy.

The mistake: copying the point instead of swapping

Two errors show up on almost every set of papers. The first is pattern matching, writing f=x,y\nabla f = \langle x, y\rangle because the components should surely go in variable order. They do go in variable order, but the entry in the xx slot is fx\frac{\partial f}{\partial x}, and that partial happens to equal yy.

The second is reaching for the product rule and differentiating both factors at once, producing fx=1y+x1=x+y\frac{\partial f}{\partial x} = 1 \cdot y + x \cdot 1 = x + y. The product rule applies only when both factors depend on the variable you are differentiating. Here yy does not depend on xx, so its derivative with respect to xx is zero and the second term never appears.

  • fx=y\frac{\partial f}{\partial x} = y, so the answer at a point uses the other coordinate.
  • f=x+y,x+y\nabla f = \langle x + y, x + y \rangle is the product-rule error, and you can spot it because the two components come out equal.
  • A quick sanity check: on the line y=5y = 5, f=5xf = 5x has slope 55 in the xx direction, matching fx=y=5\frac{\partial f}{\partial x} = y = 5.

Level curves, and a perpendicularity check

For each nonzero cc, setting xy=cxy = c gives a hyperbola with the coordinate axes as asymptotes, sitting in the first and third quadrants when c>0c > 0 and in the second and fourth when c<0c < 0. The level set c=0c = 0 is the degenerate case, the two axes themselves. The graph z=xyz = xy is a hyperbolic paraboloid, the standard saddle used in every Calc 3 course.

Take the point (2,3)(2,3), which sits on the level curve xy=6xy = 6. Differentiating xy=6xy = 6 implicitly gives y+xy=0y + x\,y' = 0, so y=y/x=3/2y' = -y/x = -3/2 and a tangent direction is 2,3\langle 2, -3\rangle. Dot it with the gradient:

3,22,3=66=0\langle 3, 2\rangle \cdot \langle 2, -3\rangle = 6 - 6 = 0

The gradient vanishes only at the origin, where f(0,0)=0,0\nabla f(0,0) = \langle 0,0\rangle. That is the saddle point at the centre of the surface, and it is not a maximum or a minimum: ff is positive in the first quadrant and negative in the second.

Frequently asked questions

Is the gradient of xy ever parallel to the position vector?

Yes, when y,x\langle y, x\rangle is a multiple of x,y\langle x, y\rangle, which needs y2=x2y^2 = x^2, so y=±xy = \pm x. On the line y=xy = x the gradient equals the position vector; on y=xy = -x it is the negative of it.

What is the directional derivative of xy at (2, 3) toward the origin?

The unit vector toward the origin is u=1132,3\mathbf{u} = \frac{1}{\sqrt{13}}\langle -2, -3\rangle. Then Duf=3,2u=6613=1213D_{\mathbf{u}}f = \langle 3, 2\rangle \cdot \mathbf{u} = \frac{-6 - 6}{\sqrt{13}} = \frac{-12}{\sqrt{13}}, so ff decreases in that direction.