integral involving cot coth and e using contour I am thinking it is possible to evaluate this integral using contours, but I got hung up.
$\displaystyle \int_{0}^{\infty}e^{-ax}\sin(ax)\left(\cot(x)+\coth(x)\right)dx=\frac{\pi}{2}\cdot \frac{\sinh(\pi a)}{\cosh(\pi a)-\cos(\pi a)}, \;\ a\in \mathbb{N}$
For instance, I broke it up by considering $\displaystyle\frac{e^{-az}e^{iaz}\cos(z)}{\sin(z)}$
and $\displaystyle\frac{e^{-az}e^{iaz}\cosh(z)}{\sinh(z)}$
This means there are infinite poles for the first one at $z=n\pi$ and at $z=\pi n i$
for the second one.  I tried a semi-circle and a rectangle, but got rather hung up.
I got a residue for $z=n\pi$ of $\displaystyle\frac{e^{n a \pi i}}{e^{n\pi a}}$ and a residue for 
$\displaystyle n\pi i$ of $\frac{1}{e^{n\pi a i}e^{n\pi a}}$
Since the poles are infinite, there are series to evaluate.
Summing these gave a closed form of $\displaystyle \frac{2e^{\pi a}\cos(\pi a)-2e^{2\pi a}}{2e^{\pi a}\cos(\pi a)-e^{2\pi a}-1}$
Of course, this does not lead to the correct solution.
Another thing to consider is rather 'a' is odd or even. 
May I ask what would be the best function to consider or contour to use for this one?.
Thanks
 A: We will assume that $a \in \mathbb{N}$, otherwise the integral does not converge.  
We use a rectangular contour $C$ with notches cut out as follows:

Let us first consider the following integral:
$$\oint_C dz\, e^{-b z} \coth{z}$$
Note that we will be taking $b=(1-i) a$.  By Cauchy's Integral Theorem, this integral is zero because there are no poles inside (or on) $C$.  On the other hand, the contour integral is evaluated along $C$ and may be broken up into six pieces as follows:
$$\int_{\epsilon}^R dx \, e^{-b x} \coth{x} + i \int_0^{\pi} dy \, e^{-b (R+i y)} \, \coth{(R+i y)} + \\ \int_R^{\epsilon} dx \, e^{b (x+i \pi)} \, \coth{(x+i \pi)} + i \epsilon \int_0^{-\pi/2} d\phi \, e^{i \phi} \, e^{-b \left (i \pi+ \epsilon e^{i \phi}\right)} \coth{\left (\epsilon e^{i \phi}\right)} + \\ i \int_{\pi-\epsilon}^{\epsilon} dy \, e^{-i b y} \, \coth{i y} + i \epsilon \int_0^{\pi/2} d\phi \, e^{i \phi} \, e^{-b \epsilon e^{i \phi}} \, \coth{\left (\epsilon e^{i \phi}\right)}$$
We take the limits as $\epsilon \to 0^+$ and $R \to \infty$.  The second integral vanishes in this limit because $\Re{b} \gt 0$.  Setting this sum of integrals to zero and rearranging a bit, we get
$$\left (1-e^{-i \pi b}\right) \int_0^{\infty} dx \, e^{-b x} \, \coth{x} = \int_0^{\pi} dy \, e^{-i b y} \, \cot{y} + i \frac{\pi}{2} \left (1+e^{-i \pi b}\right)$$
Note that, in the first integral on the RHS, I used the fact that $\coth{i y} = -i \cot{y}$.
Now we are ready to begin discussing the original integral.  From the above equation, we take imaginary parts; from the fact that $b=(1-i) a$, we may write
$$\int_0^{\infty} dx \, e^{-a x} \, \sin{a x} \, (\coth{x} + \cot{x}) = \frac{\pi}{2} \frac{1+(-1)^a e^{-\pi a}}{1-(-1)^a e^{-\pi a}} +\\ \int_0^{\infty} dx \, e^{-a x} \, \sin{a x} \cot{x} - \frac{1}{1-(-1)^a e^{-\pi a}} \int_0^{\pi} dx \, e^{-a x} \, \sin{a x} \cot{x}$$
Remember that $a$ is a positive integer.  I will now prove that the last two terms on the RHS cancel each other out.
Let's take the case where $a=2 n$, i.e., $a$ is even.  Then
$$\begin{align}\int_0^{\pi} dx \, e^{-2 n x} \, \sin{2 n x} \cot{x} &= \int_0^{\pi} dx \, e^{-2 n x} \, \frac{\sin{2 n x}}{\sin{x}} \cos{x} \\ &= \int_0^{\pi} dx \, e^{-2 n x} \, 2 \sum_{k=0}^{n-1} \cos{[(2 k+1) x]} \cos{x} \\ &=  \int_0^{\pi} dx \, e^{-2 n x} \, \left[1 + 2 \sum_{k=1}^{n-1}\cos{2 k x} + \cos{2 n x}\right] \\ &= \frac{1-e^{-2 \pi}}{2 n} + 2 \sum_{k=1}^{n-1} \Re{\left [  \int_0^{\pi} dx \, e^{-(2 n-i 2 k) x} \right ]} + \Re{\left [  \int_0^{\pi} dx \, e^{-(2 n-i 2 n) x} \right ]}  \\ &= \frac{1-e^{-2 \pi}}{2 n}+ 2\sum_{k=1}^{n-1} \Re{\left [ \frac{1-e^{-2 n \pi}}{2 n-i 2 k} \right]} + \Re{\left [ \frac{1-e^{-2 n \pi}}{2 n-i 2 n} \right]}\\ &= \frac{1-e^{-2 \pi}}{2 n}+2 \left ( 1-e^{-2 n \pi}\right)\sum_{k=1}^{n-1} \Re{\left [\frac{2 n+i 2 k}{4 n^2+4 k^2} \right ]} +\left ( 1-e^{-2 n \pi}\right)\Re{\left [\frac{2 n+i 2 n}{4 n^2+4 n^2} \right ]}  \\ &=\left ( 1-e^{-2 n \pi}\right) \left [ \frac{1}{n} +  n \sum_{k=1}^{n-1}\frac{1}{n^2+k^2} \right ]  \end{align}$$
Similarly, one may show that
$$\begin{align}\int_0^{\infty} dx \, e^{-2 n x} \, \sin{2 n x} \cot{x} &= \frac{1}{n} +  n \sum_{k=1}^{n-1}\frac{1}{n^2+k^2}\\ &= \frac{1}{1-e^{-2 n \pi}}\int_0^{\pi} dx \, e^{-2 n x} \, \sin{2 n x} \cot{x}  \end{align}$$
The cancellation occurs when $a$ is even.  One may show that this cancellation also occurs when $a$ is odd, i.e., when $a=2 n-1$ in a similar fashion, using the fact that
$$\frac{\sin{(2 n-1) x}}{\sin{x}} = 1+2 \sum_{k=1}^{n-1} \cos{2 k x}$$
We may then write
$$\int_0^{\infty} dx \, e^{-a x} \, \sin{a x} \, (\coth{x} + \cot{x}) = \frac{\pi}{2} \frac{1+(-1)^a e^{-\pi a}}{1-(-1)^a e^{-\pi a}}$$
or, in terms of hyperbolic functions, for $n \in \mathbb{N}$:
$$\int_0^{\infty} dx \, e^{-a x} \, \sin{a x} \, (\coth{x} + \cot{x}) = \begin{cases} \frac{\pi}{2} \coth{\pi n} & a = 2 n \\ \frac{\pi}{2} \tanh{\left ( n+\frac12\right) \pi} & a = 2 n+1\end{cases}$$
One may easily show that this agrees with the stated result.
