Use rectangular contour to integrate $\int_{0}^{\infty}\frac{\sin(ax)}{e^{2\pi x}-1}dx$ I have been self-studying CA and find it very interesting. So, working through problems in a book I have, I ran across
$$\int_{0}^{\infty}\frac{\sin(ax)}{e^{2\pi x}-1}dx=\frac{1}{4}\coth(a/2)-\frac{1}{2a}$$
and $$\int_{0}^{\infty}\frac{\sin(ax)}{e^{x}+1}dx=\frac{1}{2a}-\frac{\pi}{2\sinh(\pi a)}$$
For the former, I wrote it as $\frac{e^{aiz}}{e^{2\pi z}-1}$ and used a rectangular contour with vertices $0, \;\ R. \;\ R+i, \;\ i$
$e^{2\pi z}-1$ has poles at $ni$. Of these, I think $i$ only lies within the contour. 
Unless I am in error, I then calculated the residue at $i$ to be $\frac{e^{-a}}{2\pi}$
So, $2\pi i(\frac{e^{-a}}{2\pi})=ie^{-a}$
Now, where I get hung up is setting up the integrals around the contour. Two of which should tend to 0 as $R\to \infty$.
Here is what I done.
$$\int_{0}^{R}\frac{e^{iax}}{e^{2\pi x}-1}dx+\int_{0}^{\infty}\frac{e^{ai(R+iy)}}{e^{2\pi (R+iy)}-1}idy+\int_{R}^{0}\frac{e^{ai(x+i)}}{e^{2\pi (x+i)}-1}dx+\int_{\infty}^{0}\frac{e^{ai(iy)}}{e^{2\pi iy}-1}dy=-\sinh(a)$$
I am unsure of the limits on the second and fourth integrals.
I am not so sure this is correct. The second and fourth ones, which represent the vertical sides,  should tend to 0 as $R\to\infty$. I hope :). 
This than gave me $(1-e^{-a})\int\frac{e^{iax}}{e^{2\pi x}-1}dx=-\sinh(a)$.
Which does not look correct. I did manage to solve this using series and $\pi csc(\pi z)$, but the contour I am unsure of. 
Can someone lend a hand here?. Any advice on either would be appreciated. 
For the other one, I only posted it because it looks similar, but I believe is actually more involved and 'tougher' if you will. If I can get one, perhaps I can manage to evaluate the other.
With that one, I think the same rectangle with the same vertices can be used, but $\pi i$ would have to be avoided. Perhaps a Principal Value in there somewhere. But, I was told to use vertices $0, \;\ R, \;\ R+2\pi i, \;\ 2\pi i$
Since I am relatively new to CA, setting up those integrals is the confusing part.  
I can do easier types of contour integrals, but want to learn more about these more challenging ones. 
Thanks for any assistance.
 A: $\newcommand{\bbx}[1]{\,\bbox[8px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

Abel-Plana Formula:

\begin{align}
\sum_{n = 0}^{\infty}\expo{-n\verts{a}} & =
\int_{0}^{\infty}\expo{-\verts{a}x}\,\dd x +
\bracks{{1 \over 2}\,\expo{-\verts{a}x}}_{\ x\ =\ 0} -
2\,\Im\int_{0}^{\infty}{\expo{-\verts{a}x\ic} \over \expo{2\pi x} - 1}\,\dd x
\end{align}

\begin{align}
{1 \over 1 - \expo{-\verts{a}}} & =
{1 \over \verts{a}} + {1 \over 2} +
2\,\mrm{sgn}\pars{a}\int_{0}^{\infty}
{\sin\pars{ax} \over \expo{2\pi x} - 1}\,\dd x
\end{align}

\begin{align}
&2\,\mrm{sgn}\pars{a}\int_{0}^{\infty}
{\sin\pars{ax} \over \expo{2\pi x} - 1}\,\dd x
=
{1 \over 1 - \expo{-\verts{a}}}  - {1 \over 2} - {1 \over \verts{a}} =
{1 + \expo{-\verts{a}} \over 1 - \expo{-\verts{a}}}\,{1 \over 2} - {1 \over \verts{a}}
\end{align}

\begin{align}
&\int_{0}^{\infty}
{\sin\pars{ax} \over \expo{2\pi x} - 1}\,\dd x =
\bbx{\ds{{1 \over 4}\,\coth\pars{a \over 2} - {1 \over 2a}}}
\end{align}
A: The given integral is the imaginary part of 
$$ \int_{0}^{+\infty}\sum_{n\geq 1}\exp\left((ia-2\pi n)x\right)\,dx $$
that equals
$$ \color{red}{\frac{-2 + a \coth(a/2)}{4 a}} $$
by the Eisenstein series of the cotangent function. In particular, the given integral is bounded between $-\frac{1}{4}$ and $\frac{1}{4}$ for any $a\in\mathbb{R}$ and it is an increasing function of the $a$ variable.
A: I found $$\int_{C}\frac{e^{iaz}}{e^{2\pi z}-1}dz$$ in "Applied Complex Analysis with PDE" by Nakhle Asmar. 
If anyone is interested, he uses a contour with a line segment and quarter circle with $I_{1}, ...., I_{6}$
$\int_{C}\frac{e^{iaz}}{e^{2\pi z}-1}dz=I_{1}+I_{2}+I_{3}+I_{4}+I_{5}+I_{6}$
starting with a line segment $[\epsilon,R]$ and moving counterclockwise.  As $\epsilon\to 0^{+}$ and $R\to \infty$,  $I_{1}\to I$. 
i.e. $I_{2}, \;\ z=R+iy$, where y varies from 0 to 1.
$I_{3}, \;\ z=x+i$, where x varies from $R$ to $\epsilon$
$I_{4}$ is done over the quarter circle from $(\epsilon,\epsilon+i)$ to $0,i-i\epsilon)$
$I_{5}, \;\ z=iy$ where y varies from $i-\epsilon$ to $\epsilon$
$I_{6}$ is done over the quarter circle from $(0,i\epsilon)$ to $(\epsilon,0)$
For instance, $I_{6}$ gives $$\lim_{\epsilon\to 0}\int\frac{e^{iaz}}{e^{2\pi z}-1}dz=\frac{-\pi}{2}\text{Res}\left(\frac{e^{iaz}}{e^{2\pi z}-1},0\right)$$
$$=\frac{-\pi i}{2}\cdot \frac{e^{iaz}}{2\pi e^{2\pi (i)}}=-i\cdot \frac{e^{-a}}{4}$$
It is rather lengthy and ultimately results in $\frac{-1}{2a}+\frac{1}{4}\frac{e^{a}+1}{e^{a}-1}=\frac{-1}{2a}+\frac{1}{4}\coth(\frac{a}{2})$
A: Contour integration: We consider the integral:
$$I = \oint_{C\left(\epsilon,R\right)} \frac{\exp(i a z)dz}{\exp(2\pi z) - 1}$$
with $C\left(\epsilon,R\right)$ a rectangle from $\epsilon$ to $R$ on the real axis, from there to $R + i$ parallel to the imaginary axis, from there to $\epsilon + i$ parallel to the real axis, then a clockwise quarter turn with radius $\epsilon$ and center $i$ to the point $i - i\epsilon$, from there we move on the imaginary axis to the point $i\epsilon$ and then we take a clockwise quarter turn with radius $\epsilon$ and center the origin to move back to the starting point at $\epsilon$.
The integrand is analytic inside the contour, therefore $I = 0$. The sum of the two parts parallel to the real axis is:
$$I_r = \left[1-\exp(-a)\right]\int_\epsilon^R  \frac{\exp(i a x)dx}{\exp(2\pi x) - 1}$$
So, the desired integral will follow from the imaginary part of $I_r$. The part of the contour integral from $R$ to $R + i$ tends to zero in the limit of $R\to\infty$ so this can be disregarded. The part of the contour integral along the imaginary axis can be written as:
$$I_i = -\int_{\epsilon}^{1-\epsilon}\frac{\exp(-a y)\exp(-\pi i y)}{2\sin(\pi y)}dy$$
We then see that 
$$\lim_{\epsilon\to 0}\operatorname{Im}I_i = \frac{1-\exp(-a)}{2a}$$
The two quarter circles can be evaluated, we can borrow from the derivation of the residue theorem that each of them in the limit $\epsilon\to 0$ can be evaluated as $-\frac{\pi}{2} i$ times the residue at the poles that are at the centers of the quarter circles (unlike the case of a complete contour, this is only valid in the limit $\epsilon\to 0$). The residue at the pole at $z = 0$ is $\frac{1}{2\pi}$, while the residue at $z = i$ is $\frac{\exp(-a)}{2\pi}$. Having completed the evaluation of all parts of the contour integral, we can now equate the imaginary part of the contour integral to zero, and take the limit of $\epsilon\to 0$ and $R\to \infty$. This yields:
$$\int_0^{\infty}\frac{\sin(a x)dx}{\exp(2\pi x)-1} = \frac{1}{4}\coth\left(\frac{a}{2}\right) - \frac{1}{2 a}$$
A: For any $b>0$,
$$
\left|\int_{b}^{\infty}\frac{\sin(ax)}{e^{2\pi x}-1}dx\right|\leq\int_{b}^{\infty}\frac{1}{e^{2\pi x}-1}dx=b-\frac{\ln(e^{2\pi b}-1)}{2\pi}.
$$
Therefore, if you would like to compute your integral within an $\epsilon$
tolerance, you can compute numerically the integral
$$
\int_{0}^{b^{*}}\frac{\sin(ax)}{e^{2\pi x}-1}dx
$$
where $b^{*}$ is a positive solution of
$$
b^{*}-\frac{\ln(e^{2\pi b^{*}}-1)}{2\pi}\leq \epsilon.
$$
