How to prove that $x^y - y^x = x + y$ has only one solution in positive integers?

Prompted by this question, I tried to show that $(2,5)$ is the only solution in positive integers of $x^y - y^x = x+y$ (which would show, a fortiori, that it's the only solution in primes). It's convenient to rewrite the equation as $f(x,y) = x^y - y^x - x - y = 0$.

With the aid of some trial calculations, I reasoned informally as follows:

If $x=1$ then $f(x,y) = -2y=0$, implying $y=0$.

If $x=2$ and $y \leq 5$, then a case-by-case check shows that only $(2,5)$ is a solution.

If $(x,y) = (2,6)$ then $f(x,y) = 20$, and as $y$ increases above $6$, $f(x,y)$ increases.

If $x \geq 3$ and $y \leq x$ then $f(x,y) < 0$.

If $x \geq 3$ and $y=x+1$, then $f(x,y)>0$, and as $y$ increases above $x+1$, $f(x,y)$ increases.

How can the above be made into a rigorous proof? I've included calculus as a tag since it could be useful in showing under what conditions $f(x,y)$ is an increasing function of $y$ (viewing it as a real variable).

If $(x,y) = (2,6)$ then $f(x,y) = 20$, and as $y$ increases above $6$, $f(x,y)$ increases.

To prove this rigorously, let us prove by induction that $$2^{X-1}\gt X+1\tag1$$ for $X\ge 6$.

The base case : $2^{6-1}=32\gt 7=6+1$.

Supposing that $(1)$ holds for some $X$ gives $$2^{(X+1)-1}=2\cdot 2^{X-1}\gt 2(X+1)=X+X+2\gt (X+1)+1\quad\blacksquare$$

Using $(1)$, we get, for $y\ge 6$, $$f(2,y+1)-f(2,y)=2(2^{y-1}-y-1)\gt 0$$

If $x \geq 3$ and $y \leq x$ then $f(x,y) < 0$.

• $f(x,1)=-2\lt 0$.

• To prove that $f(x,2)\lt 0$ for $x\ge 3$, let us prove by induction that $$2^X\gt X^2-X-2\tag2$$ for $X\ge 4$. The base case : $2^4=16\gt 10=4^2-4-2$. Supposing that $(2)$ holds for some $X$ gives \begin{align}2^{X+1}&=2\cdot 2^X\\&\gt 2(X^2-X-2)\\&=(X+1)^2-(X+1)-2+X(X-3)-2\\&\ge (X+1)^2-(X+1)-2+4(4-3)-2\\&\gt (X+1)^2-(X+1)-2\quad\blacksquare\end{align} Also, it is easy to see that $(2)$ holds for $X=3$. Using this, we get, for $x\ge 3$, $$f(x,2)=(x^2-x-2)-2^x\lt 0$$

• To prove that $f(x,y)\lt 0$ for $3\le y\le x$, we use the fact that $y=\frac{\ln x}{x}$ is decreasing for $x\gt e$. We see that $\frac{\ln y}{y}\ge \frac{\ln x}{x}$ for $3\le y\le x$ from which $x^y-y^x\le 0$ follows. It follows from this that we have, for $3\le y\le x$, $$f(x,y)=x^y-y^x-x-y\le 0-x-y\lt 0$$

If $x \geq 3$ and $y=x+1$, then $f(x,y)>0$, and as $y$ increases above $x+1$, $f(x,y)$ increases.

This answer proves that $f(x,y)\gt 0$ for $x\ge 3$ and $y\ge x+2$.

Let $y=x+a$ where $a\ge 2$ is an integer. Then,

$$\frac{f(x,x+a)}{x^x}=x^{a}-\left(1+\frac ax\right)^x-\frac{2}{x^{x-1}}-\frac{a}{x^x}\gt x^a-e^a-\frac 29-\frac{a}{x^x}:=g(x)$$

Since $g'(x)=ax^{a-1}+\frac{a+a\ln x}{x^x}\gt 0$, $g(x)$ is increasing with $g(3)=3^a-e^a-\frac 29-\frac{a}{27}:=h(a)$.

We have $h'(a)=3^a\ln 3-e^a-\frac{1}{27}$ and $h''(a)=3^a(\ln 3)^2-e^a\gt 0$ with $h'(2)=9\ln 3-e^2-\frac{1}{27}\gt 0$ and $h(2)=9-e^2-\frac 29-\frac{2}{27}\gt 0$.

So, $h(a)\gt 0$ for $a\ge 2$. It follows from this that $g(x)\gt 0$ for $x\ge 3$.

Therefore, $f(x,x+a)\gt 0$ follows.