# Evaluating a real integral using complex analysis

I need to evaluate the following (real) integral using complex contour integration:

$$I=\int_{-\infty}^{\infty} \frac{{e}^{ax}}{e^x+1}dx , 0<a<1$$

I've tried to use a semicircle as a contour, i.e. splitting the complex integral $\int_{\gamma} \frac{{e}^{az}}{e^z+1}dz$ to the integral over $C_R(t)=Re^{it}, 0\le t\le \pi$ and the integral over $[-R,R]$.

I've noticed that the integral over $C_R$ goes to 0 when R goes to $\infty$, so $I=\int_{\gamma} \frac{{e}^{az}}{e^z+1}dz$. Given R, I may calculate the complex integral using the residues of the function, i.e. the zeros of the denominator. I've found that each zero is of the form $(\pi + 2\pi\mathbb Z)i$, but of-course, I would focus only on non-negative numbers (because I need the zeros be in my region). So, when R goes to $\infty$, I would expect $I$ to be $2\pi i\sum_{n=0}^{\infty} Res_{z_n} \frac{{e}^{az}}{e^z+1}$ for $z_n=(\pi + 2\pi n)i$.

According to a theorem, I may calculate the residue of $z_n$ by $\frac{{e}^{az}}{(e^z+1)'}\Biggl|_{z=z_n}=-e^{a(\pi +2\pi n)i}$.

I cannot finish the solution, how would I simplify the residues and calculate the sum?

No, that's not what you're using in those cases. In the complex domain, $e^z$ (and thus $1/(e^z+1)$) is periodic with period $2\pi i$, so your closed contour is from $-\infty$ to $+\infty$ along the real axis, and back from $+\infty+2\pi i$ to $-\infty+2\pi i$, with just one singularity at $z=\pi i$ inside (strictly speaking, it would be a rectangle, with the vertical contributions vanishing in the limit, but I guess you know the drill). So we have (since for $z=x+2\pi i$, $e^{az}=e^{2\pi a i}e^{ax}$) $$(1-e^{2\pi a i})\int^\infty_{-\infty}\frac{e^{ax}}{e^x+1}\,dx=2\pi i\,\frac{e^{a\pi i}}{-1},$$ i.e. $$\int^\infty_{-\infty}\frac{e^{ax}}{e^x+1}\,dx=\frac{\pi}{\sin\pi a}.$$