A definite integral with tanh and sin In an old textbook, Thomas John I'Anson Bromwich asks the reader to use the expansion 
$$ \tanh \left(\frac{\pi x}{2} \right) = 1 + 2 \sum_{n=1}^{\infty} (-1)^{n} e^{-n \pi x}$$
to show $$\lim_{t \to 0^{+}} \int_{0}^{\infty} e^{-tx} \tanh \left(\frac{\pi x}{2} \right) \sin (ax) \, dx = \text{csch}(a).$$
The reader is then supposed to assign this value to the divergent integral $$\int_{0}^{\infty} \tanh \left(\frac{\pi x}{2} \right) \sin (ax) \, dx $$
and deduce
$$\int_{0}^{\infty}\frac{\tanh(\frac{\pi x}{2})\sin(ax)}{x^{2}+1} \, dx= \frac{1}{2} \left[e^{-a}\log(e^{2a}-1)-e^{a}\log(1-e^{-2a})\right] \tag{1}.$$
This approach seems quite unusual and not easy to justify.
Can we prove $(1)$ in another way?

Consider the complex function $ \displaystyle f(z) = \tanh \left( \frac{\pi z}{2} \right) \frac{e^{iaz}}{1+z^{2}}$ where $a > 0$.
On the right, top, and left sides of a rectangular contour with vertices at $\pm 2N, \pm 2N + i2N$ (where N is a positive integer), $\tanh \left(\frac{\pi z}{2} \right)$ is uniformly bounded.
So using a slight modification of Jordan's lemma, we can conclude
$$ \int_{-\infty}^{\infty} \tanh \left( \frac{\pi z}{2} \right) \frac{e^{iaz}}{1+z^{2}} \, dx = 2 \pi i \left(\text{Res}[f(z),i] + \sum_{n=1}^{\infty} \text{Res}[f(z),i(2n+1)]\right) .$$
Now since
$$ \begin{align} f(z+i) &= e^{-a} \coth \left(\frac{\pi z}{2} \right) e^{iaz}\frac{1}{z} \frac{1}{z+2i} \\ &= e^{-a} \left(\frac{2 }{\pi z} + \mathcal{O}(z) \right) \left(1+iaz + \mathcal{O}(z^{2}) \right) \frac{1}{z} \left(- \frac{i}{2}+ \frac{z}{4} + \mathcal{O}(z^{2}) \right) \\ &= e^{-a} \left(-\frac{i}{\pi z^{2}} + \frac{2a+1}{2 \pi z} + \mathcal{O}(1) \right) , \end{align}$$
we get
$$ \text{Res}[f(z),i] = \text{Res}[f(z+i), 0] = \frac{e^{-a}(2a+1)}{2 \pi} .$$
And for $n \ge 1$,
$$ \begin{align}\text{Res}[f(z),i(2n+1)] &= \lim_{n \to i(2n+1)} \frac{\sinh (\frac{\pi z}{2}) e^{iaz}}{\frac{d}{dz} \,  \cosh (\frac{\pi z}{2}) (1+z^{2}) } \\ &= - \frac{1}{2 \pi} \frac{e^{-(2n+1)a}}{n(n+1)} . \end{align}$$
Therefore,
$$ \begin{align} \int_{-\infty}^{\infty} \tanh \left(\frac{\pi z}{2} \right) \frac{e^{iax}}{1+x^{2}} \ dx &= i e^{-a} (2a+1) - i \sum_{n=1}^{\infty} \frac{e^{-(2n+1)a}}{n(n+1)} \\ &= i e^{-a} (2a+1) + ie^{-a} \sum_{n=1}^{\infty} \left(\frac{1}{n+1} -\frac{1}{n} \right) e^{-2na} \\ &= 2i a e^{-a} + i e^{-a} + ie^{-a} \sum_{n=1}^{\infty} \frac{e^{-2na}}{n+1} - ie^{-a}\sum_{n=1}^{\infty} \frac{e^{-2na}}{n} \\ &= 2i a e^{-a} + ie^{-a} + i e^{-a} \left(- \frac{\log(1-e^{-2a})}{e^{-2a}} -1\right) + i e^{-a} \log (1-e^{-2a}) \\ &= 2ia e^{-a} - ie^{a} \log(1-e^{-2a})+ie^{-a} \log(1-e^{-2a}) . \end{align}$$
And equating the imaginary parts on both sides of the equation, we get
$$ \begin{align} \int_{0}^{\infty} \tanh \left(\frac{\pi x}{2} \right) \frac{\sin ax}{1+x^{2}} \ dx &= \frac{1}{2} \left( 2a e^{-a} + e^{-a} \log(1-e^{-2a}) - e^{a} \log(1-e^{-2a}) \right) \\ &= \frac{1}{2} \left(e^{-a} \log(e^{2a} (1-e^{-2a})) - e^{a} \log(1-e^{-2a})\right) \\ &= \frac{1}{2} \left(e^{-a}\log(e^{2a}-1)-e^{a}\log(1-e^{-2a})\right) . \end{align}$$
