# Sum of two consecutive squares equals difference of two consecutive cubes

To celebrate my birthday, I like to find interesting number theoretic properties of my new age. My upcoming 61st birthday was challenging, but then I noticed that $61 = 5^2 + 6^2 = 5^3 - 4^3$, the sum of two consecutive squares and the difference of two consecutive cubes. I wondered what other numbers had this property; that is, the integer solutions to $a^2+(a+1)^{2} = (b+1)^3 - b^3$ or equivalently $2a^2+2a = 3b^2+3b$. I ran an experiment in Matlab and got the following striking results.

$61 = 5^2 + 6^2 = 5^3 - 4^3$

$5941 = 54^2 + 55^2 = 45^3 - 44^3$

$582121 = 539^2 + 540^2 = 441^3 - 440^3$

$57041881 = 5340^2 + 5341^2 = 4361^3 - 4360^3$

$5589522181 = 52865^2 + 52866^2 = 43165^3 - 43164^3$

$547716131821 = 523314^2+523315^2 = 427285^3-427284^3$

$53670591396241 = 5180279^2+5180280^2 = 4229681^3 - 4229680^3$

It is easy to show that $a/b$ is close to $\sqrt{3/2}$ but not very close; the error is $O(1/b)$. The ratio between successive values of $a$ is monotonically decreasing; its last value is 9.898987988091280 so perhaps it is converging to 980/99.

Does anyone know what is going on here?

• What is it, exactly, that is "striking" and needs explaining? – Christian Gaetz Aug 22 '17 at 15:07
• See A219113 in the OEIS. There is a closed formula for this sequence and a reference or two that should be useful. – Nathaniel Johnston Aug 22 '17 at 15:21
• In particular the ratio between consecutive values of $a$ converges to $5 + 2\sqrt{6}$. $485/198$ is one of the convergents to the continued fraction of $\sqrt{6}$ and hence is a good approximation to $\sqrt{6}$, and $5 + 2(485/198) = 980/99$. – Michael Lugo Aug 22 '17 at 16:07
• Happy birthday! – Yaakov Baruch Aug 22 '17 at 21:02

There is the following sequence of positive solutions (according to Mathematica): $a_n=\frac{1}{8} \left(\left(\sqrt{6}-2\right) \left(2 \sqrt{6}+5\right)^n-\left(\sqrt{6}+2\right) \left(5-2 \sqrt{6}\right)^n-4\right),$ and $b_n=\frac{1}{12} \left(-\left(\sqrt{6}-3\right) \left(2 \sqrt{6}+5\right)^n+\left(\sqrt{6}+3\right) \left(5-2 \sqrt{6}\right)^n-6\right)$.

Your Diophantine equation is known as the Pell equation.

You can diagonalise the equation $2a(a+1)=3b(b+1)$ by writing it as $$2(2a+1)^2+1=3(2b+1)^2.$$

To parametrise all rational solutions of $2a(a+1)=3b(b+1)$ you can now homogenise $$2(2a+1)^2+1=3(2b+1)^2$$ into $$2(2a+1)^2+c^2=3(2b+1)^2$$ and define $$x:=2a+1,y:=c,z:=2b+1,$$ so that $$2(2a+1)^2+c^2=3(2b+1)^2$$ becomes $$2x^2+y^2-3z^2=0.$$ This is a diagonal conic with the rational point $(x_0,y_0,z_0)=(1,1,1)$ and you can find the parametrisation of all solutions before Theorem 2.3 these notes.

If you are only interested in the integer solutions of $2a(a+1)=3b(b+1)$ the you could try to do some arithmetic in the number field $\mathbb{Q}(\sqrt{-6})$ by noting that $$N_{\mathbb{Q}(\sqrt{-6})/\mathbb{Q}}(2(2a+1)+\sqrt{-6}(2b+1))=2((2a+1)^2-3(2b+1)^2)=2.$$

A better equation to solve in General.

$$aX^2+bX=cY^2+dY$$

As already mentioned, the task is reduced to some equivalent to the Pell equation. Actually reduced to this form.

$$p^2-acs^2=\pm1$$

Solution we write.

$$X=\pm{s(dp+cbs)}$$

$$Y=\pm{s(bp+ads)}$$

Or so.

$$X=\frac{\mp1}{a-c}((b-d)p^2-(2cb-(c+a)d)ps+c(cb-ad)s^2)$$

$$Y=\frac{\mp1}{a-c}((b-d)p^2-((a+c)b-2ad)ps+a(cb-ad)s^2)$$