Evaluating $\int_{0}^{\infty} \frac{\cos {ax}}{\cosh{x}}dx$ $\int_{0}^{\infty} \frac{\cos {ax}}{\cosh{x}}dx$ 
$a$ is a real number.
Hint: Consider a suitable rectangular contour
I know that $\frac{1}{\cosh z}$ has simple poles when $z=\frac{(2n-1)\pi}{2}i$.
What should I do next?
I would appreciate any help. Thank you.
 A: First off, let us notice that the function $\cos (ax) / \cosh (x)$ does not change under $x \mapsto -x$. So,
$$
\int\limits_0^\infty \frac{\cos ax}{\cosh x} \, dx = \frac{1}{2} \int\limits_{-\infty}^\infty \frac{\cos ax} {\cosh x} \, dx.
$$
Next, we should take the contour $\gamma_M$ to be like that. Line (1) is a part of real line $[-M, \, M]$, and the upper line (3) is the same line translated by $\pi i$.
The integral over line (3) could be rewritten as
$$
\int\limits_{(3)} \frac{\cos ax}{ \cosh x} \, dx = \int\limits_{(1)} \frac{\cos a(x + \pi i)}{\cosh (x + \pi i)} \, dx = (*).
$$
Notice, that $\cosh (x + \pi i) = - \cosh x$ and
$$
\cos a (x + \pi i) = \cos (ax) \cos ( a \pi i) - \sin (ax) \sin ( a \pi i).
$$
Therefore,
$$
(*) = \cos (a \pi i )\int\limits_{(1)} \frac{\cos a x}{\cosh x} \, dx - \sin (a \pi i) \int\limits_{(1)} \frac{\sin a x}{\cosh x} \, dx.
$$
Last integral clearly equals zero, as it is the sum of symmetric and antisymmetric function over symmetric interval.
Integrals over lines (2) and (4) go to zero as $M \to \infty$. So, we have now, via residuals theorem
$$
2 \pi i \, \mathrm{res} \; \frac{\cos a x}{\cosh x} = \lim\limits_{M \to \infty} \int\limits_{\gamma_M} \frac{\cos a x}{\cosh x} \, dx = (1 + \cos (a \pi i)) \int\limits_{-\infty}^\infty \frac{\cos a x}{\cosh x} \, dx
$$
$$\int\limits_{0}^\infty \frac{\cos a x}{\cosh x} \, dx =  \pi i \, \mathrm{res} \; \frac{\cos a x}{\cosh x} * \frac{1}{(1 + \cos (a \pi i))}$$
A: Let us assume $a>0$. By geometric series we have
$$\begin{eqnarray*} \int_{0}^{+\infty}\frac{\cos(ax)}{\cosh(x)}\,dx &=& 2\sum_{n\geq 0}(-1)^n\int_{0}^{+\infty}\cos(ax) e^{-(2n+1)x}\,dx\\&=&2\sum_{n\geq 0}\frac{(2n+1)(-1)^n}{a^2+(2n+1)^2}\end{eqnarray*}$$
and we may notice that
$$\operatorname*{Res}_{z=(2n+1)}\left(\frac{\pi}{2}\sec\frac{\pi z}{2}\right)=(-1)^{n+1} $$
so by invoking Herglotz' trick we get:
$$ \int_{0}^{+\infty}\frac{\cos(ax)}{\cosh(x)}\,dx = \color{red}{\frac{\pi}{2\cosh\frac{\pi a}{2}}}. $$
