# Solving an equation with Lambert's W function? Or by any other means?

I am trying to solve the following equation for x in terms of $y$ and $c$ (with $x,y \in [0,1]$) $$\log\left(\frac{x}{1-x-y}\right) + \frac{x}{1-x-y} + \frac{y}{1-x-y} = c$$

I can solve this easier equation $$\log\left(\frac{x}{1-x-y}\right) + \frac{x}{1-x-y} = c$$

Let $$z = \frac{x}{1-x-y}$$

Then I can solve for $x$ using Lambert's W function \begin{align} \log(z) + z &= c \notag \\ z &= \exp(c)\exp(-z) \notag \\ z \exp(z) &= \exp(c) \notag \\ z &= W(\exp(c)) \notag \\ x &= \frac{(1-y)W(\exp(c))}{1+W(\exp(c))} \notag \end{align}

Can anyone help me solve the harder equation? Is Lambert's W function helpful here?

Thanks!

\begin{align} \ln\left(\frac{x}{1-x-y}\right) +\frac{x}{1-x-y} + \frac{y}{1-x-y} &= c \tag{1}\label{1} \end{align}

\begin{align} \ln\left(\frac{x}{1-x-y}\right) &= c+\frac{1-x-y-1}{1-x-y} ,\\ \ln\left(\frac{1-y}{1-x-y}-1\right) &= c+1-\frac{1}{1-x-y} ,\\ \ln\left(\frac{1-y}{1-x-y}-1\right) &= c-\left(\frac{1}{1-x-y}-1\right) ,\\ \ln\left(\frac{1-y}{1-x-y}-1\right) &= c-\frac{1}{1-y}\left(\frac{1-y}{1-x-y}-(1-y)\right) ,\\ \ln\left(\frac{1-y}{1-x-y}-1\right) &= c-\frac{1}{1-y}\left(\frac{1-y}{1-x-y}-(1-y)\right) ,\\ \ln\left(\frac{1-y}{1-x-y}-1\right) &= c-\frac{y}{1-y}-\frac{1}{1-y}\left(\frac{1-y}{1-x-y}-1\right) . \end{align}

Let

\begin{align} \frac{1-y}{1-x-y}-1&=z ,\\ c-\frac{y}{1-y}&=u ,\\ -\frac{1}{1-y}&=v \end{align}

and we have an equation

\begin{align} \ln z&=u+vz , \end{align}

which has a standard solution for $z$ in terms Lambert W function

\begin{align} z&=-\frac{\operatorname{W}(-v\exp(u))}{v} ,\\ x&=(1-y)\left(1-\frac1{1+z}\right) . \end{align}

You can use the Lambert $W$ to solve $$\log(s) + s + t = c$$ and get a curve parameterized by $t$.

For each value of $(s,t)$, then, $$\frac{x}{1-x-y} = s \qquad\qquad \frac{y}{1-x-y} = t$$ now reduces to a system of linear equations in $x$ and $y$, which is easy to solve.

All in all, you get $(x,y)$ as afunction of $t$.

• Hi Henning, thanks for your answer! This makes sense to me. Do you agree that it gives an implicit solution in the sense that $t = y / (1 - x - y)$? Is an implicit solution the best we can hope for here? Thanks! – alex Sep 12 '18 at 12:18
• @alex: I can't rule out that there is something smarter that could be done with this result, but I don't immediately see what it would be. – Henning Makholm Sep 12 '18 at 12:47

I fill in the details of Henning Makholm's answer here

First, the parametrized curve \begin{align} \log(s) + s + t &= c \notag \\ s \exp(s) &= \exp(c - t) \notag \\ s &= W(\exp(c-t)) \notag \end{align}

Second, the linear system gives $$x = \frac{s}{1+s+t}, \quad \quad y = \frac{t}{1+s+t}$$

Substituting $s$ gives $$x = \frac{W(\exp(c-t))}{1+W(\exp(c-t))+t}, \quad \quad y = \frac{t}{1+W(\exp(c-t))+t}$$

This solves for $x$ and $y$ in terms of $c$ and $t$. The solution is implicit in the sense that $t = \frac{y}{1-x-y}$.