Finding definite integral using contour integration Wanting to find the value of the integral $\int_{0}^{\infty} \dfrac{1}{\cosh (x)} dx$ and know I have to find the residue at $\dfrac{\pi i}{2}$ which I find to be $-i$. So far so good. So then, I know to take the contour from R to -R, $-R to -R$ to $-R-i \pi$ to $-R-i \pi$ to $R + i \pi$ back to R. Now, where I'm getting caught up on is how to proceed. First, I get the wrong expression for the RHS which becomes $2 \pi i * -i= 2\pi$ and on the LHS, I can't work out how to get the definite integral out of the tangle of 4 integrals. Any ideas?
 A: Going counterclockwise around a rectangle with vertices at $z=-R, z=R, z=R+ i \pi$, and  $z=-R+ i \pi$, 
$$ \int_{-R}^{R} \frac{1}{\cosh x} \ dx + i \int_{0}^{\pi} \frac{1}{\cosh (R+it)} \ dt + \int_{R}^{-R} \frac{1}{\cosh( t + i \pi)} \ dt  + i \int_{\pi}^{0} \frac{1}{\cosh (-R + it)} \ dt$$
$$ = 2 \pi i \ \text{Res} \left[\frac{1}{\cosh z}, \frac{i \pi}{2} \right] = 2 \pi$$
But $$ \begin{align} \cosh (t + i \pi) &= \frac{e^{t + i \pi} + e^{-t-i \pi}}{2} \\ &= \frac{-e^{t}-e^{-t}}{2} \\  &= -\frac{e^{t}+e^{-t}}{2} \\ &=  -\cosh t \end{align}$$
So combining the first and third integrals,
$$ = 2 \int_{-R}^{R} \frac{1}{\cosh x} \ dx +  i \int_{0}^{\pi} \frac{1}{\cosh (R+it)} \ dt -  i \int_{0}^{\pi} \frac{1}{\cosh (-R + it)} \ dt = 2 \pi$$
Now we need to show that as $R \to \infty$, the second and third integrals vanish.
Using the ML inequality,
$$ \begin{align} \Big| \int_{0}^{\pi} \frac{1}{\cosh (R +it)} \ dt \Big| &\le \int_{0}^{\pi} \Big|\frac{1}{\cosh (R+it)} \Big| \ dt  \\ &= \pi \ \frac{2}{|e^{R+it} +e^{-R-it}|}\\ &\le 2 \pi \frac{1}{|e^{R+it}|-|e^{-R-it}|} \ \ \text{reverse triangle inequality} \\ &= 2 \pi \frac{1}{e^{R}-e^{-R}} \to 0 \ \text{as} \ R \to \infty \end{align}$$
Showing that the the other integral vanishes is similar.
And we have
$$ 2 \int_{-\infty}^{\infty} \frac{1}{\cosh x} \ dx = 2 \pi$$
or 
$$ \int_{0}^{\infty} \frac{1}{\cosh x} \ dx = \frac{\pi}{2}$$
