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

### Triangular Numbers That are Perfect Squares

```
Date: 09/07/99 at 07:05:28
From: Manuel
Subject: Triangular numbers that are perfect squares

Hi, this is my problem:

Triangular numbers are 1, 3, 6, 10, ..., (1/2)n(n+1)
Square numbers are 1, 4, 9, 16, ..., m^2

I am searching for a general formula that will give me numbers that
are both triangular and square.

My first idea was to show that:

m^2 = (1/2)n(n+1)

Then I rearranged this equation to solve for m:

m = ((1/2)n(n+1))^1/2

This was than entered into a spreadsheet and values for m and n were
produced. The correct values for m that can be used in the formula for
square numbers would appear as whole numbers, which is how they were
identified. The values for m increase very rapidly. I looked at
differences between the values for m (which include: 1, 6, 35, 204,
1189) and found nothing.

I then looked at the growth factors between them. I found that the
growth factor converges and becomes constant to three decimal places
at 5.828. I know from this that successive values for m can be
estimated from this growth factor, but I require a general formula.

I'm sure that my methods are leading me in the right direction but I
require assistance in deriving a general formula.

I have also come across an inductive formula by accident and I don't
know how to derive it:

m_n = 6m_(n-1) - m_(n-2)

where m_0 = 0, m_1 = 1 and n in this case is the nth term.

I came across this inductive definition by playing around with the
values for m with the Fibonacci sequence in mind.

I will be extremely grateful for your help.
Thank you.
```

```
Date: 09/07/99 at 09:45:36
From: Doctor Mitteldorf
Subject: Re: Triangular numbers that are perfect squares

Dear Manuel,

I can't tell you how to derive the formula, but I can show you what it
is. Here is the formula:

a(n) = sqrt of the nth square triangle

then

a(n) = ((3+sqrt(8))^(n+1) - (3-sqrt(8))^(n+1)) / (2* sqrt(8))

Can you prove that it has the property you want? (Can you even prove
that it's an integer?)

- Doctor Mitteldorf, The Math Forum
http://mathforum.org/dr.math/
```

```
Date: 09/07/99 at 10:32:29
From: Doctor Floor
Subject: Re: Triangular numbers that are perfect squares

Hi, Manuel,

Thanks for your question. You found some good things; let me try to
explain how I know you can find all triangular numbers that are
squares.

First we consider Pell's equation (which is the wrong name, because in
fact it wasn't John Pell, but W. Brouncker, who solved this equation):

x^2 - Ny^2 = 1

In this equation N is fixed. We are looking for all possible pairs
(x,y) of natural numbers (i.e. nonnegative integers) that yield a
solution.

There is one trivial solution, (x,y) = (1,0). All other solutions must
have p > 0 and q > 0.

Now suppose that we have a minimal solution (x,y) = (p,q) such that
p > 0 and q > 0. (There is always a solution other than the trivial
one, when N is not a square. Thus there is a minimal solution. I am
not going to prove that, we will have no trouble finding the minimal
solution). What do we mean by minimal? Minimal means here that
p + q*sqrt(N) has a minimal value.

We will show that all solutions (u,v) of Pell's equation can be found
by

u + v*sqrt(N) = (p + q*sqrt(N))^n

for a nonnegative integer n.

Proof:

The trivial solution (1,0) is found when n = 0.

Note that for each solution (x,y) of Pell's equation:

[x + y*sqrt(N)]*[x - y*sqrt(N)] = x^2 - N*y^2 = 1
so
1 / [x + y*sqrt(N)] = x - y*sqrt(N).

Also note the following: let (a,b) and (c,d) be solutions of Pell's
equation. We rewrite

[a + b*sqrt(N)]*[c + d*sqrt(N)] = e + f*sqrt(N)   ...........[1]

for some integers e and f. And we find

[a - b*sqrt(N)]*[c - d*sqrt(N)] = e - f*sqrt(N)

We conclude

e^2 - N*f^2

= [e + f*sqrt(N)]*[e - f*sqrt(N)]

= [a + b*sqrt(N)]*[c + d*sqrt(N)]*[a - b*sqrt(N)]*[c - d*sqrt(N)]

= [a + b*sqrt(N)]*[a - b*sqrt(N)]*[c + d*sqrt(N)]*[c - d*sqrt(N)]

= (a^2 - N*b^2)*(c^2 - N*d^2)

= 1*1 = 1

so (e,f) is a solution of Pell's equation, too, only possibly e and f
are negative. The same is found when we change one or two of the +'s
of the left-hand side of [1].

Now suppose that (u,v) is a solution other than the trivial solution
of Pell's equation. We will choose n such that:

1 <= [u + v*sqrt(N)] / [p + q*sqrt(N)]^n < p + q*sqrt(N)   ...[2]

p + q*sqrt(N) as many times as needed to get < p + q*sqrt(N) for the
first time).

We have:

[u + v*sqrt(N)]/[p + q*sqrt(N)]^n

= [u + v*sqrt(N)]*[p - q*sqrt(N)]^n

= [r + t*sqrt(N)] for some r and t

From r + t*sqrt(N) >= 1 (see [2]) and the fact that (r,t) must be a
solution of Pell's equation (only possibly r and/or t are negative),
we find that

0 < r - t*sqrt(N) = 1/[r + t*sqrt(N)] <= 1   .................[3]

Adding r + t*sqrt(N) >= 1 and r - t*sqrt > 0 (see [3]) we find that
2r > 1, and since r is an integer, that means that r >= 1.

From [3] we can also find that

r - t*sqrt(N) <= 1

and thus

-r + t*sqrt(N) >= -1

r + t*sqrt(N) >= 1

we find that

2*t*sqrt(N) >= 0

So t >= 0.

This trouble was needed to conclude that r and t are nonnegative
integers. We have created a solution (r,t) such that r + t*sqrt(N) is
greater than or equal to 1 and smaller p + q*sqrt(N). Since
p + q*sqrt(N) was the minimal solution, r + t*sqrt(N) can only be 1,
the trivial solution.

So, we have

[u + v*sqrt(N)]/[p + q*sqrt(N)]^n = 1

and
u + v*sqrt(N) = [p - q*sqrt(N)]^n

as desired. And our theorem about Pell's equation is proven.

What has it to do with square and triangular numbers?

Let's consider the equation m^2 = n(n+1)/2 where the mth square is
equal to the nth triangular number.

We can rewrite:

m^2 = n(n+1)/2

8m^2 = 4n^2 + 4n

8m^2 + 1 = 4n^2 + 4n + 1

8m^2 + 1 = (2n+1)^2

(2n+1)^2 - 8m^2 = 1

And we have Pell's equation for N = 8.

The simple observation that for n = 1 and m = 1 we find the smallest
solution:

3^2 - 8*1^2 = 1

gives us that we can find all solutions using

(3 + sqrt(8))^n

Example:

(3+sqrt(8))^2 = 17+6sqrt(8) --> 2n+1 = 17, thus n = 8 and m = 6

Finally, suppose we have a solution a + b*sqrt(8) of Pell's equation.
Of course we know that b^2 is the square that is also a triangular
number. We see that the following squares are found:

a      +  b      *sqrt(8)  [4]
(a     +  b*sqrt(8))    *(3+sqrt(8)) =  3a+8b  + (a+3b)  *sqrt(8)  [5]
(3a+8b + (a+3b)*sqrt(8))*(3+sqrt(8)) = 17a+48b + (6a+17b)*sqrt(8)  [6]
etc.

Note that [6] = 6*[5] - [4], which gives that the row of numbers b(n),
such that b(n)^2 is a triangular number as well as a square, is given
by the recursion relation b(n) = 6*b(n-1) - b(n-2).

I hope this helped. If you have more questions, write us back.

Best regards,
- Doctor Floor, The Math Forum
http://mathforum.org/dr.math/
```
Associated Topics:
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