# Approximate solution of $x^a\tanh(x)=1$

As the title says, I am concerned by approximations of the solution of $$x^a\tanh(x)=1\tag1$$ where $$a$$ is a positive real number. From a numerical point of view, there is no problem to obtain the exact solution.

When $$a$$ is large, the asymptotics is $$x \sim 1+\frac{\beta}{a}+\frac{\beta (\beta -4 \sinh (\beta))}{2 a^2}\qquad \text{where} \qquad \beta=\log (\coth (1))$$ For example, if $$a=5$$, the above formula leads to $$1.04994$$ while the exact solution is $$1.05042$$ (relative error of $$0.05$$%).

Now, what I wanted is to get for any value of $$a$$ a good estimate of the solution without any iterative calculations. So what I did is to use one single iteration of Newton and higher order methods as described here using, for conveniency $$x_0=1$$; this is equivalent to solving for zero the numerator of the $$[1,k]$$ Padé approximant ($$k=0$$ corresponding to Newton, $$k=1$$ to Halley, $$k=3$$ to Householder).

As a result, the approximate solution is given by $$x_{(k)}=1+\frac{P_k(a)}{P_{k+1}(a)}$$ where $$P_n(a)$$ is a polynomial of degree $$n$$ the coefficients of which being themself polynomials in $$e$$. For example, for Halley's method $$(k=1)$$ the expression is $$x_{(1)}=1+\frac{2 \left(e^2-1\right) a+4}{e^2(e^2-1) a^2+\left(5 e^2-1\right) a+2}$$

Below are given some results for small $$k$$'s (without any problem, I generated the expressions up to $$k=10$$) $$\left( \begin{array}{ccccccc} a & x_{(0)} & x_{(1)}& x_{(2)} & x_{(3)} & x_{(4)} & \text{exact} \\ 1 & 1.2384058 & 1.1970317 & 1.1997872 & 1.1996704 & 1.1996799 & 1.1996786 \\ 2 & 1.1353353 & 1.1124979 & 1.1142730 & 1.1141829 & 1.1141849 & 1.1141850 \\ 3 & 1.0944859 & 1.0791714 & 1.0802947 & 1.0802452 & 1.0802458 & 1.0802462 \\ 4 & 1.0725789 & 1.0611595 & 1.0619446 & 1.0619148 & 1.0619149 & 1.0619151 \\ 5 & 1.0589184 & 1.0498479 & 1.0504375 & 1.0504180 & 1.0504179 & 1.0504180 \end{array} \right)$$

Where came my surprise is when I tried for small values of $$a$$

$$\left( \begin{array}{ccccccc} a & x_{(0)} & x_{(1)}& x_{(2)} & x_{(3)} & x_{(4)} & \text{exact} \\ \frac{1}{2} & 1.38502 & 1.32696 & 1.32578 & 1.32618 & 1.32629 & 1.32626 \\ \frac{1}{4} & 1.55598 & 1.51622 & 1.49335 & 1.49428 & 1.49557 & 1.49535 \\ \frac{1}{8} & 1.71463 & 1.77409 & 1.70469 & 1.69606 & 1.70227 & 1.70214 \\ \frac{1}{16} & 1.83357 & 2.08297 & 1.97567 & 1.92313 & 1.93420 & 1.93904 \\ \frac{1}{32} & 1.90923 & 2.38806 & 2.32647 & 2.18582 & 2.17615 & 2.19868 \\ \frac{1}{64} & 1.95246 & 2.63209 & 2.74297 & 2.52022 & 2.42933 & 2.47520 \\ \frac{1}{128} & 1.97565 & 2.79525 & 3.15685 & 2.95906 & 2.72910 & 2.76427 \\ \frac{1}{256} & 1.98768 & 2.89148 & 3.49084 & 3.47976 & 3.13242 & 3.06280 \end{array} \right)$$ which are not ridiculously bad.

The problem is that when $$a \to 0$$, $$x \to \infty$$ and I have no idea for expanding $$(1)$$ as a series for so large values of $$x$$ mainly because of the $$\tanh(x)$$ function.

Any idea or suggestion would really be welcome. Thanks in advance.

Edit

In his answer, Dr. Lutz Lehmann gave as an estimate $$x=\frac{1}{2} \left(\log \left(\frac{2}{a}\right)-\log \left(\log \left(\frac{1}{2} \log \left(\frac{2}{a}\right)\right)\right)\right)$$ and this looks to be an extremely good asymptotic formula for small values of $$a$$. For illustration using $$a=10^{-p}$$ $$\left( \begin{array}{ccc} p & \text{estimate} &\text{exact} \\ 1 & 1.9509850 & 1.7754966 \\ 2 & 2.6622064 & 2.6601002 \\ 3 & 3.6559407 & 3.6692855 \\ 4 & 4.7168233 & 4.7312764 \\ 5 & 5.8067083 & 5.8200164 \\ 6 & 6.9123770 & 6.9123770 \end{array} \right)$$

• Any special reason to avoid iteration? Computing the coefficients of $P_k, P_{k+1}$ probably leads to the same computational complexity. – PierreCarre Dec 2 '19 at 11:46
• @PierreCarre. Just for "l'amour de l'art" ! I wrote that,this does not make any problem. – Claude Leibovici Dec 2 '19 at 11:50

Taking the 1/1 Padé approximation $$e^u=\frac{1+\frac12u}{1-\frac12u}$$ of the exponential for $$x^{-a}=e^{-a\ln x}$$ results in comparing with $$\tanh(x)=\frac{1-e^{-2x}}{1+e^{-2x}}$$ in the approximation $$\frac a2 \ln x=e^{-2x}\iff 2x=\ln\frac2a-\ln(\ln(x))$$ which suggests $$x_1=\frac12\left[\ln\frac2a-\ln\left(\ln\left(\frac12\ln\frac2a\right)\right)\right]$$ as a first approximation. To have a point of reference, use some method to get a more exact approximation of the solution, here as a quick-to-implement method use the fixed point iteration $$x_{n+1}=\tanh^{-1}(x^{-a})$$ and test the result on the original equation.

for n in range(2,20):
a = 2**-n; x0 = log(2/a)/2;
x = x1 = x0-log(log(x0))/2;
for k in range(10): x=atanh(x**-a);
print n, "& \\frac1{%d}&"%(2**n), x1, " & ", x, " & ", x**a*tanh(x)-1, "\\\\"


This gives on the sequence of $$a$$ in the last table in the question following table $$\begin{array}{rc|ll|l} n& a=2^{-n} & x_1 & x_{11} & x_{11}^a\cdot\tanh(x_{11})-1\\ \hline 2 & \frac1{4}& 2.66243094375 & 1.77633206765 & 0.0901611590769 \\ 3 & \frac1{8}& 1.94575146365 & 1.70270926716 & 0.000117344143408 \\ 4 & \frac1{16}& 2.03198848232 & 1.93904599147 & 8.19762613569e-07 \\ 5 & \frac1{32}& 2.23536105442 & 2.19868481845 & 9.19858500481e-09 \\ 6 & \frac1{64}& 2.4863932055 & 2.47520347264 & 1.16757048474e-10 \\ 7 & \frac1{128}& 2.76279455706 & 2.76427224535 & -8.78186412478e-13 \\ 8 & \frac1{256}& 3.05471753622 & 3.06279840543 & -3.53383988738e-13 \\ 9 & \frac1{512}& 3.35700216967 & 3.3685741973 & -4.59632332195e-14 \\ 10 & \frac1{1024}& 3.66663363816 & 3.68000759967 & -5.66213742559e-15 \\ 11 & \frac1{2048}& 3.98171067569 & 3.99593300799 & -7.77156117238e-16 \\ 12 & \frac1{4096}& 4.30096413533 & 4.31548248049 & 0.0 \\ 13 & \frac1{8192}& 4.62350862728 & 4.63799869386 & 0.0 \\ 14 & \frac1{16384}& 4.94870429689 & 4.96297571276 & -1.11022302463e-16 \\ 15 & \frac1{32768}& 5.27607516971 & 5.29001819157 & 0.0 \\ 16 & \frac1{65536}& 5.60525852668 & 5.61881285943 & -1.11022302463e-16 \\ 17 & \frac1{131072}& 5.93597223767 & 5.94910828218 & 0.0 \\ 18 & \frac1{262144}& 6.26799296135 & 6.28070027781 & 0.0 \\ 19 & \frac1{524288}& 6.60114117195 & 6.61342125003 & 0.0 \\ \end{array}$$ This accuracy of the first digits holds also down to $$a=10^{-16}$$, after that the value of $$x^a$$ rounds to $$1$$ in floating point, which gives the unsolvable equation $$1=\tanh(x)$$.

• The OP suggested not using iteration. To keep iterations to a minimum, using your suggestion for initial approximation, Newton's method obtains similar or better results in no more than 3 iterations. – PierreCarre Dec 2 '19 at 16:49
• @PierreCarre : This might be a misunderstanding, the proposed answer is the first (or second, if one considers the part $x_0=\ln(2/a)/2$) approximation value $x_1$. The iteration only serves to produce a more exact value to compare the initial approximation to, it is just a quick'n'dirty fixed-point iteration. There is no doubt that any approximately quadratic method will be faster. – Lutz Lehmann Dec 2 '19 at 22:30
• Thank you for the clarification. $X_1$ is actually a very good approximation if we must abstain form iterating. – PierreCarre Dec 2 '19 at 22:37
• Thanks for your answer. As said, I do not want to iterate. Your $x_1$ is a very nice asymptotics. I added results in my edit. – Claude Leibovici Dec 3 '19 at 8:01
• Thinking about your formula, I am almost sure that it hides a Lambert function. – Claude Leibovici Dec 9 '19 at 8:17