$x^x = 2^{1000}$
I have tried newton-raphson but equation gets more complex as we progress. Is there any more simpler method to solve this?
$x^x = 2^{1000}$
I have tried newton-raphson but equation gets more complex as we progress. Is there any more simpler method to solve this?
On
The Lambert W function solves all your problems.
You can rewrite the problem as :
$x^x =2^{1000}$
$x\ln(x) =1000\cdot\ln(2)$
$e^{\ln(x)}\ln(x) = 1000\cdot \ln(2)$
$\ln(x) = W\bigg(1000\cdot \ln(2)\bigg)$
$x= e^{W\big(1000\cdot \ln(2)\big)}$
This can equivalently be written as :
$x= \dfrac{1000\cdot\ln(2)}{W(1000\cdot\ln(2))}$
On
From a programming point of view, you just want to find the one number that, when raised to itself, is $2^{1000}$ or at least in the neighborhood. So forget the Newton-Raphson method, just take a simple while loop and iterate the number $x$ until $2^{1000}-x^x\leq 0$.
x = 128;
dx = 0.1;
while 2^1000 - x^x > 0
x = x + dx;
end
$x=128$ is chosen because it is clear that $128=2^7$ so $(2^7)^{2^7}=2^{7\cdot128}$ and $7\cdot128<1000$
More precision on $x$ is acquired by making $dx$ smaller.
Rewrite the question as $$x\log(x) = 1000 \log(2)$$
and your Newton-Raphson recurrence becomes $$x_{n+1} = x_n - \dfrac{x_n\log(x_n) - 1000 \log(2)}{\log(x_n)+\log(e)}$$
using whatever logarithm base is most convenient for you ($e$, $2$ or $10$ are obvious possibilities)
Clearly $x_0=1$ is too low and $x_0=1000$ is too high but using either as a starting point will get you close to the answer in a handful of steps