I really hate integration by parts, so when faced with $\int_{-\pi}^\pi x^2 \cos n x \, dx$ I tried writing it as \int_{-\pi}^\pi x^2 \cos n x \, dx =
\frac{d}{dn} \int_{-\pi}^\pi x \sin n x \, dx = \frac{d^2}{dn^2} \int_{-\pi}^\pi \cos n x \, dx 1
I have done something wrong. The integrand is continuously differentiable with respect to n and I thought that was enough. How can I get differentiating under the integral sign to work?