A log improper integral Evaluate :
$$\int_0^{\frac{\pi}{2}}\ln ^2\left(\cos ^2x\right)\text{d}x$$
I found it can be simplified to
$$\int_0^{\frac{\pi}{2}}4\ln ^2\left(\cos x\right)\text{d}x$$
I found the exact value in the table of integrals:
$$2\pi\left(\ln ^22+\frac{\pi ^2}{12}\right)$$
Anyone knows how to evaluate this?
 A: A related problem. Using the substitution $ \cos(x) = y $, we have

$$ 4\int_0^{\frac{\pi}{2}}\ln^2\left(\cos x\right)\text{d}x = 4\int _{0}^{1}\!{\frac {  \ln^2  \left( y \right)}{
\sqrt {1-{y}^{2}}}}{dy} = I. $$

To evaluate the last integral $I$, consider the integral

$$ F := 4\int _{0}^{1}\!{\frac { y^\alpha}{
\sqrt {1-{y}^{2}}}}{dy} = 2\,{\frac {\sqrt {\pi }\,\Gamma\left( \frac{\alpha}{2}+\frac{1}{2} \right) }{
\Gamma\left( \frac{\alpha}{2}+1 \right) }}. $$

$F$ was evaluated using the beta function. Now, $I$ follows directly from $F$ as

$$ I = F_{\alpha \alpha}|_{\alpha=0} = \frac{\pi}{6} \, \left( {\pi }^{2}+12\, \left( \ln  \left( 2 \right) \right)^{2} \right) \sim 8.186488098. $$

Note 1: Maple can not give a closed form solution for this kind of integrals. 
Note 2: One can evaluate more general integrals, for instance

$$ \int_0^{\frac{\pi}{2}}\ln^3\left(\cos ^2x\right)\text{d}x= -\pi \, \left( 6\,\zeta  \left( 3 \right) +{\pi }^{2}\ln  \left( 2
 \right) +4\, \left( \ln  \left( 2 \right)  \right) ^{3} \right).$$ 

A: $$\int _{ 0 }^{ \frac { \pi  }{ 2 }  }{ { \sin }^{ 2m-1 }\left( x \right) { \cos }^{ 2n-1 }\left( x \right) dx } =B\left( m,n \right) \\ \int _{ 0 }^{ \frac { \pi  }{ 2 }  }{ { \sin }^{ 2m-1 }\left( x \right) { \left( { \cos }^{ 2 }x \right)  }^{ \frac { 2n-1 }{ 2 }  }dx } =B\left( m,n \right) $$
On differentiating it twice w.r.t. to n and taking $m=\frac{1}{2}$ and $n=\frac{1}{2}$, we get
$$\int _{ 0 }^{ \frac { \pi  }{ 2 }  }{ (\ln { \left( { \cos }^{ 2 }x \right) dx })^2  } =\frac { 1 }{ 2 } \frac { { \left( \Gamma \left( \frac { 1 }{ 2 }  \right)  \right)  }^{ 2 } }{ 1 } \left\{ { \left( \psi \left( \frac { 1 }{ 2 }  \right) -\psi \left( 1 \right)  \right)  }^{ 2 }+\psi '\left( \frac { 1 }{ 2 }  \right) -\psi '\left( 1 \right)  \right\} $$
$$\therefore \int _{ 0 }^{ \frac { \pi  }{ 2 }  }{ (\ln { \left( { \cos }^{ 2 }x \right) dx })^2  } =\frac { { \pi  }^{ 3 } }{ 6 } +2\pi { \left( \ln { 2 }  \right)  }^{ 2 }$$
A: I find a way to get the number using gamma functions, nothing is rigorous.
Consider the integral $I(\beta) = \int_{-\frac{\pi}{2}}^{\frac{\pi}{2}}(\cos x)^\beta dx$.
We know:
$$2 \frac{d^2}{d\beta^2} I(\beta) \bigg|_{\beta=0} = 4 \int_{0}^{\frac{\pi}{2}} \ln^2(\cos x) dx$$
is the integral we want. Introduce $u = \frac{1 + \sin x}{2}$, we have:
$$\begin{align}
  I(\beta) &= \int_{-\frac{\pi}{2}}^{\frac{\pi}{2}}(\cos x)^{\beta-1} d\sin x\\
           &= \int_0^1 (4 u (1-u))^{\frac{\beta-1}{2}} d( 2u )\\
           &= 2^{\beta} \int_0^1 u^{\frac{\beta+1}{2}-1} (1-u)^{\frac{\beta+1}{2}-1} du\\
           &= 2^{\beta} \frac{\Gamma(\frac{\beta+1}{2})^2}{\Gamma(\beta+1)}
\end{align}$$
Using the taylor expansion of various terms at $\beta = 0$,
$$\begin{align}
  2^{\beta} &= 1 + \ln(2) \beta + \frac{\ln^2 2}{2}\beta^2 + \,...\\
  \Gamma(\frac{\beta+1}{2}) &= \sqrt{\pi} \left(
   1 - \frac{\gamma + 2\ln 2}{2} \beta +  \frac{\pi^2+2( \gamma + 2\ln 2)^2}{16}\beta^2 + \, ...\right)\\
  \Gamma(\beta+1) &= 1 -\gamma \beta + \frac{6\gamma^2 + \pi^2}{12} \beta^2 + \,...
\end{align}
$$
We get:
$$\begin{align}
&I(\beta) = \pi \left( 1 - \ln(2) \beta + \frac{\pi^2 + 12 \ln^2 2}{24}\beta^2 + \,... \right)\\
\implies &2 \frac{d^2}{d\beta^2} I(\beta)\bigg|_{\beta=0} = 2\pi \left( \frac{\pi^2}{12} + \ln^2 2 \right)
\end{align}$$
A: Start with
$$
\begin{align}
\int_0^{\pi/2}\log(\sin(x))\,\mathrm{d}x
&=\frac12\int_0^\pi\log(\sin(x))\,\mathrm{d}x\\
&=\int_0^{\pi/2}\log(\sin(2x))\,\mathrm{d}x\\
&=\int_0^{\pi/2}\Big(\log(2)+\log(\sin(x))+\log(\cos(x))\Big)\,\mathrm{d}x\\
&=\frac\pi2\log(2)+2\int_0^{\pi/2}\log(\sin(x))\,\mathrm{d}x\tag{1}
\end{align}
$$
Therefore,
$$
\int_0^{\pi/2}\log(\sin(x))\,\mathrm{d}x=-\frac\pi2\log(2)\tag{2}
$$

Next
$$
\begin{align}
\int_0^{\pi/2}\log^2(\sin(x))\,\mathrm{d}x
&=\int_0^{\pi/2}\Big(\log(2)+\log(\sin(x))+\log(\cos(x))\Big)^2\,\mathrm{d}x\\
&=\frac\pi2\log^2(2)+4\log(2)\int_0^{\pi/2}\log(\sin(x))\,\mathrm{d}x\\
&+2\int_0^{\pi/2}\log(\sin(x))\log(\cos(x))\,\mathrm{d}x\\
&+2\int_0^{\pi/2}\log^2(\sin(x))\,\mathrm{d}x\tag{3}
\end{align}
$$
Using $(2)$ in $(3)$ yields
$$
\int_0^{\pi/2}\log^2(\sin(x))\,\mathrm{d}x
=\frac32\pi\log^2(2)-2\int_0^{\pi/2}\log(\sin(x))\log(\cos(x))\,\mathrm{d}x\tag{4}
$$

As in this answer, we can use contour integration to get that
$$
\begin{align}
\int_0^\infty\frac{\log^2(x)}{1-x^2}\mathrm{d}x
&=\int_0^\infty\frac{\log^2(ix)}{1+x^2}\mathrm{d}ix\\
&=i\int_0^\infty\frac{\left(\frac\pi2i+\log(x)\right)^2}{1+x^2}\mathrm{d}x\\
&=i\int_0^\infty\frac{\log^2(x)-\frac{\pi^2}{4}}{1+x^2}\mathrm{d}x
-\pi\int_0^\infty\frac{\log(x)}{1+x^2}\mathrm{d}x\tag{5}
\end{align}
$$
Looking at the imaginary part of $(5)$, we see that
$$
\int_0^\infty\frac{\log^2(x)}{1+x^2}\mathrm{d}x=\frac{\pi^3}8\tag{6}
$$

With a change of variables, $(6)$ becomes
$$
\begin{align}
\frac{\pi^3}8
&=\int_0^{\pi/2}\log^2(\tan(x))\,\mathrm{d}x\\
&=\int_0^{\pi/2}\Big(\log^2(\sin(x))+\log^2(\cos(x))-2\log(\sin(x))\log(\cos(x))\Big)\,\mathrm{d}x\tag{7}
\end{align}
$$
which yields
$$
\int_0^{\pi/2}\log^2(\sin(x))\,\mathrm{d}x
=\frac{\pi^3}{16}+\int_0^{\pi/2}\log(\sin(x))\log(\cos(x))\,\mathrm{d}x\tag{8}
$$

Adding twice $(8)$ to $(4)$ and dividing by $3$ gives
$$
\int_0^{\pi/2}\log^2(\sin(x))\,\mathrm{d}x=\frac{\pi^3}{24}+\frac12\pi\log^2(2)\tag{9}
$$
Therefore,
$$
\int_0^{\pi/2}\log^2(\cos^2(x))\,\mathrm{d}x=\frac{\pi^3}{6}+2\pi\log^2(2)\tag{10}
$$
A: First of all, substituting $x\to\frac\pi2-x$ yields
$$\int_0^{\frac\pi2} \ln(\cos^2(x)) \, dx = \int_0^{\frac\pi2} \ln(\sin^2(x)) \, dx = 2 \int_0^{\frac\pi2} \ln(\sin(x)) \, dx = -\pi\ln(2)$$
where the log-sine integral can be computed using the identity
$$\ln(\sin(x)) = -\ln(2) - \sum_{k=1}^\infty \frac{\cos(2kx)}k$$
Using the same substitution,
$$\int_0^{\frac\pi2} \ln^2(\cos^2(x)) \, dx = \int_0^{\frac\pi2} \ln^2(\sin^2(x)) \, dx = 4 \int_0^{\frac\pi2} \ln^2(\sin(x)) \, dx$$
In the identity above, square both sides and integrate:
$$\begin{align}
\ln^2(\sin(x)) &= \ln^2(2) + 2\ln(2) \sum_{k=1}^\infty \frac{\cos(2kx)}k + \left(\sum_{k=1}^\infty \frac{\cos(2kx)}k\right)^2 \\[2ex]
\int_0^{\frac\pi2} \ln^2(\sin(x)) \, dx &= \frac\pi2 \ln^2(2) - 2\ln(2)  \int_0^{\frac\pi2} (\ln(2) + \ln(\sin(x)) \, dx \\[1ex]
& \qquad + \int_0^{\frac\pi2} \sum_{k=1}^\infty \frac{\cos^2(2kx)}{k^2} \, dx + 2 \int_0^{\frac\pi2} \sum_{i<j}\frac{\cos(2ix)\cos(2jx)}{ij} \, dx\\[2ex]
&= \frac\pi2 \ln^2(2) + \frac12 \sum_{k=1}^\infty \frac1{k^2} \int_0^{\frac\pi2} (1+\cos(4kx)) \, dx \\[1ex]
&\qquad + \sum_{i<j} \frac1{ij} \int_0^{\frac\pi2} (\cos(2(i+j)x) + \cos(2(i-j)x)) \, dx \\[2ex]
&= \frac\pi2\ln^2(2) + \frac\pi4 \sum_{k=1}^\infty \frac1{k^2} \\[2ex]
&= \frac\pi2\ln^2(2) + \frac{\pi^3}{24}
\end{align}$$
and so
$$\int_0^{\frac\pi2} \ln^2(\cos^2(x)) \, dx = \boxed{2\pi\ln^2(2) + \frac{\pi^3}6}$$
