# Which triangular numbers are also squares?

I'm reading Stopple's A Primer of Analytic Number Theory:

Exercise 1.1.3: Which triangular numbers are also squares? That is, what conditions on $m$ and $n$ will guarantee that $t_n=s_m$? Show that if this happens, then we have:

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

a solution to Pell's equation, which we will study in more detail in Chapter $11$.

I thought about the following:

$$\begin{eqnarray*} {t_n}&=&{s_n} \\ {\frac{n^2+n}{2}}&=&{m^2} \\ {n^2+n}&=&{m^2} \end{eqnarray*}$$

I've solved for $n$ and $m$ but I still have no clue of how to proceed. I've looked at the book's solution and the solution is as follows:

$$\begin{eqnarray*} {\frac{n(n+1)}{2}}&=&{m^2} \\ {n(n+1)}&=&{2m^2} \\ {\color{red}{4n(n+1)}}&\color{red}{=}&{\color{red}{8m^2}} \\ {4n^2+4n+1-1}&=&{8m^2} \\ {(2n+1)^2-1}&=&{8m^2} \\ \end{eqnarray*}$$

In the red line, he multiplies the equation by $4$, I don't understand why to do it nor how the condition is achieved.

-
The multiplication by $4$ is to make the completing the square nice. –  André Nicolas Apr 13 at 1:36
@AndréNicolas I've done the following: $n^2+n+\frac{1}{4}=m^2+\frac{1}{4}$. –  Vladimir Putin Apr 13 at 1:40
–  Lucian Apr 13 at 1:41
Number-theoretic reasoning tends to be more accurate if one avoids fractions. –  André Nicolas Apr 13 at 2:13
To complete the square in $ax^2+bx+c$, it is useful to multiply by $4a$. –  André Nicolas Apr 14 at 4:16

$$n(n+1) = \underbrace{n^2 + n = \left(n^2+n+\frac 1 4\right) - \frac 1 4}_{\text{completing the square}} = \left( n + \frac 1 2 \right)^2 - \frac 1 4$$

The reason for multiplying by $4$ is so that only integers will appear in the line above.

$$4n(n+1) = \underbrace{4n^2 + 4n = \left(4n^2+4n+1\right) - 1}_{\text{completing the square}} = (2n+1)^2 - 1$$

-

He multiplies it by $4$ so as to simplify the condition $\frac{n(n+1)}{2}=m^2$ to a simpler condition, involving a quadratic term on the left hand side (since there is a quadratic term on the right hand side, too). This allows us to complete the square (and also makes the equation "look good").

To proceed from your work, multiply both the sides by $4$ and then following the book's solution: $$4\times(n^2+n)=4\times(2m^2)$$ The condition is achieved simply by moving $1$ to the right hand side and by moving $8m^2$ to the left hand side.

-
What I still don't understand is why that is the condition. –  Vladimir Putin Apr 14 at 4:12

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}$.
For each integer value of the index $U$ — positive, zero or negative — there is such a pair.
If $m_0=0$ and $m_1=1$, then $m_U=6m_{U-1}-m_{U-2}=6m_{U+1}-m_{U+2}$.
If $n_0=0$ and $n_1=1$, then $n_U=6n_{U-1}-n_{U-2}+2=6n_{U+1}-n_{U+2}+2$.

-

This conversion course gives solutions, but there are obtained two equations.

Certainly better to solve the equation.

Of course the solution of equation: $Y^2=\frac{X(X\pm1)}{2}$

Defined solutions of Pell's equation: $p^2-2s^2=\pm1$

But it is necessary to write the formula describing their solutions through solving Pell's equation:

$X=p^2+4ps+4s^2$

$Y=p^2+3ps+2s^2$

And more.

$X=2s^2$

$Y=ps$

$p,s$ - These numbers can be any character.

If you need to have a solution of the equation: $Y^2=\frac{X(X\pm{a})}{2}$

It is necessary to substitute into the formulas equation Pellya solutions: $p^2-2s^2=\pm{a}$

-