# Closed form solution to $x\log_2(1+\frac{a}{x}) = b$ using Lambert W.

Is there an expression for the solution to

$$x\log_2(1+\frac{a}{x}) = b$$ where $a$ and $b$ are constants, and $x$ is the variable? I am aware that there are no solutions that can be expressed in terms of elementary functions, but perhaps there is one using the Lambert W function?

Yet another: \begin{align} x\log_2\left(1+\frac ax\right)&=b\tag{1}\\ 1+\frac ax&=e^{b\log(2)/x}\tag{2}\\ 1+\frac ax&=2^{-b/a}e^{\large\frac{b\log(2)}a\left(1+\frac ax\right)}\tag{3}\\ \color{#00A000}{-\frac{b\log(2)}a\left(1+\frac ax\right)}e^{\color{#00A000}{\large-\frac{b\log(2)}a\left(1+\frac ax\right)}}&=-\frac{b\log(2)}a2^{-b/a}\tag{4}\\ -\frac{b\log(2)}a\left(1+\frac ax\right)&=\mathrm{W}\!\left(-\frac{b\log(2)}a2^{-b/a}\right)\tag{5}\\ x&=\bbox[5px,border:2px solid #F0C060]{\frac{-ab\log(2)}{b\log(2)+a\mathrm{W}\!\left(-\frac{b\log(2)}a2^{-b/a}\right)}}\tag{6}\\ &=\bbox[5px,border:2px solid #F0C060]{\frac{-\lambda a}{\lambda+\mathrm{W}\!\left(-\lambda e^{-\lambda}\right)}}\tag{7} \end{align} Explanation:
$(2)$: multiply by $\frac{\log(2)}x$ and exponentiate
$(3)$: add $\frac{b\log(2)}a$ to the exponent and divide by $2^{b/a}$
$(4)$: multiply both sides by $-\frac{b\log(2)}ae^{\large-\frac{b\log(2)}a\left(1+\frac ax\right)}$
$(5)$: apply $\mathrm{W}$
$(6)$: algebraically solve for $x$
$(7)$: substitute $\lambda=\frac{b\log(2)}a$

Note that in $(7)$, it appears that $\mathrm{W}\!\left(-\lambda e^{-\lambda}\right)=-\lambda$, making the denominator $0$. However, when the argument of $\mathrm{W}$ is negative, there are two branches. Thus, we need to use the other branch of $\mathrm{W}$ so that the denominator is not $0$.

• Ah! That last comment about the branches is really helpful; I couldn't figure out why only the $W_{-1}$ branch gave sensible, real answers (or why, when I numerically checked my solution in Mathematica, it insisted that there was a root whereabout $10^{22}$) – Milo Brandt Mar 14 '15 at 3:10

Yes; the first reasonable step is to isolate the logarithm so that we can get rid of it; dividing through by $x$ (which can't be $0$ if $b$ is non-zero) yields: $$\log_2\left(1+\frac{a}x\right)=\frac{b}x$$ and rewriting $\log_2(x)$ in terms of the natural logarithm as $\frac{\log(x)}{\log(2)}$ and rearranging gives: $$\log\left(1+\frac{a}x\right)=\frac{b\log(2)}x.$$ we then raise $e$ to the power of each side to get: $$1+\frac{a}x=e^{\frac{b\log(2)}x}.$$ Now, this looks kind of nasty; we need the exponent to be a simpler form before we can apply the product log - in particular, let $u=\frac{-b\log(2)}x$ and $\alpha=\frac{a}{b\log(2)}$. Then we write $$1-\alpha u = e^{-u}$$ which simplifies to $$(1-\alpha u)e^u = 1.$$ which is starting to look more manageable - but that addition on the left is still kind of worrisome - but we can get it out with another substitution. If we let $v$ be such that $u=v+\frac{1}{\alpha}$, then we get: $$-\alpha v e^{v+\frac{1}{\alpha}}=1$$ $$ve^v=-\frac{e^{-\frac{1}{\alpha}}}{\alpha}$$ Oh goody! We can definitely apply the product log to that: $$v=W\left(-\frac{e^{-\frac{1}{\alpha}}}{\alpha}\right)$$ meaning $$u=W\left(-\frac{e^{-\frac{1}{\alpha}}}{\alpha}\right)+\frac{1}{\alpha}$$ and hence $$x=\frac{-b\log(2)}{W\left(-\frac{e^{-\frac{1}{\alpha}}}{\alpha}\right)+\frac{1}{\alpha}}$$ and subbing in for the $\alpha$'s and doing careful simplification yields $$x=\frac{-b\log(2)}{W\left(-\frac{b}a2^{-b/a}\log(2)\right)+\frac{b\log(2)}a}$$

• one question, how does $-\alpha v e^{v+\frac{1}{\alpha}}=1$ become $ve^v=-\frac{e^{-\frac{1}{α}}}{α}$ – Irrational Person Mar 13 '15 at 0:06
• @IrrationalPerson Multiply both sides by $-\frac{e^{\frac{-1}{\alpha}}}{\alpha}$ and combine $e^{v+\frac{1}{\alpha}}e^{\frac{-1}{\alpha}}=e^v$. – Milo Brandt Mar 13 '15 at 0:08
• thanks for the explanation. – Irrational Person Mar 13 '15 at 0:11
• Wow, that's some fiendishly clever manipulation and substitution. Thanks! – user173690 Mar 13 '15 at 0:26