Solving $x^{x^x}=c$ with Lambert's W function

Solution 1:

Taking a part of Yves Daoust's answer, see that

$$x^{x^{x+1}}=(x^x)^{x^x}=\left(x^{x^x}\right)^x=c$$

can be solved with two applications of the Lambert W function.

But of course, you wish to find $x^{x^x}=c$.

Suppose you know $x\approx d$.

This means

$$d^{d^d}\approx c$$

$$\implies d^{d^{d+1}}\approx c^d$$

Or,

$$x_{n+1}^{x_{n+1}^{x_{n+1}+1}}=c^{x_n}$$

$$\large x_{n+1}=e^{W\left[W(x_n\ln(c))\right]}$$

So, if you have a calculator handy, you can do something along these lines:

$$x_0=d$$

$$x_1=e^{W\left[W(d\ln(c))\right]}$$

$$x_2=e^{W\left[W(x_1\ln(c))\right]}$$

$$etc.$$

Testing it with $c=500$ and $x_0=2.3$:

$$\begin{align} x_0 & =\overline{2.3} \\ x_1 & =\overline{2.33}3760625 \\ x_2 & =\overline{2.339}000432 \\ x_3 & =\overline{2.3398}0707 \\ x_4 & =\overline{2.3399}31091 \\ x_5 & =\overline{2.33995}0156 \\ x_6 & =\overline{2.339953}086 \\ x_7 & =\overline{2.3399535}36 \\ \end{align}$$

See that $x_7^{x_7^{x_7}}=499.9994005$. The calculations may be a little off because I did them with my scientific calculator though, but it seems accurate enough. It also seems that it approximates one more digit at a time correctly, which may seem slow, but given the size of the numbers we are trying to use, a few digits make good differences. (compare $x=2.3$ and $x=2.4$ and see how far they are off from $c=500$.)

Also note that for the most part, the solution will be less than $4$ if $c$ even fits on your calculator.

Solution 2:

Not a solution, but you can solve a similar equation with a double application of $W$:

$$x^{x^{x+1}}=c,$$

because

$$x^{x^{x+1}}=(x^x)^{x^x}.$$

Unfortunately, $x^{x^{x+1}}$ is far form $x^{x^x}$, as it is $(x^{x^x})^x$.


For a numerical solution, I recommend Newton, with the iterations

$$x\leftarrow x-\frac{x\ln x+\ln \ln x-\ln\ln c}{\ln x+1-\dfrac1{x\ln x}}.$$

For the case $x^{x^x}=500$ with the starting approximation $2.3$, in three steps,

$$\begin{align}2.3&\to 286.234283705\\ 2.33993454643&\to 499.860587996\\ 2.33995361844&\to 499.999999977\\ 2.33995361844&\to 500.0\end{align}$$


An initial value can be estimated empirically by dropping the second term in

$$x\ln x+\ln\ln x=\ln\ln c.$$

Then solving with Lambert and using one of its asymptotic expressions we get

$$x\approx\frac{\ln\ln c}{\ln\ln\ln c}(\ln\ln\ln c)^{1/k \ln\ln\ln c}.$$

By trial and error, we found $k=4$ to give good results (e.g. $500\to2.457$) for values of $c$ in the range of double-precision floats. It is worth to note that because of some overshoot, with this starting formula Newton's iterations fail on the evaluation of $\ln\ln x$ for $c<33$. Smaller values require a different method.

Solution 3:

A potential solution can be extrapolated from my first question on this site (found here), where I explain that the function $$x^{x^x} = \,^3x = x + \sum_{n=2}^{\infty}\sum_{k=0}^{n-2}\bigg(\frac{S_{n-1}^{k+1}\log^{k+n}(x)x^n}{\Gamma(n)}\bigg) = x + \sum_{n=0}^{\infty}\sum_{k=0}^{n}\bigg(\frac{S_{n+1}^{k+1}\log^{k+n+2}(x)x^{n+2}}{\Gamma(n+2)}\bigg)$$
Where $S_n^k$ are the Stirling numbers of the second kind. This could potentially be used to express a solution in terms of an infinite series which could then be calculated to arbitrary accuracy.