Associated Topics || Dr. Math Home || Search Dr. Math

### Solving the Diophantine Equation x^y - y^x = x + y

```Date: 04/30/2005 at 08:48:50
From: Paulo
Subject: math

It was presented to me, to be solved in integers, the following
equation: x^y - y^x = x + y.  The two obvious solutions, just by
inspection, are (x,y)=(1,0) and (2,5).  My feeling is that there are
no more solutions, but how can that be proved?  Or, if there are more
solutions, how do we find them?  Thank you for your attention.

```

```
Date: 04/30/2005 at 15:55:55
From: Doctor Vogler
Subject: Re: math

Hi Paulo,

Thanks for writing to Dr. Math.  This is called a Diophantine Equation
because you are looking for integer solutions (although some reserve
the word for polynomial equations only).  It is not an easy one to
solve, although it is solvable.  It is similar to the related problem
which you can find in our archives

Solving the Equation x^y = y^x
http://mathforum.org/library/drmath/view/66166.html

x^y - y^x = x + y.

Now let's check negative numbers first.

If x <= 0 and y <= 0, then we multiply both sides of the equation by
(x+y)*x^(-y)*y^(-x) and factor

( (x+y)x^(-y) - 1 )( (x+y)y^(-x) + 1 ) = -1,

where each factor is an integer.  Then we either have

(x+y)x^(-y) = (x+y)y^(-x) = 0,

which gives x = -y (and then the hypothesis requires x = y = 0), or

(x+y)x^(-y) = 2
(x+y)y^(-x) = -2.

But this requires x^(-y) divisible by 2, hence x divisible by 2.  Thus
x = -1 or x = -2.  Similarly, y = -1 or y = -2.  We try all four
combinations, and none work.
So x and y can't BOTH be negative.

If x >= 0, then x^y = y^x + x + y is an integer, so x = 1 or y >= 0.
And x = 1 implies 1 - y = 1 + y, thus y = 0.  Indeed, (1, 0) is a
solution.  In any case, y >= 0.

If y >= 0, then y^x = x^y - x - y is an integer, so y = 1 or x >= 0.
And y = 1 implies x - 1 = x + 1, which has no solutions.  Thus x >= 0.

So we conclude that, apart from (0, 0), we have x > 0 and y > 0.

Now we look at the positive solutions, and we ask which is bigger: x or y?

If x >= y >= 3, then (log x)/x <= (log y)/y, since

f(x) = (log x)/x

is a decreasing function for x > e, and therefore y log x <= x log y,
and x^y <= y^x, so

0 < x + y = x^y - y^x <= 0.

If y = 2 and x > 0, then we still get (log x)/x <= (log y)/y except
when x = 3, but (3, 2) is not a solution.

We already saw that y = 1 implies x - 1 = x + 1, which has no solutions.

If y = 0 and x > 0, then 1 = x + y, thus x = 1, and we have the
solution (1, 0).

Therefore, (0, 0) and (1, 0) are the only solutions with x >= y.

Now we conclude that 0 < x < y.

We already checked x = 1, which gives y = 0.  So 1 < x < y.  We want
to show that x^y - y^x is usually much bigger than x + y.  We might
have trouble when x = 2.  So we'll save that for later.  Fix x >= 3,
and let

g(y) = x^y - y^x - x - y,

so that

g'(y) = (x^y)(log y) - (x)(y^(x-1)) - 1.

I want to show that g'(y) > 0 when y > x.  Recall that y > x >= 3 implies

(log x)/x > (log y)/y
y log x > x log y.

Also, y > x implies y >= x + 1, and therefore

log y >= log (x + 1),

and y > x >= 3 implies that

log log y > 0.

y log x + log y + log log y > x log y + log (x + 1).

Anti-logging gives

x^y * y * log y > y^x * (x + 1).

Then we divide by y and get

(x^y)(log y) > y^(x-1) * (x + 1)
= (x)(y^(x-1)) + y^(x-1)
> (x)(y^(x-1)) + 1

which is equivalent to g'(y) > 0.  Therefore, when x >= 3, the
smallest value of g(y) with y > x occurs when y = x + 1.

Therefore, if y > x >= 3, then

x^y - y^x - x - y = g(y) >= g(x+1) = x^(x+1) - (x+1)^x - x - (x+1).

Now I want to show that this is bigger than zero.  So let

h(x) = x^(x+1) - (x+1)^x - x - (x+1).
= e^((x+1)(log x)) - e^(x log(x+1)) - 2x - 1

So that its derivative is

h'(x) =
(x^(x+1))(log x + 1 + 1/x) - ((x+1)^x)(log(x+1) + 1 - 1/(x+1)) - 2

= (x^(x+1))(log x) - ((x+1)^x)(log(x+1))
+ x^(x+1) + x^x - (x+1)^x + (x+1)^(x-1) - 2

> (x^(x+1) - (x+1)^x)(log x) +
(x^(x+1) - (x+1)^x) + x^x + (x+1)^(x-1) - 2

which is positive since x >= 3 implies

x^(x+1) - (x+1)^x > 0,
log x > 0,
x^x > 2.

Therefore, h(x) is always increasing for x >= 3.  And

h(3) = 3^4 - 4^3 - 3 - 4 = 81 - 64 - 3 - 4 = 10 > 0,

which means that h(x) > 0 for all x >= 3.  Therefore, we have no
solutions with y > x >= 3.

Finally, we have to check x = 2.  We already know that there is one
solution with x = 2.  Now consider

g(y) = 2^y - y^2 - y - 2.

We want to find its roots.  As before, take the derivative

g'(y) = (2^y)(log 2) - 2y - 1.

A graphing calculator shows that this function is negative for y
values from zero to something between 3 and 4, and

then it becomes positive.  So first let's show that if y >= 4, then
g'(y) > 0.  By taking another derivative, we get

g"(y) = (2^y)(log 2)^2 - 2

and then this is positive since y >= 4 (in fact, y > 3) implies

2^y > 2^3 = 8
(2^y)(log 2)^2 - 2 > (2^y)(1/2)^2 - 2 > (8)(1/4) - 2 = 0.

Therefore, g'(y) is increasing when y > 3.  So when y >= 4, then

g'(y) >= g'(4) = (2^4)(log 2) - 2*4 - 1

and this is positive as long as

log 2 > 9/16,

which it is (9/16 = 0.5625, and log 2 = 0.6931...).  Therefore, g(y)
is increasing for y >= 4.  As you already know, g(5) = 0, which means
that g(y) > 0 when y > 5.  So now we check y values less than 5 (that
is, y=1, 2, 3, and 4 when x = 2), and we find that there are no other
solutions.

And there you have it!

back and show me what you have been able to do, and I will try to
offer further suggestions.

- Doctor Vogler, The Math Forum
http://mathforum.org/dr.math/
```
Associated Topics:
College Number Theory
High School Number Theory

Search the Dr. Math Library:

 Find items containing (put spaces between keywords):   Click only once for faster results: [ Choose "whole words" when searching for a word like age.] all keywords, in any order at least one, that exact phrase parts of words whole words

Submit your own question to Dr. Math
Math Forum Home || Math Library || Quick Reference || Math Forum Search