# Solving a second-degree two-variables diaphontine equation

my friend sent me a problem about the number of "Square and Triangular in the same time" numbers and the formula which generates them if possible $$\text {We know that: }T_m = \frac {m (m+1)}2 \quad S_n=n^2\\ \exists^{\infty}? (n,m)\in\mathbb{N}^2 :\quad m^2+m-2n^2=0$$ (My question is not about the solution, but the approach.) I solved that problem(yes there exist infinitely such numbers), but I used some methods that require a "Good Luck" For exemple I searched the first two no zero solutions then i built the next one from them and so on $$(n_1,m_1)=(6;8),(n_2,m_2)=(35;49): \quad n_3\approx \frac{n_2^2}{n_1}\\ m_3\approx \frac{m_2^2}{m_1}$$ Then I assumed that $n_{p+2} = a n_{p+1} + b n_p$ Using the known values i searched for $a$ and $b$ and solved $x^2 - ax - b=0$. The roots were $x_{1/2}=3\pm 2\sqrt {2}$ and then I assumed again that $n_p = \alpha x_1^p + \beta x_2^p$ And finally I got $$n_p = \frac {4+3\sqrt{2}}{8}(3+2\sqrt {2})^p +\frac {4-3\sqrt{2}}{8}(3-2\sqrt {2})^p$$ And for $m_p$ I solved with respect to $m_p : m_p^2-m_p-2n_p^2=0$ and after taking the positive solution: $$m_p = -\frac12 +\sqrt {2}\left(\frac {4+3\sqrt{2}}{8}(3+2\sqrt {2})^p -\frac {4-3\sqrt{2}}{8}(3-2\sqrt {2})^p\right)$$ For this problem (and generally any second-degree two-variables diaphontine equation)

1. Did my approach include all solutions?

2. Does the assumption '$n_{p+2} = a n_{p+1} + b n_p$' work in general, and why?

3. Does the assumption '$n_p = \alpha x_1^p + \beta x_2^p$' work in general, and why?

1. Can you give me a better approach? (I wanted to consider the equation as that of a conic but I didn't know what to do further)

2. For this type of problems, what are the most effecient approaches?

To avoid an answer getting to long, I here give the proof of the mentioned reccurence relation.

The smallest solutions of the Pell-equation are $(3,2)$ and $(17,12)$. If $(u,v)$ is a solution, then the next two solutions are given by

$$(3u+4v,2u+3v)$$ and $$(17u+24v,12u+17v)$$

To show that the $u's$ and the $v's$ satisfy the relations

$$u_{n+1}=6u_n-u_{n-1}$$ and $$v_{n+1}=6v_n-v_{n-1}$$

(which must be either guessed or known, there is a related question mentioning these relations. To be honest, I have no idea to find such relations in general.)

you simply use $17u+24v=6(3u+4v)-u$ and $12u+17v=6(2u+3v)-v$ and apply induction over $n$. It is easy to show that the $B_n$'s which are just the halves of the $v's$ satisfy the same relation : $B_{n+1}=6B_n-B_{n-1}$. The first two values are $1$ and $6$ because $v$ starts with $2$ and $12$.

We want to find the integer solutions of $$\frac{m(m+1)}{2}=n^2$$

We are interested in triangular numbers, so we can assume $m\ge 0$ and we can also assume $n\ge 0$

As you already stated , this is equivalent to $$m^2+m=2n^2$$ Now, here comes the trick : Multiply with $4$ and add $1$ to get

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

Hence

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

With $u=2m+1$ and $v=2n$ we get the Pell-equation $$u^2-2v^2=1$$

$v$ cannot be odd since then, we would have $u^2\equiv 3\mod 4$ and $u$ must be odd. So, every solution of the pell-equation leads to a solution of the original equation.

The fundamental solution is $(3,2)$. Multiplying the matrix $$\pmatrix{3&4\\2&3}$$ with a given solution gives the next solution.

The numbers occuring in the sequence $$B_1=1$$ $$B_2=6$$ $$B_{n+1}=6B_n-B_{n-1}$$ have the property that $B_n^2$ is both a square and a triangular number. Moreover, those numbers (besides $0$) are all with the desired propery.

The first numbers both a square and a triangular number are :

? for(j=0,10^8,if(issquare(j*(j+1)/2)==1,print1(j*(j+1)/2," ")))
0 1 36 1225 41616 1413721 48024900 1631432881 55420693056 1882672131025
63955431761796 2172602007770041

• Thank you for your answer, but how did get the sequence from the Pell Equation? – Rami Zouari Apr 3 '17 at 10:59
• I really appreciate your help, you just gave a good answer about the topic, but to avoid asking too many questions, where can I find such detailed explanations of second degree diaphontine equations – Rami Zouari Apr 3 '17 at 13:59
• Wikipedia doesn't have a detailed article about that by the way – Rami Zouari Apr 3 '17 at 14:00
• @RamiZouari Sorry, I do not know such an article. But if you are really interested, write another question about reccurence relations in general. – Peter Apr 3 '17 at 14:19