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)=exsinycoszf(x,y,z) = e^x \sin y \cos z
f=exsinycosz,  excosycosz,  exsinysinz\nabla f = \left\langle e^x \sin y \cos z,\; e^x \cos y \cos z,\; -e^x \sin y \sin z \right\rangle
fx=exsinycosz\frac{\partial f}{\partial x} = e^x \sin y \cos z
fy=excosycosz\frac{\partial f}{\partial y} = e^x \cos y \cos z
fz=exsinysinz\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.

fx=(ddxex)sinycosz=exsinycosz\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, fx=f\frac{\partial f}{\partial x} = f everywhere.

fy=excosycosz,fz=exsinysinz\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 ddzcosz=sinz\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 fz=exsinysinz\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 fy\frac{\partial f}{\partial y}, both exe^x and cosz\cos z are constants, so no extra terms appear.
  • Sign check: ddysiny=cosy\frac{d}{dy}\sin y = \cos y is positive in the formula, ddzcosz=sinz\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 cos0=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 sin0=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 sin2y+cos2y\sin^2 y + \cos^2 y pair collapses and you are left with a two term expression.

f2=e2x(cos2z+sin2ysin2z)\left| \nabla f \right|^2 = e^{2x}\left(\cos^2 z + \sin^2 y \sin^2 z\right)

Frequently asked questions

Why does fx\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 fx=f\frac{\partial f}{\partial x} = f at every point.

Where is the gradient zero?

Where siny=0\sin y = 0 and cosz=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 siny\sin y and cosy\cos y never vanish together, the middle component forces cosz=0\cos z = 0, and then the third component forces siny=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.