Square Triangular Numbers

The triangular numbers are 

        1, 3, 6, 10, 15, 21, 28, 36, 45, ...

and so on, given by the formula n(n+1)/2.  Notice that the numbers
1 and 36 on this list are perfect squares as well as triangular.  A
standard problem in elementary number theory is to determine ALL 
the numbers that are both square and triangular.  Thus we want
all the solutions of m^2 = n(n+1)/2.  Solving this for n using 
the quadratic formula gives
                           __________
                     -1 + / 1 + 8m^2
               n  =  ----------------
                              2

Obviously this equation will give an integer value of n if and only if 
the quantity inside the square root is a square, so there must be an 
integer q such that

                   q^2  -  8 m^2  =  1

Equations of this form are called Pell's equation, and there are 
infinitely many pairs of integers (q,m) that satisfy this equation.  
The usual method of determining these solutions is via the 
continued fraction for sqrt(8)

                                    1
        sqrt(8) =   2 +  ------------------------
                                       1
                            1 +   ----------------
                                            1
                                    4 + ------------
                                                1
                                          1 + -------
                                                 etc.

The period of this continued fraction is 2, so every 2nd convergent 
is q/m where (q,m) satisfy the Pell equation.  It follows that q 
and m satisfy the recurrences

                    q[k] = 6 q[k-1] - q[k-2]

                    m[k] = 6 m[k-1] - m[k-2]

where q[k],m[k] denotes the kth solution.  By the theory of difference
equations we know that q[k] and m[k] must both be of the form

                          A r^k  +  B s^k

where A and B are constants and r and s are the roots of the 
characteristic equation 

                    x^2  -  6 x  +  1   =   0

Thus we have  r = 3 + 2 sqrt(2)  and  s = 3 - 2 sqrt(2).  For q(k) we 
see from the initial values that  A = B = 1/2, so

                    (3+2sqrt(2))^k  +  (3-2sqrt(2))^k
           q[k]  = -----------------------------------
                                    2

and of course the kth value of n is

            q[k] - 1        (3+2sqrt(2))^k  + (3-2sqrt(2))^k - 2
  n[k]  =  ----------   =   ------------------------------------
                2                             4

where n[k] is the kth solution of our original square-triangular
equation n(n+1)/2 = m^2.  The first few values of n[k] for k=1,2,..
are
                 1, 8, 49, 288, 1681, ...

Letting u and U denote 3+2sqrt(2) and 3-2sqrt(2) respectively, we
can substitute the expression for n[k] into the expression for m^2
to give the formula for the kth square triangular number

        1           1  / u^k + U^k - 2 \  / u^k + U^k + 2 \
  m^2 = - n (n+1) = - ( --------------  )( --------------  )
        2           2  \      4        /  \      4        /

                   _                  _
              1   |            2       |
           = ---- | (u^k + U^k)  -  4  |
              32  |_                  _|

Expanding the square, and noting that u^2 = 17+12sqrt(2), U^2 =
17-12sqrt(2), and 2uU = 2, we have
                        _                                      _
         n(n+1)     1  |               k                 k      |
   m^2 = ------ = ---- | [17+12sqrt(2)]  + [17-12sqrt(2)]  -  2 |
           2       32  |_                                      _|

Incidentally, the numbers n[k] alternate odd and even, because they 
safisfy the recurrence n[k] = 6n[k-1] - n[k-2] + 2.  Furthermore, 
from the relation
                        (n)(n+1) = 2m^2

and the fact that n and n+1 are coprime (i.e., have no common factor),
it follows that either n or n+1 must be an odd square and the other 
must be twice a square, accordingly as n is odd or even.  So, we've
shown that n[k] is a square for every odd index k=2j-1, and of course 
the quantity 4n is a square if and only if n is a square, so we have
the related result that the number

 4 n[2j-1]  =  (3+2sqrt(2))^(2j-1)  +  (3-2sqrt(2))^(2j-1)  -  2

is a square for every positive integer j.

Return to MathPages Main Menu