TITLE: Integral: $\int_0^{\pi} \frac{x}{x^2+\ln^2(2\sin x)}\,dx$
QUESTION [24 upvotes]: I am trying to solve the following by elementary methods:
$$\int_0^{\pi} \frac{x}{x^2+\ln^2(2\sin x)}\,dx$$

I wrote the integral as:
$$\Re\int_0^{\pi} \frac{dx}{x-i\ln(2\sin x)}$$
But I don't find this easier than the original integral. I have seen solutions which make use of complex analysis but I am interested in elementary approaches. 
Any help is appreciated. Thanks!

REPLY [25 votes]: Here is an approach without using contour integration (Cauchy's theorem).
I've found the following result.

Theorem. Let $a$ be any real number. 
Then
  $$
\begin{align} 
  \displaystyle \int_{0}^{\pi} \frac{x}{x^2+\ln^2(2 e^{a} \sin x)}\mathrm{d}x 
  & = \, \frac{2 \pi^2}{\pi^2+4a^2},\tag1\\\\ 
  \int_{0}^{\pi} \frac{\ln(2 e^{a} \sin x)}{x^2+\ln^2(2 e^{a} \sin x)}\mathrm{d}x & =  \frac{4\pi a}{\pi^2+4a^2}.\tag2
\end{align} 
$$

from which, by putting $a=0$, you deduce the evaluation of the desired integral:

Example $1 (a)$. $$ \begin{align}
\int_{0}^{\pi} \frac{x}{x^2+\ln^2(2 \sin x)}\:\mathrm{d}x 
  & = 2 \tag3
\end{align}
$$

and 

Example $1 (b)$. $$ \begin{align}
\int_{0}^{\pi} \frac{\ln(2\sin x)}{x^2+\ln^2(2\sin x)}\mathrm{d}x& = 0. \\ \tag4
\end{align}
$$

Proof of the Theorem. We consider throughout the principal value of $\log(z)$ defined for $z\neq 0$ by
$$
\log(z)= \ln |z| + i \arg z, \,  - \pi < \arg z \leq \pi,
$$
where $\ln$ is the base-$e$ logarithm $\ln e = 1$.
Let $a$ be any real number. Since $\displaystyle z \mapsto i \pi/2+a+\log(1+z) $ is analytic on $|z| < 1$ non-vanishing at the point $z=0$, one may obtain the following power series expansion
$$
\begin{align} 
\displaystyle \frac{1}{i \pi/2+a+\log \left(1+z\right)} - \frac{1}{i \pi/2+a}
= \sum_{n=1}^{\infty} \displaystyle \frac{a_n(\alpha)}{n!} z^n,\tag5
\end{align}
$$  with
$$  \displaystyle a_1(\alpha) = -\alpha^2,  
\quad a_2(\alpha) = \alpha^3+\alpha^2/2, \, ... ,
$$
$\displaystyle {a}_n(\cdot)$ being a polynomial of degree $n+1$ in  $\displaystyle \alpha$,
 where we have set $\displaystyle \alpha:=1/(i \pi/2+a)$. 
Plugging $z=-e^{2ix}$ in $(3)$, for $0<x<\pi$, 
noticing 
$$
i x +\ln(2e^{a} \sin x) = \log\left(ie^{a}\left(1-e^{2ix} \right) \right),
$$
separating real and imaginary parts, gives the Fourier series expansions:
$$
\begin{align} 
\displaystyle \frac{x}{x^2 +\ln^2(2e^{a}\sin x)}
 & =  \frac{2\pi}{\pi^2+4a^2}+  \sum_{n=1}^{\infty}(-1)^n \left( \frac{a_n^{-}(\alpha)}{n!} \cos (2nx)+\frac{a_n^{+}(\alpha)}{n!} \sin (2nx)\right)
\\ \frac{\ln(2e^{a}\sin x)}{x^2 +\ln^2(2e^{a}\sin x)}
 & =  \frac{4a}{\pi^2+4a^2}+  \sum_{n=1}^{\infty}(-1)^n \left( \frac{a_n^{+}(\alpha)}{n!} \cos (2nx)-\frac{a_n^{-}(\alpha)}{n!} \sin (2nx)\right)
\end{align}
$$ with $\displaystyle a_n^{+}(\alpha):= {\mathfrak{R}}a_n(\alpha)$ and $\displaystyle a_n^{-}(\alpha):= {\mathfrak{I}}a_n(\alpha)$.
Now, a termwise integration with respect to $x$ from 0 to $\pi$, justified by the convergence of the series $\sum_{n=1}^{\infty} \displaystyle \frac{a_n(\alpha)}{n!}  $, leads to the Theorem due to 
$$
\begin{align} 
\displaystyle \int_{0}^{\pi} \cos(2nx)\:\mathrm{d}x = \int_{0}^{\pi} \sin(2nx)\:\mathrm{d}x = 0.
\end{align}
$$

One may observe that, by uniqueness of the Fourier coefficients, you have the following closed forms.

Example $2 (a)$.
  $$
\begin{align}
\int_{0}^{\pi} \frac{x}{x^2+\ln^2(2 \sin x)}\cos^{2} x \:\mathrm{d}x 
  & = 1,  \tag6 \\ 
  \int_{0}^{\pi} \frac{x}{x^2+\ln^2(2 \sin x)}\sin^{2} x\:\mathrm{d}x & =  1. \tag7
\end{align} 
$$

$$
$$

Example $2 (b)$.
  $$
\begin{align}
  \int_{0}^{\pi} \frac{\ln(2 \sin x)}{x^2+\ln^2(2 \sin x)} \cos^{2} x \:\mathrm{d}x 
  & = -\frac{1}{\pi},  \tag8 \\ 
  \int_{0}^{\pi} \frac{\ln(2 \sin x)}{x^2+\ln^2(2 \sin x)}\sin^{2} x\:\mathrm{d}x & = \frac{1}{\pi}. \tag9
\end{align} 
$$

A general result does exist.