Integrating $\int_0^\pi \frac{x\cos x}{1+\sin^2 x}dx$ I am working on $\displaystyle\int_0^\pi \frac{x\cos x}{1+\sin^2 x}\,dx$
First: I use integrating by part then get 
$$ x\arctan(\sin x)\Big|_0^\pi-\int_0^\pi \arctan(\sin x)\,dx $$
then I have $\displaystyle -\int_0^\pi \arctan(\sin x)\,dx$ because $x\arctan(\sin x)\Big|_0^\pi$ is equal to $0$
However, I don't know how to integrate $\displaystyle -\int_0^\pi \arctan(\sin x)\,dx$
Can someone give me a hint?
Thanks
 A: Here is another approach.
The idea, in order to evaluate
$$
\int_0^{\pi}\frac{x \cos{x}}{1+\sin^2{x}} {\rm d}x ,
$$
is to start with a Fourier series expansion of $\displaystyle \frac{1}{1+\sin^2{x}} $. 
For $0\leq x \leq\pi$, we easily obtain
$$\begin{align}
 \frac{1}{1+\sin^2{x}} &= \Re \frac{1}{1-i\sin{x}}\\\\
&=  \Re \frac{2e^{ix}}{2-(e^{ix}-1)^2}\\\\
 &=  \frac{\sqrt{2}}{2}+\frac{\sqrt{2}}{2}\sum_{n=2}^{\infty}\left(\sqrt{2}-1\right)^n(1+(-1)^n)\cos (nx) \tag2
\end{align}
$$
The series in $(2)$ is normally convergent on $[0,\pi]$, we are then allowed to integrate termwise:
$$
\int_0^{\pi}\frac{x \cos{x}}{1+\sin^2{x}} {\rm d}x =\frac{\sqrt{2}}{2}\sum_{n=2}^{\infty}(\sqrt{2}-1)^n(1+(-1)^n)\!\!\int_0^{\pi}\!\! x\cos{x}\cos (nx)x \:{\rm d}x. \tag3
$$
The latter integral is classic, we write $$ 2\cos{x}\cos (nx)=\cos((n+1)x)+\cos((n-1)x)$$ then integrate twice by parts to get
$$
-2\int_0^{\pi} x\cos{x}\cos (nx)x \:{\rm d}x=\frac{1}{(n+1)^2}+\frac{1}{(n-1)^2},\quad n=2,3,\ldots. \tag4
$$
It is easy to see that
$$
\sum_{n=2}^{\infty}(1+(-1)^n)\left(\frac{x^n}{(n+1)^2}+\frac{x^n}{(n-1)^2}\right)=\left(x+\frac1x\right)\left({\rm{Li}}_2(x)-{\rm{Li}}_2(-x)\right), \quad |x|<1,
$$ where ${\rm{Li}}_2(\cdot)$ is the dilogarithm function.
Now, putting $x:= \sqrt{2}-1$ in the preceding identity and using the following closed form  $$\rm{Li}_2{(\sqrt{2}-1)}-\rm{Li}_2{(-(\sqrt{2}-1))} = \frac{\pi^2}{8} - \frac12 \log^2{(\sqrt{2}+1)}, \tag5$$ as previously explaned by Ron Gordon, gives easily

$$
\int_0^{\pi}\frac{x \cos{x}}{1+\sin^2{x}} {\rm d}x =\log^2{(\sqrt{2}+1)}-\frac{\pi^2}{4}.
$$

A: Split the integral at $\dfrac{\pi}{2}$, we get 
$\displaystyle \begin{align} \int_0^\pi \frac{x\cos x}{1+\sin^2 x}\,dx &= \int_0^{\pi/2} \frac{x\cos x}{1+\sin^2 x}\,dx + \int_{\pi/2}^{\pi} \frac{x\cos x}{1+\sin^2 x}\,dx \\ & = \int_0^{\pi/2} \frac{x\cos x}{1+\sin^2 x}\,dx - \int_0^{\pi/2} \frac{(x+\pi/2)\sin x}{1+\cos^2 x}\,dx \\ &= 2\int_0^{\pi/2} \frac{x\cos x}{1+\sin^2 x}\,dx - \pi\int_0^{\pi/2} \frac{\cos x}{1+\sin^2 x}\,dx  \\ &= 2\int_0^{\pi/2} \frac{x\cos x}{1+\sin^2 x}\,dx - \frac{\pi^2}{4}\end{align}$
At this point we can write the above integral:
$\displaystyle \int_0^{\pi/2} \frac{x\cos x}{1+\sin^2 x}\,dx = \frac{\pi^2}{8} - \int_0^{\pi/2} \tan^{-1} \sin x \,dx$
The later can be evaluated in many ways. See for example Here.
See integral representations of Legendre $\chi$-function.
Also sos440 blog entry has a very nice solution to the problem.
A: Let be
$$\begin{align} I=\int_0^\pi \frac{x\cos x}{1+\sin^2 x}\operatorname{d}x&=-\int_0^\pi \arctan(\sin x)\operatorname{d}x \\
&=-2\int_0^{\pi/2} \arctan(\sin x)\operatorname{d}x\\
&=-2\int_0^1\frac{\arctan t}{\sqrt{1-t^2}}\operatorname{d}t
\end{align}$$
Let $$ \displaystyle I(a) = \int_{0}^{1} \frac{\arctan at}{\sqrt{1-t^{2}}} \ dt.$$
Differentiating under the integral, 
$$ \begin{align}  I'(a) &= \int_{0}^{1} \frac{t}{(1+a^{2}t^{2})\sqrt{1-t^{2}}} \ dt \\ &=  \frac{1}{a \sqrt{1+a^{2}}} \text{arctanh} \left( \frac{a}{\sqrt{1+a^{2}}} \right)\\ 
&= \frac{1}{a \sqrt{1+a^{2}}} \text{arcsinh}(a) . 
\end{align}$$
Integrating back,
$$ \begin{align} I(1)-I(0) = I(1) &= \int_{0}^{1} \frac{\text{arcsinh}(a)}{a \sqrt{1+a^{2}}} \ da \\ &= - \text{arcsinh}(a) \text{arcsinh}(\frac{1}{a}) \Big|^{1}_{0} + \int_{0}^{1} \frac{\text{arcsinh}(\frac{1}{a})}{\sqrt{1+a^{2}}} \ da \\ &= - \text{arcsinh}^{2}(1) +  \int_{0}^{1} \frac{\text{arcsinh}(\frac{1}{a})}{\sqrt{1+a^{2}}} \ da \\ &= - \ln^{2}(1+\sqrt{2}) + \int_{0}^{1} \frac{\text{arcsinh}(\frac{1}{a})}{\sqrt{1+a^{2}}} \ da . \end{align}$$
Now let $ \displaystyle w = \frac{1}{a}$.
Then
$$ I(1) = - \ln^{2}(1+\sqrt{2}) + \int_{1}^{\infty} \frac{\text{arcsinh}(w)}{w \sqrt{1+w^{2}}}$$
$$ =  - \ln^{2}(1+\sqrt{2}) + I(\infty) - I(1) .$$
Therefore,
$$ \begin{align} I(1) &= - \frac{\ln^{2}(1+\sqrt{2})}{2} + \frac{I(\infty)}{2} \\ &= - \frac{\ln^{2}(1+\sqrt{2})}{2} + \frac{\pi}{4} \int_{0}^{1} \frac{1}{\sqrt{1-t^{2}}} \ dt \\ &= - \frac{\ln^{2}(1+\sqrt{2})}{2} + \frac{\pi^{2}}{8} . \end{align}$$
Finally
$$\color{blue}{\int_0^\pi \frac{x\cos x}{1+\sin^2 x}\operatorname{d}x=-2I(1)=\ln^{2}(1+\sqrt{2})-\frac{\pi^{2}}{4}.}$$
