The product rule is d(uv)/dx, where u and v are functions of x, =u.dv/dx+v.du/dx. For example, if you need to differentiate xsinx, let u=x, so du/dx=1; and let v=sinx, so dv/dx=cosx. Therefore d(xsinx)/dx=xcosx+sinx. If you have an expression that can be factorised, such as x^2+xsinx-xcosx-sinxcosx=(x+sinx)(x-cosx), then you can put u=x+sinx and v=x-cosx, so du/dx=1+cosx and dv/dx=1+sinx. The differential becomes (x+sinx)(1+sinx)+(x-cosx)(1+cosx)=x+xsinx+sinx+sin^2x+x+xcosx-cosx-cos^2x=2x+x(sinx+cosx)+sinx-cosx+sin^2x-cos^2x=2x+x(sinx+cosx)+(sinx-cosx)(1+sinx+cosx).