# How to solve $n$ for $n^n = 2^c$?

How to solve $n$ for $n^n = 2^c$?

What's the numerical method?

I don't get this.

For $c=1000$, $n$ should be approximately $140$, right?

• try something like solve(n^n = 2^1000,n) instead of what you did. – Myself Mar 17 '11 at 13:13
• Out of curiosity. Where does this equation come up? Or is it just an exercise? – user2468 Mar 17 '11 at 16:57

Alpha sometimes goes off into the complex plane when what you want is only the reals. I agree with you and get about 140.222. If you ask to solve n(ln(n))=1000 ln(2) you get what you want.

Hint: Consider this.

Hint 2: First take $\log$ on both sides.

And explicitly: The solution to your question is given by $$n = e^{W(c\log 2)} = \frac{{c\log 2}}{{W(c\log 2)}}.$$ For $c=1000$, this gives $n \approx 140.2217$. The function $W$ is standard (ProductLog in Wolfram Mathematica).

EDIT: For large $c$, a rough but very simple approximation to the solution $n$ of $n^n = 2^c$ can be obtained as follows (cf. this, also for improvement of the approximation): $$n \approx (c\log 2)[\log (c\log 2)]^{1/\log (c\log 2) - 1} .$$ For example, for $c=1000$ this gives $n \approx 141.2083$, not far from the exact value of about $140.2217$.

• The wolframalpha link in the question actually has the $n = \exp(W(c\log 2))$ solution. :) – leif Mar 17 '11 at 15:08
• @leif: I noticed that after I posted the answer. – Shai Covo Mar 17 '11 at 15:23

Yes, take the $log_2$ of both sides gives you:

$$n log_2(n) = c$$

You can use Newton's method to solve this:

$$x_0 = c$$ $$x_{k+1} = x_k - (x_k log(x_k) - c log(2))/(1 + log(x_k))$$

where now "log" is the natural logarithm.

This gives the solution $n \sim x_4 = 140.221667$.

Starting with a better $x_0$, like $x_0=c / log(c)$ gives you even faster convergence. With c=1000 or c=1000000, the value $x_3$ is correct with an error of $10^{-8}$.