# Integral with Tanh: $\int_{0}^{b} \tanh(x)/x \mathrm{d} x$

two integrals that got my attention because I really don't know how to solve them. They are a solution to the CDW equation below critical temperature of a 1D strongly correlated electron-phonon system. The second one is used in the theory of superconductivity, while the first is a more complex variation in lower dimensions. I know the result for the second one, but without the whole calculus, it is meaningless.

$$\int_0^b \frac{\tanh(c(x^2-b^2))}{x-b}\mathrm{d}x$$

$$\int_0^b \frac{\tanh(x)}{x}\mathrm{d}x \approx \ln\frac{4e^\gamma b}{\pi} \text{as} \ b \to \infty$$ where $\gamma = 0.57721...$ is Euler's constant

-
If you had edited your MO question with your motivation, I'm sure it would have been reopened. Nevertheless, your second result is wrong; differentiating the right-hand side does not give the integrand. –  Guess who it is. Nov 19 '10 at 16:00
you are right J.M. I've should have put $\approx$ sign in the second integral, but then again when I calculate it numerically it agrees perfectly.. –  zoran Nov 19 '10 at 16:16
What exactly is the domain of validity for your $b$ ? I have apparently made the implicit assumption that $b\in\mathbb{R}$, but there will have to be something special about your $b$ for "when I calculate it numerically it agrees perfectly" to be true. –  Guess who it is. Nov 19 '10 at 17:00
@ J.M.: agreed: integrating tanh(x)/x from 0 to 1 yields approximately 0.91. The natural logarithm of $4e^{\gamma}/(\pi)$ is about 0.82. So at least for b=1, the second equality isn't correct. –  Max Muller Nov 19 '10 at 19:54
Also, doing a quick inverse lookup on Wolfram Alpha's value for the integral from 0 to 1 yields nothing that looks remotely close, so I'm skeptical of any clean closed-form solution. –  Steven Stadnicki Nov 19 '10 at 21:10

The constant $C$ given in Aryabhata's answer, as suspected, is exactly

$$\gamma + \log \frac{4}{\pi},$$

which, together with Aryabhata's answer, nicely rounds off the second part of this question.

Since $\text{sech} x = 2(e^{-x} – e^{-3x} + e^{-5x} + \cdots ) \qquad (1)$ we have

$$\int_0^1 \frac{\tanh x}{x}\mathrm dx = 2\int_0^1 \frac{\sinh x}{x}(e^{-x} – e^{-3x} + e^{-5x} + \cdots )\mathrm dx$$

Now

$$2\int_0^1 \frac{\sinh x}{x} e^{-x}\mathrm dx = - \mathrm{Ei}(-2) + \gamma + \log 2$$ $$2\int_0^1 \frac{\sinh x}{x} e^{-3x}\mathrm dx = - \mathrm{Ei}(-4) + \mathrm{Ei}(-2) + \log 2$$ $$2\int_0^1 \frac{\sinh x}{x} e^{-5x}\mathrm dx = - \mathrm{Ei}(-6) + \mathrm{Ei}(-4) + \log (3/2)$$ $$2\int_0^1 \frac{\sinh x}{x} e^{-7x}\mathrm dx = - \mathrm{Ei}(-8) + \mathrm{Ei}(-6) + \log (4/3)$$

and so on, where $\mathrm{Ei}(x)$ is the exponential integral.

Thus, interchanging the order of summation, summing and using Wallis's product we obtain $$\int_0^1 \frac{\tanh x}{x}\mathrm dx = \gamma + \log \frac{4}{\pi} -2\mathrm{Ei}(-2)+2\mathrm{Ei}(-4)-2\mathrm{Ei}(-6) + \cdots. \qquad (2)$$

Using $(1)$ for $\mathrm{sech} x$ we also have

$$\int_0^1 \frac{2}{x(e^{2/x}+1) }\mathrm dx = 2 \int_1^\infty \frac{1}{x(e^{2x}+1)}\mathrm dx$$ $$= \int_1^\infty \frac{\text{sech} x}{x} e^{-x}\mathrm dx = 2 \int_1^\infty \frac{e^{-2x}}{x} - \frac{e^{-4x}}{x} + \frac{e^{-6x}}{x} - \cdots\mathrm dx$$ $$= -2\mathrm{Ei}(-2)+2\mathrm{Ei}(-4)-2\mathrm{Ei}(-6) + \cdots.$$

And so the result follows from $(2).$

-
+1 Very nice :-) –  Aryabhata Nov 22 '10 at 16:11

I get

$$\displaystyle \int_{0}^{b}\dfrac{\tanh(x)}{x} \approx C + \log b$$

where

$$\displaystyle C = \int_{0}^{1}(\dfrac{\tanh(x)}{x} -\dfrac{2}{x(e^{2/x}+1)} \ )\text{dx} = 0.81878\dots$$

We have $\displaystyle \log \frac{4e^{\gamma}}{\pi} = 0.81878\dots$, so your formula could be right! It is in fact correct.

Derivation

We have $\displaystyle \dfrac{\tanh(x)}{x} = \dfrac{1}{x} - \dfrac{2}{x(e^{2x}+1)}$

Assuming $b > 1$,

$$\displaystyle f(b) = \int_{0}^{b}\dfrac{\tanh(x)}{x} \ \text{dx} = \int_{0}^{1}\dfrac{\tanh(x)}{x} \ \text{dx} + \int_{1}^{b} (\dfrac{1}{x} - \dfrac{2}{x(e^{2x}+1)})\ \text{dx}$$

$$\displaystyle f(b) = \int_{0}^{1}\dfrac{\tanh(x)}{x} \ \text{dx} + \log b - \int_{1}^{b}\dfrac{2}{x(e^{2x}+1)}\ \text{dx}$$

Now $$\displaystyle \int_{1}^{b}\dfrac{2}{x(e^{2x}+1)}\ \text{dx} = \int_{1}^{\infty}\dfrac{2}{x(e^{2x}+1)}\ \text{dx} - \int_{b}^{\infty}\dfrac{2}{x(e^{2x}+1)}\ \text{dx}$$

Subsitute $t = \dfrac{1}{x}$ in the first integral, we get

$$\displaystyle \int_{1}^{\infty}\dfrac{2}{x(e^{2x}+1)}\ \text{dx} = \int_{0}^{1}\dfrac{2}{t(e^{2/t}+1)}\ \text{dt}$$

Thus

$$\displaystyle f(b) = \int_{0}^{1}(\dfrac{\tanh(x)}{x} -\dfrac{2}{x(e^{2/x}+1)} \ )\text{dx} + \log b + \int_{b}^{\infty}\dfrac{2}{x(e^{2x}+1)}\ \text{dx}$$

Now, as $\displaystyle b \to \infty$, $\displaystyle \int_{b}^{\infty}\dfrac{2}{x(e^{2x}+1)}\ \text{dx} \to 0$

Thus we have that,

$$\displaystyle \int_{0}^{b}\dfrac{\tanh(x)}{x} \approx \log b + \int_{0}^{1}(\dfrac{\tanh(x)}{x} -\dfrac{2}{x(e^{2/x}+1)} \ )\text{dx}$$

Thus

$$\displaystyle \int_{0}^{b}\dfrac{\tanh(x)}{x} \approx C + \log b$$

where

$$\displaystyle C = \int_{0}^{1}\left(\dfrac{\tanh(x)}{x} -\dfrac{2}{x(e^{2/x}+1)} \ \right)\text{dx} = 0.81878\dots$$

-
I thought that as well, but you just obtain the same integral as a result. Considering that the Euler-Mascheroni constant is involved, I suspect the answer is non-trivial. Maybe using Laplace-transforms in some way could help. –  Raskolnikov Nov 19 '10 at 17:52
@Rasko: You are right. I had an extra b, which cancelled the b in the denominator after integrating, giving a different integral... –  Aryabhata Nov 19 '10 at 17:55
The comments of Raskolnikov (and my response) are applicable to the first version of my answer. –  Aryabhata Nov 20 '10 at 22:47
@Moron WolframAlpha gives the value of $C$ as 0.81878 and not 0.864227, so it looks like the formula is correct. wolframalpha.com/input/?i=\int_0^1+(+(\tanh+x)/x+-+2/(x(e^(2/x)+%2B+1‌​))+)dx –  Derek Jennings Nov 22 '10 at 14:04
My link didn't post correctly, but never mind, recheck how you obtained that figure of 0.864227. –  Derek Jennings Nov 22 '10 at 14:14

For $x$ large, $\tanh x$ is very close to $1$. Therefore for large $b$, $$\int_0^b \frac{\tanh x}{x} \, \mathrm{d}x \approx C + \int^b \frac{\mathrm{d}x}{x} = C' + \log b.$$ You can prove it rigorously and obtain a nice error bound if you wish. Your post indicates a specific value of $C'$, but for large $b$, any two "close" constants $C_1,C_2$ will satisfy $$\log b + C_1 \approx \log b + C_2,$$ so probably $\gamma + \log (4/\pi)$ has no significance other than being a number close to $C'$ and having a nice form.

If we do the estimation rigorously, we will probably find out that $C'$ is well defined (i.e. the error in the first $\approx$ is $o(b)$), and then one can ask for its value. It probably has no nice closed form.

EDIT: In fact $\gamma + \log (4/\pi)$ is the correct constant, as shown in Derek's answer.

-