Multivariable calculus
Gradient of x cos(y) + y sin(x), Term by Term
For f(x, y) = x cos(y) + y sin(x) the gradient is (cos y + y cos x, sin x - x sin y). Differentiate one term at a time: in the x partial, cos y is a constant multiplier on x and y is a constant multiplier on sin x. The y partial follows the same rule with the roles reversed.
Two terms, four small derivatives
Split the function and handle each term on its own. For , the term has as a frozen multiplier, and the term has as a frozen multiplier.
Now hold fixed. The term has frozen and live, which produces the minus sign, and the term has frozen.
Every term of is a product of a bare variable and a trig function of the other variable, so no product rule is ever needed. Whichever variable you differentiate, one factor is a constant.
Checking the answer at a point
The origin is the cheapest test point, because sines vanish and cosines are .
That is right: near the origin , since and is second order. A function that behaves like has gradient .
Try a point where all four pieces are active, say .
Both components collapse neatly there because and are zero. Points like that are worth hunting for when you want a quick sanity check with no decimals.
The mistake: leaking a term into the wrong component
The wrong answers here are almost always cross contamination: a piece that belongs to appears in . The classic is , where the first term was differentiated with respect to the wrong variable.
Unlike a symmetric function, this one gives you no shortcut check. Swapping and turns into , a different function, so the two components are genuinely not mirror images and you cannot verify one from the other.
- In , every trig function of must survive untouched. Seeing where the original had means a derivative was taken by accident.
- In , every trig function of must survive untouched. Seeing there is the same error mirrored.
- The minus sign belongs to the component only, since only gets differentiated anywhere.
Frequently asked questions
Why does contain but no ?
Because is a constant as far as is concerned. Differentiating with respect to can never turn a cosine of into a sine of , so any appearing in the component is a sign that a derivative was taken by mistake.
Do the mixed second partials agree for this function?
Yes, as Clairaut's theorem guarantees for a function this smooth. Differentiating with respect to gives , and differentiating with respect to gives . Same expression.