# Integral-03

#### Albert

##### Well-known member
evaluate :

$\int_{0}^{2\pi}x^2 cos(nx)\, dx$

#### MarkFL

Staff member
Re: integral-03

We are given to evaluate:

$$\displaystyle I=\int_0^{2\pi}x^2\cos(nx)\,dx$$ where (presumably) $$\displaystyle n\in\mathbb{N}$$

Using integration by parts, we may let:

$$\displaystyle u=x^2\,\therefore\,du=2x\,dx$$

$$\displaystyle dv=\cos(nx)\,dx\,\therefore\,v=\frac{1}{n}\sin(nx)$$

And we have:

$$\displaystyle I=\left.\frac{x^2}{n}\sin(nx) \right|_0^{2\pi}-\frac{2}{n}\int_0^{2\pi} x\sin(nx)\,dx$$

$$\displaystyle I=-\frac{2}{n}\int_0^{2\pi} x\sin(nx)\,dx$$

Using integration by parts again, where:

$$\displaystyle u=x\,\therefore\,du=dx$$

$$\displaystyle dv=\sin(x)\,dx\,\therefore\,v=-\frac{1}{n}\cos(nx)$$

Now we have:

$$\displaystyle I=\frac{2}{n}\left(\left.\frac{x}{n}\cos(nx) \right|_0^{2\pi}+\frac{1}{n}\int_0^{2\pi}\cos(nx)\,dx \right)$$

$$\displaystyle I=\frac{2}{n}\left(\frac{2\pi}{n}+\left.\frac{1}{n^2}\sin(nx) \right|_0^{2\pi} \right)$$

$$\displaystyle I=\frac{4\pi}{n^2}$$

Thus, we may state:

$$\displaystyle \int_0^{2\pi}x^2\cos(nx)\,dx=\frac{4\pi}{n^2}$$

#### Albert

##### Well-known member
Re: integral-03

perfect you got it

#### MarkFL

Staff member
Re: integral-03

Let's generalize a little...

We are given to evaluate:

$$\displaystyle I=\int_0^{2\pi}x^2\cos\left(nx+m\frac{\pi}{2} \right)\,dx$$ where (presumably) $$\displaystyle n\in\mathbb{N},\,m\in\{0,1,2,3\}$$

Using integration by parts, we may let:

$$\displaystyle u=x^2\,\therefore\,du=2x\,dx$$

$$\displaystyle dv=\cos\left(nx+m\frac{\pi}{2} \right)\,dx\,\therefore\,v=\frac{1}{n}\sin\left(nx+m\frac{\pi}{2} \right)$$

And we have:

$$\displaystyle I=\left.\frac{x^2}{n}\sin\left(nx+m\frac{\pi}{2} \right) \right|_0^{2\pi}-\frac{2}{n}\int_0^{2\pi} x\sin\left(nx+m\frac{\pi}{2} \right)\,dx$$

$$\displaystyle I=\frac{4\pi^2}{n}\sin\left(m\frac{\pi}{2} \right)-\frac{2}{n}\int_0^{2\pi} x\sin\left(nx+m\frac{\pi}{2} \right)\,dx$$

Using integration by parts again, where:

$$\displaystyle u=x\,\therefore\,du=dx$$

$$\displaystyle dv=\sin\left(nx+m\frac{\pi}{2} \right)\,dx\,\therefore\,v=-\frac{1}{n}\cos\left(nx+m\frac{\pi}{2} \right)$$

Now we have:

$$\displaystyle I=\frac{4\pi^2}{n}\sin\left(m\frac{\pi}{2} \right)+\frac{2}{n}\left( \left.\frac{x}{n}\cos\left(nx+m\frac{\pi}{2} \right) \right|_0^{2\pi}+\frac{1}{n}\int_0^{2\pi}\cos\left(nx+m\frac{\pi}{2} \right)\,dx \right)$$

$$\displaystyle I=\frac{4\pi^2}{n}\sin\left(m\frac{\pi}{2} \right)+ \frac{2}{n}\left(\frac{2\pi}{n}\cos\left(m \frac{\pi}{2} \right)+\left.\frac{1}{n^2}\sin\left(nx+m\frac{\pi}{2} \right) \right|_0^{2\pi} \right)$$

$$\displaystyle I=\frac{4\pi^2}{n}\sin\left(m\frac{\pi}{2} \right)+\frac{4\pi}{n^2}\cos\left(m\frac{\pi}{2} \right)$$

Thus, we may state:

$$\displaystyle m=0\implies\int_0^{2\pi}x^2\cos\left(nx \right)\,dx=\frac{4\pi}{n^2}$$

$$\displaystyle m=1\implies-\int_0^{2\pi}x^2\sin\left(nx \right)\,dx=\frac{4\pi^2}{n}$$

$$\displaystyle m=2\implies-\int_0^{2\pi}x^2\cos\left(nx \right)\,dx=-\frac{4\pi}{n^2}$$

$$\displaystyle m=3\implies\int_0^{2\pi}x^2\sin\left(nx \right)\,dx=-\frac{4\pi^2}{n}$$