# Using contour integration to solve this integral

We need to use contour integration to solve $$\int_{-\infty}^\infty {e^{ax}\over e^x+1}dx$$ given that $0<a<1$. My question is about what contour to use, knowing that the singularities are at $z=i(2n+1)\pi$. I tried the standard D-shaped contour in the upper half plane, but I'm not being able to show that the integral will vanish along the semi circular curve as R goes to infinity.

We consider the analytic function $$F(z)=\frac {e^{az} }{e^{z} + 1}$$ on the rectangle contour of $C\cup C'\cup \gamma_1\cup \gamma_2$, where $C$ is $x$-axis from $-R$ to $R$, $C'$ is horizontal line from $R+2\pi i$ to $-R+2\pi i$, $\gamma_1$ is vertical line from $R$ to $R+2\pi i$ and $\gamma_2$ is vertical line from $-R+2\pi i$ to $-R$. By Cauchy's residue theorem, we have $$\int_{-R}^RF(x)dx+\int_{C'}F(z)dz+\int_{\gamma_1}F(z)dz+\int_{\gamma_2}F(z)dz=2\pi iRes\left(F,\pi i\right)\tag1$$ Note that only pole in the contour is $z=\pi i$. Since $$Res\left(F,\pi i\right)=\lim_{z\to \pi i}(z-\pi i)F(z)=\lim_{z\to \pi i}\frac{e^{az}}{(e^{z}+1)'}=-e^{a\pi i}\tag2$$ We have $$\int_{C'}F(z)dz=\int_R^{-R}\frac{e^{a(x+2\pi i)}}{e^{x+2\pi i}+1}\:dx=-e^{2a\pi i}\int_{-R}^{R}\frac{e^{ax}}{e^{x}+1}\:dx$$ Along with $$\left|\int_{\gamma_1}F(z)dz\right|=\left|\int_{0}^{2\pi}\frac{e^{a(R+iy )}}{e^{(R+iy)}+1}idy\right|\leqslant \int_{0}^{2\pi}\frac{|e^{a(R+iy )}|}{|e^{(R+iy)}|-1}dy\leqslant \frac{2\pi e^{a R}}{e^{R}-1}\to0$$ as $R\to\infty$. And $$\left|\int_{\gamma_2}F(z)dz\right|=\left|-\int_{0}^{2\pi}\frac{e^{a(-R+iy )}}{e^{(-R+iy)}+1}idy\right|\leqslant \int_{0}^{2\pi}\frac{|e^{a(-R+iy )}|}{|e^{(-R+iy)}|-1}dy\leqslant \frac{2\pi e^{-a R}}{1-e^{-R}}\to0$$ as $R\to\infty$. So by $(1),(2)$ $$\lim_{R\to\infty}(1-e^{2a\pi i})\int_{-R}^{R}\frac{e^{ax}}{e^{x}+1}\:dx=-2\pi ie^{a\pi i}$$ i.e. $$\int_{-\infty}^{\infty}\frac{e^{ax}}{e^{x}+1}\:dx=-\frac{2\pi ie^{a\pi i}}{1-e^{2a\pi i}}=\frac{2\pi i}{e^{a\pi i}-e^{-a\pi i}}=\frac{\pi}{\sin {a\pi}}$$ Edit: This contour can also apply to solve the following integral: $$\int_{0}^{\infty}\frac{x^{a-1}}{x+1}\:dx=\frac{\pi}{\sin {a\pi}}$$ with substitution of $x=e^t$. The advantage is that the contour is rectangle and avoid the keyhole in the circle contour often used.