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?

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}$$
