How to compute $\int_0^\infty \frac{\tanh\left(\pi x\right)}{x\left(1+x^2\right)} \, \mathrm{d}x$? How do I compute the following integral?
$$\int_0^\infty \frac{\tanh\left(\pi x\right)}{x\left(1+x^2\right)} \, \mathrm{d}x$$
I tried some basic substitutions but they only make it more complicated. WolframAlpha says the answer is $2$ but I have no clue how to get there.
 A: $\newcommand{\bbx}[1]{\,\bbox[15px,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{\on}[1]{\operatorname{#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}$
\begin{align}
&\bbox[5px,#ffd]{\int_{0}^{\infty}{\tanh\pars{\pi x}
\over x\pars{1 + x^{2}}}\,\dd x}
\\ = &\
\int_{0}^{\infty}{1
\over x\pars{1 + x^{2}}}\ \overbrace{\bracks{%
{8x \over \pi}\sum_{n = 0}^{\infty}
{1 \over
\pars{x^{2} + 1}\bracks{4x^{2} + \pars{2n + 1}^{2}}}}}
^{\ds{\tanh\pars{\pi x}}}\dd x
\\[5mm] = &\
{8 \over \pi}\sum_{n = 0}^{\infty}
\int_{0}^{\infty}{\dd x \over \pars{x^{2} + 1}\bracks{4x^{2} + \pars{2n + 1}^{2}}}
\\[2mm] &\ \pars{\substack{\ds{{\large x}\mbox{-integration is straightforward with}}\\[1mm] \ds{Partial\ Fraction\ Decomposition}}}
\\[2mm] = &\
\sum_{n = 0}^{\infty}{1 \over n^{2} + 2n + 3/4} =
\sum_{n = 0}^{\infty}
{1 \over \pars{n + 3/2}\pars{n + 1/2}}
\\[5mm] = &\
\Psi\pars{3 \over 2} - \Psi\pars{1 \over 2}
\label{1}\tag{1}
\\[5mm] = &\
\bracks{\Psi\pars{1 \over 2} + {1 \over 1/2}} -
\Psi\pars{1 \over 2} = \bbx{2}\label{2}\tag{2} \\ &
\end{align}

(\ref{1}): $\ds{\Psi:\ Digamma\ Function}$.
(\ref{2}): $\ds{\Psi}$-$\ds{Recurrence}$.
A: Let $N$ be a positive integer, and consider the contour integral of
$$ f(z) = \frac{\tanh(\pi z)}{z(z^2+1)} $$
along the boundary of the rectangle with the corners $\pm N$ and $\pm N+ iN$. Noting that $\tanh(\pi z)$ has a simple zero at $ki$ and a simple pole at $z_k := \bigl(k+\frac{1}{2}\bigr)i$ for each $ k \in \mathbb{Z}$, the function $f$ has simple poles only at $z_k$'s. (The poles at $0$ and $\pm i$ are cancelled out by the zeros of $f$.) So by the residue theorem,
\begin{align*}
\int_{-N}^{N} f(x) \, \mathrm{d}x
&= 2\pi i \sum_{k=0}^{N-1} \mathop{\mathrm{Res}}_{z=z_k} f(z) - \int_{\Gamma_N} f(z) \, \mathrm{d}z,
\end{align*}
where $\Gamma_N$ is the piecewise linear path from $N$ to $N+iN$ to $-N+iN$ to $-N$. Now it is not hard to show that the integral of $f$ along $\Gamma_N$ vanishes as $N\to\infty$, and so, letting $N\to\infty$ yields
\begin{align*}
\int_{-\infty}^{\infty} f(x) \, \mathrm{d}x
&= 2\pi i \sum_{k=0}^{\infty} \mathop{\mathrm{Res}}_{z=z_k} f(z) \\
&= i \sum_{k=0}^{\infty} \frac{2}{z_k (z_k + i)(z_k - i)} \\
&= i \sum_{k=0}^{\infty} \left( - \frac{1}{z_{k-1}} + \frac{2}{z_k} - \frac{1}{z_{k+1}} \right) \\
&= \frac{i}{z_0} - \frac{i}{z_{-1}} \\
&= 4.
\end{align*}
Therefore the answer is $\frac{1}{2} \cdot 4 = 2$.
A: Another thought is to try the following substitution:
$$I(t)=\int_0^\infty\frac{\tanh(tx)}{x(x^2+1)}dx$$
$u=-x\Rightarrow du=-dx$ and so:
$$I(t)=\int_0^{-\infty}\frac{\tanh(-tu)}{-u(u^2+1)}(-du)=\int_{-\infty}^0\frac{\tanh(tx)}{x(x^2+1)}dx$$
Which means that we can write:
$$I(t)=\frac12\int_{-\infty}^\infty\frac{\tanh(tx)}{x(x^2+1)}dx$$
$$I'(t)=\frac12\int_{-\infty}^\infty\frac{\tanh(tx)}{x^2+1}$$
$$I''(t)=\frac12\int_{-\infty}^\infty\frac{x\tanh(tx)}{x^2+1}dx$$
$$I'''(t)=\frac12\int_{-\infty}^\infty\frac{x^2\tanh(tx)}{x^2+1}=\frac12\int_{-\infty}^\infty\tanh(tx)dx-\frac12\int_{-\infty}^\infty\frac{\tanh(tx)}{x^2+1}dx$$

$$I'''(t)=-I'(t)$$
$$I'''+I'=0$$
now we just need to solve this ode:
$$I=Ae^{\lambda t},I'=A\lambda e^{\lambda t},I'''=A\lambda^3e^{\lambda t}$$
$$A\lambda e^{\lambda t}+A\lambda^3e^{\lambda t}=0$$
$$\lambda+\lambda^3=0,\,\lambda(\lambda^2+1)=0$$
$$\lambda=0,\pm i$$
$$I=A+Be^{it}+Ce^{-it}\Rightarrow I=c_1+c_2\cos(t)+c_3\sin(t)$$
now we just need to work out what these constants are. This part is proving difficult, but it seems obvious that $I'(t)=0$ everywhere since it is an odd function. we also know that $I(0)=0$ and that $I''(t)$ is going to be divergent everywhere other than $I''(0)=0$. This does not seem to fit well so maybe something is wrong but we can say:
$$I'(t)=0\Rightarrow I(t)=C$$
but $I(0)=0$ and so $I(t)=0$, which is clearly untrue. I've spent a while looking at this working out why it is wrong and I believe it is because $I''$ is not convergent.
This means that one of the main issues here is:
$$\lim_{t\to 0}\int_{-\infty}^\infty\frac{x\tanh(tx)}{x^2+1}dx$$
