Multivariable calculus

Gradient of e^x sin(y) cos(z): Separable Product

For f(x, y, z) = e^x sin(y) cos(z) the gradient is (e^x sin(y) cos(z), e^x cos(y) cos(z), -e^x sin(y) sin(z)). Each component differentiates exactly one factor and copies the other two. The x component equals the function itself. At (0, pi/2, 0) the gradient is (1, 0, 0).

f(x,y,z)=exsin⁡ycos⁡zf(x,y,z) = e^x \sin y \cos z
∇f=⟨exsin⁡ycos⁡z,  excos⁡ycos⁡z,  −exsin⁡ysin⁡z⟩\nabla f = \left\langle e^x \sin y \cos z,\; e^x \cos y \cos z,\; -e^x \sin y \sin z \right\rangle
∂f∂x=exsin⁡ycos⁡z\frac{\partial f}{\partial x} = e^x \sin y \cos z
∂f∂y=excos⁡ycos⁡z\frac{\partial f}{\partial y} = e^x \cos y \cos z
∂f∂z=−exsin⁡ysin⁡z\frac{\partial f}{\partial z} = -e^x \sin y \sin z

A separable product: change one factor, copy the rest

This function is a product of three pieces, each depending on a single variable. That structure makes the gradient easy: in each component, differentiate the factor that owns that variable and leave the other two exactly as they are.

∂f∂x=(ddxex)sin⁡ycos⁡z=exsin⁡ycos⁡z\frac{\partial f}{\partial x} = \left(\frac{d}{dx}e^x\right)\sin y \cos z = e^x \sin y \cos z

Since ddxex=ex\frac{d}{dx}e^x = e^x, the xx component is the original function again. That is a useful check: for this ff, ∂f∂x=f\frac{\partial f}{\partial x} = f everywhere.

∂f∂y=excos⁡ycos⁡z,∂f∂z=−exsin⁡ysin⁡z\frac{\partial f}{\partial y} = e^x \cos y \cos z, \qquad \frac{\partial f}{\partial z} = -e^x \sin y \sin z

Only the zz component picks up a sign, because ddzcos⁡z=−sin⁡z\frac{d}{dz}\cos z = -\sin z.

The mistake: the lost minus sign, and the phantom product rule

Two errors dominate here. The first is writing ∂f∂z=exsin⁡ysin⁡z\frac{\partial f}{\partial z} = e^x \sin y \sin z without the minus. That single sign flips the direction of steepest ascent, so an otherwise perfect answer points the wrong way.

The second is applying the product rule across all three factors, producing a sum of three terms in every component. The product rule is only needed when more than one factor depends on the variable you are differentiating. Here exactly one does, so the other two are constants and their derivatives are zero.

  • In ∂f∂y\frac{\partial f}{\partial y}, both exe^x and cos⁡z\cos z are constants, so no extra terms appear.
  • Sign check: ddysin⁡y=cos⁡y\frac{d}{dy}\sin y = \cos y is positive in the formula, ddzcos⁡z=−sin⁡z\frac{d}{dz}\cos z = -\sin z is negative.
  • If a component of your gradient has three added terms, you have used the product rule where it was not needed.

Reading the gradient at a point

Take (0,π2,0)(0, \frac{\pi}{2}, 0), where e0=1e^0 = 1, sin⁡π2=1\sin\frac{\pi}{2} = 1 and cos⁡0=1\cos 0 = 1, so f=1f = 1. This is a maximum of the trigonometric part.

∇f(0,π2,0)=⟨1,  0,  0⟩\nabla f\left(0, \tfrac{\pi}{2}, 0\right) = \left\langle 1,\; 0,\; 0 \right\rangle

The yy and zz components are zero because cos⁡π2=0\cos\frac{\pi}{2} = 0 and sin⁡0=0\sin 0 = 0: the trigonometric factors are each sitting at a peak, so a small move in yy or zz barely changes ff. Only growth in xx still pays, at rate 1.

The magnitude has a tidy closed form. Squaring and adding, the sin⁡2y+cos⁡2y\sin^2 y + \cos^2 y pair collapses and you are left with a two term expression.

∣∇f∣2=e2x(cos⁡2z+sin⁡2ysin⁡2z)\left| \nabla f \right|^2 = e^{2x}\left(\cos^2 z + \sin^2 y \sin^2 z\right)

Frequently asked questions

Why does ∂f∂x\frac{\partial f}{\partial x} equal ff itself?

Because the only xx dependence is the factor exe^x, which is its own derivative. Differentiating it reproduces the same product, so this function satisfies ∂f∂x=f\frac{\partial f}{\partial x} = f at every point.

Where is the gradient zero?

Where sin⁡y=0\sin y = 0 and cos⁡z=0\cos z = 0 at the same time, that is y=kπy = k\pi and z=π2+mπz = \frac{\pi}{2} + m\pi. Since exe^x is never zero and sin⁡y\sin y and cos⁡y\cos y never vanish together, the middle component forces cos⁡z=0\cos z = 0, and then the third component forces sin⁡y=0\sin y = 0. The critical set is a grid of lines parallel to the xx-axis, and f=0f = 0 on all of them.