How to evaluate $\int_0^{\pi/4} \ln^2\cos x dx$? I got this expressions from D. F. Connon's article, "Some series and integrals involving the Riemann zeta function, binomial
coefficients and the harmonic numbers", which is in arxiv.org:
$$2\ln^2\cos x=\sum_{n=2}^{\infty}\frac{(-1)^nH_{n-1}}{n}\tan^{2n}x$$
It is obtained from a series for $\ln^2(1+x)$. Here, $H_{n-1}=1+\frac12+\frac13+...\frac{1}{n-1}$ is $(n-1)$-th harmonic number.
I also evaluated these integrals by WA: $\int_{0}^{\pi/4}\tan^{2n}xdx$
But, it is not easy to put all these stuff into a closed form. Probably this is not a good aproach. I also tried $e^{ix}$ approach by using series of $\ln^2(1+x)$. But it also gives complicated sums. I didn't continue. I am confused and dismotivated.
Is my approach the best way? Is there another approach? How to evaluate $\int_0^{\pi/4} \ln^2\cos x dx$ or $\int_0^{\pi/2} \ln^2\cos x dx$? Can it done by a contour integral and some residues?
Thanks in advance.
 A: There is an antiderivative, given, for sure, in terms of a nasty hypergeometric function.
Assuming $0 \leq x \leq \frac \pi 2$, Mathematica produces for
$$I=\int [\log(\cos(x)]^2\,dx$$
$$I=-\log ^2(\sec (x)) \sin ^{-1}(\cos (x))-2\cos(x) A$$ with
$$A=\,
   _4F_3\left(\frac{1}{2},\frac{1}{2},\frac{1}{2},\frac{1}{2};\frac{3}{
   2},\frac{3}{2},\frac{3}{2};\cos ^2(x)\right)+$$ $$\log (\sec (x)) \,
   _3F_2\left(\frac{1}{2},\frac{1}{2},\frac{1}{2};\frac{3}{2},\frac{3}{2};\cos ^2(x)\right)$$ which is not the most pleasant if you look for an explicit result of the definite integrals.
Using the resul of the summation
$$\sum_{n=2}^{\infty}\frac{(-1)^nH_{n-1}}{n}\tan^{2n}(x)=\text{Li}_2\left(\cos ^2(x)\right)-\text{Li}_2\left(-\tan ^2(x)\right)+$$ $$4
   \log (\sin (x)) \log (\cos (x))-\frac{\pi ^2}{6}$$ I have no idea for its integration.
A: (Too long for a comment.) We have
$$\int_{0}^{\pi/4}\ln^{2}\left(\cos x\right)dx = \frac{1}{4}\int_{0}^{1}\frac{\ln^{2}\left(1+x^{2}\right)}{1+x^{2}}dx = \frac{1}{4}\int_{0}^{1}\frac{\ln^{2}\left(\frac{2\left(1+x^{2}\right)}{\left(1+x\right)^{2}}\right)}{1+x^{2}}dx$$
by the transformations $x \mapsto \arctan(x)$ and $x \mapsto \dfrac{1-x}{1+x}$.
Expanding this integral yields
$$\int_{0}^{1}\frac{\ln^{2}\left(1+x\right)}{1+x^{2}}dx+\frac{1}{4}\int_{0}^{1}\frac{\ln^{2}\left(1+x^{2}\right)}{1+x^{2}}dx+\frac{\ln^{2}\left(2\right)}{4}\int_{0}^{1}\frac{1}{1+x^{2}}dx$$
$$-\int_{0}^{1}\frac{\ln\left(1+x\right)\ln\left(1+x^{2}\right)}{1+x^{2}}dx-\ln\left(2\right)\int_{0}^{1}\frac{\ln\left(1+x\right)}{1+x^{2}}dx+\frac{\ln\left(2\right)}{2}\int_{0}^{1}\frac{\ln\left(1+x^{2}\right)}{1+x^{2}}dx.$$
The third integral is trivial. The rest of the integrals can be evaluated through the help of Pisco's and Ali Shadhar's answers. Combining each messy evaluation results in
$$\int_{0}^{\pi/4}\ln^{2}\left(\cos x\right)dx = \frac{7\pi^{3}}{192}-\frac{G\left(\ln2\right)}{2}+\frac{5\pi\ln^{2}\left(2\right)}{16}-\Im\left(\operatorname{Li}_{3}\left(1-i\right)\right)$$
where $G$ denotes Catalan's Constant and $\operatorname{Li}_n(z)$ denotes the Polylogarithm Function.
Numerical approximations can be viewed here since there are a lot of computations.
