How to prove $\int_{0}^{\infty} \frac{(1-x^2) \, \text{sech}^2\left(\frac{\pi x}{2} \right)}{(1+x^2)^2}\, dx = \frac{\zeta(3)}{\pi}$?

$$\int_0^\infty \frac{1-x^2}{(1+x^2)^2}\operatorname{sech}^2 \left(\frac{\pi x}{2}\right) dx\overset{IBP}=\pi\int_{0}^\infty \frac{x}{1+x^2}\operatorname{sech}^2 \left(\frac{\pi x}{2}\right)\tanh\left(\frac{\pi x}{2}\right)dx$$ $$=2\pi\int_{-\infty}^\infty \frac{x}{1+x^2}\color{blue}{\left(\frac{e^{\pi x/2}}{\left(e^{\pi x/2}+e^{-\pi x/2}\right)^3}-\frac{e^{-\pi x/2}}{\left(e^{\pi x/2}+e^{-\pi x/2}\right)^3}\right)}dx$$ $$\overset{x\to -x}=\color{blue}{2}\cdot 2\pi\int_{-\infty}^\infty \frac{x}{1+x^2}\color{blue}{\frac{e^{\pi x/2}}{\left(e^{\pi x/2}+e^{-\pi x/2}\right)^3}}dx\overset{\pi x\to x}=4\pi\int_{-\infty}^\infty \frac{x}{\pi^2+x^2}\frac{e^{2 x}}{(1+e^{ x})^3}dx$$ $$=4\pi\int_{-\infty}^\infty \Im\left(-\color{red}{\frac{1}{\pi+ix}}\right)\frac{e^{2 x}}{(1+e^{ x})^3}dx=-4\pi\Im\int_{-\infty}^\infty \color{red}{\int_0^\infty e^{-(\pi+ix)t}}\frac{e^{2 x}}{(1+e^{ x})^3}\color{red}{dt}dx$$ $$\small \overset{\large e^x\to x}=-4\pi\Im\int_0^\infty e^{-\pi t}\left(\lim_{a\to 1-it}\int_{0}^\infty\frac{x^a}{(1+x)^3}dx\right)dt=-4\pi\Im\int_0^\infty e^{-\pi t}\left(\lim_{a\to 1-it}\frac{\pi}{2}\frac{ a(1-a)}{\sin(\pi a)}\right)dt$$ $$=2\pi^2\int_0^\infty e^{-\pi t}\frac{t^2}{\sinh(\pi t)}dt\overset{\pi t =x}=\frac{4}{\pi} \int_0^\infty \frac{e^{-2x }x^2}{1-e^{-2x}}dx\overset{\large e^{-x}\to x}=\frac{4}{\pi}\int_0^1 \frac{x\ln^2 x}{1-x^2}dx$$ $$\overset{x^2\to x}=\frac{2}{\pi}\int_0^1\frac{\ln^2 x}{1-x}dx=\frac{2}{\pi}\sum_{n=1}^\infty \int_0^1 x^{n-1}\ln^2 x\, dx=\frac{2}{\pi}\sum_{n=1}^\infty\frac{1}{2n^3}=\frac{\zeta(3)}{\pi}$$


A solution by Cornel I. Valean

\begin{equation*} \begin{aligned} \int_{0}^{\infty} \frac{\displaystyle (1-x^2) \, \text{sech}^2\left(\frac{\pi x}{2} \right)}{(1+x^2)^2}\textrm{d}x&=-\frac{1}{2\pi}\lim_{n\to1/2}\frac{d^2}{dn^2}(2\psi(2n+1)-\psi(n+1)+\gamma)\\&=\frac{\zeta(3)}{\pi} \end{aligned} \end{equation*}

where the following fact is exploited, $\displaystyle \int_0^{\infty}\frac{\tanh(n\pi x)}{x(1+x^2)}\textrm{d}x=2\psi(2n+1)-\psi(n+1)+\gamma$. This last result is immediately obtained from the generalization found at the point $iii)$, Sect. $\textbf{1.40}$, page $26$, in (Almost) Impossible Integrals, Sums, and Series.

A note: Nice to see how the harmonic numbers (in a generalized form) play a great part here!


1)Integral evaluation applying Differentiation Under the Integral Sign:

First, let's consider the following function: $$f( \alpha ) =\int _{0}^{\infty }\frac{1-x^{2}}{\left( 1+x^{2}\right)^{2}}\frac{\tanh( \alpha x)}{x} dx$$

Then similarly to OP's series expansion for $\operatorname{sech}^2\left(\frac{\pi x}{2}\right)$, let's employ the series expansion of $\tanh(\alpha x)$ presented in Section 1.421 of Gradshteyn and Ryzhik

$$f( \alpha )=\frac{2}{a}\sum _{n\geqslant 1}\int _{0}^{\infty }\frac{1-x^{2}}{\left[ x^{2} +\left(\frac{\pi ( 2n-1)}{2a}\right)^{2}\right]\left( 1+x^{2}\right)^{2}} dx$$

This integral is pretty straight foward and just requires partial fractions: $$\begin{align} &\int _{0}^{\infty }\frac{1-x^{2}}{\left( x^{2} +\beta ^{2}\right)\left( 1+x^{2}\right)^{2}} dx \\\ &= \int _{0}^{\infty }\left[\frac{\beta ^{2} +1}{\left( \beta ^{2} -1\right)^{2}\left( x^{2} +\beta ^{2}\right)} -\frac{\beta ^{2} +1}{\left( \beta ^{2} -1\right)^{2}\left( 1+x^{2}\right)} +\frac{2}{\left( \beta ^{2} -1\right)\left( 1+x^{2}\right)^{2}}\right] dx\\\ &=\left[\frac{\left( \beta ^{2} +1\right)\arctan\left(\frac{x}{\beta }\right)}{\beta \left( \beta ^{2} -1\right)^{2}} -\frac{\left( \beta ^{2} +1\right)\arctan( x)}{\left( \beta ^{2} -1\right)^{2}} +\frac{\frac{x}{1+x^{2}} +\arctan( x)}{\left( \beta ^{2} -1\right)}\right]_{0}^{\infty }\\\ &=\frac{\pi }{2\beta ( \beta +1)^{2}}\end{align}$$

Then $$\begin{align}f(\alpha)=\frac{\pi }{a}\sum _{n\geqslant 1}\frac{1}{\frac{\pi ( 2n-1)}{2a}\left( 1+\frac{\pi ( 2n-1)}{2a}\right)^{2}} &=\sum _{n\geqslant 1}\left[\frac{1}{n-\frac{1}{2}} -\frac{1}{n-\frac{1}{2} +\frac{a}{\pi }} -\frac{a/\pi }{\left( n-\frac{1}{2} +\frac{a}{\pi }\right)^{2}}\right]\\&=\psi ^{( 0)}\left(\frac{a}{\pi } +\frac{1}{2}\right) -\psi ^{( 0)}\left(\frac{1}{2}\right) -\frac{a}{\pi } \psi ^{( 1)}\left(\frac{a}{\pi } +\frac{1}{2}\right)\end{align}$$

$\require{cancel}$

Differentiating and setting $\alpha=\frac{\pi}{2}$ $$\begin{align}\frac{d}{d\alpha}f\left(\frac{\pi}{2}\right) &=\int _{0}^{\infty }\frac{1-x^{2}}{\left( 1+x^{2}\right)^{2}}\operatorname{sech}^2\left(\frac{\pi x}{2}\right) dx\\&=\cancel{{\frac{1}{\pi } \psi ^{( 1)}( 1)} }-\cancel{\frac{1}{\pi } \psi ^{( 1)}( 1)} -\frac{1}{2\pi } \psi ^{( 2)}( 1)\\&=\frac{\zeta(3)}{\pi}\end{align}$$

2) Completing OP's solution:

To prove that the arc contribution vanishes as the raidius of the contour approaches infinity, let's apply the Estimation Lemma. $$\begin{align}\left|\int _{\Gamma } f( z) dz\right| &\leqslant \int _{0}^{\pi }\left|\frac{1-\left( Re^{it}\right)^{2}}{\left( 1+\left( Re^{it}\right)^{2}\right)^{2}}\operatorname{sech}^{2}\left(\frac{\pi Re^{it}}{2}\right)\right|\left| Rie^{it} dt\right|\\&\leqslant \frac{R^3}{R^4}\int _{0}^{\pi }\frac{dt}{\left|\operatorname{sech}^{2}\left(\frac{\pi Re^{it}}{2}\right)\right|}\leqslant \frac{R^3}{R^4}\int _{0}^{\pi }dt\leqslant \frac{\pi}{R}\end{align}$$

Which means that: $$\lim_{R\rightarrow \infty}\left|\int _{\Gamma } f( z) dz\right|\leqslant \lim_{R\rightarrow \infty}\frac{\pi}{R}\leqslant 0$$


After playing around a bit more with the Weierstrass product method, I realized I could proceed to do the integration with partial fractions. Using that $$ \int_{0}^{\infty} \frac{1}{(x^2+a^2)^n} \ dx = \frac{(2n-3)!!}{(2n-2)!!}\frac{\pi}{2a^{2n-1}}, \quad a\ge0,\ n \in \mathbb{N} $$ which can be easily derived from the results shown here, we get the following $\require{cancel}$ \begin{align*} I& \overset{\color{blue}{n\to n-1}}{=}\frac{4}{\pi^2} \sum_{n\ge \color{blue}{0}} \int_{0}^{\infty} \frac{(1-x^2)}{(1+x^2)^2}\left( \frac{4(2n\mathbin{\color{blue}{+}}1)^2}{\left(x^2 + (2n\mathbin{\color{blue}{+}}1)^2\right)^2} - \frac{2}{x^2 + (2n\mathbin{\color{blue}{+}}1)^2}\right)\, dx\\ & \overset{\color{purple}{a=2n+1}}{=}\frac{4}{\pi^2}\Bigg(\int_{0}^{\infty}\underbrace{\frac{8}{(x^2 +1)^4}-\frac{8}{(x^2 +1)^3} +\frac{2}{(x^2 +1)^2}}_{\color{red}{n=0}}\ dx +\sum_{n\ge \color{red}{1}} \Bigg[\frac{4(a^2 +1)}{(a^2 -1)^2}\int_{0}^{\infty} \frac{1}{(x^2 +1)^2}\, dx \\ & \qquad- \frac{2(a^4+6a^2 +1)}{(a^2 -1)^3}\int_{0}^{\infty} \frac{1}{x^2 +1}\, dx +\frac{2(a^4+6a^2 +1)}{(a^2 -1)^3}\int_{0}^{\infty} \frac{1}{x^2 +a^2}\, dx\\ &\qquad+\frac{4a^2(a^2 +1)}{(a^2 -1)^2}\int_{0}^{\infty} \frac{1}{(x^2 +a^2)^2}\, dx \Bigg]\Bigg)\\ & =\frac{4}{\pi^2} \Bigg( \frac{40\pi}{32} - \frac{24\pi}{16} +\frac{2\pi}{4}+\sum_{n\ge 1}\Bigg[\frac{4(a^2 +1)}{(a^2 -1)^2}\frac{\pi}{4} - \frac{2(a^4+6a^2 +1)}{(a^2 -1)^3}\frac{\pi}{2}+\frac{2(a^4+6a^2 +1)}{(a^2 -1)^3}\frac{\pi}{2 a }\\ &\qquad+\frac{4a^2(a^2 +1)}{(a^2 -1)^2}\frac{\pi}{4a^3}\Bigg]\Bigg)\\ & =\frac{4}{\pi} \left( \frac{1}{4}+\sum_{n\ge 1}\Bigg[\frac{a^5-a}{a(a^2 -1)^3} - \frac{a^5+6a^3 +a}{a(a^2 -1)^3}+\frac{a^4+6a^2 +1}{a(a^2 -1)^3} +\frac{a^4-1}{a(a^2 -1)^3}\Bigg]\right)\\ & =\frac{4}{\pi} \left( \frac{1}{4}+\sum_{n\ge 1}\frac{2\cancel{a}\cancel{(a-1)^3}}{\cancel{a}(a+1)^3\cancel{(a-1)^3}}\right)\\ & \overset{\color{purple}{a=2n+1}}{=}\frac{4}{\pi} \left( \frac{1}{4}+\frac{1}{4}\sum_{n\ge 1}\frac{1}{(n+1)^3}\right)\\ & =\frac{\zeta(3)}{\pi} \end{align*}