# $\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.

• Note the limit as you've written it is $-\pi i/ \cos a\pi$. Is there an extra or missing favor of $i$ somewhere, perhaps in the residue calculation? I'm too lazy to compute it. – MPW Jan 19 '14 at 2:58
• How are you getting that? I've added a bit of explanation on the computation of the residue. – Saigyouji Jan 19 '14 at 3:06
• $e^{iz}=\cos z + i \sin z$, so $\cos z = (e^{iz} + e^{-iz})/2$. Multiply top and bottom by $e^{iz}$ to get $\cos z = (e^{2iz} + 1)/2e^{iz}$. – MPW Jan 19 '14 at 3:18
• check out math.stackexchange.com/questions/130472/… too – ir7 Jan 19 '14 at 3:37
• So @ir7 is showing that you omitted some poles in the calculation of residues – MPW Jan 19 '14 at 3:40

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}}$$

• I'm still having trouble figuring out where the negative comes from in the third integral. In the computation I posted, I gain a negative from the substitution $u = -t$ but this substitution also flips my bounds of integration. So fixing those bounds kills the negative. – Saigyouji Jan 19 '14 at 14:39
• Because in the original contour integral $z=x+i 2 \pi$ from $x \in [R,-R]$ in that order. You simply reverse the order of integration - that's all - and you get the negative sign. You do not need to introduce it artificially into the integral. – Ron Gordon Jan 19 '14 at 15:31
• I'm using a slightly different parametrization, but seeing as your parametrization clearly gives you the needed negative, I double checked a few things and realized the problem. I was accidentally using the definition of a line integral over a scalar field, which uses the absolute value of the derivative. This was killing the negative I was supposed to get from differentiating $z(t) = -x + 2\pi i$ over $[-R, R]$. – Saigyouji Jan 19 '14 at 15:44

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.

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.