How is the integral $2/π\int_{0}^{π} x^2\cos(nx) dx = \frac{4(-1)^n}{n^2}$?

886 Views Asked by At

I thought it would be this : $$2/π\int_{0}^{π} x^2\cos(nx) dx = 2/π\int_{0}^{π} x^2(-1)^n = 2/π(-1)^n\int_{0}^{π} x^2=\frac{2}{π(-1)^n}\biggl[\frac{x^3}{3}\biggr]_0^π =\frac{2(-1)^n}{3π^3}. $$

But it is actually $$\frac{2}{π}\int_{0}^{π} x^2\cos(nx) dx = \frac{4(-1)^n}{n^2}$$ according to my professor's notes. How did he get that answer?

Thanks.

4

There are 4 best solutions below

0
On BEST ANSWER

You cannot say that $\cos nx = (-1)^n$. This is valid for $x=\pi$. A counterexample would be $\cos n\cdot0 = 1$, and this doesn't depend on $n$.

The correct way to do this integral is using integration by parts, multiple times.

Hint: $u=x^2$, $\text dv = \cos nx\ \text dx$.

0
On

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

0
On

$$\dfrac{d\{x^m\cos(nx)\}}{dx}=-nx^m\sin nx+mx^{m-1}\cos(nx)$$

Integrating both sides,

$\displaystyle x^m\cos nx=-n\int x^m\sin nx+m\int x^{m-1}\cos(nx)$

$\displaystyle \pi^m\cos n\pi=-n\int_0^\pi x^m\sin nx+m\int_0^\pi x^{m-1}\cos(nx)$

$\displaystyle f(m)=\int_0^\pi x^m\sin nx=?$

Similarly,

$$\dfrac{d\{x^m\sin(nx)\}}{dx}=nx^m\cos nx+mx^{m-1}\sin(nx)$$

Integrating both sides,

$\displaystyle\implies x^m\sin(nx)=n\int x^m\cos nx\ dx+m\int x^{m-1}\sin(nx) \ dx$

$\displaystyle\implies \dfrac{n^2}m\int_0^\pi x^m\cos nx\ dx=-n\int_0^\pi x^{m-1}\sin(nx)$

$\displaystyle=-n f(m-1)=\pi^{m-1}\cos n\pi-(m-1)\int_0^\pi x^{m-1}\cos nx\ dx$

Now $\cos n\pi=(-1)^n$

Set $m=2,1$

0
On

Just another approach. From $$ \int_0^\pi \cos(ax)\,dx=\frac{\sin(a\pi)}{a}, \qquad a \in \mathbb{R},\,a\neq 0, $$ differentiating twice with respect to $a$ gives $$ \int_0^\pi x^2\cos(ax)\,dx=\frac{(2-a^2\pi^2)\sin(a\pi)}{a^3}+2\pi\,\frac{\cos(a\pi)}{a^2}, $$ then put $a:=n$ using $\sin(n\color{red}{\pi})=0$ and $\cos(n\color{red}{\pi})=(-1)^n$ where $n=1,2,\cdots$ .