Multivariable calculus

Partial Derivatives of cos(x^2 + y^2)

For f(x, y) = cos(x squared plus y squared), the partial derivative with respect to x is negative 2x sin(x squared plus y squared), and the partial derivative with respect to y is negative 2y sin(x squared plus y squared). The chain rule contributes the minus sign from cosine and the factor 2x or 2y from the inside.

f(x,y)=cos(x2+y2)f(x,y) = \cos(x^2 + y^2)
fx=2xsin(x2+y2)\frac{\partial f}{\partial x} = -2x\sin(x^2 + y^2)
fy=2ysin(x2+y2)\frac{\partial f}{\partial y} = -2y\sin(x^2 + y^2)

Chain rule with a two variable inside

Set u=x2+y2u = x^2 + y^2. The outside derivative is dducosu=sinu\frac{d}{du}\cos u = -\sin u, and it is the same for both partials. Only the inside derivative changes.

ux=2x,uy=2y\frac{\partial u}{\partial x} = 2x, \qquad \frac{\partial u}{\partial y} = 2y

Multiply the two pieces together for each variable.

fx=2xsin(x2+y2),fy=2ysin(x2+y2)\frac{\partial f}{\partial x} = -2x\sin(x^2 + y^2), \qquad \frac{\partial f}{\partial y} = -2y\sin(x^2 + y^2)

At (1,1)(1,1) the inside is 22, so both partials equal 2sin21.819-2\sin 2 \approx -1.819. Equal partials are no accident here: the point sits on the diagonal, and the surface is rotationally symmetric.

The mistake: losing the inside derivative or the sign

Two errors dominate. The first is writing sin(x2+y2)-\sin(x^2 + y^2) with no factor of 2x2x, which forgets that the inside is not simply xx. The second is writing 2xsin(x2+y2)2x\sin(x^2+y^2) with the sign of the cosine derivative dropped.

  • Test the sign at x=0.5x = 0.5, y=0y = 0: the inside is 0.250.25, sin(0.25)>0\sin(0.25) > 0, so fx=1sin(0.25)<0\frac{\partial f}{\partial x} = -1\cdot\sin(0.25) < 0. The ripple is heading downhill away from the central crest, which matches.
  • Test the missing factor along the yy axis: at x=0x = 0 the function is even in xx, so fx\frac{\partial f}{\partial x} must be zero, and only the version carrying 2x2x gives that.

The gradient lies along the radius

Collect the two partials into one vector.

f=2sin(x2+y2)(x,y)\nabla f = -2\sin(x^2+y^2)\,(x, y)

The gradient is always a scalar multiple of the position vector (x,y)(x,y), so it is radial. The sign of that multiple flips with the sine: the gradient points straight out from the origin where sin(x2+y2)<0\sin(x^2+y^2) < 0 and straight back in where the sine is positive. That is the analytic version of the statement that the level curves are circles x2+y2=cx^2 + y^2 = c, and the gradient is perpendicular to them.

One consequence is worth memorising as a check: yfxxfy=0y\frac{\partial f}{\partial x} - x\frac{\partial f}{\partial y} = 0 everywhere, because both partials share the same sine factor and differ only by xx against yy. Any function of x2+y2x^2 + y^2 alone satisfies that identity.

Frequently asked questions

Why do the ripples get steeper as you move outward?

The magnitude of the gradient is 2x2+y2sin(x2+y2)2\sqrt{x^2+y^2}\,\lvert\sin(x^2+y^2)\rvert. The factor 2x2+y22\sqrt{x^2+y^2} grows with distance, so each successive ring is squeezed into a narrower band and the slopes rise.

Where is the surface flat?

Both partials vanish when x=y=0x = y = 0 or when sin(x2+y2)=0\sin(x^2+y^2) = 0, that is on the circles x2+y2=kπx^2 + y^2 = k\pi for positive integers kk. Those circles are the crests and troughs of the ripple.