$\int_0^\frac{\pi}{2}\cos ^2x\log(\tan x)dx.$ Evaluate $\int_0^\frac{\pi}{2}\cos ^2x\log(\tan x)dx.$
Sidenote:Via mathalpha I know that answer is $-\pi/4$ but do not know how to derive that. 
 A: Let $I$ be the considered integral. The change of variables $x\leftarrow \frac{\pi}{2}-x$ shows that
$$I=-\int_0^{\pi/2}\sin^2x\,\log(\tan x)dx$$
Thus, taking the half sum,
$$\eqalign{I&=\frac{1}{2}\int_0^{\pi/2}\cos(2x)\log(\tan x)dx=\int_0^{\pi/4}\cos(2x)\log(\tan x)dx\cr
&=\left.\frac{\sin(2x)}{2}\log(\tan x)\right]_0^{\pi/4}
- \int_0^{\pi/4}\sin x\cos x\frac{1}{\cos^2 x\tan x}dx
=-\frac{\pi}{4}.
}
$$
A: With a change of variable $u = \tan^2(x)$ the integral reads:
$$
    I =  \int_0^{\pi/2} \cos^2(x) \log(\tan(x)) \mathrm{d}x = \frac{1}{4} \int_0^\infty \frac{\log(u) u^{-1/2}}{(1+u)^2} \mathrm{d}u = \left. -\frac{1}{4} \frac{\mathrm{d}}{\mathrm{d}s} \int_0^\infty \frac{u^{s-1}}{(1+u)^2}\mathrm{d}u  \right|_{s=1/2}
$$
Using
$$
   \frac{1}{(1+u)^2} = \int_0^\infty v \,\exp(-v (1+u))\mathrm{d}v
$$
and interchanging integration order as per Tonelli's theorem:
$$
  \int_0^\infty \frac{u^{s-1}}{(1+u)^2}\mathrm{d}u = \int_0^\infty v \mathrm{e}^{-v}\underbrace{\int_0^\infty u^{s-1} \exp(-v u) \mathrm{d}u }_{\Gamma(s) v^{-s}  }  \mathrm{d}v = \Gamma(s) \int_0^\infty v^{1-s} \mathrm{e}^{-v}\mathrm{d}v = \Gamma(s) \Gamma(2-s)
$$
Thus
$$
   I = \left. -\frac{1}{4} \frac{\mathrm{d}}{\mathrm{d}s}  \Gamma(s) \Gamma(2-s)   \right|_{s=1/2} = \left. -\frac{1}{4} \frac{\mathrm{d}}{\mathrm{d}s}  \pi \frac{(1-s)}{\sin(\pi s)}   \right|_{s=1/2} = -\frac{\pi}{4}
$$
A: Note that
$$
\begin{align}
I(a)
&=\int_0^{\pi/2} \cos^2 x \tan^a xdx&\\
&=\int_0^{\pi/2} \sin^a x \cos^{2-a}xdx&(\mbox{definition of beta function})\\
&=\frac{1}{2}B\left(\frac{1+a}{2},\frac{3-a}{2}\right)& \left(B(x,y)=\frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)}\right)\\
&=\frac{\Gamma\left(\frac{1+a}{2}\right)\Gamma\left(1+\frac{1-a}{2}\right)}{2\Gamma(2)}&(\Gamma(1+t)=t\Gamma(t))\\
&=\frac{\Gamma\left(\frac{1+a}{2}\right)\frac{1-a}{2}\Gamma\left(\frac{1-a}{2}\right)}{2}\\
&=\frac{1-a}{4}\Gamma\left(1-\frac{1+a}{2}\right)\Gamma\left(1+\frac{1+a}{2}\right)&\left(\Gamma(1-z)\Gamma(z)=\frac{\pi}{\sin(\pi z)}\right)\\
&=\frac{1-a}{2}\frac{\pi}{\sin\left(\pi\frac{1+a}{2}\right)}\\
&=\frac{\pi(1-a)}{4}\sec\left(\frac{\pi a}{2}\right)
\end{align}
$$
So
$$
\begin{align}
\int_0^{\pi/2} \cos^2 x\log(\tan x)dx
&=\frac{d}{da}I(a)\Biggl|_{a=0}\\
&=-\frac{1}{8}\pi\left(\pi(a-1)\tan\left(\frac{\pi a}{2}\right)+2\right)\sec \left(\frac{\pi a}{2}\right)\Biggl|_{a=0}\\
&=-\frac{\pi}{4}
\end{align}
$$
