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
 A: When I see those fractions in the integral with the denominator of $x^2+1$, I assume that this is a backwards Weierstrass substitution.
If $x=\tan{\left(\frac{t}{2}\right)}$, then:
$$\cos{t}=\frac{1-x^2}{1+x^2}$$
$$\sin{t}=\frac{2x}{1+x^2}$$
$$\frac{2 \; dx}{1+x^2}=dt$$
You can immediately obtain
$$I=\frac{1}{2} \int_0^{\pi}  e^{\frac{2}{1+x^2}} \cos{(\sin{t})} \; dt$$
Now we must represent the exponential term in terms of $t$:
$$\frac{2}{1+x^2}=\frac{1+x^2+1-x^2}{1+x^2}=1+\frac{1-x^2}{1+x^2}=1+\cos{t}$$
And plugging this back into the integral:
$$I=\frac{e}{2} \int_0^{\pi}  e^{\cos{t}} \cos{(\sin{t})} \; dt$$
This is where you should introduce the parameter $a$ inside the integral and use differentiation under the integral sign.  Determining where to introduce $a$ to easily evaluate the integral takes some intuition and guesses, which I won't show here:
$$I(a)=\frac{e}{2} \int_0^{\pi}  e^{a\cos{t}} \cos{(a\sin{t})} \; dt$$
Differentiating with respect to $a$:
$$I'(a)=\frac{e}{2} \int_0^{\pi}  e^{a\cos{t}} \left( \cos{t}\cos{(a\sin{t})}-\sin{t}\sin{(a\sin{t})}\right) \; dt$$
You should notice that this integral is:
$$I'(a)=\frac{e}{2} \int_0^{\pi}  \frac{d}{dt} \left( \frac{1}{a} \cdot e^{a\cos{t}} \sin{(a\sin{t})} \right) \; dt$$
$$I'(a)=\frac{e}{2a} \left( e^{a\cos{t}} \sin{(a\sin{t})} \right) \big \rvert_0^{\pi}=0$$
This means that $I(a)=C$, where $C$ is some constant.  To determine $C$, let $a=0$:
$$I(0)=\frac{e}{2}\int_0^{\pi} 1 \; dt = \frac{e \pi}{2}$$
In conclusion,
$$I(1)=\boxed{\frac{e \pi}{2}}$$
A: Once we reach
$$ I=\frac{e}{2}\int_{0}^{\pi}e^{\cos t}\cos(\sin t)\,dt $$
we may easily exploit power series:
$$\begin{eqnarray*} I &=& \frac{e}{2}\text{Re}\int_{0}^{\pi}\exp\left(\cos t+i\sin t\right)\,dt\\&=&\frac{e}{2}\text{Re}\int_{0}^{\pi}\exp(e^{it})\,dt\\&=&\frac{e}{2}\text{Re}\sum_{n\geq 0}\frac{1}{n!}\int_{0}^{\pi}e^{ni\theta}\,d\theta\end{eqnarray*} $$
and notice that $\int_{0}^{\pi}e^{ni\theta}\,d\theta$ is purely imaginary for any odd $n$, zero for any even $n\geq 2$ and equal to $\pi$ for $n=0$.
$$ I = \frac{\pi e}{2} $$
readily follows.
A: 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).$$
