Equation xy = yx



In general, exponentiation fails to be commutative. However, the equation $$x^y = y^x$$ has solutions, such as $$x=2,\ y=4.$$

History
The equation $$x^y=y^x$$ is mentioned in a letter of Bernoulli to Goldbach (29 June 1728 ). The letter contains a statement that when $$x\ne y,$$ the only solutions in natural numbers are $$(2, 4)$$ and $$(4, 2),$$ although there are infinitely many solutions in rational numbers, such as $$(\tfrac{27}{8}, \tfrac{9}{4})$$ and $$(\tfrac{9}{4}, \tfrac{27}{8})$$. The reply by Goldbach (31 January 1729 ) contains a general solution of the equation, obtained by substituting $$y=vx.$$ A similar solution was found by Euler.

J. van Hengel pointed out that if $$r, n$$ are positive integers with $$r \geq 3$$, then $$r^{r+n} > (r+n)^r;$$ therefore it is enough to consider possibilities $$x = 1$$ and $$x = 2$$ in order to find solutions in natural numbers.

The problem was discussed in a number of publications. In 1960, the equation was among the questions on the William Lowell Putnam Competition, which prompted Alvin Hausner to extend results to algebraic number fields.

Positive real solutions

 * Main source:

Explicit form
An infinite set of trivial solutions in positive real numbers is given by $$x = y.$$ Nontrivial solutions can be written explicitly using the Lambert W function. The idea is to write the equation as $$ae^b = c$$ and try to match $$a$$ and $$b$$ by multiplying and raising both sides by the same value. Then apply the definition of the Lambert W function $$a'e^{a'} = c' \Rightarrow a' = W(c')$$ to isolate the desired variable.


 * $$\begin{align}

y^x &= x^y = \exp\left(y\ln x\right) & \\ y^x \exp\left(-y\ln x\right) &= 1 & \left(\mbox{multiply by } \exp\left(-y\ln x\right)\right) \\ y\exp\left(-y\frac{\ln x}{x}\right) &= 1 & \left(\mbox{raise by } 1/x\right) \\ -y\frac{\ln x}{x}\exp\left(-y\frac{\ln x}{x}\right) &= \frac{-\ln x}{x} & \left(\mbox{multiply by } \frac{-\ln x}{x}\right) \end{align}$$


 * $$\Rightarrow -y\frac{\ln x}{x} = W\left(\frac{-\ln x}{x}\right)$$
 * $$\Rightarrow y = \frac{-x}{\ln x}\cdot W\left(\frac{-\ln x}{x}\right) = \exp\left(-W\left(\frac{-\ln x}{x}\right)\right)$$

Where in the last step we used the identity $$W(x)/x = \exp(-W(x))$$.

Here we split the solution into the two branches of the Lambert W function and focus on each interval of interest, applying the identities:


 * $$\begin{align}

W_0\left(\frac{-\ln x}{x}\right) &= -\ln x \quad&\text{for } &0 < x \le e, \\ W_{-1}\left(\frac{-\ln x}{x}\right) &= -\ln x \quad&\text{for } &x \ge e. \end{align}$$


 * $$0 < x \le 1$$:
 * $$\Rightarrow \frac{-\ln x}{x} \ge 0$$
 * $$\begin{align}\Rightarrow y &= \exp\left(-W_0\left(\frac{-\ln x}{x}\right)\right) \\

&= \exp\left(-(-\ln x)\right) \\ &= x \end{align}$$


 * $$1 < x < e$$:
 * $$\Rightarrow \frac{-1}{e} < \frac{-\ln x}{x} < 0$$
 * $$\Rightarrow y = \begin{cases}

\exp\left(-W_0\left(\frac{-\ln x}{x}\right)\right) = x \\ \exp\left(-W_{-1}\left(\frac{-\ln x}{x}\right)\right) \end{cases}$$


 * $$x = e$$:
 * $$\Rightarrow \frac{-\ln x}{x} = \frac{-1}{e}$$
 * $$\Rightarrow y = \begin{cases}

\exp\left(-W_0\left(\frac{-\ln x}{x}\right)\right) = x \\ \exp\left(-W_{-1}\left(\frac{-\ln x}{x}\right)\right) = x \end{cases}$$


 * $$x > e$$:
 * $$\Rightarrow \frac{-1}{e} < \frac{-\ln x}{x} < 0$$
 * $$\Rightarrow y = \begin{cases}

\exp\left(-W_0\left(\frac{-\ln x}{x}\right)\right) \\ \exp\left(-W_{-1}\left(\frac{-\ln x}{x}\right)\right) = x \end{cases}$$

Hence the non-trivial solutions are:

Parametric form
Nontrivial solutions can be more easily found by assuming $$x \ne y$$ and letting $$y = vx.$$ Then
 * $$(vx)^x = x^{vx} = (x^v)^x.$$

Raising both sides to the power $$\tfrac{1}{x}$$ and dividing by $$x$$, we get
 * $$v = x^{v-1}.$$

Then nontrivial solutions in positive real numbers are expressed as the parametric equation

The full solution thus is $$(y=x) \cup \left(v^{1/(v-1)},v^{v/(v-1)}\right) \text{ for } v > 0, v \neq 1 .$$

Based on the above solution, the derivative $$dy/dx$$ is $$1$$ for the $$(x,y)$$ pairs on the line $$y=x,$$ and for the other $$(x,y)$$ pairs can be found by $$(dy/dv)/(dx/dv),$$ which straightforward calculus gives as:
 * $$\frac{dy}{dx} = v^2\left(\frac{v-1-\ln v}{v-1-v\ln v}\right)$$

for $$v > 0$$ and $$v \neq 1.$$

Setting $$v=2$$ or $$v=\tfrac{1}{2}$$ generates the nontrivial solution in positive integers, $$4^2=2^4.$$

Other pairs consisting of algebraic numbers exist, such as $$\sqrt 3$$ and $$3\sqrt 3$$, as well as $$\sqrt[3]4$$ and $$4\sqrt[3]4$$.

The parameterization above leads to a geometric property of this curve. It can be shown that $$x^y = y^x$$ describes the isocline curve where power functions of the form $$x^v$$ have slope $$v^2$$ for some positive real choice of $$v\neq 1$$. For example, $$x^8=y$$ has a slope of $$8^2$$ at $$(\sqrt[7]{8}, \sqrt[7]{8}^8),$$ which is also a point on the curve $$x^y=y^x.$$

The trivial and non-trivial solutions intersect when $$v = 1$$. The equations above cannot be evaluated directly at $$v = 1$$, but we can take the limit as $$v\to 1$$. This is most conveniently done by substituting $$v = 1 + 1/n$$ and letting $$n\to\infty$$, so
 * $$x = \lim_{v\to 1}v^{1/(v-1)} = \lim_{n\to\infty}\left(1+\frac 1n\right)^n = e.$$

Thus, the line $$y = x$$ and the curve for $$x^y-y^x = 0,\,\, y \ne x$$ intersect at $x^{y} = y^{x}$.

As $$x \to \infty$$, the nontrivial solution asymptotes to the line $$y = 1$$. A more complete asymptotic form is
 * $$y = 1 + \frac{\ln x}{x} + \frac{3}{2} \frac{(\ln x)^2}{x^2} + \cdots.$$

Other real solutions
An infinite set of discrete real solutions with at least one of $$x$$ and $$y$$ negative also exist. These are provided by the above parameterization when the values generated are real. For example, $$x=\frac{1}{\sqrt[3]{-2}}$$, $$y=\frac{-2}{\sqrt[3]{-2}}$$ is a solution (using the real cube root of $$-2$$). Similarly an infinite set of discrete solutions is given by the trivial solution $$y=x$$ for $$x<0$$ when $$x^x$$ is real; for example $$x=y=-1$$.

Equation $x = y = e$
The equation $$\sqrt[x]y = \sqrt[y]x$$ produces a graph where the line and curve intersect at $$1/e$$. The curve also terminates at (0, 1) and (1, 0), instead of continuing on to infinity.

The curved section can be written explicitly as

$$y=e^{W_0(\ln(x^x))} \quad \mathrm{for} \quad 0<x<1/e,$$

$$y=e^{W_{-1}(\ln(x^x))} \quad \mathrm{for} \quad 1/e<x<1.$$

This equation describes the isocline curve where power functions have slope 1, analogous to the geometric property of $$x^y = y^x$$ described above.

The equation is equivalent to $$y^y=x^x,$$ as can be seen by raising both sides to the power $$xy.$$ Equivalently, this can also be shown to demonstrate that the equation $$\sqrt[y]{y}=\sqrt[x]{x}$$ is equivalent to $$x^y = y^x$$.

Equation $x} = \sqrt{x$
The equation $$\log_x(y) = \log_y(x)$$ produces a graph where the curve and line intersect at (1, 1). The curve becomes asymptotic to 0, as opposed to 1; it is, in fact, the positive section of y = 1/x.