General formula to obtain triangular-square numbers
I am trying to find a general formula for triangular square numbers. I have calculated some terms of the triangular-square sequence ($TS_n$):
$TS_n=$1, 36, 1225, 41616, 1413721, 48024900, 1631432881, 55420693056 1882672131025, 63955431761796, 2172602007770041, 73804512832419600
I have managed to find that:
$m^2 = \frac{n(n+1)}{2}$
where $m$ is the $m^{th}$ term of the square number sequence, and $n$ is the $n^{th}$ term of the triangular numbers sequence.
Would anyone be able to point out anything that could help me derive a formula for the square-triangular sequence?
Since all triangular numbers are of the form $\frac{n(n+1)}{2}$, we must have the condition cited $$ m^2=\frac{n(n+1)}{2}\tag{1} $$ Equation $(1)$ is equivalent to $$ 2 = \frac{(2n+1)^2-1}{(2m)^2}\tag{2} $$ According to standard continued fraction theory, a rational approximation to $\sqrt{2}$ as good as $(2)$ must also be an approximant for the continued fraction of $\sqrt{2}$. So we must find an overestimate for $\sqrt{2}$ with an even denominator (continued fraction approximants alternate between over- and under-estimates). The continued fraction for $\sqrt{2}$ is $\{1;2,2,2,\dots\}$, so the sequences of numerators and denominators for the approximants satisfy $$ \begin{array}{}a_k=2a_{k-1}+a_{k-2}&\text{ and }&b_k=2b_{k-1}+b_{k-2}\end{array}\tag{3} $$ where $a_0=a_1=b_1=1$ and $b_0=0$. Computing the first few approximants, we get $$ \frac{1}{1},\frac{3}{2},\frac{7}{5},\frac{17}{12},\frac{41}{29},\frac{99}{70},\dots\tag{4} $$ It follows from $(3)$ that every other denominator is even, and that they correspond to the overestimates. Therefore, every other approximant yields a square triangular number.
Every other term of a sequence that satisfies $(3)$, also satisfies $$ \begin{array}{}a_{2k}=6a_{2k-2}-a_{2k-4}\text{ and }b_{2k}=6b_{2k-2}-b_{2k-4}\end{array}\tag{5} $$ where $a_0=1$, $a_2=3$, $b_0=0$, and $b_2=2$. Let $2n_k+1=a_{2k}$ and $2m_k=b_{2k}$. Applying $(5)$ yields $$ \begin{array}{}n_k=6n_{k-1}-n_{k-2}+2\text{ and }m_k=6m_{k-1}-m_{k-2}\end{array}\tag{6} $$ where $n_0=m_0=0$ and $n_1=m_1=1$.
Using standard recurrence methods, we can solve $(6)$ for $m_k$ to get $$ \begin{align} m_k^2 &=\left(\frac{(3+2\sqrt{2})^k-(3-2\sqrt{2})^k}{4\sqrt{2}}\right)^2\\ &=\frac{(17+12\sqrt{2})^k+(17-12\sqrt{2})^k-2}{32}\tag{7} \end{align} $$ Thus, the sequence $TS_k=m_k^2$.
See this page: Square Triangular Numbers. In particular:
In 1778 Leonhard Euler determined the explicit formula: $$ \left( \frac{(3 + 2\sqrt{2})^k - (3 - 2\sqrt{2})^k}{4\sqrt{2}} \right)^2.$$
The wikipedia page above is very useful. It explains the connection to Pells Equation.