TITLE: How to compute $\int_0^\infty \frac{\tanh\left(\pi x\right)}{x\left(1+x^2\right)} \, \mathrm{d}x$?
QUESTION [7 upvotes]: 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.

REPLY [2 votes]: $\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}$.