$\int \frac{\tanh(x+c)}{x} dx$

86 Views Asked by At

I am struggling with the indefinite integration:

$\int \frac{\tanh(x+c)}{x} dx$

I doubt if the answer will be just transcendental functions. But what about special functions?

2

There are 2 best solutions below

2
On BEST ANSWER

I should be very careful if I had to use a series expansion of the integrand because it is impossible for a polynomial to fit a function as $\frac{\tanh(x)}{x}$.

What I prefer is to use a simple $[2,2]$ Padé approximant of the integrand. This would give $$ \frac{\tanh(x+c)}{x} =\frac{3 t^2+2 t x+\left(t^2-1\right) x^2 } {3 t x+\left(3 t^2-1\right) x^2 }\quad \text{where} \quad t=\tanh(c)$$ from which $$\int\frac{\tanh(x+c)}{x} dx=t \log(x)-\frac{t^2-1}{\left(1-3 t^2\right)^2}\left((1-3t^2)x +9t^2\log((3t^2-1)x+3t)\right)$$ Using it for the computation of $$I(a)=\int_1^a\frac{\tanh(x+\pi)}{x} dx$$ we should have the following results $$\left( \begin{array}{ccc} a & \text{approximation} & \text{exact}\\ 2 & 0.69248 & 0.69298 \\ 3 & 1.09691 & 1.09843 \\ 4 & 1.38315 & 1.38611 \\ 5 & 1.60452 & 1.60926 \\ 6 & 1.78482 & 1.79158 \\ 7 & 1.93675 & 1.94573 \\ 8 & 2.06790 & 2.07926 \\ 9 & 2.18317 & 2.19704 \\ 10 & 2.28592 & 2.30240 \end{array} \right)$$ which does not seem to be totally ridiculous.

For sure, we could use the next $[3,3]$ Padé approximant which would be $$ \frac{\tanh(x+c)}{x} =\frac { t+\left(1-\frac{t^2}{5}\right) x+\frac{t }{5}x^2+\frac{1}{15} \left(1-t^2\right) x^3} { x+\frac{4 t }{5}x^2+\frac{2-t^2}{5} x^3}$$ which, after partial fraction decomposition write $$\frac{(t^2-1) }{3 \left(t^2-2\right)}+\frac{t}{x}+\frac{\left(15 t^4-40 t^2+25\right)+\left(-3 t^5+13 t^3-10 t\right) x } {3(t^2-2)(-5-4 t x+\left(t^2-2\right) x^2)}$$ Repeating the same calculations as above $$\left( \begin{array}{ccc} a & \text{approximation} & \text{exact}\\ 2 & 0.69301 & 0.69298 \\ 3 & 1.09859 & 1.09843 \\ 4 & 1.38654 & 1.38611 \\ 5 & 1.61010 & 1.60926 \\ 6 & 1.79299 & 1.79158 \\ 7 & 1.94785 & 1.94573 \\ 8 & 2.08220 & 2.07926 \\ 9 & 2.20092 & 2.19704 \\ 10 & 2.30731 & 2.30240 \end{array} \right)$$ which is much better.

0
On

I prefer to add a separate answer for the specific case where $c=0$.

Staying with the idea of Padé approximants, the case where $c=0$ is interesting since they will write as $$P_{2n,2n}=\frac{\prod _{i=1}^n \left(x^2+a_i\right)} { \prod _{i=1}^n \left(x^2+b_i\right)}$$ where all coefficients $(a_i,b_i)$ are strictly positive $\forall i$. Up to $n=4$, these coefficients can be exactly computed with radicals.

Using partial fraction decomposition this will write as $$P_{2n,2n}=1+\sum_{i=1}^n \frac {c_i} {x^2+b_i}$$ and $$\int\frac{\tanh(x)}{x} dx\sim\int P_{2n,2n}\,dx=x+\sum_{i=1}^n \frac{c_i }{\sqrt{b_i}}\tan ^{-1}\left(\frac{x}{\sqrt{b_i}}\right)$$ The table below reports the value of $$I(a)=\int_0^a\frac{\tanh(x)}{x}\, dx$$ for the very first values of $n$

$$\left( \begin{array}{ccccccc} a & n=1 & n=2 & n=3 & n=4 & n=5 & \text{exact} \\ 1 & 0.90973 & 0.90968 & 0.90968 & 0.90968 & 0.90968 & 0.90968 \\ 2 & 1.52160 & 1.51941 & 1.51941 & 1.51941 & 1.51941 & 1.51941 \\ 3 & 1.93060 & 1.91817 & 1.91811 & 1.91811 & 1.91811 & 1.91811 \\ 4 & 2.24038 & 2.20553 & 2.20515 & 2.20515 & 2.20515 & 2.20515 \\ 5 & 2.49948 & 2.42961 & 2.42824 & 2.42823 & 2.42823 & 2.42823 \\ 6 & 2.73020 & 2.61410 & 2.61059 & 2.61054 & 2.61054 & 2.61054 \\ 7 & 2.94367 & 2.77203 & 2.76485 & 2.76469 & 2.76469 & 2.76469 \\ 8 & 3.14594 & 2.91128 & 2.89863 & 2.89823 & 2.89822 & 2.89822 \\ 9 & 3.34056 & 3.03690 & 3.01687 & 3.01603 & 3.01601 & 3.01600 \\ 10 & 3.52975 & 3.15230 & 3.12298 & 3.12142 & 3.12137 & 3.12137 \\ 11 & 3.71493 & 3.25985 & 3.21940 & 3.21678 & 3.21668 & 3.21668 \\ 12 & 3.89709 & 3.36127 & 3.30797 & 3.30390 & 3.30369 & 3.30369 \\ 13 & 4.07690 & 3.45782 & 3.39007 & 3.38410 & 3.38374 & 3.38373 \\ 14 & 4.25486 & 3.55042 & 3.46678 & 3.45844 & 3.45787 & 3.45784 \\ 15 & 4.43133 & 3.63980 & 3.53896 & 3.52777 & 3.52688 & 3.52683 \\ 16 & 4.60659 & 3.72652 & 3.60731 & 3.59277 & 3.59146 & 3.59137 \\ 17 & 4.78084 & 3.81100 & 3.67237 & 3.65399 & 3.65213 & 3.65199 \\ 18 & 4.95426 & 3.89360 & 3.73460 & 3.71190 & 3.70937 & 3.70915 \\ 19 & 5.12698 & 3.97460 & 3.79439 & 3.76689 & 3.76354 & 3.76322 \\ 20 & 5.29909 & 4.05422 & 3.85204 & 3.81930 & 3.81498 & 3.81451 \end{array} \right)$$

Edit

All of the above was done on the basis of function and derivatives values at $x=0$.

For sure, this could be improved at the price of some empirical fit. For example, if $n=2$, the approximant is $$P_{4,4}=\frac { 1+\frac{1}{9}x^2+\frac{1}{945}x^4} {1+\frac{4 }{9}x^2+\frac{1}{63}x^4 }$$ while, fitted over the range $0 \leq x \leq 20$, $$Q_{4,4}=\frac {1+\frac{23 }{297}x^2+\frac{1}{5350}x^4 } {1+\frac{110 }{271}x^2+\frac{1}{154}x^4 }$$ is incredibly better. To give an idea $$\int_0^{20} \left(\frac{\tanh (x)}{x}-P_{4,4}\right)^2 \, dx=4.84\times 10^{-3}$$ $$\int_0^{20} \left(\frac{\tanh (x)}{x}-Q_{4,4}\right)^2 \, dx=1.07\times 10^{-5}$$ are in a ratio of $453$.

For $a=20$ the integral will be $3.81597$