How can I compute this integral in closed form : $\int_0^{\frac{π}{4}}\ln^2(\tan x)dx$ How can I compute this integral in closed form :
$$\displaystyle\int_{0}^{\displaystyle \tfrac{π}{4}}\ln^{2}\left(\tan x\right)dx$$
How can use Fourier series here ?
$$-2\displaystyle \sum_{n=0}^{\infty}\frac{\cos((4n+2)x)}{2n+1}$$
$$=\ln\left(\tan x\right)$$
And what's about if
$\displaystyle\int_0^{\displaystyle \tfrac{π}{4}}\ln^2(\cot x)dx$
Please give me ideas or hints
 A: Hint. The change of variable
$$
t=\tan x,\quad x=\arctan t,\quad dx=\frac{dt}{1+t^2},
$$ gives
$$
I=\int_0^{\pi/4}\ln^2\tan x\,dx=\int_0^1\frac{\ln^2t}{1+t^2}\,dt
$$ then expanding 
$$
\frac{1}{1+t^2}=\sum_{n=0}^\infty(-1)^nt^{2n},\quad |t|<1,
$$and integrating termwise gives
$$
I=\frac{\pi^3}{16}.
$$ 
A: Your integral is $4A+8B$  with $$A:=\sum_{n\ge 0}\frac{1}{(2n+1)^2}\int_0^{\pi/4}\cos^2((4n+2)x)dx$$and$$B:=\sum_{m>n\ge 0}\frac{1}{(2m+1)(2n+1)}\int_0^{\pi/4}\cos((4m+2)x)\cos((4n+2)x)dx.$$Obviously $\int_0^{\pi/4}\cos^2((4n+2)x)dx=\frac{\pi}{8}$ because we're averaging $\cos^2 y$ on $2n+1$ half-periods, and since $\sum_{n\ge 0}\frac{1}{(2n+1)^2}=\frac{\pi^2}{8}$ we have $A=\frac{\pi^3}{64}$. Meanwhile, all the integrals in $B$ famously vanish, so the integral is $\frac{\pi^3}{16}$ as per @OlivierOloa's answer.
A: Following is an alternative way to evaluate the integral using complex analysis.
Let $I$ be the integral at hand. Change variable first to $t = \tan x$ and then to $s = \frac1t$, we get
$$I = \int_0^1 \frac{\log^2(t)}{1+t^2}dt = \int_1^\infty \frac{\log^2(s)}{1+s^2}ds$$
Taking average, we obtain
$$I = \frac12 \int_0^\infty \frac{\log^2(t)}{1+t^2}dt$$
Consider the contour integral
$$J = \frac{1}{2\pi i}\int_H \frac{\log(-z)^3}{1+z^2}dz$$
where $H$ is the Hankel contour which extends from $[+\infty,\delta]$, around the origin counter-clockwise and back to $[+\infty,-\delta]$ and $\delta$ is an arbitrary small positive constants.
In $J$, we will take the branch cut of $\log(-z)$ to be along the positive real axis. On the upper and lower side of the branch cut, we have $\log(-z) = \log z - i\pi$ and $\log z + i\pi$ respectively. This means
$$J = \frac{1}{2\pi i}\int_0^\infty \frac{(\log z + i\pi)^3 - (\log z - i\pi)^3}{1+z^2}dz
= \int_0^\infty \frac{3\log^2 z -\pi^2}{1+z^2}dz\\
\implies I = \frac16\left(J + \frac{\pi^3}{2}\right)
$$
Complete $H$ with a circle of arbitrary large radius $R$. Notice the integral along the circle converges to $0$ as $R \to \infty$. We can evaluate $J$ by taking residues at its pole. Since the extended contour wind around the poles
in a clockwise manner, there is an extra minus sign in front of both residues.
The end result is
$$\begin{align}
J &= - {\rm Res}\left[ \frac{\log^3(-z)}{1 + z^2}; z = i \right]
- {\rm Res}\left[ \frac{\log^3(-z)}{1 + z^2}; z = -i \right]\\
&= -\frac{1}{2i}\log^3(-i) + \frac{1}{2i}\log^3(i)\\
&= -\frac{1}{2i}\left(-\frac{\pi}{2}i\right)^3 + \frac{1}{2i}\left(\frac{\pi}{2}i\right)^3\\
&= -\frac{\pi^3}{8}
\end{align}
$$
As a result,
$$I = \frac16\left(-\frac{\pi^3}{8} + \frac{\pi^3}{2}\right)= \frac{\pi^3}{16}$$
A: In fact, we may find 
$$f(s)=\int_0^{\pi/4}\ln^s(\tan x)\,dx$$
for $s\in \Bbb N_0$. First with $t=\arctan x$:
$$f(s)=\int_0^1 \frac{\ln^s(x)}{1+x^2}dx$$
Which is 
$$f(s)=\sum_{n\geq0}(-1)^n\int_0^1 x^{2n}\ln^s(x)dx$$
it is elementary to show that 
$$\int_0^1 x^udx=\frac1{u+1}$$
So using the Lebiniz integral rule,
$$\begin{align}
\int_0^1 x^u\ln^s(x)dx&=\left(\frac{\partial }{\partial u}\right)^{s}\frac1{u+1}\\
&=\frac{(-1)^s s!}{(u+1)^{s+1}}
\end{align}$$
Hence 
$$f(s)=\sum_{n\geq0}(-1)^n\frac{(-1)^s s!}{(2n+1)^{s+1}}$$
Which is $$f(s)=(-1)^s s!\beta(s+1)$$
Where $$\beta(s)=\sum_{n\geq0}\frac{(-1)^n}{(2n+1)^s}$$
is the Dirichlet Beta function. Your result follows by plugging in $s=2$.
A: An elementary solution. Utilize
$$ J=\int_0^\infty \frac{(x^2-1)\ln y }{(y+x^2)(y+1)}
\overset{y\to \frac{x^2}y}{dy}=\int_0^\infty \frac{(x^2-1)\ln (x^2) }{(y+x^2)(y+1)}dy- J= {2\ln^2 x}$$
and $x=\tan t $
\begin{align}
&\int_0^{\pi/4}\ln^2(\tan t)\ dt\\
=& \int_0^1\frac{\ln^2x}{1+x^2}\overset{x\to 1/x}{dx}
=\int_1^\infty\frac{\ln^2x}{1+x^2} dx= \frac12\int_0^\infty\frac{\ln^2x}{1+x^2}dx\\
=&\ \frac14\int_0^\infty\int_0^\infty\frac1{1+x^2}\frac{(x^2-1)\ln y}{(y+x^2)(y+1)}\ dy \ dx\\
 =& \ \frac14\int_0^\infty\int_0^\infty
\frac{\ln y}{(y+x^2)(y-1)}-\frac{2\ln y}{(1+x^2)(y^2-1)}\ dx \ dy\\
=& \ \frac\pi8 \int_0^\infty \frac{\ln y}{\sqrt y(y-1)} \overset{y\to y^2}{dy}- \frac\pi4 \int_0^\infty \frac{\ln y}{y^2-1}\ dy
=\frac\pi4 \int_0^\infty \frac{\ln y}{y^2-1}\ dy\\
 =& \ \frac\pi4 \int_0^\infty \int_0^1 \frac{x}{1+(y^2-1)x^2}dx\>dy
= \frac{\pi^2}8\int_0^1 \frac1{\sqrt{1-x^2}}dx=\frac{\pi^3}{16}
\end{align}
