Multivariable calculus
Gradient of e^x cos(y): Components and Magnitude
For f(x, y) = e^x cos(y) the gradient is the vector (e^x cos y, -e^x sin y). Each partial treats the other variable as a constant, so the x partial reproduces the function and the y partial picks up the minus sign from the derivative of cosine. The length of this gradient is e^x at every point.
A product where each factor owns one variable
No chain rule and no product rule are needed here. The factor contains no , so for it is just a constant multiplier sitting in front of .
Swap roles for the other component. Now is the constant and is live, and the derivative of cosine carries a minus sign.
The partial coming back as itself is not a coincidence to be suspicious of. Differentiating returns , and the factor never moved.
The length is e^x, and the direction spins with y
Factor out of the gradient and the Pythagorean identity finishes the magnitude.
So the steepness of this surface depends only on . Move along a vertical line and the surface rises and falls, yet the maximum rate of change never changes size; only the direction of steepest ascent rotates, tracing the unit vector as increases.
The gradient is never the zero vector, since and and never vanish at the same . This surface has no critical points at all.
One more property worth carrying forward: the second partials cancel, , so is harmonic. It is the real part of in complex variables, which is where this example usually reappears.
The mistake: losing the minus sign, or chain-ruling the exponential
Two errors dominate on this page.
- Writing without the minus. Then the gradient points the wrong way in the direction, and the linear approximation predicts the surface rising where it actually falls.
- Writing , as if the exponential needed a chain rule in . Its exponent is alone, so with respect to it is a frozen constant.
Check at : . The surface at that point is level in the direction, which matches having a maximum at . A wrong sign would not show up here, so test at as well, where and is clearly decreasing in .
Frequently asked questions
Why does the magnitude of the gradient not depend on ?
Because the two components are and , and squaring and adding them gives . The dependence sits entirely in the direction of the vector, not its length.
Does have any maximum or minimum?
No. A local extremum needs , and that would force and at the same , which is impossible. On any closed bounded region the extreme values are therefore on the boundary.