# Help solving definite integral

I'm trying to solve the following definite integral:

$\int_{0}^{\pi/2}{x^2\cos x}dx$

I can confirm that I get the correct answer for the indefinite integral

$\int{x^2 \cos x}dx = \sin x(x^2 -2) + 2x\cos x + K$

but when I try to evaluate the definite integral for range shown above my answers don't agree with a variety of sources.

I get the answer to be: $\frac{\pi^2 - 2}{4} - \pi$

The correct answer seems to be: $\frac{\pi^2 - 2}{4}$

Can anybody show me how this answer is obtained (assuming it is indeed correct)

• The correct answer is I think $\frac{\pi^2}{4}-2$, or if you prefer $\frac{\pi^2-8}{4}$. That comes directly from your integral, which is correct. – André Nicolas Jan 18 '16 at 8:56

I used integration by parts twice.

\begin{align*}\int_0^{\pi/2} x^2\cos xdx &= [\sin x(x^2 -2) + 2x \cos x]_0^{\pi/2}\\ &=\left[x^2\sin x\right]_0^{\pi/2}-\int_0^{\pi/2}\frac{1}{2}x\sin xdx\\ &=\left[\frac{\pi^2}{4}-0\right]-\left[\left(-\frac{1}{2}x\cos x\right)_0^{\pi/2}+2\int_0^{\pi/2}\cos xdx\right]\\ &=\frac{\pi^2}{4}-\left[0+2\left[\sin x\right]_0^{\pi/2}\right]\\ &=\frac{\pi^2}{4}-2 \end{align*}

Edit: I lost a factor somewhere in my work. I corrected it. The answer is $\frac{\pi^2}{4}-2.$

Also, $$\sin \frac{\pi}{2}\left[\left(\frac{\pi}{2}\right)^2 -2\right] + 2\left(\frac{\pi}{2}\right)\cos \frac{\pi}{2}-\left[(\sin 0)(0^2 -2) + 2(0)\cos 0\right]= \frac{\pi^2}{4}-2$$ from your indefinite integral.

• Thank you, I can see the error I was making now. – blobby Jan 18 '16 at 18:12

The correct answer should be (π^2-8)/4, checked the answer using malmath also. After integrating by parts twice, you should get

x^2*sin(x)+2*x*cos(x)-2sin(x)


Integrating from 0 to π/2 will give

π^2/4 - 2 which is (π^2-8)/4.