Evaluate $\int_0^{\pi} \frac{x \sin x}{1+\cos ^2 x}dx$ Find $$\int_0^{\pi} \frac{x \sin x}{1+\cos ^2 x}dx$$ by hand. I'm aware Mathematics gives $\frac{\pi^2}{4}$, but I need to learn this without the aid of Mathematica. I tried using substitutions like $u= \tan \frac{x}{2}$ and some trig identities, but I still can't work this out.
 A: Let $$f(x)=\frac{\sin x}{{1+\cos^2x}}=\frac{\sin x}{{2-\sin^2x}}.$$ 
Note that $$f(π-t)=f(t).$$
Using $x=\pi-t$, 
$$\begin{align}I&=\int_{0}^{\pi} xf(x) dx\\&=\int_{0}^{\pi} (π-t) f(π-t) (-dt)
 \\&=\int_{0}^{\pi} (π-t) f(t) dt 
 \\&=π\int_{0}^{\pi} f(t) dt-\int_{0}^{\pi}tf(t) dt
 \\&=π\int_{0}^{\pi}f(t) dt-I.\end{align}$$
Hence, we have
$$2I=π\int_{0}^{\pi}f(t) dt.$$
Also, since the graph of $y=f(t)$ is symmetric with $x=π/2$, 
$$\int_{0}^{\pi}f(t) dt=2\int_{0}^{{\pi}/{2}} f(t) dt.$$
Hence,
$$I=π\int_{0}^{{\pi}/{2}} f(t) dt.$$
Here, using $\cos t =u$,
$$\begin{align}I=π\int_{1}^{0} \frac{\sin t}{{1+\cos^2t}} \left(\frac{-du}{\sin t}\right)
 =π\int_{0}^{1} \frac{1}{1+u^2} du=\frac{{\pi}^2}{4}. \end{align}$$
So, we know that we can get the answer you wrote.
A: There is an nice little result that says that $$\int_0^\pi xf(\sin x)dx=\frac{\pi}2\int_0^\pi f(\sin x)dx$$
Can you prove it? Then, it all comes down to using the chain rule.
A: $$
\begin{align}
\int_0^\pi\frac{x\sin(x)}{1+\cos^2(x)}\,\mathrm{d}x
&=-\int_0^\pi\frac{x}{1+\cos^2(x)}\,\mathrm{d}\cos(x)\tag{1}\\
&=-\int_0^\pi x\,\mathrm{d}\arctan(\cos(x))\tag{2}\\
&=-x\arctan(\cos(x))\Big]_0^\pi+\int_0^\pi\arctan(\cos(x))\,\mathrm{d}x\tag{3}\\
&=\frac{\pi^2}{4}+\int_{-\pi/2}^{\pi/2}\arctan(\sin(x))\,\mathrm{d}x\tag{4}\\
&=\frac{\pi^2}{4}\tag{5}
\end{align}
$$
Justification:
$(1)$: $\mathrm{d}\cos(x)=-\sin(x)\,\mathrm{d}x$
$(2)$: $\mathrm{d}\arctan(u)=\frac1{1+u^2}\mathrm{d}u$
$(3)$: integration by parts
$(4)$: substitute $x\mapsto\frac\pi2-x$
$(5)$: integral of an odd function over a symmetric domain is $0$
A: I prove lemma that says that $$\int_0^\pi xf(\sin x)dx=\frac{\pi}2\int_0^\pi f(\sin x)dx$$
let $t=\pi-x$,so
\begin{align*}
\int_0^\pi xf(\sin x)dx&=\int_\pi^0(\pi-t)f(\sin(\pi-t))(-dt)=\int_0^\pi(\pi-t)f(\sin t)dt\\
&=\pi\int_0^\pi f(\sin t)dt-\int_0^\pi tf(\sin t)dt
\end{align*}
so
$$\int_0^\pi xf(\sin x)dx=\dfrac{\pi}{2}\int_0^\pi f(\sin x)dx$$
Finally
\begin{align*}
 \int_0^{\pi} \frac{x \sin x}{1+\cos ^2 x}dx&=\dfrac{\pi}{2}\int_0^\pi\frac{ \sin x}{1+\cos ^2 x}dx=-\dfrac{\pi}{2}\int_0^{\pi}\frac{1}{1+\cos ^2 x}d\cos x\\
&=-\dfrac{\pi}{2}\arctan\cos x\Bigg|_0^\pi=\dfrac{\pi^2}{4}
\end{align*}
A: HINT:
use $$I=\int_a^bf(x)dx=\int_a^bf(a+b-x)dx$$
so that $$2I=\int_a^bf(x)dx+\int_a^bf(a+b-x)dx=\int_a^b\{f(x)+f(a+b-x)\}dx$$
using $\sin(\pi+0-x)=\sin x$ and  $\cos(\pi+0-x)=-\cos x$
