How to compute $\int_0^\infty \frac{\tanh\left(\pi x\right)}{x\left(1+x^2\right)} \, \mathrm{d}x$?

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$.


$\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}$.