Integrate $\frac{\theta \sin \theta}{1+\cos^2 \theta}$ with respect to $\theta$

$$I=\int_0^\pi \frac{\theta \sin \theta}{1+\cos^2 \theta} d\theta\tag 1$$ Using property of definite integral: $\int_a^bf(x)dx=\int_a^bf(a+b-x)dx$, $$I=\int_0^\pi \frac{(\pi-\theta) \sin \theta}{1+\cos^2 \theta} d\theta\tag 2$$ Adding (1) and (2), $$2I=\int_0^\pi \frac{\pi \sin \theta}{1+\cos^2 \theta} d\theta$$ $$I=\frac{\pi}{2}\int_0^{\pi} \frac{ \sin \theta \ d\theta}{1+\cos^2 \theta} $$ $$I=- \pi\int_0^{\pi/2} \frac{ d(\cos \theta)}{1+\cos^2 \theta} $$ $$I=-\pi\left[\tan^{-1}\left(\cos\theta\right)\right]_0^{\pi/2}$$ $$=\frac{\pi^2}{4}$$


Here's a trick which I use always with integrals involving trigonometric functions : $$\int_\alpha^\beta \varphi (\xi) d\xi=\int_\alpha^\beta \varphi (\alpha +\beta-\xi) d\xi$$ The proof is trivial and left for you as an exercise, lol!

Anyway, applying this technique to this integral :

Let $$I=\int_0^\pi \frac{x\sin x}{1+\cos^2x}dx$$ We'll have after applying this formula : \begin{align} I&=\int_0^\pi \frac{(\pi-x)\sin (\pi-x)}{1+\cos^2(\pi-x)} dx\\ 2I&=\int_0^\pi \frac{x\sin x}{1+\cos^2x} + \frac{(\pi-x)\sin (\pi-x)}{1+\cos^2(\pi-x)}dx\\ I&=\frac{1}2\int_0^\pi \frac{x \sin x+\pi \sin x-x\sin x}{1+\cos^2x}\\ &=\frac{1}2\int_0^\pi \frac{\pi \sin x}{1+\cos^2x}\\ &=\frac{\pi}2\int_0^\pi \frac{ \sin x}{1+\cos^2x} \end{align} Now using the substitution you did earlier $$ u=\cos x \Leftrightarrow du=-\sin x$$ So ; \begin{align} I&=\frac{\pi}2\int_1^{-1} \frac{-du}{1+u^2}\\ &=\frac{\pi}2\int_{-1}^{1} \frac{du}{1+u^2}\\ &=\frac{\pi}2 \arctan u\bigg\vert_{-1}^1\\ &=\frac{\pi}2 \bigg(\frac{\pi}4 +\frac{\pi}4\bigg)\\ &=\frac{\pi^2}{4} \end{align} Hence as @PeterForeman said your integral is : $\displaystyle \frac{\pi^2}{4}$

By the way, if you want the proof of the formula, all that you have to do is : $$\xi=\alpha +\beta-u \Leftrightarrow d\xi=-du$$ Therefore;

$$\int_\beta^\alpha \varphi (\alpha+\beta-u) (-du)=\int_\alpha^\beta \varphi (\alpha +\beta-\xi) d\xi$$


Another really cool way of getting the answer is from infinite series!!!!

Notice that

$${\frac{1}{1+\cos^2(x)}=\sum_{n=0}^{\infty}\left(-\cos^2(x)\right)^n}$$

And so

$${\int_{0}^{\pi}\frac{x\sin(x)}{1+\cos^2(x)}dx=\int_{0}^{\pi}x\sin(x)\sum_{n=0}^{\infty}\left(-\cos^2(x)\right)^ndx}$$

After interchanging a few things around, the integral becomes

$${=\sum_{n=0}^{\infty}(-1)^n\int_{0}^{\pi}x\sin(x)\cos^{2n}(x)dx}$$

If we use integration by parts on the inner integral, with ${dv=\sin(x)\cos^{2n}(x)dx}$ and ${u=x}$ you end up with

$${\int_{0}^{\pi}(-1)^nx\sin(x)\cos^{2n}(x)dx=(-1)^n\left(\left(x\frac{-\cos^{2n+1}(x)}{2n+1}\right)_{x=0}^{x=\pi} + \frac{1}{2n+1}\int_{0}^{\pi}\cos^{2n+1}(x)dx\right)}$$

The rightmost integral will always be zero, and so we just end up with

$${=\frac{(-1)^n\pi}{2n+1}}$$

Hence overall

$${\int_{0}^{\pi}\frac{x\sin(x)}{1+\cos^2(x)}dx=\pi \sum_{n=0}^{\infty}\frac{(-1)^n}{2n+1}}$$

The infinite sum is just the Leibniz infinite series for ${\frac{\pi}{4}}$. So

$${=\pi\frac{\pi}{4}=\frac{\pi^2}{4}}$$