How to integrate $\int(x\pi-x^2)\cos(kx)dx$ My question is can I solve by integrating by parts if I do $u = (x\pi-x^2)$,or first I have to do $∫[x\pi \cos(kx)-x^2\cos(kx)]dx$ and then split it in two integrals $\int x\pi\cos(kx)dx-\int x^2\cos(kx)dx$ ?

$\textbf{Another way:}$
$$
\pi\frac{d}{dk}\int \sin k x dx + \frac{d^2}{dk^2}\int \cos k x dx = \int \left(\pi x-x^2\right)\cos kx dx
$$
