Problem with improper integral $\int_0^{\frac{\pi}{2}} \ln^2\left({\cos{x}}\right)$

definite integralsimproper-integralslimits

So I was trying to solve this integral (I'm not asking how to solve it) and I thought I did some progress but I can't figure out what I've done. (See below) This integral converges, and I got to something which is indeterminate plus another integral which I suppose is convergent. WolframAlpha shows that the numerical value of this last integral is the same as that of the original integral, so I suppose the indeterminate part should cancel to 0. However, I think I got $- \infty$, which doesn't make sense for what I said. Therefore, my question: Does the indeterminate part approach $- \infty$? Does it approach 0? How do you compute it? And anyway, is there anything wrong with my approach (something should definitely be wrong…) ?

$$\int_0^{\frac{\pi}{2}} \ln^2\left({\cos{x}}\right) = x \ln^2\left({\cos{x}} \right) \Big|_0^{\frac{\pi}{2}} +2 \int_0^{\frac{\pi}{2}} x \tan{x} \ln\left({\cos{x}}\right)dx = x \ln^2\left({\cos{x}} \right) \Big|_0^{\frac{\pi}{2}} +2 \int_{-\infty}^0 u \arccos\left({e^u}\right) du = x \ln^2\left({\cos{x}} \right) \Big|_0^{\frac{\pi}{2}} +2 \int_{-\infty}^0 u \left( \frac{\pi}{2} – \arcsin\left({e^u}\right)\right) du = x \ln^2\left({\cos{x}} \right) \Big|_0^{\frac{\pi}{2}} + \frac{\pi}{2} u^2 \Big|_{-\infty}^0 – 2\int_{-\infty}^0 u \arcsin\left({e^u}\right)du$$

First I did integration by parts and then change of variable $\ln\left(\cos{x}\right) = u$

Best Answer

From Fourier series of Log sine and Log cos we have \begin{eqnarray*} -\log(\cos(x))=\sum_{k=1}^\infty(-1)^k\frac{\cos(2kx)}{k}+\log(2). \end{eqnarray*} Square this & integrate, the only terms that will survive, give \begin{eqnarray*} I= \frac{ \pi}{2} \left( (\ln(2))^2+ \frac{1}{2} \sum_{k=1}^{\infty} \frac{1}{k^2} \right) = \frac{ \pi}{2} \left( (\ln(2))^2+ \frac{\pi^2}{12} \right). \end{eqnarray*}