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}$? I was recently searching for interesting looking integrals. In my search, I came upon the following result:

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

and I wanted to try and prove it.

Inspired by this answer by Jack D'Aurizio, I took the Weierstrass product for $\cosh(x)$ to obtain
$$
\cosh\left(\frac{\pi x}{2} \right) = \prod_{n \ge 1}\left(1 + \frac{x^2}{(2n-1)^2} \right)
$$
And by logarithmically differentiating twice we get
$$
\frac{\pi^2}{4}\text{sech}^2\left(\frac{\pi x}{2} \right)  = \sum_{n \ge 1} \frac{4(2n-1)^2}{\left(x^2 + (2n-1)^2\right)^2} - \frac{2}{x^2 + (2n-1)^2}
$$
Which means we get
\begin{align*}
\int_{0}^{\infty} \frac{(1-x^2) \, \text{sech}^2\left(\frac{\pi x}{2} \right)}{(1+x^2)^2}\, dx & =\frac{4}{\pi^2}\sum_{n\ge 1} \int_{0}^{\infty}  \frac{(1-x^2)}{(1+x^2)^2}\left( \frac{4(2n-1)^2}{\left(x^2 + (2n-1)^2\right)^2} - \frac{2}{x^2 + (2n-1)^2}\right)\, dx
\end{align*}
However, after this, I couldn't figure out how to evaluate the resulting integral.
Does anyone know how I could continue this method? Or alternatively, does anyone know another way in which the result can be proven? Thank you very much!!
Edit:
Per jimjim's request, I'll add that I found this integral on the Wikipedia article for $\zeta(3)$. I believe the reference is to this text where the following formula is given
$$
(s-1) \zeta(s) = 2\pi \int_{\mathbb{R}}\frac{\left(\frac{1}{2} + xi \right)^{1-s}}{\left(e^{\pi x} +e^{-\pi x} \right)^2}\, dx
$$
which for the case of $s=3$ reduces to the surprisingly concise
$$
\int_{\mathbb{R}}\frac{\text{sech}^2(\pi x)}{(1+2xi)^2} \, dx = \frac{\zeta(3)}{\pi}
$$
And I presume that one can modify the previous equation to get to the original integral from the question, but it is not apparent to me how this may be done.
Edit 2:
Random Variable has kindly posted in the comments how to go from $\int_{\mathbb{R}}\frac{\text{sech}^2(\pi x)}{(1+2xi)^2} \, dx$ to $ \int_{0}^{\infty} \frac{(1-x^2) \, \text{sech}^2\left(\frac{\pi x}{2} \right)}{(1+x^2)^2}\, dx$. Thank you very much!
 A: 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!
A: 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}
$$
as shown in this answer, 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*}
A: 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$$
A: A somewhat simpler approach using contour integration is to first notice that  $$ \begin{align} \int_{-\infty}^{\infty} \frac{\operatorname{sech}^{2}\left(\frac{\pi x}{2}\right)}{\left(x+i \right)^{2}} \,  \mathrm dx  &=   \int_{-\infty}^{\infty} \frac{x^{2}-1}{(1+x^2)^{2}} \operatorname{sech}^{2} \left(\frac{\pi x}{2} \right) \, \mathrm dx - i\int_{-\infty}^{\infty} \frac{2x}{(1+x^2)^2} \operatorname{sech}^{2} \left(\frac{\pi x}{2} \right)   \, \mathrm dx  \\ &= \int_{-\infty}^{\infty} \frac{x^{2}-1}{(1+x^2)^{2}} \operatorname{sech}^{2} \left(\frac{\pi x}{2} \right) \, \mathrm dx.\end{align} $$
Integrating by parts, we get $$\int_{-\infty}^{\infty} \frac{\operatorname{sech}^{2} \left(\frac{\pi x}{2} \right)}{(x+i)^2} \, \mathrm dx = \frac{4}{\pi}\int_{-\infty}^{\infty} \frac{\tanh \left(\frac{\pi x}{2} \right)}{(x+i)^3} \, \mathrm dx.  $$
Now let's integrate the function $$ f(z) =\frac{\tanh \left(\frac{\pi z}{2} \right)}{(z+i)^3} $$ around a square contour with vertices at $ \pm N$, $\pm N + 2iN,$ where $N$ is some positive integer.
Since $\tanh \left(\frac{\pi z}{2} \right) $ is $2$- periodic in the imaginary direction and tends to $\pm 1$ as $\Re(z) \to \pm \infty$, the magnitude of $\tanh \left(\frac{\pi x}{2} \right)  $ remains bounded on the contour as $N \to \infty$ through the positive integers since the contour stays away from the poles on the imaginary axis.
We can therefore use the estimation lemma to argue that the integral vanishes on the vertical sides of the contour and the upper side of the contour as $N \to \infty$.
Inside the contour there are simple poles at $z= i(2n+1), n \in \mathbb{N}_{\ge 0}$.
Therefore, we have $$\begin{align} \int_{-\infty}^{\infty} \frac{\tanh \left(\frac{\pi x}{2} \right)}{(x+i)^3} \, \mathrm dx &= 2 \pi i \sum_{n=0}^{\infty}\operatorname{Res} [f(z), i(2n+1)] \\ &= 2 \pi i \sum_{n=0}^{\infty} \lim_{z \to i(2n+1)} \frac{\sinh \left(\frac{\pi z}{2} \right)}{\frac{\mathrm d}{\mathrm dz}\left((z+i)^3 \cosh \left(\frac{\pi z}{2} \right)\right)} \\ &= -2 \pi i \sum_{n=0}^{\infty} \frac{1}{4 \pi i (n+1)^3}  \\ &= -\frac{\zeta(3)}{2}, \end{align}$$
from which it follows that  $$\begin{align} \int_{0}^{\infty} \frac{1-x^2}{(1+x^2)^{2}} \operatorname{sech}^{2} \left(\frac{\pi x}{2} \right) \, \mathrm dx &= -\frac{1}{2} \int_{-\infty}^{\infty} \frac{x^2-1}{(1+x^2)^{2}} \operatorname{sech}^{2} \left(\frac{\pi x}{2} \right) \, \mathrm dx \\ &= -\frac{2}{\pi} \int_{-\infty}^{\infty} \frac{\tanh \left(\frac{\pi x}{2} \right)}{(x+i)^3} \, \mathrm dx \\ &=- \frac{2}{\pi} \left(-\frac{\zeta(3)}{2}  \right) \\ &= \frac{\zeta(3)}{\pi}. \end{align}$$
A: Following K.defaoite's suggestion, I've managed to get a partial solution using the Residue Theorem. Rewriting the integrand with the Weierstrass product for $\cosh$ squared in the denominator we get
$$
f(x) =\frac{(1-x^2) \, \text{sech}^2\left(\frac{\pi x}{2} \right)}{(1+x^2)^2} = \frac{(1-x^2) }{(x+i)^4(x-i)^4 \prod_{n\ge2}\left(\frac{1}{(2n-1)^4}\left(x+i(2n-1)\right)^2\left(x-i(2n-1)\right)^2 \right)}
$$
from where we see that we have poles of order $2$ at $z = \pm i(2n-1), \ k \ge 2$ and we have poles of order $4$ at $z = \pm i$.

To calculate the residues we'll use that
$$
\lim_{z \to (2n-1)i} \frac{(z -(2n-1)i)^2}{\cosh^2\left(\frac{\pi z}{2}\right)} \overset{\text{L.H.}}{=}\frac{4}{\pi}\lim_{z \to (2n-1)i} \frac{z -(2n-1)i}{\sinh\left(\pi z\right)}\overset{\text{L.H.}}{=}\frac{4}{\pi^2}\lim_{z \to (2n-1)i} \frac{1}{\cosh\left(\pi z\right)} =-\frac{4}{\pi^2}\tag{1}
$$
as $\cosh(iz) = \cos(z)$ and $\cos(-\pi) = -1$. And also
\begin{align*}
\lim_{z \to (2n-1)i} \frac{d}{dz} \left(\frac{z-(2n-1)i}{\cosh\left( \frac{z \pi}{2}\right)}\right)&\overset{u = z/i}{=}\frac{i}{i}\lim_{u \to 2n-1} \frac{d}{du} \left( \frac{u-(2n-1)}{\cos\left( \frac{u \pi}{2}\right)}\right)\\
& = \lim_{u \to 2n-1}\frac{\cos\left( \frac{u \pi}{2}\right) +\frac{\pi}{2}u\sin\left( \frac{u \pi}{2}\right) - \frac{\pi}{2}(2n-1)\sin\left( \frac{u \pi}{2}\right)}{\cos^2\left( \frac{u \pi}{2}\right)}\\
& \overset{\text{L.H.}}{=}\lim_{u \to 2n-1}\frac{\frac{\pi^2}{4}(u-(2n-1))\cos\left( \frac{u \pi}{2}\right)}{-\pi \sin\left( \frac{u \pi}{2}\right)\cos\left( \frac{u \pi}{2}\right)}\\
& = 0\tag{2}
\end{align*}
So we get
\begin{align*}
\text{Res}\left(f, i(2n-1)\right) & =\lim_{z \to (2n-1)i}\frac{d}{dz}\left(\frac{1-z^2}{(1+z^2)^2}\cdot \frac{(z - (2n-1)i)^2}{\cosh^2\left(\frac{\pi z}{2} \right)}\right)\\
& = \lim_{z \to (2n-1)i}\frac{2z(z^2-3)}{(1+z^2)^3}\cdot\underbrace{ \lim_{z \to (2n-1)i} \frac{(z - (2n-1)i)^2}{\cosh^2\left(\frac{\pi z}{2} \right)}}_{-\frac{4}{\pi^2}} \\
&\qquad + \lim_{z \to (2n-1)i}\left(\frac{1-z^2}{(1+z^2)^2}\right)\cdot 2 \lim_{z \to (2n-1)i} \left(\frac{z-(2n-1)i}{\cosh\left( \frac{z \pi}{2}\right)}\right)\underbrace{\lim_{z \to (2n-1)i} \frac{d}{dz} \left(\frac{z-(2n-1)i}{\cosh\left( \frac{z \pi}{2}\right)}\right) }_{0}\\
& = -\frac{4}{\pi^2}\frac{2((2n-1)i)(((2n-1)i)^2-3)}{(1+((2n-1)i)^2)^3}\\
& =-\frac{i}{2\pi^2}\left(\frac{1}{n^3} + \frac{1}{(n-1)^3} \right)
\end{align*}
By a similar (yet longer) procedure we can also get that
$$
\text{Res}\left(f, i\right) = -\frac{i}{2\pi^2}
$$
as can be verified here.

So we get that the residues are:
\begin{align*}
\text{Res}\left(f, i(2n-1)\right) &= -\frac{i}{2\pi^2}\left(\frac{1}{n^3} + \frac{1}{(n-1)^3} \right), \qquad n \ge 2\\
\text{Res}\left(f, i\right) &= -\frac{i}{2\pi^2}
\end{align*}
Now we take a semicircular contour with diameter from $-a$ to $a$, where the semicircle is on the upper part of the complex plane over which to integrate. As we tend to an infinite radius said contour will engulf the singularities $z =  i(2n-1), \ k \ge 1$, which means that
\begin{align}
\lim_{a \to \infty}\oint_{C}\frac{(1-z^2) \, \text{sech}^2\left(\frac{\pi z}{2} \right)}{(1+z^2)^2} \, dz & = 2 \pi i \left(-\frac{i}{2\pi^2}+\sum_{n=2}^{\infty} -\frac{i}{2\pi^2}\left(\frac{1}{n^3} + \frac{1}{(n-1)^3} \right)\right)\\
& =\frac{2}{\pi}  \zeta(3)\\
\end{align}
But remembering that
$$\lim_{a \to \infty}\oint_{C} f = \int_{\mathbb{R}} f + \lim_{a \to \infty}\int_{\text{Arc}} f =2\int_{0}^{\infty} f + \lim_{a \to \infty}\int_{\text{Arc}} f $$
it sufficies to show that the limit of the integral over the arc goes to $0$ to finish the solution, but I haven't found a way to justify this.
A: $$\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}$$
