2
$\begingroup$

How can I algebraically solve $n-\log(na)=b$ for $n$. I figured out a simple algorithm to get arbitrary close to the solution (estimate, then negate log term and use answer in the log term, then repeat), but I want to know how I can solve this exact.

$\endgroup$
  • $\begingroup$ There is no exact way of solving this-everything will eventually be an estimate. $\endgroup$ – John Dec 14 '13 at 13:08
  • $\begingroup$ Hmm, well are there at least any better algorithms than the one I described? $\endgroup$ – Jori Dec 14 '13 at 13:13
  • $\begingroup$ en.wikipedia.org/wiki/Lambert_W_function $\endgroup$ – mdenton8 Dec 14 '13 at 13:13
  • $\begingroup$ You can use the Lambert W function- but that is just another representation of the solution. There are many different type of algorithms-some that are very complicated. Calculators use some of these algorithms. $\endgroup$ – John Dec 14 '13 at 13:14
  • $\begingroup$ But does this special function evaluate faster to the solution than this simple algorithm (and are there any asymptotic bounds on how much faster)? I will look into this function though, thanks :) . $\endgroup$ – Jori Dec 14 '13 at 13:18
3
$\begingroup$

You can't solve this algebraically. However, you can rewrite your equation and express it in terms of a known special function, the Lambert W function:

$$n - \log(na) = b \iff n - \log n = b + \log a \iff \frac{e^n}{n} = a e^b \\ \iff n e^{-n} = \frac{1}{a e^b} \iff (-n)e^{-n} = -\frac{1}{a e^b} \implies n = -W\left(-\frac{1}{a e^b}\right)$$

| cite | improve this answer | |
$\endgroup$
2
$\begingroup$

If you cannot use Lambert function, the only way I can concieve is a root-finder method such as Newton. Provided a "good" guess, then the problem is quite simple. What you suggest would work but you have two manner for doing it.

The first one is the one you suggest, that is to say repeating
n = b + Log(n a)

The second one would be to repeat in the same spirit
n = Exp[n - b] / a

But both of same will be much slower than Newton iterative scheme which will write
n = n (-1 + b + Log[a] + Log[n]) / (n -1)
the rhs updating the lhs.

| cite | improve this answer | |
$\endgroup$
0
$\begingroup$

Hint: Use the Lambert W-function.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.