Apply the product rule:
; to find :
The derivative of a constant times a function is the constant times the derivative of the function.
Apply the power rule: goes to
So, the result is:
; to find :
The derivative of sine is cosine:
The result is:
Now simplify:
The answer is:
-a*sin(x) - a*x*cos(x)
a*(-2*cos(x) + x*sin(x))