Integrals from Brasilian Math Olympiad 2019

$$\int_1^2\frac{e^x(x-1)}{x(x+e^x)}dx=\int_1^2 \frac{e^x\left(\frac{1}{x}-\frac{1}{x^2}\right)}{1+\frac{e^x}{x}}dx=\ln\left(1+\frac{e^x}{x}\right)\bigg|_1^2 =\ln\left(\frac{1+\frac{e^2}{2}}{1+e}\right)$$


For the second one, let $\frac{\pi}{2}-x=t$ to get: $$\mathcal J=\int_0^{\pi/2}\frac{x\sin(2x)}{1+\cos^2(2x)}dx=\int_{\pi/2}^0 \frac{\left(\frac{\pi}{2}-t\right)\sin(2t)}{1+\cos^2(2t)}(-dt)\overset{t=x}=\int_0^\frac{\pi}{2}\frac{\left(\frac{\pi}{2}-x\right)\sin(2x)}{1+\cos^2(2x)}dx$$ Now add them up to get: $$2\mathcal J=\frac{\pi}{2}\int_0^\frac{\pi}{2}\frac{\sin(2x)}{1+\cos^2(2x)}dx\Rightarrow \mathcal J=-\frac{\pi}{8}\arctan(\cos(2x))\bigg|_0^\frac{\pi}{2}=\frac{\pi^2}{16}$$


For the second integral, use $\int_a^bf(x) = \int_a^bf(a+b-x)$ and add these together to get $I =$$ \int_0^\frac\pi2 {\frac \pi4\sin(2x)\over1+\cos(2x)^2}$. Substituting with $\cos(2x) = t$ gives the solution easily.


Hint: $$\int \frac {2\sin (2x)}{1+\cos^2(2x)}dx=-\arctan (\cos(2x))$$ (you can show this by substitution)