I am trying to evaluate the improper integral $I:=\int_{-\infty}^\infty f(x)dx$, where $$ f(z) := \frac{\exp((1+i)z)}{(1+\exp z)^2}. $$
I tried to do this by using complex integration. Let $L,L^\prime>0$ be real numbers, and $C_1, C_2, C_3, C_4$ be the line segments that go from $-L^\prime$ to $L$, from $L$ to $L+2\pi i$, from $L + 2\pi i$ to $-L^\prime+2\pi i$ and from $-L^\prime+2\pi i$ to $-L^\prime$, respectively. Let $C = C_1 + C_2 + C_3 + C_4$.
Here we have (for sufficiently large $L$ and $L^\prime$) $$ \int_{C_2}f(z) dz \le \int_0^{2\pi}\left|\frac{\exp((1+i)(L+iy))}{(\exp(L+iy)+1)}i\right| dy \le \int\frac{1}{(1-e^{-L})(e^L - 1)}dy\rightarrow0\quad(L\rightarrow\infty), $$ $$ \int_{C_4}f(z)dz\le\int_0^{2\pi}\left|\frac{\exp((1+i)(-L^\prime+iy))}{(\exp(-L^\prime + iy) + 1))^2}(-i)\right|dy\le\int\frac{e^{-L^\prime}}{(1-e^{-L})^2}dy\rightarrow 0\quad(L^\prime\rightarrow\infty), $$ and $$ \int_{C_3}f(z)dz = e^{-2\pi}\int_{C_1}f(z)dz. $$ Thus $$I = \lim_{L,L^\prime\rightarrow\infty}\frac{1}{ (1 + e^{-2\pi})}\oint_Cf(z)dz.$$
Within the perimeter $C$ of the rectangle, $f$ has only one pole: $z = \pi i$. Around this point, $f$ has the expansion $$ f(z) = \frac{O(1)}{(-(z-\pi i)(1 + O(z-\pi i)))^2} =\frac{O(1)(1+O(z-\pi i))^2}{(z-\pi i)^2} = \frac{1}{(z-\pi i)^2} + O((z-\pi i)^{-1}), $$ and thus the order of the pole is 2. Its residue is $$ \frac{1}{(2-1)!}\frac{d}{dz}\Big|_{z=\pi i}(z-\pi i)^2f(z) = -\pi \exp(i\pi^2) $$ (after a long calculation) and we have finally $I=-\exp(i\pi^2)/2i(1+\exp(-2\pi))$.
My question is whether this derivation is correct. I would also like to know if there are easier ways to do this (especially, those of calculating the residue). I would appreciate if you could help me work on this problem.
Everything appears right except :
Computing residues in a practical way is often done using our favorite software to get the Laurent series of $f(z)$ at $z=\pi i$.
Without computer I spontaneously expanded $f(z)$ this way (for $\,z:=\pi i+x\,$ with $\,|x|\ll 1$) : \begin{align} f(\pi i+x)&=\frac{e^{(1+i)(\pi i+x)}}{(1+e^{\pi i+x})^2}=\frac{-e^{-\pi}\;e^{(1+i)x}}{(1-e^x)^2}\\ &=-e^{-\pi}\frac {1+(1+i)x+O\bigl(x^2\bigr)}{x^2\left(1+x/2+O\bigl(x^2\bigr)\right)^2}\\ &=-\frac{e^{-\pi}}{x^2}\left((1+(1+i)x)(1-x)+O\bigl(x^2\bigr)\right)\\ &=-\frac{e^{-\pi}}{x^2}\left(1+ix+O\bigl(x^2\bigr)\right)\\ &=-\frac{e^{-\pi}}{x^2}-\frac{i\,e^{-\pi}}{x}+O(1) \end{align}