Computation of an integral using residue theorem. 
Using residue theorem compute the following integral $$\int_{-\infty}^{\infty} \frac {e^{\frac {x} {2}}} {1 + e^x}\ dx.$$

I have tried to proceed by the method of substitution by taking $y = e^{\frac {x} {2}}.$ Then $dy = \frac {1} {2} e^{\frac {x} {2}}\ dx$ i.e. $e^{\frac {x} {2}}\ dx = 2\ dy.$ Then the limit of integration becomes $0$ to $\infty.$ So by this substitution the integral becomes $$2 \int_{0}^{\infty} \frac {dy} {1 + y^2} = 2 \lim\limits_{x \to \infty} \arctan x = \pi.$$
By residue theorem how to deal with the same integral? Any help in this regard would be much appreciated.
Thanks for your time.
 A: Starting from your result, we have that
$$2\int_{[0,\infty)}\frac{1}{1+y^2}dy=\int_{\mathbb{R}}\frac{1}{1+z^2}dz$$
Consider the half-disk of radius $R$, which we call $C_R$; by the residue theorem
$$\int_{C_R}\frac{1}{1+z^2}dz=2\pi i\, \textrm{Res}\bigg(\frac{1}{1+z^2},i\bigg)$$
$$\textrm{Res}\bigg(\frac{1}{1+z^2},i\bigg)=\lim_{z \to i}(z-i)\frac{1}{(z-i)(z+i)}=-\frac{1}{2}i$$
$$\int_{C_R}\frac{1}{1+z^2}dz=\pi$$
We may want to estimate the integral on the semicircle $\Gamma_R$.
$$\bigg|\int_{\Gamma_R}\frac{1}{1+z^2}dz\bigg|\leq \pi R \max_{z \in \Gamma_R}\bigg|\frac{1}{1+z^2}\bigg|$$
$$\bigg|\int_{\Gamma_R}\frac{1}{1+z^2}dz\bigg|\leq \pi R \frac{1}{R^2-1}\stackrel{R \to \infty}{\rightarrow} 0$$
Since
$$\int_{[-R,R]}\frac{1}{1+y^2}dy=\int_{C_R}\frac{1}{1+z^2}dz-\int_{\Gamma_R}\frac{1}{1+z^2}dz$$
in the limit we obtain the desired result.
A: The function has poles at
$$e^z = -1 \implies z = i\pi + i2\pi k \hspace{12 pt} k\in\Bbb{Z}$$
So choose $C$ to be rectangle with corners $z=\pm R, \pm R + 2\pi i $ and integrate
$$\int_{C_R}f(z)\:dz = \int_{-R}^R f(x)\:dx + \int_0^{2\pi}f(R+iy)\:idy + \int_R^{-R}f(x+2\pi i)\:dx + \int_{2\pi}^0f(-R+iy)\:idy$$
$$=2\pi i \sum_z \operatorname{Res}_z(f) = 2\pi i\operatorname{Res}_{i\pi}(f)$$
$f(x+2\pi i) = -f(x)$, so in the limit the two long sides add and the short sides vanish
$$\lim_{R\to\infty}\int_{C_R}f(z)\:dz = 2 \int_{-\infty}^\infty f(x)\:dx = 2\pi i\lim_{z\to i\pi}\frac{(z-i\pi)e^{\frac{z}{2}}}{1+e^z} = 2\pi i \cdot -i = 2\pi$$
Thus we have
$$\implies \int_{-\infty}^\infty f(x)\:dx = \pi$$
A: alternatively:
$$\int\limits_{\mathbb R}\frac{e^{x/2}}{1+e^{x}}dx=\int\limits_{\mathbb R}\frac{dx}{e^{x/2}+e^{-x/2}}$$
making the substitution $u=x/2\Rightarrow dx=2du$ we get:
$$2\int\limits_{\mathbb R}\frac{du}{e^u+e^{-u}}=\int\limits_{\mathbb R}\operatorname{sech}(u)\,du=\pi$$

Or as others have said make the substitution $u=e^{x/2}$ and you will get something in terms of $\arctan$
