TITLE: Evaluate $\int_0^{\pi/2}\frac{x^2\log^2{(\sin{x})}}{\sin^2x}dx$
QUESTION [26 upvotes]: How  evaluate this integral?
 $$I=\int_0^{\pi/2}\frac{x^2\log^2{(\sin{x})}}{\sin^2x}\,dx$$
 Note: $$\int_0^{\pi/2}\frac{x^2\log{(\sin x)}}{\sin^2x}dx=\pi\ln{2}-\frac{\pi}{2}\ln^22-\frac{\pi^3}{12}.$$

REPLY [36 votes]: Let's start out with the auxiliary result
\begin{equation*}
\int_0^{\pi/2}\frac{x^2\log{(\sin(x))}}{\sin^2(x)}dx=\pi\ln{(2)}-\frac{\pi}{2}\ln^2(2)-\frac{\pi^3}{12}.
\end{equation*}
By the integration by parts all reduces to 
$$\int_0^{\pi/2} \cot(x) (x^2 \cot(x)+2 x\log(\sin(x))) \ dx=\int_0^{\pi/2} x^2 \cot^2(x) \ dx+2\int_0^{\pi/2} x\cot(x) \log(\sin(x))) \ dx.$$
For the first integral in the right-hand side we apply the integration by parts that yields
\begin{equation*}
\begin{aligned}
\int_0^{\pi/2} x^2 \cot^2(x) \ dx &=-\frac{\pi^3}{8}+\int_0^{\pi/2} 2 x (x+\cot (x)) \ dx \\
                                                        &=-\frac{\pi^3}{24}+2\int_0^{\pi/2}x \cot (x) \ dx \\
                                                        &=-\frac{\pi^3}{24}-2\int_0^{\pi/2} \log(\sin(x)) \ dx \\
                                                        &=-\frac{\pi^3}{24}-\int_0^{\pi} \log(\sin(x)) \ dx \\                                                        
\end{aligned}
\end{equation*}
where in the penultimate equality we used again the integration by parts, and then the symmetry.
Then, 
\begin{equation*}
\begin{aligned}
\int_0^{\pi} \log(\sin(x)) \ dx &=\int_0^{\pi} \log(2\sin(x/2)\cos(x/2)) \ dx \\
                                                &=\pi \log(2)+ \int_0^{\pi} \log(\sin(x/2)) \ dx+ \int_0^{\pi} \log(\cos(x/2)) \ dx.                                    
\end{aligned}
\end{equation*}
Letting $x/2=y$ in both integrals in the right-hand side, we obtain that 
\begin{equation*}
\begin{aligned}
\int_0^{\pi} \log(\sin(x)) \ dx &=\pi \log(2) + 2\int_0^{\pi/2} \log(\sin(x)) \ dx+2\int_0^{\pi/2} \log(\cos(x)) \ dx \\      
                                                &=\pi \log(2) + 4\int_0^{\pi/2} \log(\sin(x)) \ dx \\ 
                                                &=\pi \log(2) + 2\int_0^{\pi} \log(\sin(x)) \ dx \\                               
\end{aligned}
\end{equation*}
whence we get that
$$\int_0^{\pi} \log(\sin(x)) \ dx =-\pi\log(2).$$
Then, 
$$\int_0^{\pi/2} x^2 \cot^2(x) \ dx=\pi\log(2)-\frac{\pi^3}{24}.$$
On the other hand, the integration by parts yields that
\begin{equation*}
\begin{aligned} 
2\int_0^{\pi/2}x\cot(x) \log(\sin(x)) \ dx &=-2\int_0^{\pi/2}  (\log ^2(\sin (x))+ x \cot (x) \log (\sin (x))) \ dx \\
                                                                    &=-2\int_0^{\pi/2}  \log ^2(\sin (x)) \ dx -2\int_0^{\pi/2} x \cot (x) \log (\sin (x)) \ dx
\end{aligned}
\end{equation*}
whence we have that 
$$\int_0^{\pi/2}x\cot(x) \log(\sin(x)) \ dx=-\frac{1}{2}\int_0^{\pi/2}  \log ^2(\sin (x)) \ dx.$$
According to the trigonometric form of the beta function, we have that 
$$\int_0^{\pi/2} \sin^a(x)\cos^b(x) \ dx=\frac{1}{2}B \left(\frac{1}{2}(a+1),\frac{1}{2}(b+1)\right).$$
Differentiating $2$ times with respect to $a$ and then letting $a\to 0$ and $b\to 0$, we obtain that
\begin{equation*}
\begin{aligned} 
\int_0^{\pi/2}  \log ^2(\sin (x)) \ dx &=\frac{1}{2} \lim_{b \to 0} \lim_{a \to 0} \frac{\partial^2}{\partial a^2}\left(B \left(\frac{1}{2}(a+1),\frac{1}{2}(b+1)\right)\right) \\
                                                           &=\frac{1}{24} \left(\pi ^3+12 \pi  \log ^2(2)\right).
\end{aligned}
\end{equation*}
Thus, 
$$\int_0^{\pi/2}x\cot(x) \log(\sin(x)) \ dx=-\frac{1}{48} \left(\pi ^3+12 \pi  \log ^2(2)\right).$$
and finally our auxiliary result is proved.
$$\int_0^{\pi/2}\frac{x^2\log{(\sin(x))}}{\sin^2(x)}dx=\pi\ln{(2)}-\frac{\pi}{2}\ln^2(2)-\frac{\pi^3}{12}.$$
Now, we prove the main result, 
\begin{equation*}
\int_0^{\pi/2}\frac{x^2\log^2{(\sin(x))}}{\sin^2(x)}dx=\left(\frac{\pi ^3 }{6} +2 \pi \right)  \log (2)+\frac{1}{3} \pi  \log ^3(2)+\frac{1}{8}\pi  \zeta (3)-\frac{\pi ^3}{6}-\pi  \log ^2(2).
\end{equation*}
Applying the integration by parts, we get 
$$2\int_0^{\pi/2} x^2 \cot ^2(x) \log (\sin (x)) \ dx+2 \int_0^{\pi/2} x \cot (x) \log ^2(\sin (x)) \ dx$$
For the integral in the left side we make use of the integration by parts that yields 
$$2\int_0^{\pi/2} x^2 \cot ^2(x) \log (\sin (x)) \ dx$$
$$=2 \int_0^{\pi/2} x^3 \cot (x) \ dx + 2 \int_0^{\pi/2} x^2 \cot ^2(x) \ dx + 4\int_0^{\pi/2} x^2 \log (\sin (x)) \ dx+4  \int_0^{\pi/2} x \cot (x) \log (\sin (x)) \ dx$$
$$=\frac{2}{3} \int_0^{\pi/2} x^3 \cot (x) \ dx + 2 \int_0^{\pi/2} x^2 \cot ^2(x) \ dx +4  \int_0^{\pi/2} x \cot (x) \log (\sin (x)) \ dx$$
and since the last $2$ integrals are already compute (see the auxiliary result), we obtain 
$$\frac{2}{3} \int_0^{\pi/2} x^3 \cot (x) \ dx + 2 \int_0^{\pi/2} x^2 \cot ^2(x) \ dx +4  \int_0^{\pi/2} x \cot (x) \log (\sin (x)) \ dx$$
$$=\frac{2}{3} \int_0^{\pi/2} x^3 \cot (x) \ dx+2\pi\log(2)-\pi\log^2(2)-\frac{\pi^3}{6}$$
and integrating by parts again, we get 
$$-2\int_0^{\pi/2} x^2 \log(\sin(x)) \ dx+2\pi\log(2)-\pi\log^2(2)-\frac{\pi^3}{6}.$$
Using that $\displaystyle \log(\sin(x))=-\log(2)-\sum_{n=1}^{\infty} \frac{\cos(2 n x)}{n}$, we obtain
$$-2\int_0^{\pi/2} x^2\left(-\log(2)-\sum_{n=1}^{\infty} \frac{\cos(2 n x)}{n}\right)\ dx+2\pi\log(2)-\pi\log^2(2)-\frac{\pi^3}{6}$$
$$=2\log(2)\int_0^{\pi/2} x^2\ dx+2\int_0^{\pi/2} x^2 \sum_{n=1}^{\infty} \frac{\cos(2 n x)}{n} \ dx+2\pi\log(2)-\pi\log^2(2)-\frac{\pi^3}{6}$$
$$=2\int_0^{\pi/2} x^2 \sum_{n=1}^{\infty} \frac{\cos(2 n x)}{n} \ dx+2\pi\log(2)-\pi\log^2(2)-\frac{\pi^3}{6}+\frac{1}{12} \pi ^3 \log (2)$$
$$=2  \sum_{n=1}^{\infty} \int_0^{\pi/2} x^2 \frac{\cos(2 n x)}{n} \ dx+2\pi\log(2)-\pi\log^2(2)-\frac{\pi^3}{6}+\frac{1}{12} \pi ^3 \log (2)$$
$$=-\frac{3}{8} \pi \zeta(3)+2\pi\log(2)-\pi\log^2(2)-\frac{\pi^3}{6}+\frac{1}{12} \pi ^3 \log (2).$$
Therefore, we have that 
$$2\int_0^{\pi/2} x^2 \cot ^2(x) \log (\sin (x)) \ dx=-\frac{3}{8} \pi \zeta(3)+2\pi\log(2)-\pi\log^2(2)-\frac{\pi^3}{6}+\frac{1}{12} \pi ^3 \log (2).$$
For the remaining integral, we use the integration by parts again that yields 
$$2 \int_0^{\pi/2} x \cot (x) \log ^2(\sin (x)) \ dx=-2\int_0^{\pi/2} \log ^3(\sin (x)) \ dx-4 \int_0^{\pi/2} x \cot (x) \log ^2(\sin (x)) \ dx$$
and thus
$$2 \int_0^{\pi/2} x \cot (x) \log ^2(\sin (x)) \ dx=-\frac{2}{3}\int_0^{\pi/2} \log ^3(\sin (x)) \ dx.$$
According to the trigonometric form of the beta function, we know that
$$\int_0^{\pi/2} \sin^a(x)\cos^b(x) \ dx=\frac{1}{2}B \left(\frac{1}{2}(a+1),\frac{1}{2}(b+1)\right).$$
Differentiating $3$ times with respect to $a$ and then letting $a\to 0$ and $b\to 0$, we obtain that
\begin{equation*}
\begin{aligned} 
\int_0^{\pi/2}  \log ^3(\sin (x)) \ dx &=\frac{1}{2} \lim_{b \to 0} \lim_{a \to 0} \frac{\partial^3}{\partial a^3}\left(B \left(\frac{1}{2}(a+1),\frac{1}{2}(b+1)\right)\right) \\
                                                           &=-\frac{3 \pi }{4}\zeta (3)-\frac{1}{2} \pi  \log ^3(2)-\frac{1}{8} \pi ^3 \log (2).
\end{aligned}
\end{equation*}
Thus, 
$$2 \int_0^{\pi/2} x \cot (x) \log ^2(\sin (x)) \ dx=\frac{1}{2}\pi  \zeta (3)+\frac{1}{3} \pi  \log ^3(2)+\frac{1}{12} \pi ^3 \log (2).$$
Hence, 
$$\int_0^{\pi/2}\frac{x^2\log^2{(\sin(x))}}{\sin^2(x)}dx=\left(\frac{\pi ^3 }{6} +2 \pi \right)  \log (2)+\frac{1}{3} \pi  \log ^3(2)+\frac{1}{8}\pi  \zeta (3)-\frac{\pi ^3}{6}-\pi  \log ^2(2).$$
Q.E.D.