# Integral $\int_0^\infty\frac{\tanh^2(x)}{x^2}dx$

It appears that $$\int_0^\infty\frac{\tanh^2(x)}{x^2}dx\stackrel{\color{gray}?}=\frac{14\,\zeta(3)}{\pi^2}.\tag1$$ (so far I have about $1000$ decimal digits to confirm that). After changing variable $x=-\tfrac12\ln z$, it takes an equivalent form $$\int_0^1\frac{(1-z)^2}{z\,(1+z)^2 \ln^2z}dz\stackrel{\color{gray}?}=\frac{7\,\zeta(3)}{\pi^2}.\tag2$$ Quick lookup in Gradshteyn—Ryzhik and Prudnikov et al. did not find this integral, and it also is returned unevaluated by Mathematica and Maple. How can we prove this result? Am I overlooking anything trivial?

Further questions: Is it possible to generalize it and find a closed form of $$\mathcal A(a)=\int_0^\infty\frac{\tanh(x)\tanh(ax)}{x^2}dx,\tag3$$ or at least of a particular case with $a=2$?

Can we generalize it to higher powers $$\mathcal B(n)=\int_0^\infty\left(\frac{\tanh(x)}x\right)^ndx?\tag4$$

Thanks to nospoon's comment below, we know that $$\mathcal B(3)=\frac{186\,\zeta(5)}{\pi^4}-\frac{7\,\zeta(3)}{\pi^2}\tag5$$ I checked higher powers for this pattern, and, indeed, it appears that \begin{align}&\mathcal B(4)\stackrel{\color{gray}?}=-\frac{496\,\zeta(5)}{3\,\pi^4}+\frac{2540\,\zeta(7)}{\pi^6}\\ &\mathcal B(5)\stackrel{\color{gray}?}=\frac{31\,\zeta(5)}{\pi^4}-\frac{3175\,\zeta(7)}{\pi^6}+\frac{35770\,\zeta(9)}{\pi^8}\\ &\mathcal B(6)\stackrel{\color{gray}?}=\frac{5842\,\zeta(7)}{5\,\pi^6}-\frac{57232\,\zeta(9)}{\pi^8}+\frac{515844\,\zeta(11)}{\pi^{10}}\end{align}\tag6

I will open with the main theorem.

Let $s$ be a positive real number. Then the following equality holds. $$\frac{\pi^2}{4}\int_0^{\infty} \dfrac{\tanh(x)\,\tanh(x s)}{x^2}\,dx = s \int_0^1 \ln\left(\frac{1-x}{1+x}\right) \ln\left(\frac{1-x^s}{1+x^s}\right) \,\frac{dx}{x}.\tag{1}$$

Proof.

First, loagrithmically differentiate the Weierstrass-form product of the hyperbolic cosine, to obtain $\displaystyle \, \frac{1}{8x}\tanh(x)=\sum_{n=0}^{\infty} \frac1{\pi^2 (2n+1)^2+(2x)^2}\,.$

Also, since (elementarily) we have $\displaystyle \,\,\int_0^{\infty} \frac1{a^2+x^2}\,dx=\frac{\pi}{2a},\,\,$ it follows that $\displaystyle \,\int_0^{\infty} \frac1{(a^2+x^2)(b^2+x^2)}\,dx=\frac1{b^2-a^2}\int_0^{\infty}\left(\frac1{a^2+x^2}-\frac1{b^2+x^2}\right)dx=\frac{\pi}{2}\,\frac1{ab(a+b)}.$

So, \begin{align*} \int_0^{\infty} \frac{\tanh(x)\,\tanh(x s)}{64 x^2 s}\,dx\\ &=\int_0^{\infty} \sum_{n,m=0}^{\infty} \dfrac1{(\pi^2(2n+1)^2+(2x)^2)(\pi^2(2m+1)^2+(2xs)^2)}\,\,dx\\ &=\frac1{2^2 (2s)^2} \sum_{n,m=0}^{\infty} \int_0^{\infty} \dfrac1{x^2+\left(\frac{\pi}{2}(2n+1)\right)^2}\,\dfrac1{x^2+\left(\frac{\pi}{2s}(2m+1)\right)^2}\,dx\\ &=\frac1{4\pi^2} \sum_{n,m=0}^{\infty} \dfrac1{(2n+1)\,(2m+1)\,\,((2n+1)+s(2m+1))}\\ &=\frac1{4\pi^2} \sum_{n,m=0}^{\infty} \dfrac1{(2n+1)(2m+1)} \int_0^1 x^{(2n+1)+s(2m+1)}\,\frac{dx}{x}\\ &=\frac1{16\pi^2} \int_0^1 \ln\left(\frac{1-x}{1+x}\right)\ln\left(\frac{1-x^s}{1+x^s}\right)\,\frac{dx}{x}. \end{align*}

Example no. 1

Set $s=1$. With the substitution $x \mapsto \frac{1-x}{1+x},$ we have \begin{align*} \frac{\pi^2}{4}\int_0^{\infty} \frac{\tanh^2 x}{x^2}\,dx\\ &=\int_0^1 \ln^2\left(\frac{1-x}{1+x}\right)\,\frac{dx}{x}\\ &=2\int_0^1 \frac{\ln^2 x}{1-x^2}\,dx\\ &=2\int_0^1 \ln^2 x \sum_{n=0}^{\infty} x^{2n} \,dx\\ &=\sum_{n=0}^{\infty} \frac{4}{(2n+1)^3}=\frac{7}{2}\zeta(3). \end{align*}

Therefore,

$$\,\,\int_0^{\infty} \frac{\tanh^2 x}{x^2}\,dx=\frac{14\zeta(3)}{\pi^2}.$$

Example no. 2

Set $s=3$. Employing the same substitution, we have $$\int_0^1 \ln\left(\frac{1-x}{1+x}\right)\ln\left(\frac{1-x^3}{1+x^3}\right)\,\frac{dx}{x}=2\int_0^1 \frac{\ln x}{1-x^2} \ln\left(\frac{x(x^2+3)}{3x^2+1}\right)dx$$

Now, I was able to obtain the following: $$f(a)=\int_0^1 \dfrac{\ln x \,\ln(a^2+x^2)}{1-x^2}dx=-\frac{\pi^2}{8}\ln(1+a^2)+\frac14 F\left(-\frac1{a^2}\right)-2\operatorname{Re} F\left(\frac{i}{a}\right),$$

where $$F(z)=\text{Li}_3(z)+2\text{Li}_3(1-z)-\ln(1-z)\text{Li}_2(1-z)-\frac{\pi^2}{6}\ln(1-z)-2\zeta(3).$$

It comes from the fact that whenever $|z|<1$, $\displaystyle \,\, F(z)=\sum_{n=1}^{\infty} \frac{H_{n}^{(2)}}{n}\,z^n.$

Using that notation, $\displaystyle \,\,2\int_0^1 \frac{\ln x}{1-x^2}\ln\left(\frac{x(x^2+3)}{3x^2+1}\right)dx=\frac{7}{2}\zeta(3)+\frac{\pi^2}{4}\ln3+2f(\sqrt{3})-2f\left(\frac1{\sqrt{3}}\right).$

The trouble was simplifying the hideous, monstrous expression. After several hours of painful simplification by hand, I finally obtained

$$\int_0^1 \ln\left(\frac{1-x}{1+x}\right)\,\ln\left(\frac{1-x^3}{1+x^3}\right)\frac{dx}{x}=\frac{\pi^2}{18}\ln3-\frac{2\pi^2}{3}\ln2+\frac{8}{3}\ln^3 2-\frac{7}{2}\zeta(3)-2\text{Li}_3\left(\frac14\right)\\+16\operatorname{Re} \text{Li}_3(1-i\sqrt{3})-\frac{2\pi}{3}\operatorname{Im}\text{Li}_2\left(-\frac{i}{\sqrt{3}}\right).$$

(can it be simplified more?)

Or,

$$\int_0^{\infty} \frac{\tanh(x)\tanh(3x)}{x^2}\,dx=\frac23\ln3-8\ln2+\frac{32\ln^3 2}{\pi^2}-\frac{42\zeta(3)}{\pi^2}-\frac{24\text{Li}_3\left(\frac14\right)}{\pi^2}\\+\frac{192}{\pi^2}\operatorname{Re}\text{Li}_3(1-i\sqrt{3})-\frac{8}{\pi}\operatorname{Im}\text{Li}_2\left(-\frac{i}{\sqrt{3}}\right).$$

If we set $s=4$ and again substitute $x \mapsto \frac{1-x}{1+x},\,$ we find $$\int_0^1 \ln\left(\frac{1-x}{1+x}\right)\,\ln\left(\frac{1-x^4}{1+x^4}\right)\frac{dx}{x}=2\int_0^1 \frac{\ln x}{1-x^2} \ln\left(\frac{4x(1+x^2)}{x^4+6x^2+1}\right)\,\frac{dx}{x} \\=-\frac{\pi^2}{2}\ln2+\frac{7}{2}\zeta(3)+2f(1)-2f(\sqrt{2}+1)-2f(\sqrt{2}-1)$$

I am not courageous enough to even begin simplifying that.

It seems that a closed form may exist for each natural $s$ (and therfore, for each $1/n$ where $n$ is natural).

For example, under the subsitution $x \mapsto \frac{1-x}{1+x}$, the expression $\displaystyle \frac{1-x^5}{1+x^5}$ turns into $\displaystyle \frac{x(x^4+10x^2+5)}{5x^4+10x^2+1}$.

Factorizing $x^4+10x^2+5=(x^2+5+2\sqrt{5})(x^2+5-2\sqrt{5})$ and $\displaystyle 5x^4+10x^2+1=5\left(x^2+\frac1{5+2\sqrt{5}}\right)\left(x^2+\frac1{5-2\sqrt{5}}\right)$,

it follows that $$\int_0^1 \ln\left(\frac{1-x}{1+x}\right)\ln\left(\frac{1-x^5}{1+x^5}\right)\frac{dx}{x}=\frac72\zeta(3)+\frac{\pi^2}{4}\ln5+2f\left(\sqrt{5+2\sqrt{5}}\right)+2f\left(\sqrt{5-2\sqrt{5}}\right)-2f\left(\frac1{\sqrt{5+2\sqrt{5}}}\right)-2f\left(\frac1{\sqrt{5-2\sqrt{5}}}\right).$$

Similarly, $$\int_0^1 \ln\left(\frac{1-x}{1+x}\right)\ln\left(\frac{1-x^6}{1+x^6}\right)\frac{dx}{x}=\frac72\zeta(3)-\frac{\pi^2}{4}\ln6+2f(\sqrt{3})+2f\left(\frac1{\sqrt{3}}\right)-2f(1)-2f(2+\sqrt{3})-2f(2-\sqrt{3}).$$

A pattern can be seen. It seems that we can always factorize the expression that results by applying $x\mapsto \frac{1-x}{1+x}$ to $\frac{1-x^n}{1+x^n}$ into factors of the form $x$ and $x^2+r^2$ ($r \in \mathbb{C}$), implying that there is indeed a closed form in terms of logarithms and polylogarithms for $\int_0^{\infty} \tanh(x)\tanh(xn)/x^2\,\,dx$. In fact, the roots $r$ in the factorization seem to always be $\tan(q \pi)$ (up to multiplication by an imaginary unit), where q is a rational number (whose denominator is $n$ when $n$ is odd and $2n$ when it is even) . For example, $\displaystyle \sqrt{2}-1=\tan\left(\frac{\pi}{8}\right),\,\,\,\,\sqrt{5-2\sqrt{5}}=\tan\left(\frac{\pi}{5}\right),\,\,\,\,\,2-\sqrt{3}=\tan\left(\frac{\pi}{12}\right)\,\,$etc.

I am too lazy to write a general formula that works for every natural number.

$\Large \mathbf {EDIT}$

For the sake of completeness, I add below the general formula, which works for every natural number.

Theorem 2.$\,$ Let $n$ be a positive integer. Define the function $F$ by $$F(z)=\text{Li}_3(z) + 2\text{Li}_3(1-z) - \ln(1-z)\text{Li}_2(1-z) -\frac{\pi^2}{6}\ln(1-z)-2\zeta(3),$$ where we assume the principal value of the logarithm. Now, define the function $g$ by $$g(z)=F(-z^2)-8 \operatorname{Re} F(i z).$$ Then $$\int_0^1 \ln\left(\frac{1-x}{1+x}\right)\ln\left(\frac{1-x^n}{1+x^n}\right)\frac{dx}{x} =\frac{7}{2}\zeta(3)+\frac12 \sum_{k=1}^{n-1} (-1)^k g\left(\cot\left(\frac{k \pi}{2 n}\right)\right) .$$

This result, with the help of theorem $(1)$, can easily be seen to establish a closed form for $\mathcal A(n) = \int_0^{\infty} \frac{\tanh(x) \tanh(n x)}{x^2}dx$ for each natural $n$.

The solution for $n=3$ can be easily generalized to any $n\ge 2$: it suffices to use parity to extend the integration to $\mathbb R$ and then compute integral by residues by moving the contour to $i\infty$. The residues come from the poles of $\tanh^n z$ given by $z_k=i\pi\left(k+\frac12\right)$, $k\in \mathbb Z$.

For example, as $z\to z_k$, we have $$\frac{\tanh^2 z}{z^2}=\frac{1}{z_k^2}\frac{1}{(z-z_k)^2}-\frac{16i}{\pi^3(2k+1)^3}\frac{1}{z-z_k}+\mathrm{reg.},$$ and therefore the integral is given by $$\int_0^{\infty}\frac{\tanh^2 z}{z^2} dz=\frac12\cdot 2\pi i\sum_{k=0}^{\infty}\left(-\frac{16i}{\pi^3(2k+1)^3}\right)=\frac{14\zeta(3)}{\pi^2}.$$ For general $n$, we will obviously have a finite sum of zeta values.

The case of $$\mathcal I:=\int_0^{\infty}\frac{\tanh z\tanh 2 z}{z^2} dz$$ can be treated analogously. Potential poles of the integrand are given by $z^{I}_k=\frac{i\pi}{2}\left(k+\frac12\right)$ and $z^{II}_k=i\pi\left(k+\frac12\right)$, and we have $$\frac{\tanh z\tanh 2z}{z^2}= \begin{cases}\frac{\tanh z_k^I}{2\left(z_k^{I}\right)^2}\frac{1}{z-z_k^I}+\mathrm{reg.} & \text{as } z\to z_k^I,\\ \mathrm{reg.} & \text{as } z\to z_k^{II}, \end{cases}$$ so that the actual poles are only given by $z_k^I$. Therefore $$\mathcal I=\pi i\sum_{k=0}^{\infty}\frac{\tanh z_k^I}{2\left(z_k^{I}\right)^2} =\pi i\sum_{k=0}^{\infty}\frac{i(-1)^k}{2\left(\frac{i\pi}{2}\left(k+\frac12\right)\right)^2}=\frac{8K}{\pi},$$ where $K$ denotes Catalan's constant.

• (+1) Very nice answer. An alternative is given by the use of the Laplace transform. Commented Dec 20, 2015 at 15:17
• @JackD'Aurizio It would be nice to see an alternative approach as well. Commented Dec 20, 2015 at 20:21
• (+1) I was just made aware that my answer is very similar to yours, at least in a couple of points. I don’t know if my answer adds much but detail, but if you want, I will delete my answer.
– robjohn
Commented Jul 22, 2021 at 19:52
• @robjohn I think it is useful, and you definitely should NOT delete it. Commented Jul 22, 2021 at 21:46

I found a way to evaluate this integral without complex analysis, although I think that it is not rigorous yet, because I do not know how to justify the swapping of the integrals and the swapping of the integral and the infinite sum.

Anyway, start with the identity $\displaystyle \,\,\int_0^{\infty} \frac{\sin(z x)}{\sinh(\frac{\pi}{2}x)}dx=\tanh z\,\,\,\,\,\,$ (see here for a proof, for example.) So $$I=\int_0^{\infty} \frac{\tanh^2 z}{z^2}dz=\int_0^{\infty}\int_0^{\infty}\int_0^{\infty}\frac{\sin(zx)\sin(zt)}{z^2\sinh(\frac{\pi}{2}x)\sinh(\frac{\pi}{2}t)}dxdtdz \\\\=\int_0^{\infty}\int_0^{\infty}\frac{f(x,t)}{\sinh(\frac{\pi}{2}x)\sinh(\frac{\pi}{2}t)}dxdt$$

Where $$f(x,t)=\int_0^{\infty}\frac{\sin(z x)\sin(x t)}{z^2}dz=\large\begin{cases} \frac{\pi}{2}x &:&0<x\le t \\\\\frac{\pi}{2}t&:&0<t\le x\end{cases}$$

which I saw on this Wikipedia list. I could not evaluate this myself, nor find a reference anywhere. (Edit: found a reference.)

Anyway, due to the symmetry, $$I=\int_0^{\infty}\int_0^{\infty}\frac{f(x,t)}{\sinh(\frac{\pi}{2}x)\sinh(\frac{\pi}{2}t)}dxdt \\=\int_0^{\infty}\int_0^{t}\frac{f(x,t)}{\sinh(\frac{\pi}{2}x)\sinh(\frac{\pi}{2}t)}dxdt+\int_0^{\infty}\int_t^{\infty}\frac{f(x,t)}{\sinh(\frac{\pi}{2}x)\sinh(\frac{\pi}{2}t)}dxdt \\\\=2\int_0^{\infty}\int_t^{\infty}\frac{f(x,t)}{\sinh(\frac{\pi}{2}x)\sinh(\frac{\pi}{2}t)}dxdt \\\\=2\int_0^{\infty}\int_t^{\infty}\frac{\frac{\pi}{2} t}{\sinh(\frac{\pi}{2}x)\sinh(\frac{\pi}{2}t)}dxdt \\\\=-2\int_0^{\infty} \frac{t}{\sinh(\frac{\pi}{2} t)}\ln\tanh(\frac{\pi}{4} t)\,dt.$$

Since $\displaystyle \,\,\,\int \frac1{\sinh x}dx=\ln\tanh(\frac{x}{2})+C.$

Now substitute $x=\tanh(\frac{\pi}{4}t)$ to get $$I=-2\int_0^{\infty} \frac{t}{\sinh(\frac{\pi}{2} t)}\ln\tanh(\frac{\pi}{4} t)\,dt \\=-\frac{16}{\pi^2}\int_0^1\frac{\ln x}{x}\,\operatorname{arctanh} x\, dx \\=-\frac{16}{\pi^2}\int_0^1 \frac{\ln x}{x} \sum_{n=0}^{\infty} \frac{x^{2n+1}}{2n+1}\,dx \\=\frac{16}{\pi^2}\sum_{n=0}^{\infty} \frac1{(2n+1)^3} \\=\frac{14\zeta(3)}{\pi^2}.$$

I guess similar reasoning could be used to calculate $\mathcal B(n)$ for bigger natural $n$'s.

Also, here is a reference for other evaluations of $\mathcal A(2)$.

Edit

Yet another solution.

Again, start with the identity $\displaystyle \,\,\int_0^{\infty} \frac{\sin(z x)}{\sinh(\frac{\pi}{2}x)}dx=\tanh z\,.$

Differentiate to obtain
$\displaystyle \,\int_0^{\infty} \frac{x \cos(z x)}{\sinh(\frac{\pi}{2}x)}dx=\operatorname{sech}^2 z.$

It follows that $\displaystyle \,\,\,\,\int_0^{\infty} \frac{x(1- \cos(z x))}{\sinh(\frac{\pi}{2}x)}dx=1-\operatorname{sech}^2 z=\tanh^2 z.$

Recalling that $\int_0^{\infty} \frac{\sin^2 z}{z^2}dz=\frac{\pi}{2}$, we have $\displaystyle \int_0^{\infty} \frac{1-\cos(z x)}{z^2}dz=\int_0^{\infty} \frac{2\sin^2(z x /2)}{z^2}dz=\frac{\pi x}{2}.$

Finally, $$\int_0^{\infty} \frac{\tanh^2 z}{z^2}dz=\int_0^{\infty} \int_0^{\infty} \frac{x(1- \cos(z x))}{z^2 \sinh(\frac{\pi}{2}x)}dx dz\\ =\frac{\pi}{2}\int_0^{\infty} \frac{x^2}{\sinh(\frac{\pi}{2}x)}dx\\ =\frac{8}{\pi^2} \int_0^{\infty} x^2 \sum_{n=0}^{\infty} e^{-x(2n+1)}\,dx\\ =\frac{14\zeta(3)}{\pi^2}.$$

We can use an integral representation of the Dirichlet eta function to show that $$\int_{0}^{\infty} \frac{\tanh^{2}(x)}{x^{2}} \, dx = \int_{0}^{\infty} \left(1-\frac{1}{\cosh^{2}(x)} \right) \frac{dx}{x^{2}} = -56 \, \zeta'(-2) = \frac{14 \, \zeta(3)}{\pi^{2}}.$$

An integral representation of the Dirichlet eta function is $$\eta(s) = \frac{1}{\Gamma(s)}\int_{0}^{\infty} \frac{x^{s-1}}{e^{x}+1} \, dx \, , \quad \text{Re}(s) >0.$$

Integrating by parts, we get \begin{align} \eta(s) &= \frac{1}{s \, \Gamma(s)} \int_{0}^{\infty} \frac{x^{s} e^{x}}{(e^{x}+1)^{2}} \, dx= \frac{1}{4 \, \Gamma(s+1)}\int_{0}^{\infty} \frac{x^{s}}{\cosh^{2} \left(\frac{x}{2} \right)} \, dx \\ &=\frac{2^{s-1}}{\,\Gamma(s+1)} \int_{0}^{\infty} \frac{u^{s}}{\cosh^{2}(u)} \, dx \, , \quad \text{Re}(s) >-1. \tag{1} \end{align}

Combining $(1)$ with the Laplace transform of $x^{s}$, we get

$$\int_{0}^{\infty} \left(e^{-ax} - \frac{1}{\cosh^{2}(x)}\right)x^{s} = \Gamma(s+1) \left(\frac{1}{a^{s+1}} - \frac{\eta(s)}{2^{s-1}} \right) \, , \tag{2}$$ which holds for $\text{Re}(a) >0$ and $\text{Re}(s) >-2$.

If we restrict $s$ to the strip $-2 < \text{Re}(s) <-1$, then $(2)$ also holds for $a=0$.

So letting $s$ tend to $-2$ (and using the fact that $\eta(s)$ has a zero at $s=-2$), we get \begin{align} \int_{0}^{\infty} \left(1-\frac{1}{\cosh^{2}(x)}\right)\frac{dx}{x^{2}} &= -\lim_{s \downarrow -2} \frac{\Gamma(s+1) \eta(s)}{2^{s-1}} \\ &= -\lim_{s \downarrow -2} \left(- \frac{1}{s+2} + \mathcal{O}(1) \right) \eta(s) \left(8 + \mathcal{O}(s+2) \right) \\ &= 8 \lim_{s \downarrow -2} \frac{\eta(s) }{s+2} \\ &= 8 \, \eta'(-2) \\ &= -8 \left(1-2^{3} \right) \zeta'(-2) \tag{3} \\ &=-56 \, \zeta'(-2). \end{align}

But by differentiating both sides of the functional equation for the Riemann zeta function, we see that $$\zeta'(-2) = 2^{s-1} \pi^{s} \cos \left(\frac{\pi s}{2} \right) \Gamma(1-s) \zeta(1-s) \Big|_{s=-2} = -\frac{ \zeta(3)}{4\pi^{2}}.$$

Therefore, $$\int_{0}^{\infty} \left(1-\frac{1}{\cosh^{2}(x)} \right) \frac{dx}{x^{2}} = \frac{14 \zeta(3)}{\pi^{2}}.$$

An elementary evaluation:

\begin{align} I=&\int_{-\infty}^\infty\frac{\tanh^2 x}{2x^2} \overset{t=1/e^{2x}}{dx}\\ =&\int_0^\infty \left(\frac{1-t}{1+t}\right)^2\frac{1}{t\ln^2t}dt \overset{ibp}=4\int_0^\infty \frac{t-1}{(1+t)^3\ln t}dt \end{align}

Let $$J(a) =\int_0^\infty \frac{t^a-1}{(1+t)^3}\frac{dt}{\ln t}$$ $$J’(a)=\int_0^\infty \frac{t^a}{(1+t)^3}dt =\frac{\pi a(1-a) }{2\sin\pi a}$$

$$I=4\int_0^1J’(a)da \overset{ibp}=\int_0^1(4a-2)\ln \tan \frac{\pi a}2 da\\ \overset{t=\tan\frac{\pi a}2}= \frac4{\pi^2}\int_0^\infty \frac{\ln t\tan^{-1}\sqrt t}{\sqrt t(1+t)}dt$$ Let $$K(a)=\int_0^\infty \frac{\ln t\tan^{-1}a\sqrt t}{\sqrt t(1+t)}dt$$ $$K’(a)= \int_0^\infty \frac{\ln t}{(1+t)(1+a^2t)}dt = \frac{2\ln^2a}{1-a^2}$$ $$I = \frac4{\pi^2}\int_0^1 K’(a)da =\frac8{\pi^2}\int_0^1 \frac{\ln^2a}{1-a^2} da = \frac8{\pi^2}\frac74\zeta(3) =\frac{14 \zeta(3)}{\pi^2}$$

$$\mathcal{A}(m,n)=\int_{0}^{\infty}\frac{\tanh(z)^m}{z^n}\text{d}z\qquad m+1>n>1$$ We have \begin{aligned} &\mathcal{A}\left(1,p+1\right) =\frac{(2^{p+1}-1)}{\pi^p\cos\frac{p\pi}{2} } \zeta(p+1)\\ &\mathcal{A}\left(2,p+1\right)= \frac{(p+1)(2^{p+2}-1)}{\pi^{p+1}\sin\frac{p\pi}{2} } \zeta(p+2)\\ &\mathcal{A}\left(3,p+1\right)= \frac{(2^{p+1}-1)}{\pi^p\cos\frac{p\pi}{2} } \zeta(p+1) -\frac{(p+1)(p+2)(2^{p+3}-1)}{2\pi^{p+2}\cos\frac{p\pi}{2} }\zeta(p+3)\\ &\mathcal{A}\left(4,p+1\right)= \frac{4(p+1)(2^{p+2}-1)}{3\cdot\pi^{p+1}\sin\frac{p\pi}{2} } \zeta(p+2) -\frac{(p+1)(p+2)(p+3)(2^{p+4}-1)}{6\cdot\pi^{p+3}\sin\frac{p\pi}{2} }\zeta(p+4)\\ &\mathcal{A}\left(5,p+1\right)= \frac{(2^{p+1}-1)}{\pi^p\cos\frac{p\pi}{2} } \zeta(p+1) -\frac{5(p+1)(p+2)(2^{p+3}-1)}{6\cdot\pi^{p+2}\cos\frac{p\pi}{2} } \zeta(p+3) +\frac{(p+1)(p+2)(p+3)(p+4)(2^{p+5}-1)}{24\cdot\pi^{p+4}\cos\frac{p\pi}{2} }\zeta(p+5)\\ &\mathcal{A}\left(6,p+1\right)= \frac{23(p+1)(2^{p+2}-1)}{15\cdot\pi^{p+1}\sin\frac{p\pi}{2} } \zeta(p+2) -\frac{(p+1)(p+2)(p+3)(2^{p+4}-1)}{3\cdot\pi^{p+3}\sin\frac{p\pi}{2} } \zeta(p+4) +\frac{(p+1)(p+2)(p+3)(p+4)(p+5)(2^{p+6}-1)}{120\cdot\pi^{p+5}\sin\frac{p\pi}{2} }\zeta(p+6) \end{aligned} And substitute different p(can be a non-integer),your cases will done.

Proof: For $$n+m=2k$$,consider the function $$f(z)=\frac{\tanh(z)^m}{z^n}$$ And I get $$\int_{0}^{\infty}\frac{\tanh(z)^m}{z^n} \text{d}z =-\pi i\sum_{k=-\infty}^{\infty} \text{Res}(f,\frac{\pi}{2}(2k+1)i )$$ For $$n+m=2k+1$$,consider $$f(z)=\frac{\tanh(z)^m}{z^n}\ln z$$ And I get $$\int_{0}^{\infty}\frac{\tanh(z)^m}{z^n} \text{d}z =-\sum_{k=-\infty}^{\infty} \text{Res}(f,\frac{\pi}{2}(2k+1)i )$$ I dont have time to write a full answer.Thanks. (I will have exams for three days tomorrow.)

If we consider the function $$f(z)=\frac{\tanh z}{z^{1+p}}$$ And use the keyhole contour,we can obtain $$(1-e^{-2p\pi i})\int_{0}^{\infty} \frac{\tanh z}{z^{1+p}}\text{d}z = 2\pi i\sum_{k=-\infty}^{\infty}\text{Res}\left (\frac{\tanh z}{z^{1+p}}, \frac{\pi}{2}(2k+1)i \right )$$

A few examples

\begin{aligned} &\int_{0}^{\infty} \frac{\tanh z}{z^{3/2}} \text{d}z =\frac{4-\sqrt{2} }{\sqrt{\pi} } \zeta\left ( \frac{3}{2} \right )\\ &\int_{0}^{\infty} \frac{\tanh z}{z^{5/3}} \text{d}z =\frac{2(2^{5/3}-1)}{\pi^{2/3}}\zeta\left ( \frac{5}{3} \right )\\ &\int_{0}^{\infty} \frac{\tanh^2 z}{z^{2}} \text{d}z = \frac{14}{\pi^2}\zeta(3)\\ &\int_{0}^{\infty} \frac{\tanh^2 z}{z^{3/2}} \text{d}z = \frac{24-3\sqrt{2} }{2\pi^{3/2}} \zeta\left ( \frac{5}{2} \right )\\ &\int_{0}^{\infty} \frac{\tanh^2 z}{z^{5/2}} \text{d}z = \frac{80-5\sqrt{2} }{2\pi^{5/2}} \zeta\left ( \frac{7}{2} \right )\\ & \end{aligned}

Using the Taylor series for $$\tan\left(z+\frac{(2k+1)\pi}2\right)=-\frac1z+\frac z3+O\!\left(z^3\right)$$ and $$i\tanh(z)=\tan(iz)$$, we get $$\newcommand{\Res}{\operatorname*{Res}} \tanh^2\left(z+i\frac{(2k+1)\pi}2\right)=\frac1{z^2}+\frac23+O\!\left(z^2\right)\tag1$$ Using the Taylor series for $$\frac1{1+z}=1-z+O\!\left(z^2\right)$$, we get $$\frac1{\left(z+i\frac{(2k+1)\pi}2\right)^2}=-\frac4{(2k+1)^2\pi^2}-\frac{16iz}{(2k+1)^3\pi^3}+O\!\left(z^2\right)\tag2$$ Therefore, with $$z_k=i\frac{(2k+1)\pi}2$$ we get that $$\Res\limits_{z=z_k}\left(\frac{\tanh^2(z)}{z^2}\right)=-\frac{16i}{(2k+1)^3\pi^3}\tag3$$ We can use the contour of integration

\begin{align} \int_0^\infty\frac{\tanh^2(x)}{x^2}\,\mathrm{d}x &=\frac12\int_{-\infty}^\infty\frac{\tanh^2(x)}{x^2}\,\mathrm{d}x\tag{4a}\\ &=\pi i\sum_{k=0}^\infty\frac{-16i}{(2k+1)^3\pi^3}\tag{4b}\\ &=\frac{14}{\pi^2}\zeta(3)\tag{4c} \end{align} Explanation:
$$\text{(4a)}$$: use symmetry
$$\text{(4b)}$$: the integral along the contour is $$2\pi i$$ times the sum of the residues inside
$$\text{(4c)}$$: $$\sum\limits_{k=0}^\infty\frac1{(2k+1)^3}=\frac78\zeta(3)$$

The answer for $$(3)$$ from the question, with $$a=2$$, is given in this answer.

• This seems to be the same as Start wearing purple's answer but with more details. Commented Jul 22, 2021 at 19:31
• @RandomVariable: you know, his handling of $(1)$ from the question was so brief, that I missed it. I saw the result for $\tanh(x)\tanh(2x)$ and missed $\tanh^2(x)$. It’s hard to see everything, especially when there are a number of fairly long answers. I hope I didn’t step on any toes.
– robjohn
Commented Jul 22, 2021 at 19:46

Let $$\psi_{1}(z)$$ be the trigamma function.

Similar to the answer here, we can integrate the function $$g(z) = \psi_{1}\left(\frac{z}{\pi i } \right) \tanh^{2}(z)$$ around an rectangular contour with vertices at $$\pm R, \pm R + \pi i$$.

The function $$\psi_{1}\left(\frac{z}{\pi i} \right)$$ has a double pole at the origin, but it's canceled by the double zero of $$\tanh^{2}(z)$$.

Also, as $$\Re(z) \to \pm \infty$$, the magnitude of $$\tanh^{2}(z)$$ tends to $$1$$, while the magnitude of $$\psi_{1}\left(\frac{z}{\pi i} \right)$$ decays like $$\frac{\pi}{z}$$. This, coupled with the fact the height of the contour is fixed, causes the integral to vanish on the vertical sides of the contour as $$R \to \infty$$.

We therefore get

\begin{align}\lim_{R \to \infty}\oint g(z) \, \mathrm dz &=\int_{-\infty}^{\infty} \psi_{1}\left(\frac{x}{\pi i } \right) \tanh^{2}(x) \, \mathrm dx - \int_{-\infty}^{\infty}\psi_{1}\left(\frac{x}{\pi i} + 1 \right) \tanh^{2}(x) \, \mathrm dx \\ &= - \pi^{2} \int_{-\infty}^{\infty} \frac{\tanh^{2}(x)}{x^{2}} \, \mathrm dx \tag{1} \\ &= 2 \pi i \operatorname{Res}\left[g(z), \frac{\pi i}{2} \right] \\ &= 2 \pi i \left(\frac{\psi_{2} \left(\frac{1}{2} \right)}{\pi i}\right)\\& = -28 \zeta(3) \tag{2}.\end{align}

The result then follows.

The fastest way to determine the residue at $$z = \frac{\pi i}{2}$$ is to multiply the Laurent series expansion $$\tanh^{2}(z) = \frac{1}{\left(z-\frac{\pi i}{2}\right)^{2}} + \mathcal{O}(1)$$ with the Taylor expansion of $$\psi_{1} \left(\frac{z}{\pi i} \right)$$ at $$z= \frac{\pi i}{2}$$.

$$(1)$$ https://en.wikipedia.org/wiki/Polygamma_function#Recurrence_relation

$$(2)$$ https://mathworld.wolfram.com/PolygammaFunction.html (16)

To evaluate the integral $$\mathcal A(3)= \int_{0}^{\infty} \frac{\tanh (x) \tanh(3x)}{x^{2}} \, \mathrm dx,$$ we can integrate the function $$g(z) = \psi_{1} \left(\frac{z}{\pi i} \right) \tanh (z) \tanh(3z)$$ around the same contour.

We get \begin{align} \mathcal{A}(3) &= \frac{1}{\pi i } \left(\operatorname{Res}\left[g(z), \frac{\pi i }{6}\right] + \operatorname{Res}\left[g(z), \frac{5 \pi i}{6}\right] + \operatorname{Res}\left[g(z), \frac{\pi i}{2} \right]\right) \\ &= \frac{1}{\pi i} \left(\frac{i}{3} \, \psi_{1} \left(\frac{1}{6} \right) \tan \left(\frac{\pi}{6} \right) + \frac{i}{3} \, \psi_{1} \left(\frac{5 }{6} \right) \tan \left(\frac{5 \pi }{6} \right)- \frac{i}{3 \pi} \, \psi_{2} \left(\frac{1}{2} \right)\right) \\ &= \frac{1}{3 \sqrt{3} \, \pi} \left(\psi_{1} \left(\frac{1}{6} \right) - \psi_{1} \left(\frac{5}{6} \right) + \frac{14\sqrt{3}}{\pi} \, \zeta(3) \right). \end{align}

To show that $$\operatorname{Res} \left[g(z), \frac{\pi i}{2} \right] = \frac{1}{3 \pi i} \, \psi_{2} \left(\frac{1}{2} \right),$$ we can use the formula for the residue of a double pole derived here.

\begin{align} \operatorname{Res} \left[g(z), \frac{\pi i}{2} \right] &= \operatorname{Res} \left[\frac{\psi_{1} \left(\frac{z}{\pi i }\right) \sinh(z) \sinh(3z)}{\cosh(z) \cosh(3z)}, \frac{\pi i}{2} \right] \\ &= \operatorname{Res} \left[\frac{\psi_{1} \left(\frac{z}{\pi i }\right) \left(\cosh(4z) - \cosh(2z) \right)}{\cosh(2z) +\cosh(4z)}, \frac{\pi i}{2} \right] \\ &= \frac{6 \left( \frac{2}{\pi i} \, \psi_{2} \left(\frac{1}{2} \right)(12) \right) - 2 \left( 2 \, \psi_{1} \left(\frac{1}{2} \right)(0) \right)}{3(12)^{2}} \\ &= \frac{1}{3 \pi i} \, \psi_{2} \left(\frac{1}{2} \right) \end{align}

• Any ideas about $\tanh(x)\tanh(ax)$? Commented Jul 21, 2021 at 21:58
• @Random Variable $$\int_{0}^{\infty} \frac{\tanh(z)\tanh(2\alpha z)}{z^2} \text{d}z =\frac{1}{\pi\alpha} \sum_{k=0}^{\alpha-1} \tan\left ( \frac{\pi(2k+1)}{2\alpha} \right ) \psi^{(1)}\left ( \frac{2k+1}{2\alpha} \right )$$ For any $\alpha\in\mathbb{N}^{+}$ Commented Jul 23, 2021 at 11:41

$$\newcommand{\bbx}[1]{\,\bbox[8px,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{\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}$$ $$\ds{\large\mbox{Identity}\ \pars{1}\ \mbox{in the OP post:}}$$

Integrating twice by parts: \begin{align} \int_{0}^{\infty}{\tanh^{2}\pars{x} \over x^{2}}\,\dd x & = 2\int_{0}^{\infty}{\tanh\pars{x}\,\mrm{sech}^{2}\pars{x} \over x}\,\dd x \\[5mm] & = -6\ \underbrace{\int_{0}^{\infty}\ln\pars{x}\,\mrm{sech}^{4}\pars{x}\,\dd x} _{\ds{\mc{J}_{4}'\pars{0}}}\ +\ 4\ \underbrace{\int_{0}^{\infty}\ln\pars{x}\,\mrm{sech}^{2}\pars{x}\,\dd x} _{\ds{\mc{J}_{2}'\pars{0}}}\label{1}\tag{1} \end{align}

\begin{align} \mc{J}_{\nu}\pars{\mu} & \equiv \int_{0}^{\infty}x^{\mu}\,\mrm{sech}^{\nu}\pars{x}\,\dd x = 2^{\nu}\int_{0}^{\infty}x^{\mu}\expo{-\nu x}\,\pars{1 +\expo{-2x}}^{-\nu}\,\dd x \\[5mm] = &\ 2^{\nu}\sum_{n = 0}^{\infty}{-\nu \choose n}\int_{0}^{\infty}x^{\mu} \expo{-\pars{2n + \nu}x}\,\dd x = 2^{\nu}\,\Gamma\pars{\mu + 1}\sum_{n = 0}^{\infty} {\nu + n - 1 \choose \nu - 1}{\pars{-1}^{n} \over \pars{2n + \nu}^{\,\mu + 1}} \\[5mm] & = 2^{\nu - \mu - 1}\,\Gamma\pars{\mu + 1}\sum_{n = 0}^{\infty} {\nu + n - 1 \choose \nu - 1}{\pars{-1}^{n} \over \pars{n + \nu/2}^{\,\mu + 1}} \end{align}
\begin{align} \mc{J}_{2}\pars{\mu} & = 2^{1 - \mu}\,\Gamma\pars{\mu + 1}\sum_{n = 0}^{\infty} {\pars{-1}^{n} \over \pars{n + 1}^{\,\mu}} = 2^{2 - 2\mu}\pars{2^{\mu - 1} - 1}\Gamma\pars{\mu + 1}\zeta\pars{\mu} \\[5mm] \mc{J}_{2}'\pars{0} & = \bbx{\ds{-\gamma + \ln\pars{\pi \over 4}}} \label{2}\tag{2} \end{align}
\begin{align} \mc{J}_{4}\pars{\mu} & = 2^{3 - \mu}\,\Gamma\pars{\mu + 1}\sum_{n = 0}^{\infty}\pars{-1}^{n}\, {\pars{n + 3}\pars{n + 2}\pars{n + 1}/3! \over \pars{n + 2}^{\,\mu + 1}} \\[5mm] & = {1 \over 3}\,2^{2 - 2\mu}\Gamma\pars{\mu + 1}\bracks{% 4\zeta\pars{\mu - 2} - \zeta\pars{\mu} - 4\zeta\pars{\mu - 2,{3 \over 2}} + \zeta\pars{\mu,{3 \over 2}}} \\[5mm] \mc{J}_{4}'\pars{0} & = -\,{2 \over 3}\,\gamma - {2 \over 3}\,\ln\pars{4 \over \pi} + {28 \over 3}\,\ \overbrace{\zeta'\pars{-2}}^{\ds{-\,{\zeta\pars{3} \over 4\pi^{2}}\phantom{-}}} = \bbx{\ds{-\,{2 \over 3}\,\gamma - {2 \over 3}\,\ln\pars{4 \over \pi} - {7 \over 3\pi^{2}}\,\zeta\pars{3}}} \label{3}\tag{3} \end{align} $$\ds{\zeta'\pars{-2}}$$ is evaluated with [Riemann Functional Equation](https://en.wikipedia.org/wiki/Riemann_zeta_function#The_functional_equation).
With \eqref{1}, \eqref{2} and \eqref{3}: \begin{align} \int_{0}^{\infty}{\tanh^{2}\pars{x} \over x^{2}}\,\dd x & = -6\bracks{-\,{2 \over 3}\,\gamma - {2 \over 3}\,\ln\pars{4 \over \pi} - {7 \over 3\pi^{2}}\,\zeta\pars{3}} + 4\bracks{-\gamma + \ln\pars{\pi \over 4}} \\[5mm] & = \bbx{\ds{14\zeta\pars{3} \over \pi^{2}}} \\ & \end{align}

Solution 1. By the residue theorem, for any positive integer $$k$$, $$\int_{\gamma_k} \frac{\tanh ^2(z)}{z^2} d z=2 \pi i \sum_{j=1}^k \operatorname{Res}\left(\frac{\tanh ^2(z)}{z^2}, z_j\right)$$ where $$\gamma_k$$ is the boundary of the rectangle $$[-k, k] \times[0, i \pi k]$$ oriented counter-clockwise and $$z_j=$$ $$i \pi(j-1 / 2)$$ for $$j \in \mathbb{Z}$$ are the poles of the integrand function. We note that along the two vertical sides of $$\gamma_k$$, $$|\tanh ( \pm k+i y)|=\left|\frac{e^{ \pm k+i y}-e^{\mp k-i y}}{e^{ \pm k+i y}+e^{\mp k-i y}}\right| \leq \frac{e^k+e^{-k}}{e^k-e^{-k}} \leq \frac{1}{\tanh (k)} \leq \frac{1}{\tanh (1)}<2,$$ whereas, along the horizontal upper side, $$|\tanh (x+i \pi k)|=|\tanh (x)|<1$$. Hence, as $$k \rightarrow+\infty$$, $$\left|\int_{\gamma_k \backslash[-k, k]} \frac{\tanh ^2(z)}{z^2} d z\right| \leq 2 \int_0^{\pi k} \frac{4}{k^2+y^2} d y+\int_{-k}^k \frac{1}{x^2+\pi^2 k^2} d x \leq \frac{8 \pi k}{k^2}+\frac{2 k}{\pi^2 k^2}=\frac{8 \pi^3+2}{\pi^2 k} \rightarrow 0 .$$

Moreover, the following series expansion at $$z=z_j$$ holds: as $$w=z-z_j \rightarrow 0$$, $$\tanh (z)=\tanh \left(z_j+w\right)=\frac{1}{\tanh (w)}=\frac{1}{w+O\left(w^3\right)}=\frac{1}{w}+O(w)$$

Therefore $$\frac{\tanh ^2(z)}{z^2}=\frac{\left(\frac{1}{w}+O(w)\right)^2}{\left(z_j+w\right)^2}=\frac{1}{z_j^2}\left(\frac{1}{w^2}+O(1)\right)\left(1-\frac{2 w}{z_j}+O\left(w^2\right)\right)=\frac{1}{z_j^2 w^2}-\frac{2}{z_j^3 w}+O(1)$$ which implies that $$\operatorname{Res}\left(\frac{\tanh ^2(z)}{z^2}, z_j\right)=-\frac{2}{z_j^3}=-\frac{2 i}{\pi^3(j-1 / 2)^3}=-\frac{16 i}{\pi^3(2 j-1)^3} .$$

Finally, \begin{aligned} \int_0^{\infty} \frac{\tanh ^2(x)}{x^2} d x & =\frac{1}{2} \lim _{k \rightarrow \infty} \int_{-k}^k \frac{\tanh ^2(x)}{x^2} d x=\frac{1}{2} \lim _{k \rightarrow \infty} \int_{\gamma_k} \frac{\tanh ^2(z)}{z^2} d z \\ & =\pi i \sum_{j=1}^{\infty} \operatorname{Res}\left(\frac{\tanh ^2(z)}{z^2}, z_j\right)=\pi i \sum_{j=1}^{\infty} \frac{-16 i}{\pi^3(2 j-1)^3}=\frac{16}{\pi^2} \cdot \frac{7 \zeta(3)}{8}=\frac{14 \zeta(3)}{\pi^2} . \end{aligned}