TITLE: Integral $\int_0^{\pi/4}\frac{x^2\tan x}{\cos^2 x}dx=\frac{\log 2}{2}-\frac{\pi}{4}+\frac{\pi^2}{16}$
QUESTION [5 upvotes]: Hi I am trying to evaluate the definite integral which has a closed form given by: 
$$
\mathcal{I}=\int_0^{\pi/4}\frac{x^2\tan x}{\cos^2 x}dx=\frac{\log 2}{2}-\frac{\pi}{4}+\frac{\pi^2}{16}.
$$
We can possibly write $y=\cos x$
$$
\mathcal{I}=\int_0^{\pi/4}\frac{x^2\sin x}{\cos^3x}dx=\int_{\frac{1}{\sqrt 2}}^1\frac{(\cos^{-1}y)^2}{y^3}dy
$$
however I am now sure how that will help us.
We can also try $u=\tan x, du=\frac{dx}{\cos^2x}$ to obtain
$$
\mathcal{I}=\int_0^1 (\tan^{-1}u)^2 u\, du
$$
however I am unsure where to go from here.  How can we solve $\mathcal{I}$?  Thank you

REPLY [11 votes]: $$I=\int_0^{\pi/4} \frac{x^2\tan x}{\cos^2 x}\,dx=\int_0^{\pi/4} x^2\tan x\sec^2 x\,dx$$
Now use integration by parts:
$$I=\left(x^2 \frac{\tan^2x}{2}\right|_0^{\pi/4}-\int_0^{\pi/4} x\tan^2 x\,dx=\frac{\pi^2}{32}-\int_0^{\pi/4} x\tan^2 x\,dx$$
Use integration by parts again to evaluate the last integral:
$$I=\frac{\pi^2}{32}-\left(x(\tan x-x)\right|_0^{\pi/4}+\int_0^{\pi/4}(\tan x-x)\,dx$$
$$\Rightarrow I=\frac{\pi^2}{32}-\frac{\pi}{4}+\frac{\pi^2}{16}+\frac{\ln 2}{2}-\frac{\pi^2}{32}=\boxed{\dfrac{\ln 2}{2}-\dfrac{\pi}{4}+\dfrac{\pi^2}{16}}$$
$\blacksquare$