# Generate All Triangular Square Numbers Recursively?

We define a triangular number as follows:

$$\sum_{n=1}^{n} x_{i}$$

As in $T_3$ = $3+2+1$, or $6$. Generating these triangular numbers is rather simple and done by the equation:

$$T_n ={(n^2 + n)}/{2}$$

I am asking a question about how to generate Triangular Square numbers, those numbers that are both triangular and perfect squares. As in,

$$s^2 = {(t^2 + t)}/{2}$$

Completing the square yields the following:

$$(2t + 1)^2 - 8s^2 = 1$$

Which is known as an instance of the pell equation, or

$$x^2 -2y^2 = 1$$

This is where I kind of get stuck. I thought about taking the line $y = mx - m, m \in Q$ searching for the other intersection point. Is that a way to go about this? If so,

Substituting y from the line into the pell equation yields:

$$x^2 -2m^2(x-1)^2 -1$$

Which, when divided by the other intersection point $x-1$ should yield another intersection point:

$$\dfrac{x^2 -2m^2(x-1)^2 -1}{x-1} = -2 m^2 x+2 m^2+x+1$$

Solving for x,

$$x = \dfrac{2 m^2+1}{2 m^2-1}$$

Substituting back into the line equation we can get the ordered pair of the other intersection point:

$$(x,y) = \Big(\dfrac{2 m^2+1}{2 m^2-1}, \dfrac{2 m}{2 m^2-1}\Big)$$

Though, how can I generate integer solutions? I see that some people say to take $$m = \dfrac{v}{u}, u^2 -2v^2 = 1$$

Following this advice, one gets the denominator $2 m^2-1$ to be

$$2\big(\dfrac{v^2}{u^2}\big) - 1 = \dfrac{-u^2 + 2v^2}{u^2} = -1/u^2$$

Therefore, the point comes out as follows:

$$(x,y) = \Big(-u^2 - 2v^2, -2vu\Big)$$

Which for some reason is very similar to the generating function of pythagorean triples, but I think thats besides the point? Well, we have somewhat done what we set out to with this function. Take the solution to the equation (3,2) for example, using our new point we get (17,12) which yields the triangular square 36. Keeping this up recursively will keep us going! Woohoo!

But why? What does this tell us? I tried to work it out and don't see those always being integer solutions. How can I generate all of these triangular square numbers. Does continuing with this method guarantee there are infinitely many? How do you prove every triangular square is of this form?

• To generate integer solutions, you want your denominator $2m^2 - 1$ to be an integer. As $m$ is your (presumably rational) slope, you might as well call $m = u/v$. Then your denominators become $2v^2 - u^2 = 1$, which is morally the same Pell Equation as you started with. So you have travelled in a circle thus far. – davidlowryduda Jan 23 '16 at 21:16
• The $m$th square number is equal to the $n$th triangular number if $m={{\left(3+2\sqrt 2\right)^u-\left(3-2\sqrt 2\right)^u}\over{4\sqrt 2}}$ and $n={{\left(3+2\sqrt 2\right)^u-2+\left(3-2\sqrt 2\right)^u}\over 4}$. – Senex Ægypti Parvi Jan 23 '16 at 21:38
• I would suggest substituting the expression for $m$ into the formula for square numbers $m^2$ and the expression for $n$ into the formula for triangular numbers $\frac{n^2+n}2$. If the two results are equal, then the assertion is proved. It's simpler than you think. It is easy to prove, but to render it in MathJax is a pain in the kiester. If $u$ is an integer, then $m$ and $n$ will be, too. – Senex Ægypti Parvi Jan 23 '16 at 21:47
If $A_n$ is the $n$th triangular square, then for $n \ge 2$ the recursion $$A_n = 34A_{n-1} - A_{n-2} + 2$$ holds, with initial conditions $A_0 = 0$ and $A_1 = 1$.