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?


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


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 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).$$