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

### Interesting Diophantine Equation

```Date: 12/06/2005 at 17:00:57
From: Jenny
Subject: Squares and powers of 3

Find all integers x such that x^2 + 3^x is the square of an integer.

The numbers can get pretty large pretty quickly, so it's quite hard
to check cases of larger values of x.  Perhaps it may be possible to
factorize the expression, or regard the x^2 and 3^x separately.

I'm not really sure where to go on this problem, and help would be
greatly appreciated.

```

```
Date: 12/06/2005 at 22:08:04
From: Doctor Vogler
Subject: Re: Squares and powers of 3

Hi Jenny,

Thanks for writing to Dr. Math.  What you have is a type of
Diophantine equation, which means that you want integer solutions to
your equation.  You want all pairs of integers (x, y) that satisfy

x^2 + 3^x = y^2.

One idea is to notice that, if x is large, then y must be a lot
larger, because 3^x is very big compared to x^2.  That means that y^2
must be very close to 3^x.  If x is even, then y must be very close to
3^(x/2).  So we have

Case 1:  x is even.

Now, x = 0 is a solution, but otherwise, if x = 2k is even, then

y^2 = 3^x + x^2 > 3^x = 3^(2k) = (3^k)^2,

so

y > 3^k.

That means that

y >= 3^k + 1,

y^2 >= 3^(2k) + 2*3^k + 1,

and so

(2k)^2 = x^2 = y^2 - 3^x = y^2 - 3^(2k) >= 2*3^k + 1 > 2*3^k,

or

2k^2 >= 3^k,

but when k > 0, this never happens.

Case 2:  x is odd.

Trying to use the above method doesn't work at all when x is odd,
because you can find squares that are very close to 3 times another
square.

But then we have a very different idea that doesn't depend on whether
x is even or odd.  The idea is to move over the x^2 and factor that
side of the equation

3^x = y^2 - x^2

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

Now, if the product on the right is a power of 3, then the only way
that can happen is if each factor is a power of 3 (or if each factor
is the negative of a power of 3).  So that means that

y + x = 3^a
y - x = 3^b

which implies

y = (3^a + 3^b)/2
x = (3^a - 3^b)/2
x = a + b

So now we just need to solve the equation

2(a + b) = 3^a - 3^b.

We can assume that a will be larger than b, so let's define

c = a - b

and then we have

2(2b + c) = [3^c - 1]*3^b.

Now, if we can find that

4b < 3^b

and

2c < 3^c - 2

then we will be able to conclude that

4b + 2c < 3^b + 3^c - 2
<= 3^b + (3^b)*(3^c - 2)
= 3^b * (3^c - 1)
= 2(2b + c),

which is, of course, impossible.  But it turns out that

4b < 3^b

when b >= 2, and

2c < 3^c - 2

when c >= 2.  So that means that if we have any solutions at all, they
must satisfy

b <= 1
c <= 1,

but

a = c + b <= 2,

and

x = a + b <= 3,

which means that we only have to check the possibilities

x = 0, 1, 2, 3.

And it turns out that three of the four work.

So we have only the three solutions:

x = 0,
x = 1,
x = 3.

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: 12/07/2005 at 14:18:16
From: Doctor Vogler
Subject: Re: Squares and powers of 3

Hi Jenny,

I just realized that I made a mistake in my last answer to you, so I
will correct that here.  You'll recall that I said:

But it turns out that

4b < 3^b

when b >= 2, and

2c < 3^c - 2

when c >= 2.  So that means that if we have any solutions at all, they
must satisfy

b <= 1
c <= 1.

This is not quite correct.  I should have said:

So that means that if we have any solutions at all, they must satisfy

b <= 1   or   c <= 1.

I haven't proven that a solution will satisfy both inequalities.  Now,
if c <= 0, then this implies that a <= b, and therefore x <= 0.  But
we already know about the solution x = 0, and x < 0 implies that

x^2 + 3^x

is not an integer, therefore not the square of an integer.  So the
only way for c <= 1 is if c = 1.  What happens when c = 1?  Then

2(2b + c) = [3^c - 1]*3^b

becomes

2(2b + 1) = [3 - 1]*3^b = 2*3^b
2b + 1 = 3^b.

4b < 3^b

when b >= 2, so even if c = 1, we still must have

b <= 1.

So now we know that, apart from x = 0, any solution must satisfy

b <= 1.

But b < 0 implies that

x = (3^a - 3^b)/2

is not an integer.  So we conclude that either b = 0 or b = 1.

If b = 0, then

2(2b + c) = [3^c - 1]*3^b

becomes

2c = 3^c - 1

which happens exactly when c = 1, and then c > 1 makes the right side
too big.  So we have one solution with b = 0, which is

b = 0, c = 1, a = 1, x = (3 - 1)/2 = 1, y = 2.

If b = 1, then

2(2b + c) = [3^c - 1]*3^b

becomes

4 + 2c = 3^(c+1) - 3

or

7 + 2c = 3^(c+1)

which happens exactly when c = 1, again, and then c > 1 makes the
right side too big.  So we have one solution with b = 1, which is

b = 1, c = 1, a = 2, x = (9 - 3)/2 = 3, y = 6.

And those are all of the possibilities, so that means that those three
solutions

x = 0
x = 1
x = 3

are the only ones.

- 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