Prove that $\int\limits_{-\infty}^{\infty} \frac{e^{-x}}{1+e^{-2\pi x}}\,dx=\frac1{2\sin\left(\frac{1}{2}\right)}$
I need to prove that $\displaystyle\int_{-\infty}^{\infty} \dfrac{e^{-x}}{1+e^{-2\pi x}}\,dx=\dfrac{1}{2\sin\left(\frac{1}{2}\right)}$. This is an exercise from Basic Complex Analysis by Marsden and Hoffman. My attempt:
First, Marsden says that we need to consider the complex function $f(z)=\dfrac{e^{-z}}{1+e^{-2\pi z}}$ and the next curve
$\gamma_2=r+t\pi i$ with $t\in [0,1]$
$\gamma_3=(\pi i+r)-2tr$ with $t\in [0,1]$
$\gamma_4=(1-t)(\pi i-r)-tr$ with $t\in [0,1]$
Note that the only poles of the function $f(z)$ in the rectangle are when $z=\dfrac{i}{2}$, $z=\dfrac{3i}{2}$ and $z=\dfrac{5i}{2}$. From a direct calculation we obtain that $\text{Res}\left(f(z),\dfrac{i}{2}\right)=\dfrac{e^{-i/2}}{2\pi}$, $\text{Res}\left(f(z),\dfrac{3i}{2}\right)=\dfrac{e^{-3i/2}}{2\pi}$ and $\text{Res}\left(f(z),\dfrac{5i}{2}\right)=\dfrac{e^{-5i/2}}{2\pi}$.
After to a lot of calculations we obtain a bound for the integral over $\gamma_2$: $$\dfrac{e^{-r}}{\sqrt{(1-e^{-2\pi r})^2}}\geq \dfrac{|e^{-r-t\pi i}|}{|1+e^{-2\pi(r+t\pi i)}|}\geq 0$$Thus $$\displaystyle\int_{\gamma_2}^{}f(\gamma_2)\cdot d\gamma\leq \dfrac{e^{-r}}{\sqrt{(1-e^{-2\pi r})^2}}$$When $r\to\infty$ then $\displaystyle\int_{\gamma_2}^{}f(\gamma_2)\cdot d\gamma\to 0$
I think that is the same for $\gamma_4$ but I have troubles with $\gamma_3$. After a lot of calculations we obtain the next bound: $$\dfrac{e^{-r+2rt}}{\sqrt{1+2e^{-2\pi}\cos(-2\pi^2)+e^{-4\pi r}}}\geq \dfrac{|e^{-r+2rt-\pi i}|}{|1+e^{-2\pi(\pi i+r-2rt)}|}$$ but when $r\to\infty$ we obtain that $\dfrac{e^{-r+2rt}}{\sqrt{1+2e^{-2\pi}\cos(-2\pi^2)+e^{-4\pi r}}}\to\infty$ and I need, maybe, that this limits exists (maybe, zero).
Clearly I want the integrals over the curves because if $\gamma=\gamma_1\cup\gamma_2\cup\gamma_3\cup\gamma_4$ then $\displaystyle\int_{\gamma} f(\gamma)\cdot d\gamma=\displaystyle\int_{\gamma_1} f(\gamma_1) \cdot d\gamma_1+\displaystyle\int_{\gamma_2} f(\gamma_2) \cdot d\gamma_2+\displaystyle\int_{\gamma_3} f(\gamma_3) \cdot d\gamma_3+\displaystyle\int_{\gamma_4} f(\gamma_4) \cdot d\gamma_4$ and I want to use the Residue Theorem. But, is the rectangle the correct curve? Here an screenshot of the exercise:
For your question, you will have to consider a rectangular contour with vertices $\pm R$ and $\pm R+i$. I'm guessing the authors meant by "same technique" as in a rectangular contour situated in the upper half of the contour plane. Calling our integrand as $f(z)$
$$f(z)\equiv\frac {e^{-z}}{1+e^{-2\pi z}}$$
and parametrizing about all four sides of the contour gives us
$$\begin{multline}\oint\limits_{\mathrm C}dz\, f(z)=\int\limits_{-R}^{R}dz\, f(x)+i\int\limits_0^1dy\, f(R+yi)-\int\limits_{-R}^{R}dz\, f(z+i)-i\int\limits_0^1dy\, f(-R+yi)\end{multline}$$
When we take the limit as $R\to\infty$, it can be shown that the integrals of the vertical sides (i.e the second and fourth integrals) vanish. This can be justified using the estimation lemma. Both integrals have a length of $L=1$ while their upper-bound $M$ can be computed by using the fact that $|e^{-yi}|\leq 1$ and $|e^{\pm R}|=e^{\pm R}$.
$$\begin{align*}M_1 & =\left|\,\frac {e^{-R}e^{-yi}}{1+e^{-2\pi R}e^{-2\pi yi}}\,\right|=\frac {e^{-R}}{1+e^{-2\pi R}}\xrightarrow{R\,\to\,\infty}0\\M_2 & =\left|\,\frac {e^{R}e^{-yi}}{1+e^{2\pi R}e^{-2\pi yi}}\,\right|=\frac {e^{R}}{1+e^{2\pi R}}\xrightarrow{R\,\to\,\infty}0\end{align*}$$
Taking their product and calling their arcs $\Gamma_{1}$ and $\Gamma_{2}$ respectively
$$\begin{align*} & \left|\,\int\limits_{\Gamma_{1}}dz\,\frac {e^{-z}}{1+e^{-2\pi z}}\,\right|\leq M_1L=0\\ & \left|\,\int\limits_{\Gamma_{2}}dz\,\frac {e^{-z}}{1+e^{-2\pi z}}\,\right|\leq M_2L=0\end{align*}$$
As in, the arc integrals vanish as $R\to\infty$. Now, what's left is
$$\oint\limits_{\mathrm C}dz\, f(z)=(1-e^{-i})\int\limits_{-\infty}^{\infty}dx\, f(x)$$
The contour integral is also equal to the sum of its residues inside the contour multiplied by $2\pi i$. Fortunately, there is only one residue inside at $z=i/2$. Therefore
$$\operatorname*{Res}_{z\,=\, i/2}\frac {e^{-z}}{1+e^{-2\pi z}}=\lim\limits_{z\,\to\, i/2}\frac {(z-i/2)e^{-z}}{1+e^{-2\pi z}}=\frac {e^{-i/2}}{2\pi}$$
Hence the contour integral is
$$\oint\limits_{\mathrm C}dz\, f(z)=ie^{-i/2}$$
Putting everything together and isolating our integral $I$, we get
$$\int\limits_{-\infty}^{\infty}dx\,\frac {e^{-x}}{1+e^{-2\pi x}}=\frac {ie^{-i/2}}{1-e^{-i}}\color{blue}{=\frac 12\csc\left(\frac 12\right)}$$
Somewhat briefly:
- Take the rectangle with the upper corners at $-r+i$ and $r+i$. Then you get one residue at $z=i/2$ and the integral over $\gamma_3$ (orientation right to left) $$ -\int_{-r}^r\frac{e^{-x-i}}{1+e^{-2\pi(x+i)}}\,dx=-e^{-i}\int_{-r}^r\frac{e^{-x}}{1+e^{-2\pi x}}\,dx. $$ It gives as $r\to\infty$ the equation for the integral $I$ to be calculated $$ I+0-e^{-i}I+0=2\pi i\cdot\frac{e^{-i/2}}{2\pi}. $$ To finish is straightforward.
- "After a lot of calculations" may be simplified as e.g. for $\gamma_2$ $$ \left|\frac{e^{-r-i\theta}}{1+e^{-2\pi(r+i\theta)}}\right|= \frac{e^{-r}|e^{-i\theta}|}{|1+e^{-2\pi r}e^{-i2\pi\theta}|}\le \frac{e^{-r}\cdot 1}{1-|e^{-2\pi r}e^{-i2\pi\theta}|}=\frac{e^{-r}}{1-e^{-2\pi r}}\to 0,\quad r\to\infty. $$