<s>[INST] 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?
 [/INST] 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}$$
</s>