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

### Finding Integer Solutions to a^b = b^a

```Date: 02/02/2005 at 12:31:23
From: jim
Subject: Number Theory

Find all positive integers a and b such that a^b = b^a.

I can think of some examples of numbers that will work (a = 2 and b =
4), but I don't know how to generalize the equation.  I need to have a
general proof for this problem.

If I take the log of each side I can get b log a = a log b, then
divide by ab to get (log a)/a = (log b)/b.  From there I don't know
where to go.

```

```
Date: 02/02/2005 at 19:00:11
From: Doctor Vogler
Subject: Re: Number Theory

Hi Jim,

Thanks for writing to Dr. Math.  The short answer to your question is
that all solutions in positive integers are a = b and

(2, 4) or (4, 2).

The long answer, of course, is a proof of the same.  Before going
there, however, I would like to point out that your idea is a terrific
idea for finding all *real* solutions.  Allow me to elaborate.

Since the function

f(x) = (log x)/x

increases from x=0 to x=e and then decreases from x=e to infinity, if

0 < a < b <= e

or if

e <= b < a,

then we have

f(a) < f(b)

and therefore

(log a)/a < (log b)/b
b log a < a log b
a^b < b^a.

But if we have

a < e < b,

then that is not enough information to tell whether a^b or b^a is
bigger.  And for each a < e there is exactly one b > e where

f(a) = f(b)

and therefore

a^b = b^a,

and for smaller values of b (but still bigger than e) you will have

a^b < b^a

while for larger values of b you will have

a^b > b^a.

But this idea of using continuous functions becomes less useful when
dealing with integer or rational solutions, since the Intermediate
Value Theorem doesn't apply.  So we need to try a different idea.

Try this:  Substitute

t = b/a

into your equation.  If a and b are integers, or if a and b are
rational numbers, then t will be rational.  Substituting a*t for b, we get

t a       a
(a )  = (at) .

Now, taking the (positive real) a'th root of both sides of the
equation, we get

t
a  = at

and therefore

t-1
a    = t

and

1/(t-1)
a = t       .

In fact, we can get a parametrized form for all rational solutions
from this equation.  Let

n = 1/(t-1),

so that

a = (1 + 1/n)^n
b = (1 + 1/n)^(n+1).

These are rational solutions for all (nonzero) integers n.  It takes a
little more work to show that these (along with a=b) are *all*
rational solutions.  And that work begins with proving the lemma:

If r/s and c/d are rational numbers in lowest terms, and (r/s)^(c/d)
is also rational, then r and s are both d'th powers of integers.

But you wanted integer solutions.  And I'm done with my tangents.  The
first step is to prove that t is an integer.  Then all that's left is
a simple induction argument.

Of course, t is not an integer if b=2 and a=4.  But if we permit
ourselves to switch a with b (note that this doesn't change the
equation) so that

a <= b

then we can prove that t will be an integer.  You see, if a <= b, then

a            b
a   divides  a .

But a^b = b^a, which means that

a            a
a   divides  b ,

and this is enough to imply that a divides b (think about the previous
statement in terms of the prime factorizations of a and b), and
therefore t=b/a is an integer.  And if a and b are positive, then t is
also positive.

Now t=1 gives the solutions with a=b.  And if t=2, then

t-1
a    = t

gives a = 2 (and therefore b = 4).  And a=1 quickly implies b=1.  But
if a >= 2, then

t-1     t-1
a    >= 2   ,

and we can prove by induction that

t-1
2    > t

for all integers t >= 3.  This is easily verified for t=3.  Now
suppose that

t-2
2    > t-1

and then we have

t-1        t-2
2    = 2 * 2    > 2(t-1) = t + (t-2) > t.

Therefore, there are no solutions with t > 2, and so we have found all
of the integer solutions, namely (k,k), (2,4), and (4,2).

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/

```

```
Date: 08/01/2011
From: Nathan
Subject: Simpler solution?

f(x) = (log x)/x

increases from x=0 to x=e and then decreases from x=e to infinity

and decided that I knew exactly where it would go from there...

The solutions should be pairs from the sets (1, e) and (e, \inf).  Since
there is clearly a useful bijection between them, and there's only one
integer, 2, in the first set, a=2, b=4 is the only solution.

```
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