I'm looking for a quick and elegant way to calculate the integral: $$\int x\sin ax \cos x\, dx$$
It's doable by using $$\cos x=\frac{e^{ix}+e^{-ix}}2, ~~\sin ax=\frac{e^{iax}-e^{-iax}}{2i},$$ and then integrating by parts, but I find that solution too long and brute-force. Can you solve it alternatively?
Edit: $$\sin ax\cos x=\frac{\sin (a+1)x+\sin (a-1)x}2$$ does the trick.
$$I(x;a,b):=-\int \cos ax\cos bx\,dx=-\frac{\sin((a+b)x)}{2(a+b)}-\frac{\sin((a-b)x)}{2(a-b)}$$
and
$$\int x\sin ax\cos x\,dx=\frac\partial{\partial a}I(x;a,1).$$