elbluffz1

2022-01-25

How is the integral $\frac{2}{\pi }{\int }_{0}^{\pi }{x}^{2}\mathrm{cos}\left(nx\right)dx=\frac{4{\left(-1\right)}^{n}}{{n}^{2}}$?
I thought it would be this :
$\frac{2}{\pi }{\int }_{0}^{\pi }{x}^{2}\mathrm{cos}\left(nx\right)dx=\frac{2}{\pi }{\int }_{0}^{\pi }{x}^{2}{\left(-1\right)}^{n}=\frac{2}{\pi }{\left(-1\right)}^{n}{\int }_{0}^{\pi }{x}^{2}=\frac{2}{\pi {\left(-1\right)}^{n}}{\left[\frac{{x}^{3}}{3}\right]}_{0}^{\pi }=\frac{2{\left(-1\right)}^{n}}{3{\pi }^{3}}$
But it is actually
$\frac{2}{\pi }{\int }_{0}^{\pi }{x}^{2}\mathrm{cos}\left(nx\right)dx=\frac{4{\left(-1\right)}^{n}}{{n}^{2}}$

Georgia Ingram

You cannot say that $\mathrm{cos}nx={\left(-1\right)}^{n}$. This is valid for $x=\pi$. A counterexample would be $\mathrm{cos}n\cdot 0=1$, and this doesnt

Eliza Norris

Hint: Two times integrating by parts we get
${\int }_{0}^{\pi }{x}^{2}\mathrm{cos}\left(nx\right)dx=\frac{{\pi }^{2}\mathrm{sin}\left(\pi n\right){n}^{2}+2n\mathrm{cos}\left(\pi n\right)\pi -2\mathrm{sin}\left(\pi n\right)}{{n}^{3}}$

Do you have a similar question?