Solution:
Key idea: The function y is a sum of two variable powers, so we differentiate each term separately by logarithmic differentiation and then add.
Step 1 — Name the two terms.
Let u=xcosx and v=(cosx)sinx, taken where x>0 and cosx>0. Then y=u+v.
Step 2 — Differentiate u=xcosx.
Taking the natural logarithm brings the power cosx down.
logu=cosxlogx
By the product rule, the derivative of cosxlogx is cosx⋅x1+logx⋅(−sinx).
u1dxdu=xcosx−sinxlogx
dxdu=xcosx[xcosx−sinxlogx]
Step 3 — Differentiate v=(cosx)sinx.
Taking the natural logarithm brings the power sinx down.
logv=sinxlogcosx
By the product rule, the derivative is cosxlogcosx+sinx⋅cosx−sinx.
v1dxdv=cosxlogcosx−cosxsin2x
We write both terms over the common denominator cosx.
v1dxdv=cosxcos2xlogcosx−sin2x
dxdv=(cosx)sinx[cosxcos2xlogcosx−sin2x]
Step 4 — Add the two derivatives.
Since y=u+v, its derivative is the sum of the results of Steps 2 and 3.
dxdy=xcosx[xcosx−sinxlogx]+(cosx)sinx[cosxcos2xlogcosx−sin2x]
Watch out: The minus sign before sinxlogx comes from dxdcosx=−sinx; it is easy to drop.
Therefore, dxdy=xcosx[xcosx−sinxlogx]+(cosx)sinx[cosx−sin2x+cos2xlogcosx].