Integrate $\int_0^{\infty} \frac{e^{\frac{2}{1+x^2}} \cos{\left(\frac{2x}{1+x^2}\right)}}{x^2+1} \mathop{dx}$ A challenge problem $$\int_0^{\infty} \frac{e^{\frac{2}{1+x^2}} \cos{\left(\frac{2x}{1+x^2}\right)}}{x^2+1} \mathop{dx}$$
Someone said that differentiation in the integral should be used, I dont know how? I try $u=\frac{1}{x^2+1}$, $u=\frac{x}{1+x^2}$, and others but I am confused and want help.  Thanks

Expanding on my comment, the integrand is the real part of the complex function $$f(z) = \frac{\exp \left(\frac{2}{1-iz} \right)}{1+z^{2}}. $$
And by letting $z= x+iy$, we find that the real part of $\frac{2}{1-iz}$ is $$\frac{2(y+1)}{x^{2}+(y+1)^{2}}.$$
Therefore, in the upper half of the complex plane, the magnitude of $\exp \left(\frac{2}{1-iz} \right) $ is less than $e^{2}$.
So by integrating $f(z)$ around a contour that consists of the real axis and the infinitely large semicircle above it, it follows that  $$ \int_{-\infty}^{\infty} f(x) \, \mathrm dx = 2\pi i \operatorname{Res} \left[f(z), i \right] = 2\pi i \left( \frac{e}{2i} \right)= \pi e.$$
Now just equate the real parts on both sides of the equation.

In general, we have $$\int_{0}^{\infty} \frac{\exp \left(\frac{a}{1+x^{2}} \right) \cos \left(\frac{ax}{1+x^{2}} \right)}{b^{2}+x^{2}} \, \mathrm dx = \frac{\pi}{2b} \exp \left(\frac{a}{1+b} \right), \quad \left(a \in \mathbb{R}, \ b > 0 \right).$$

The same approach using the fact that $$\lim_{R \to \infty} \int_{R \exp \left(i[0, \pi] \right)} \frac{z \exp \left( \frac{az}{1-iz}\right)}{b^{2}+z^{2}} = \pi i $$ shows that $$\int_{0}^{\infty} \frac{x \exp \left(\frac{a}{1+x^{2}} \right) \sin\left(\frac{ax}{1+x^{2}} \right)}{b^{2}+x^{2}} \, \mathrm dx = \frac{\pi}{2} \left( \exp \left(\frac{a}{1+b} \right)-1 \right), \quad \left(a \in \mathbb{R}, \ b \ge 0 \right).$$
