Hello I'm trying to evaluate $$\int_{-\pi}^{\pi} x^2\cos(nx)dx$$
I understand you have to apply integration by parts twice but I always get zero and I know this is wrong.
I always end up with $$-\int_{-\pi}^{\pi} \frac{2x\sin(nx)}{n} dx$$ which when integrated by parts again just gives me zero. Is there something I'm doing wrong?
Check your integration by parts again. You should get $$\int_\ x^2\cos(nx)dx = \frac{x^2\sin(nx)}{n}+\frac{2x\cos(nx)}{n^2}-\frac{2\sin(nx)}{n^3}$$