Multivariable calculus

Gradient of sin(xy): Components and Geometry

For f(x, y) = sin(xy) the gradient is the vector (y cos(xy), x cos(xy)). Differentiate the sine to get cos(xy), then multiply by the derivative of the inside, xy, which is y when x is the live variable and x when y is. The gradient is cos(xy) times the vector (y, x).

f(x,y)=sin(xy)f(x,y) = \sin(xy)
f=ycos(xy),  xcos(xy)\nabla f = \left\langle y\cos(xy),\; x\cos(xy) \right\rangle
fx=ycos(xy)\frac{\partial f}{\partial x} = y\cos(xy)
fy=xcos(xy)\frac{\partial f}{\partial y} = x\cos(xy)

Outer derivative first, then the inner one

Set u=xyu = xy, so f=sinuf = \sin u. The chain rule for a partial derivative reads fx=cosuux\frac{\partial f}{\partial x} = \cos u \cdot \frac{\partial u}{\partial x}, and the only thing that changes between the two components is that inner derivative.

xsin(xy)=cos(xy)x(xy)=ycos(xy)\frac{\partial}{\partial x}\sin(xy) = \cos(xy)\cdot \frac{\partial}{\partial x}(xy) = y\cos(xy)
ysin(xy)=cos(xy)y(xy)=xcos(xy)\frac{\partial}{\partial y}\sin(xy) = \cos(xy)\cdot \frac{\partial}{\partial y}(xy) = x\cos(xy)

Stack the two into a vector and factor out what they share.

f=cos(xy)y,  x\nabla f = \cos(xy)\,\left\langle y,\; x \right\rangle

The function is symmetric in xx and yy, so the two components must be each other with the letters swapped. They are, which is a free correctness check.

Reading the vector: hyperbolic level curves and flat ridges

Every level set sin(xy)=c\sin(xy) = c breaks into curves xy=constantxy = \text{constant}, each one a hyperbola. Since f\nabla f is cos(xy)\cos(xy) times y,x\left\langle y, x\right\rangle, and y,x\left\langle y, x\right\rangle is the gradient of xyxy, the gradient of ff is always normal to those hyperbolas. The factor cos(xy)\cos(xy) only decides how long the vector is and which way along the normal it points.

At (1,π)(1, \pi) the inside is xy=πxy = \pi, and cos(π)=1\cos(\pi) = -1.

f(1,π)=1π,  1=π,  1\nabla f(1,\pi) = -1\cdot\left\langle \pi,\; 1 \right\rangle = \left\langle -\pi,\; -1 \right\rangle

The gradient vanishes in two situations, and it is worth knowing both:

  • On the curves xy=π2+kπxy = \frac{\pi}{2} + k\pi, where cos(xy)=0\cos(xy) = 0. These are the crests and troughs of the surface, where f=±1f = \pm 1, and the gradient is zero along an entire hyperbola rather than at isolated points.
  • At the origin, where y,x=0,0\left\langle y, x\right\rangle = \left\langle 0, 0\right\rangle even though cos(0)=1\cos(0) = 1.

The mistake: leaving the inner derivative behind

The common wrong answer is f=cos(xy),cos(xy)\nabla f = \left\langle \cos(xy), \cos(xy) \right\rangle. It comes from differentiating the sine and stopping there, as if xyxy were a single letter.

A point test exposes it instantly. At (1,π)(1,\pi) the true xx component is π3.1416-\pi \approx -3.1416, while the wrong version gives 1-1. That is a factor of π\pi, not a rounding difference.

The structural warning sign is that the wrong gradient has two identical components. If ff genuinely had matching partials, the surface would climb equally fast in both directions everywhere, which no surface built from the product xyxy does.

Frequently asked questions

Where is the gradient of sin(xy)\sin(xy) the zero vector?

At the origin, and along every hyperbola xy=π2+kπxy = \frac{\pi}{2} + k\pi. On those hyperbolas cos(xy)=0\cos(xy) = 0, so both components die at once and the surface has a flat ridge or trough running along the whole curve.

Is the gradient perpendicular to the level curves here?

Yes, as it is for any differentiable function. You can see it directly: the level curves are xy=constantxy = \text{constant}, whose normal direction is y,x\left\langle y, x\right\rangle, and f=cos(xy)y,x\nabla f = \cos(xy)\left\langle y, x\right\rangle is a scalar multiple of exactly that.