Complex integral over rectangle I have a problem with an example in complex integration : 
"Determine the value of $\int_{-\infty}^{\infty} \frac {e^{ix}}{cosh \space x}dx$
Try integrating over the rectangle: $-R$, $R$, $R+i\pi $, $-R+i\pi$ ."
I know that $\int_{-R}^{R}$+$\int_{R}^{R+i\pi}$+$\int_{R+i\pi}^{-R+i\pi}$+$\int_{-R+i\pi}^{-R}$ = $\sum Res(f,a)$, Im(a)>0, or a are inside the rectangle. Where $f=\frac{e^{ix}}{cosh \space x}$, and a are the singularities. And that $lim_{R-> \infty}\int_{-R}^{R}$=$\int_{-\infty}^{\infty}$. The problem I'm having is with the basic contour integration of $\int_{R}^{R+i\pi}$+$\int_{R+i\pi}^{-R+i\pi}$+$\int_{-R+i\pi}^{-R}$ , no substitution in $\int \frac {e^{ix}}{cosh \space x}$=$\int \frac {2\space e^{ix}}{e^x+e^{-x}}$ seems to work. So... how can I integrate $\int_{R}^{R+i\pi}\frac {2\space e^{ix}}{e^x+e^{-x}}$ ? 
 A: Notation:
$A:=\int_{-R}^{R}\frac {e^{ix}}{cosh \space x}dx $
$B:=\int_{R}^{R+i\pi}\frac {e^{ix}}{cosh \space x}dx $
$C:=\int_{R+i\pi}^{-R+i\pi}\frac {e^{ix}}{cosh \space x}dx$
$D:=\int_{-R+i\pi}^{-R}\frac {e^{ix}}{cosh \space x}dx $
Solution:
For integration B: As $|\frac{e^{ix}}{cosh \space x}| = \frac{1}{|cosh \space x|} \to 0 $ when $R \to \infty \implies R>\delta, |\frac{e^{ix}}{cosh \space x}| < \epsilon$ Hence, $|B| =|\int_{|R|}^{|R+i\pi|}\frac {e^{ix}}{cosh \space x}dx|=\int_{|R|}^{|R+i\pi|}|\frac {e^{ix}}{cosh \space x}|dx <^{\text[1]} \epsilon  \pi \implies B \to 0$. So $B = 0$.
The $[1]$ inequality comes from M-L inequality.
The same argument for $D$.
For integration C: 
$$C =\int_{R+i\pi}^{-R+i\pi}\frac {e^{ix}}{cosh \space x}dx = \int_{R}^{-R}\frac {e^{ix-\pi}}{\cosh (x+\pi i)}dx =  -e^{-\pi}\int_{R}^{-R}\frac {e^{ix}}{\cosh (x)}dx = e^{-\pi}A.$$
So the contour integration becomes:$(1+e^{-\pi})A = 2\pi i\sum Res(f,a)$
Since the locus encloses only one singular point $x = \frac \pi 2 i$.
And the residue $Res(f,\frac \pi 2 i) = - e^{-\pi/2} i$
$$(1+e^{-\pi})A = 2\pi i \times (- e^{-\pi/2} i) = 2 \pi e^{-\pi /2 }\implies\\\
A = \frac{ 2 \pi e^{-\pi /2 }}{1+e^{-\pi}} = \pi sech(\pi/2)
$$
A: We may show that $\frac{1}{\cosh x}$ is almost a fixed point of the Fourier transform in the following way: since we have an even function and $2\cosh(x)=e^{x}+e^{-x}$,
$$ \forall x\neq 0,\qquad \frac{1}{\cosh(x)}=2\sum_{n\geq 0}(-1)^n e^{-(2n+1)|x|} \tag{1}$$
hence:
$$ \int_{-\infty}^{+\infty}\frac{e^{ix}}{\cosh(x)}\,dx = 4\sum_{n\geq 0}\frac{(-1)^n (2n+1)}{(2n+1)^2+1}.\tag{2} $$
On the other hand, the meromorphic function $\frac{1}{\cosh(x)}$ has simple poles at $\frac{\pi i}{2}+k\pi i$ and the residues are simple to compute, leading to:
$$ \frac{1}{\cosh(x)}=4\sum_{n\geq 0}\frac{(-1)^n(2n+1)\pi}{(2n+1)^2 \pi^2+4x^2}\tag{3} $$
so, by putting together $(2)$ and $(3)$,
$$ \boxed{\int_{-\infty}^{+\infty}\frac{e^{ix}}{\cosh x}\,dx = \color{red}{\frac{\pi}{\cosh\frac{\pi}{2}}}}\tag{4} $$
easily follows.
