# Looking for closed-forms of $\int_0^{\pi/4}\ln^2(\sin x)\,dx$ and $\int_0^{\pi/4}\ln^2(\cos x)\,dx$

A few days ago, I posted the following problems

Prove that $$\int_0^{\pi/2}\ln^2(\cos x)\,dx=\frac{\pi}{2}\ln^2 2+\frac{\pi^3}{24}\\[20pt] -\int_0^{\pi/2}\ln^3(\cos x)\,dx=\frac{\pi}{2}\ln^3 2+\frac{\pi^3}{8}\ln 2 +\frac{3\pi}{4}\zeta(3)$$

My next question is finding the closed-forms for

\begin{align} \int_0^{\pi/4}\ln^2(\sin x)\,dx\tag1\\[20pt] \int_0^{\pi/4}\ln^2(\cos x)\,dx\tag2\\[20pt] \int_0^1\frac{\ln t~\ln\big(1+t^2\big)}{1+t^2}dt\tag3 \end{align}

I have a strong feeling that the closed-forms exist because we have nice closed-forms for $$\int_0^{\pi/4}\ln(\sin x)\ dx=-\frac12\left(C+\frac\pi2\ln2\right)\\ \text{and}\\ \int_0^{\pi/4}\ln(\cos x)\ dx=\frac12\left(C-\frac\pi2\ln2\right).$$ The complete proofs can be found here.

As shown by Mr. Lucian in his answer below, the three integrals are closely related, so finding the closed-form one of them will also find the other closed-forms. How to find the closed-forms of the integrals? Could anyone here please help me to find the closed-form, only one of them, preferably with elementary ways (high school methods)? If possible, please avoiding contour integration and double summation. Any help would be greatly appreciated. Thank you.

Following the same approach as in this answer,

\begin{align} &\int_{0}^{\pi/4} \log^{2} (2 \sin x) \ dx = \int_{0}^{\pi/4} \log^{2}(2) \ dx + 2 \log 2 \int_{0}^{\pi/4}\log(\sin x) \ dx + \int_{0}^{\pi /4}\log^{2}(\sin x) \ dx \\ &= \frac{\pi}{4} \log^{2}(2) - \log (2) \left(G + \frac{\pi}{2} \log (2) \right) + \int_{0}^{\pi/4} \log^{2}(\sin x) \ dx \\ &= \int_{0}^{\pi /4} \left(x- \frac{\pi}{2} \right)^{2} \ dx + \text{Re} \int_{0}^{\pi/4} \log^{2}(1-e^{2ix}) \ dx \\ &= \frac{7 \pi^{3}}{192} + \frac{1}{2} \text{Im} \int_{{\color{red}{1}}}^{i} \frac{\log^{2}(1-z)}{z} \ dz \\ &= \frac{7 \pi^{3}}{192} + \frac{1}{2} \text{Im} \left(\log^{2}(1-i) \log(i) + 2 \log(1-i) \text{Li}_{2}(1-i) - 2 \text{Li}_{3}(1-i) \right) \\ &= \frac{7 \pi^{3}}{192} + \frac{1}{2} \left(\frac{\pi}{8} \log^{2}(2) - \frac{\pi^{3}}{32} + \log(2) \ \text{Im} \ \text{Li}_{2}(1-i) - \frac{\pi}{2} \text{Re} \ \text{Li}_{2}(1-i)- 2 \ \text{Im} \ \text{Li}_{3}(1-i)\right) . \end{align}

Therefore,

\begin{align}\int_{0}^{\pi/4} \log^{2}(\sin x) \ dx &= \frac{\pi^{3}}{48} + G \log(2)+ \frac{5 \pi}{16}\log^{2}(2) + \frac{\log(2)}{2} \text{Im} \ \text{Li}_{2}(1-i) - \frac{\pi}{4} \text{Re} \ \text{Li}_{2}(1-i) \\ &- \text{Im} \ \text{Li}_{3}(1-i) \approx 2.0290341368 . \end{align}

The answer could be further simplified using the dilogarithm reflection formula $$\text{Li}_{2}(x) {\color{red}{+}} \text{Li}_{2}(1-x) = \frac{\pi^{2}}{6} - \log(x) \log(1-x)$$

and the fact that $$\text{Li}_{2}(i) = - \frac{\pi^{2}}{48} + i G.$$

EDIT:

Specifically, $$\text{Li}_{2}(1-i) = \frac{\pi^{2}}{16} - i G - \frac{i \pi}{4} \log(2).$$

So $$\int_{0}^{\pi /4} \log^{2}(\sin x) \ dx = \frac{\pi^{3}}{192} + G\frac{ \log(2)}{2} + \frac{3 \pi}{16} \log^{2}(2) - \text{Im} \ \text{Li}_{3}(1-i).$$

• Thank you Mr. Random variable, for now I'll upvote this answer and study it (ô‿ô) – Anastasiya-Romanova 秀 Sep 5 '14 at 12:21
• There were a couple of errors that I fixed. – Random Variable Sep 5 '14 at 15:54
• I added a bit more detail to the other answer. – Random Variable Sep 6 '14 at 7:52
• Ack. Apparently I accidentally downvoted, and now it's locked in. I'll fix this if you edit. :( – David H Sep 6 '14 at 10:57
• @DavidH Why did you do that? I consider this answer as a strong candidate winner for my bounty! ᕙ(｀皿´)╯ – Anastasiya-Romanova 秀 Sep 6 '14 at 11:18

$$\int_0^\frac\pi4\Big(\ln\sin x\Big)^2~dx~=~\dfrac{23}{384}\cdot\pi^3~+~\dfrac9{32}\cdot\pi\cdot\ln^22~+~\underbrace{\beta(2)}_\text{Catalan}\cdot\dfrac{\ln2}2~-~\Im\bigg[\text{Li}_3\bigg(\dfrac{1+i}2\bigg)\bigg].$$

$$\int_0^\frac\pi4\Big(\ln\cos x\Big)^2~dx~=~\dfrac{-7}{384}\cdot\pi^3~+~\dfrac7{32}\cdot\pi\cdot\ln^22~-~\underbrace{\beta(2)}_\text{Catalan}\cdot\dfrac{\ln2}2~+~\Im\bigg[\text{Li}_3\bigg(\dfrac{1+i}2\bigg)\bigg].$$

$$S=\int_0^\frac\pi4\Big(\ln\sin x\Big)^2~dx~+~\int_0^\frac\pi4\Big(\ln\cos x\Big)^2~dx=I+J.$$

But, by a simple change of variable, $$t=\dfrac\pi2-x,~J$$ can be shown to equal $$\displaystyle\int_\frac\pi4^\frac\pi2\Big(\ln\sin x\Big)^2~dx$$,

in which case $$I+J=\displaystyle\int_0^\frac\pi2\Big(\ln\sin x\Big)^2~dx=\dfrac{\pi^3}{24}+\dfrac\pi2\ln^22.~$$ So we know their sum! Now all

that's left to do is to find out their difference, $$D=I-J.~$$ Then we'll have $$I=\dfrac{S+D}2$$ and

$$J=\dfrac{S-D}2$$.

$$D=I-J=\int_0^\frac\pi4\Big(\ln\sin x\Big)^2~dx-\int_0^\frac\pi4\Big(\ln\cos x\Big)^2~dx=\int_0^\frac\pi4\Big(\ln^2\sin x-\ln^2\cos x\Big)~dx$$

$$=\int_0^\frac\pi4\Big(\ln\sin x-\ln\cos x\Big)~\Big(\ln\sin x+\ln\cos x\Big)~dx=\int_0^\frac\pi4\ln\frac{\sin x}{\cos x}~\ln\big(\sin x~\cos x\big)~dx=$$

$$=\int_0^\frac\pi4\ln\tan x\cdot\ln\frac{\sin2x}2~dx=\frac12\int_0^\frac\pi2\ln\tan\frac x2\cdot\ln\frac{\sin x}2~dx=\int_0^1\ln t\cdot\ln\frac t{1+t^2}\cdot\frac{dt}{1+t^2}$$

where the last expression was obtained by using the famous Weierstrass substitution, $$t=\tan\dfrac x2$$

$$=\int_0^1\frac{\ln t\cdot\Big[\ln t-\ln(1+t^2)\Big]}{1+t^2}dt~=~\int_0^1\frac{\ln^2t}{1+t^2}dt~-~\int_0^1\frac{\ln t~\ln\big(1+t^2\big)}{1+t^2}dt~=~\frac{\pi^3}{16}-K,$$

where $$~K=2~\Im\bigg[\text{Li}_3\bigg(\dfrac{1+i}2\bigg)\bigg]-\dfrac{\pi^3}{64}-\dfrac\pi{16}\ln^22-\underbrace{\beta(2)}_\text{Catalan}\ln2.~$$ It follows then that our two

definite integrals possess a closed form expression if and only if $$~\text{Li}_3\bigg(\dfrac{1+i}2\bigg)$$ has one as well. As

an aside, $$~\Re\bigg[\text{Li}_3\bigg(\dfrac{1+i}2\bigg)\bigg]=\dfrac{\ln^32}{48}-\dfrac5{192}~\pi^2~\ln2+\dfrac{35}{64}~\zeta(3).~$$ Also, $$~K=\displaystyle\sum_{n=1}^\infty\frac{(-1)^n~H_n}{(2n+1)^2}$$.

• +1 Mr. Lucian, your method is easy to follow but I have a question, how to evaluate $$\int_0^1\frac{\ln t~\ln\big(1+t^2\big)}{1+t^2}dt$$ – Anastasiya-Romanova 秀 Sep 3 '14 at 10:41
• @Lucian Do you mind explaining how you compute $\displaystyle K=\sum^\infty_{n=1}\frac{(-1)^n H_n}{(2n+1)^2}$? Thanks. – SuperAbound Sep 3 '14 at 10:53
• @SuperAbound: I didn't. Mathematica did. Basically, I struggled for hours to find an expression which my CAS could finally evaluate, since all other intermediary results available on this page were impenetrable, and, in the end, I actually did. Then I posted the result. As far as the integral is concerned, I tried the two main approaches: series expansion and the Feynman trick, both of which failed miserably, but your Euler sum gives me hope. $($How on earth did you even come up with it, anyway?$)$ My only idea would be to write $H_n$ as a sum, then switch the order of the two summations. – Lucian Sep 3 '14 at 15:03
• @V-Moy: In my opinion, SuperAbound's Euler sum seems the way to go. Indeed, many such similar sums have been solved on this site, so I am rather hopeful. – Lucian Sep 3 '14 at 15:18
• @SuperAbound: The real part of the complex polylogarithm I posted possesses a closed form, so perhaps its imaginary part does so as well. Either way, I will not be the one to find it, so any help would, at this point, be deeply appreciated. – Lucian Sep 3 '14 at 15:25

By setting $x=\arctan t$ we have: $$\int_{0}^{\pi/4}\log^2(\cos x)\,dx = \frac{1}{4}\int_{0}^{1}\frac{\log^2(1+t^2)}{1+t^2}.$$ Attack plan: get the Taylor series of $\log^2(1+t^2)$ and integrate it termwise.

Since $$-\log(1-z)=\sum_{n=1}^{+\infty}\frac{z^n}{n}$$ it follows that $$[z^n]\log^2(1-z)=\sum_{k=1}^{n-1}\frac{1}{k(n-k)}=2\frac{H_{n-1}}{n},$$ $$\log^2(1+t^2)=\sum_{n=2}^{+\infty}2\frac{H_{n-1}}{n}(-1)^n t^{2n}.\tag{1}$$ If now we set $$\mathcal{J}_m = \int_{0}^{1}\frac{t^{2m}}{t^2+1}\,dt$$ we have $\mathcal{J}_0=\frac{\pi}{4}$ and $\mathcal{J}_{m+1}+\mathcal{J}_m = \frac{1}{2m+1}$, hence: $$\mathcal{J}_m = (\mathcal{J}_m+\mathcal{J}_{m-1})-(\mathcal{J}_{m-1}+\mathcal{J}_{m-2})+\ldots\pm(\mathcal{J}_1+\mathcal{J}_0)\mp\mathcal{J}_0,$$ $$\mathcal{J}_m = \sum_{j=0}^{m-1}\frac{(-1)^j}{(2m-2j-1)}+(-1)^m\frac{\pi}{4}=(-1)^m \sum_{j\geq m}\frac{(-1)^j}{2j+1}.\tag{2}$$ From $(1)$ and $(2)$ it follows that: $$\int_{0}^{\pi/4}\log^2(\cos x)\,dx=\frac{1}{2}\sum_{n=2}^{+\infty}\frac{H_{n-1}}{n}\sum_{r\geq n}\frac{(-1)^r}{2r+1},\tag{3}$$ and summation by parts gives:

$$\int_{0}^{\pi/4}\log^2(\cos x)\,dx=\frac{1}{4}\sum_{n=2}^{+\infty}(H_n^2-H_n^{(2)})\frac{(-1)^n}{2n+1}.\tag{4}$$

UPDATE: the question is now set in an answer to another question. This site (many thanks to @gammatester) is devoted to the evaluation of sums like the one appearing in the RHS of $(4)$. Through Euler-Landen's identity (see the line below $(608)$ in the linked site) it is not too much difficult to see that the RHS of $(4)$ depends on $\operatorname{Li}_3\left(\frac{1+i}{2}\right)$ as stated in the @Lucian's answer.

• +1 for your answer before I sleep Mr. Jack D'Aurizio (ô‿ô) – Anastasiya-Romanova 秀 Sep 2 '14 at 18:00
• another approach: using the following identity: $$\displaystyle \frac{\ln^2(1-x)}{1-x}=\sum_{n=1}^{\infty}\left(H_n^2-H_n^{(2)}\right)x^n$$ replacing $x$ with $-x^2$ and integrating both sides from $0$ to $1$ gives: $$\int_{0}^{1}\frac{\log^2(1+x^2)}{1+x^2}\ dx=\sum_{n=1}^{\infty}(H_n^2-H_n^{(2)})\frac{(-1)^n}{2n+1}$$ – Ali Shather May 2 at 1:35

my approach to problem $$(3)$$: \begin{align} I&=\int_0^1\frac{\ln x\ln(1+x^2)}{1+x^2}\ dx=-2\int_0^{\pi/4}\ln(\tan x)\ln(\cos x)\ dx\\ &=-2\int_0^{\pi/4}\ln(\sin x)\ln(\cos x)\ dx+2\int_0^{\pi/4}\ln^2(\cos x)\ dx\\ &=-\int_0^{\pi/2}\ln(\sin x)\ln(\cos x)\ dx+2\int_0^{\pi/4}\ln^2(\cos x)\ dx\\ &=-\left(\frac{\pi}{2}\ln^22-\frac{\pi^3}{48}\right)+2\left(\frac7{192}\pi^3+\frac5{16}\pi\ln^22-\frac12\ln2~G-\text{Im}\operatorname{Li_3}(1+i)\right)\\ &=\frac3{32}\pi^3+\frac{\pi}8\ln^22-\ln2~G-2\text{Im}\operatorname{Li_3}(1+i) \end{align}

note that we evaluated the first integral using the derivative of beta function and as follows: \begin{align} J&=\int_0^{\pi/2}\ln(\sin x)\ln(\cos x)\ dx=\frac18\frac{\partial^2}{\partial{a}\partial{b}}\beta(a,b)\Bigg\rvert_{a\to1/2,~b\to1/2}\\ &=\frac18\beta(a,b)\left(\left(\psi(a)-\psi(a+b)\right)\left(\psi(b)-\psi(a+b)\right)-\psi^{(1)}(a+b)\right)\Bigg\rvert_{a\to1/2,~b\to1/2}\\ &=\frac18\beta(1/2,1/2)\left((\psi(1/2)-\psi(1))^2-\psi^{(1)}(1)\right)\\ &=\frac{\pi}8\left(4\ln^22-\zeta(2)\right)\\ &=\frac{\pi}2\ln^22-\frac{\pi^3}{48} \end{align}

we can prove, using the same strategy of Random Variable, the following equality:

$$\int_0^{\pi/4}\ln^2(\cos x)\ dx=\frac7{192}\pi^3+\frac5{16}\pi\ln^22-\frac12\ln2G-\text{Im}\operatorname{Li_3}(1+i)$$ proof :
\begin{align*} \ln(1+e^{2ix}) &= \ln (e^{-ix}+e^{ix}) + \ln(e^{ix}) \\ &= \ln(2\cos x) + ix \end{align*}

squaring both sides and integrating, we get

$$\int_0^{\pi/4}\ln^2(1+e^{2ix})\ dx=\int_0^{\pi/4}(\ln(2\cos x)+ix)^2\ dx$$ equating the real parts on both sides and rearranging the terms, we have:

\begin{align*} \int_0^{\pi/4}\ln^2(\cos x)\ dx&=\int_0^{\pi/4}(x^2-\ln^22)\ dx-2\ln2\int_0^{\pi/4}\ln(\cos x)\ dx+\text{Re}\int_0^{\pi/4}\ln^2(1+e^{2ix})\ dx\\ &=\frac{\pi^3}{192}-\frac{\pi}{4}\ln^22-2\ln2\left(\frac12G-\frac{\pi}{4}\ln2\right)+\text{Re}\int_0^{\pi/4}\ln^2(1+e^{2ix})\ dx\\ &=\frac{\pi^3}{192}+\frac{\pi}{4}\ln^22-\ln2G+\text{Re}\int_0^{\pi/4}\ln^2(1+e^{2ix})\ dx \tag{1}\\ \end{align*} Evaluating the last integral: \begin{align*} I&=\text{Re}\int_0^{\pi/4}\ln^2(1+e^{2ix})\ dx=\frac12\text{Im}\int_1^i\frac{\ln^2(1+x)}{x}\ dx\\ &=\frac12\text{Im}\left(\ln(-i)\ln^2(1+i)+2\ln(1+i)\operatorname{Li_2}(1+i)-2\operatorname{Li_3}(1+i)\right)\\ &=\frac{\pi^3}{32}+\frac{\pi}{16}\ln^22+\frac12\ln2G-\text{Im}\operatorname{Li_3}(1+i)\tag{2} \end{align*} Plugging $$(2)$$ in $$(1)$$ we get our result.

note that we used: $$\ln(-i)=-\frac{\pi}{2}i$$ $$\ln(1+i)=\frac12\ln2+\frac{\pi}{4}i$$ $$\operatorname{Li_2}(1+i)=\frac{\pi^2}{16}+\left(\frac{\pi}{4}\ln2+G\right)i$$ which give us: $$\ln(-i)\ln^2(1+i)=\frac{\pi^2}{8}\ln2+\left(\frac{\pi^3}{32}-\frac{\pi}{8}\ln^22\right)i$$ $$\ln(1+i)\operatorname{Li_2}(1+i) =-\frac{\pi}{4}G-\frac{\pi^2}{32}\ln2+\left(\frac12\ln2G+\frac{\pi^3}{64}+\frac{\pi}{8}\ln^22\right)i$$