When x refuses to be boxed in

When x refuses to be boxed in

A rather peaceful sunday afternoon. I opened up my instagram and started scrolling through the feeds. Out of the blue, an asian beauty popped up and said "if you can't solve x18=6xx^{18} = 6^x, you are gay!". No joke, I literally jumped out my bed, took a piece of white paper and started solving it in a attempt to prove myself not gay. The strategy was pretty straight forward - isolate x. But dear god, this was one of those equations where x refuses to be linear about its feelings just like most "ex"s.

When powers are involved you take log to simplify, that's the golden rule and here's where it lead me to:

ln(x18)=ln(6x)\ln(x^{18}) = \ln(6^x)
18ln(x)=xln(6)18 \ln(x) = x \ln(6)

A bit of rearrangement gives you:

ln(x)x=ln(6)18\frac{\ln(x)}{x} = \frac{\ln(6)}{18}

Now what? After a few excruciating minutes of existential crisis, it finally hit me. I could just match LHS and RHS instead of actually solving for x. All I had to do was multiply the numerator and denominator of RHS with 2.

ln(x)x=2ln(6)218\frac{\ln(x)}{x} = \frac{2*\ln(6)}{2*18}
ln(x)x=ln(62)218\frac{\ln(x)}{x} = \frac{\ln(6^2)}{2*18}
ln(x)x=ln(36)36\frac{\ln(x)}{x} = \frac{\ln(36)}{36}
x=36x = 36

With a sigh of relief, proving myself not gay, I resumed the video. It presented a slight variation of the same trick and yielded 36 at the end.

But that got me thinking, is that really it? Would there be other solutions for the equation? After all, the solution that occurred to me was a random stroke of luck. Not that I really succeeded in isolating x.

And not just that, the function ln(x)\ln(x) is only defined for x>0x > 0 in the real number system. So when I transformed the equation from x18=6xx^{18} = 6^x to lnxx=ln618\frac{\ln x}{x} = \frac{\ln 6}{18}, I performed a step that is only valid for positive numbers (x>0x > 0).

Seems too incomplete to leave it at that.

*Throws the mobile phone away. Well I proved I am not gay 🤷*

Back to the whiteboard

Let's try to plot the graph of y=x18y = x^{18} and y=6xy = 6^x.

function_linear_scale

There are three intersecting points in the graph corresponding to the solutions to the equation x18=6xx^{18} = 6^x. "Wait a minute, I only see two" is probably what you are thinking. The point corresponding to x=36x=36 is indeed there but the y value, 6366^{36} or 361836^{18}, is so large that it can't be plotted easily on most graphs. Let's take y axis in logarithmic scale to see all the solutions clearly.

functions_plotted_in_logarithmic_scale

There we go! Three solutions to the problem and x=36x=36 is just one among them. But how to get the other two with a non-graphical approach. Enter the Lambert W function.

Lambert W function

To understand the Lambert W function better, let's just forget about the initial equation in question. We'll revisit that in a while.

Now consider the function y=xexy = xe^x.

This equation involves both a power of xx and an exponential of xx. The beauty of the latter is that all attempts to isolate xx in terms of yy, using standard algebraic operations, ends up in vain. These type of equations are called transcendental equations - meaning they cannot be solved using a finite number of additions, subtractions, multiplications, divisions, and root extractions.

Lambert W function, gives us a formal solution to solve a specific set of such transcendental equations that can be manipulated into the form:

f(x)ef(x)=yf(x) e^{f(x)} = y

In these cases f(x)f(x) can be solved as:

f(x)=W(y)f(x) = W(y)

where W is Lambert W function or the Omega function.

Now what exactly is this W function? To answer that let's further the analyze the function y=xexy = xe^x by plotting it.

y = xe^x

Notice that different values of xx can yield the same value of yy? That's the characteristic of a many-to-one function. This is contrary to the behavior of a one-to-one or injective functions where each value of yy have a distinct pre-image xx.

injective functions

Now we know that f(x)=xexf(x) = xe^x is a many-to-one function. So what's the big deal? Well, by trying to isolate and represent xx in terms of yy, what we are essentially doing is trying to find the inverse of f(x)f(x), i.e, f1(x)f^{-1}(x). And guess what, when you try to find the inverse of a many-to-one function, it ceases to exists as a single function and becomes a multi-valued relation.

why_non_injective_functions_cant_be_inverted_as_a_single_function

So how would the multi-valued inverse relation of y=xexy = xe^x look like? Technically it should satisfy the equation x=yeyx=ye^{y} which can be plotted.

inverse relation

Notice how the same value of x gives two different values of y. So how do we convert this relation to a predictable function. Behold, branching!

inverse to function by branching

In mathematics, a branch is defined as a maximal connected portion of the inverse that remains "well-behaved" (analytic and single-valued). To put it simply, a branch is just the result of taking a pair of scissors and cutting that curve into pieces so that each piece becomes a proper, predictable function. The point where you cut the function should be at a place where the function transitions from being single-valued to multi-valued—specifically at its critical point, so that each "branch" behaves like a proper function without ambiguity.

The multi-valued inverse relation of y=xexy = xe^x will give us two real branches if we split it at the critical point (1/e,1)(-1/e,-1). This gives us two separate, predictable "scissors-cut" functions: W0W_0 and W1W_{-1}.

two branches of the multi-valued inverse relation of y = xe^x

For real-valued inputs zz, the "full" Lambert W relation is written as a piecewise function:

W(z)={W0(z)if z1/e, gives W1W1(z)if 1/ez<0, gives W1W(z) =\begin{cases}W_0(z) & \text{if } z \geq -1/e, \text{ gives } W \geq -1 \\ W_{-1}(z) & \text{if } -1/e \leq z < 0, \text{ gives } W \leq -1\end{cases}

The defining identity of the Lambert W function is:

W(zez)=zW(z e^z) = z

That's a wrap to Lambert's W function. Let's pivot back to the original question now.

Solving equation using Lambert W function

Let's do some modifications on x18=6xx^{18} = 6^x until it matches the "template" of the function: wew=zw e^w = z.

First, we apply ln\ln to both sides to bring the exponents down and do a bit of rearrangement just like before:

ln(x)x=ln(6)18\frac{\ln(x)}{x} = \frac{\ln(6)}{18}

We know that, by logarithmic property, 1x=eln(x)\frac{1}{x} = e^{-\ln(x)}. Substituting this in the equation gives:

ln(x)eln(x)=ln(6)18\ln(x) \cdot e^{-\ln(x)} = \frac{\ln(6)}{18}

The template requires weww e^w. Right now, our exponent is ln(x)-\ln(x) but our coefficient is ln(x)\ln(x). They are opposite in sign. To fix this, we multiply the entire equation by 1-1:

ln(x)eln(x)=ln(6)18-\ln(x) \cdot e^{-\ln(x)} = -\frac{\ln(6)}{18}

Now the equation perfectly matches wew=zw e^w = z where: w=ln(x)w = -\ln(x) and z=ln(6)18z = -\frac{\ln(6)}{18}

To solve for xx, apply the Lambert W function to both sides:

W(ln(x)eln(x))=W(ln(6)18)W\left(-\ln(x) e^{-\ln(x)}\right) = W\left(-\frac{\ln(6)}{18}\right)
ln(x)=W(ln(6)18)-\ln(x) = W\left(-\frac{\ln(6)}{18}\right)

Finally, multiply by 1-1 and exponentiate to isolate xx:

ln(x)=W(ln(6)18)\ln(x) = -W\left(-\frac{\ln(6)}{18}\right)
x=eW(ln(6)18)x = e^{-W\left(-\frac{\ln(6)}{18}\right)}

There is a handy identity: eW(z)=W(z)ze^{-W(z)} = \frac{W(z)}{z}. Using this, we can rewrite the solution without the ee base:

x=W(ln(6)18)ln(6)18=18ln(6)W(ln(6)18)x = \frac{W\left(-\frac{\ln(6)}{18}\right)}{-\frac{\ln(6)}{18}} = -\frac{18}{\ln(6)} W\left(-\frac{\ln(6)}{18}\right)

Recall the piecewise Lambert function equation:

W(z)={W0(z)if z1/e, gives W1W1(z)if 1/ez<0, gives W1W(z) =\begin{cases}W_0(z) & \text{if } z \geq -1/e, \text{ gives } W \geq -1 \\ W_{-1}(z) & \text{if } -1/e \leq z < 0, \text{ gives } W \leq -1\end{cases}

When the argument is negative (between 1/e-1/e and 00), we get two branches; when it is positive, we get only one. Since in this case the argument is negative, for each branch, W0W_0 and W1W_1, we get a different value for xx, i.e, 1.1171.117 and 3636.

We are not done yet. To find the negative root, we have to account for the fact that x18=x18x^{18} = |x|^{18}.

xx can be negative as well.

Assume x=yx = -y where yy is a positive value (y>0y > 0). The equation x18=6xx^{18} = 6^x then becomes

(y)18=6y(-y)^{18} = 6^{-y}
y18=6yy^{18} = 6^{-y}

Now, let's force this into the wew=zwe^w = z template following a similar logic to before:

ln(y)y=ln(6)18\frac{\ln(y)}{y} = -\frac{\ln(6)}{18}
ln(y)eln(y)=ln(6)18\ln(y) e^{-\ln(y)} = -\frac{\ln(6)}{18}
ln(y)eln(y)=ln(6)18-\ln(y) e^{-\ln(y)} = \frac{\ln(6)}{18}

Now we have the form wew=zwe^w = z where: w=ln(y)w = -\ln(y) and z=ln(6)18z = \frac{\ln(6)}{18}

Apply the Lambert W function:

W(ln(y)eln(y))=W(ln(6)18)W(-\ln(y) e^{-\ln(y)}) = W\left(\frac{\ln(6)}{18}\right)
ln(y)=W(ln(6)18)-\ln(y) = W\left(\frac{\ln(6)}{18}\right)

Isolate yy:

y=eW(ln(6)18)y = e^{-W\left(\frac{\ln(6)}{18}\right)}

Since we defined x=yx = -y:

x=eW(ln(6)18)x = -e^{-W\left(\frac{\ln(6)}{18}\right)}

Using the identity eW(z)=W(z)ze^{-W(z)} = \frac{W(z)}{z} again:

x=W(ln(6)18)ln(6)18x = -\frac{W\left(\frac{\ln(6)}{18}\right)}{\frac{\ln(6)}{18}}

Because the argument to the Lambert function is positive, it falls into the part of the function where there is only one branch (W0W_0). Calculating this gives: x0.91311x \approx -0.91311

There it is, three solutions to the equation x18=6xx^{18} = 6^x. The content creator, who mad me do all this, should be proud. Well, here's to me unnecessarily saving another day.

നന്ദി... നമസ്കാരം (Nanni Namaskaram)