$\int_{-\infty}^\infty \frac{e^{ax}}{1+e^x}dx$ with residue calculus I'm trying to compute $\displaystyle \int_{-\infty}^\infty \frac{e^{ax}}{1+e^x}dx$, $(0<a<1)$
Let $f$ denote the integrand.
I'm using the rectangular contour given by the following curves:
$c_1: z(t) = R+it, t \in [0, 2\pi]$
$c_2: z(t) = -t+2\pi i, t \in [-R, R]$
$c_3: z(t) = -R + i (2\pi - t), t \in [0, 2\pi]$
$c_4: z(t) = t, t \in [-R, R]$  
There is one singularity within the contour, at $z = \pi i$.
Expanding out the denominator as a power series shows that it's a simple pole, and allows us to evaluate the residue as
$\displaystyle \lim_{z \rightarrow \pi i} f(z)(z-\pi i) = - e^{a \pi i}$  
This is computed by expanding $1+e^z$ as a Taylor series around $\pi i$. The first coefficient will be 0, and the second will be $-1$. The rest will have orders of $(z - \pi i)$ greater than 1, and will thus vanish when we take the limit.
So the integral over the entire contour is $- 2\pi i e^{a \pi i}$  
An easy enough estimate on the $c_1$ shows that the integral vanishes as $R \rightarrow \infty$.
With a variable change, c_3 is the same as c_1 and also vanishes.
$c_4$ becomes the integral we want when we take a limit.
$c_2$ becomes $c_4$ with a constant:  
\begin{align*} \int_{c_2} f(z)dz &= \int_{-R}^{R} \frac{e^{-at}e^{a 2\pi i}}{1+e^{-t}e^{2\pi i}}dt
\\ &= e^{a 2 \pi i}\int_{-R}^{R} \frac{e^{-at}}{1+e^{-t}}dt
\\ &=e^{a 2 \pi i}\int_{R}^{-R} - \frac{e^{au}}{1+e^{u}}du \ \ \ (u = -t, du = -dt)  
\\ &= e^{a 2 \pi i}\int_{-R}^{R} \frac{e^{au}}{1+e^{u}}du
\\ &= e^{a 2 \pi i} I(R)
\end{align*}  
Where $I(R)$ is the line integral over $c_4$.
Putting it all together and taking the limit gives us
$\displaystyle \lim_{R \rightarrow \infty} I(R) = \frac{- 2\pi i e^{a \pi i}}{(1 + e^{a 2 \pi i}) }$  
But this can't be the value of the integral, because it's a real-valued function integrated over $R$. I can't figure out where I'm going wrong. Note that I've avoided posting all the details of my solution since this is from a current problem set for a class on complex analysis. 
 A: The residue can also be calculated without the use of a taylor series expansion
$$\lim_{z \to \pi i} \frac{(z-\pi i)\exp(az)}{1+\exp(z)} = \lim_{z \to \pi i} \frac{\exp(az)+ (z-\pi i) ~ a ~ \exp(az)}{\exp(z)} = - \exp(a ~ \pi~ i)$$
Since we can use L'Hôpital's rule.
A: I think you may just have a simple sign error.  Using the same contour you describe, I get that
$$\int_{-R}^R dx \frac{e^{a x}}{1+e^x} + i \int_0^{2 \pi} dy \frac{e^{a (R + i y)}}{1+e^{R+i y}} - e^{i a 2 \pi} \int_{-R}^R dx \frac{e^{a x}}{1+e^x} - i \int_0^{2 \pi} dy \frac{e^{a (-R + i y)}}{1+e^{-R+i y}} = -i 2 \pi e^{i a \pi}$$
As $R \to \infty$, the second integral (because $a \lt 1$) and the fourth integral (because $a \gt 0$) vanish.  Thus we have
$$\int_{-\infty}^{\infty} dx \frac{e^{a x}}{1+e^x} = - i 2 \pi \frac{e^{i a \pi}}{1-e^{i 2 a \pi}} = \frac{\pi}{\sin{\pi a}}$$
A: Would it help you to make a change of variable $$x = \operatorname{Log}[y - 1]$$ ? 
The integrand just becomes
$$\frac{(y - 1)^{a-1}}{ y}$$
and the integral has to be taken from $1$ to infinity.
