3

Question: If the sum of the squares of two consecutive integers is equal to the square of another integer, then find a general method to find particular solutions. E.g., $27304196^2+27304197^2=38613965^2$.

I tried to figure out other solutions such as $3^2+4^2=5^2$ and $20^2+21^2=29^2$, but I don't know how to find a method for general solutions.

Can anybody help me

J. W. Tanner
  • 60,406
Paras
  • 1,412

4 Answers4

4

If $n^2+(n+1)^2=k^2$, then $2n^2+2n+1=k^2$, so $(2n+1)^2=4n^2+4n+1=2k^2-1$.

So we are looking for solutions to the negative Pell equation $(2n+1)^2-2k^2=-1$,

which are $2n+1=1, 7, 41, 239, 1393, 8119, 47321, 275807, 1607521, 9369319,$

$54608393, ...,$ listed in OEIS.

J. W. Tanner
  • 60,406
2

For $A^2+B^2=C^2:\space B=A\pm1\quad$ the $C$-values are the odd Pell numbers $(5,29,169,985\cdots)$ as shown in A000129 and the triples $T_n$ that contain them can be generate sequentially by the formula below with a seed of $\quad T_0=(0,0,1)$

$$A_{n+1}=3A_n+2C_n+1\qquad B_{n+1}=3A_n+2C_n+2\qquad C_{n+1}=4A_n+3C_n+2$$

For example, it generates the following $$T_1=(3,4,5)\quad T_2=(20,21,29)\quad T_3=(119,120,169)\quad T_4=(697,696,985)$$

They may also be generated directly using Euclid's formula

$$\text{where} \qquad A=m^2-k^2 \qquad B=2mk \qquad C=m^2+k^2\quad \text{and}$$

\begin{equation} m_n= \frac{(1 + \sqrt{2})^{n+1} - (1 - \sqrt{2})^{n+1}}{2\sqrt{2}}\qquad \qquad\qquad k_n= \frac{(1 + \sqrt{2})^n - (1 - \sqrt{2})^n}{2\sqrt{2}} \end{equation}

For example \begin{align*} \frac{(1 + \sqrt{2})^{2} - (1 - \sqrt{2})^{2}}{2\sqrt{2}}=2 \qquad & \frac{(1 + \sqrt{2})^1 - (1 - \sqrt{2})^1}{2\sqrt{2}}=1 \\ &\qquad\qquad F(2,1)=(3,4,5)\\ \frac{(1 + \sqrt{2})^{3} - (1 - \sqrt{2})^{3}}{2\sqrt{2}}=5 \qquad & \frac{(1 + \sqrt{2})^2 - (1 - \sqrt{2})^2}{2\sqrt{2}}=2 \\ & \qquad\qquad F(5,2)=(21,20,29)\\ \frac{(1 + \sqrt{2})^{4} - (1 - \sqrt{2})^{4}}{2\sqrt{2}}=12 \qquad & \frac{(1 + \sqrt{2})^3 - (1 - \sqrt{2})^3}{2\sqrt{2}}=5 \\ &\qquad\qquad F(12,5)=(119,120,169)\\ \frac{(1 + \sqrt{2})^{5} - (1 - \sqrt{2})^{5}}{2\sqrt{2}}=29 \qquad & \frac{(1 + \sqrt{2})^4 - (1 - \sqrt{2})^4}{2\sqrt{2}}=12 \\ &\qquad\qquad F(29,12)=(697,696,985) \end{align*}

poetasis
  • 6,338
1

We want to find all $x,y \in \mathbb N$ such that $x^2+(x+1)^2=y^2$. Multiplying both sides by $2$ and rearranging gives

$$ (2x+1)^2 - 2y^2 = -1. $$

This is a Pell equation:

\begin{equation} \tag{Pell} X^2 - dY^2 = \pm 1, \end{equation}

where $d>0$ and squarefree. All solutions in integer pairs $(X,Y)$ can be obtained from the fundamental unit ${\epsilon}_0$ in the ring of integers ${\mathscr O}_K$ in $K={\mathbb Q}(\sqrt{d})$. It turns out that

$$ {\mathscr O}_K = \begin{cases} {\mathbb Z}[\sqrt{d}] & \:\mbox{if}\: d \not\equiv 1\pmod{4}; \\ {\mathbb Z}\left[1,\frac{1+\sqrt{d}}{2}\right] & \:\mbox{if}\: d \equiv 1\pmod{4}. \end{cases} $$

Solutions $(X,Y)$ to eqn. (Pell) correspond to units in ${\mathscr O}_K$. Units are the invertible elements in the ring. The norm function ${\mathcal N}: {\mathscr O}_K \to \mathbb Z$ given by

$$ {\mathcal N}(a+b\sqrt{d}) = (a+b\sqrt{d})(a-b\sqrt{d}) = a^2-db^2 $$

is multiplicative: ${\mathcal N}(\alpha\beta)={\mathcal N}(\alpha) \cdot {\mathcal N}(\beta)$. Thus, $\alpha$ is a unit if and only if ${\mathcal N}(\alpha)=\pm 1$.

The problem of solving eqn. (Pell) is that of determining units in ${\mathscr O}_K$. The set of units form a cyclic group, upto sign. The generator of this group is called the fundamental unit, ${\epsilon}_0$, and is characterized as the smallest unit $>1$. Thus, the set of all units in ${\mathscr O}_K$ is

$$ U({\mathscr O}_K) = \{ \pm {\epsilon}_0^n: n \in \mathbb Z\}. $$

Solutions with $(X,Y)$ in the first quadrant correspond to $+{\epsilon}_0^n$, with $n>0$. Solutions with $(X,Y)$ in the other three quadrants arise out of choosing whether $n>0$ or $n<0$ and out of the sign $+$ or $-$ to multiply by.

Let us look for solutions with $X>0$ and $Y>0$. The fundamental unit ${\epsilon}_0$ is computed from the continued fraction of $\sqrt{d}$, which we know has the special form

$$ \sqrt{d} = \langle a_0; \overline{a_1,\ldots,a_{\ell-1},2a_0} \rangle, $$

where the sequence $a_1,\ldots,a_{\ell-1}$ is a palindrome - it reads the same left to right as right to left.

Now the fundamental unit is given by

$$ {\epsilon}_0 = X + Y\sqrt{d}, $$

where

$$ \dfrac{X}{Y} = \langle a_0; a_1, \ldots, a_{\ell-1} \rangle. $$

Thus, ${\mathcal N}({\epsilon}_0)=\pm 1$. In fact, it turns out that ${\mathcal N}({\epsilon}_0)=(-1)^{\ell}$. Note that $\ell$ denotes the length of the periodic part of the continued fraction for $\sqrt{d}$.

The eqn. (Pell) with $+1$ always has infinitely many solutions; the one with $-1$ sign either has no solution or infinitely many solutions.

$\bullet$ If ${\mathcal N}({\epsilon}_0)=1$, all solutions $(X,Y)$ with $X>0$ and $Y>0$ for the eqn. (Pell) with $+1$ may be derived from $X_n+Y_n\sqrt{d}={\epsilon}^n$, $n \ge 1$. There is no solution corresponding to $-1$.

$\bullet$ If ${\mathcal N}({\epsilon}_0)=-1$, all solutions $(X,Y)$ with $X>0$ and $Y>0$ for the eqn. (Pell) with $+1$ may be derived from $X_n+Y_n\sqrt{d}={\epsilon}^n$, $n$ even, $n \ge 1$; those corresponding to the eqn. (Pell) with $-1$ may be derived from $X_n+Y_n\sqrt{d}={\epsilon}^n$, $n$ odd, $n \ge 1$.

That is all the theory I will write for now.

To solve $X^2-2Y^2=-1$ we must first compute the continued fraction of $\sqrt{2}$:

$$ \sqrt{2} = \langle 1; \overline{2} \rangle. $$

Thus, ${\epsilon}_0=1+\sqrt{2}$. Note that ${\mathcal N}({\epsilon}_0)=-1$, either by definition of norm or from $\ell=1$. Hence, all solutions $(X,Y)$ with $X>0$ and $Y>0$ are computed from

$$ X_n + Y_n\sqrt{2} = (1+\sqrt{2})^n, \quad n \:\text{odd}, n \ge 1. $$

Since $(1+\sqrt{2})^2=3+2\sqrt{2}$, we have

$$ X_{n+2}+Y_{n+2}\sqrt{2} = (3+2\sqrt{2})(X_n+Y_n\sqrt{2}) = (3X_n+4Y_n)+(2X_n+3Y_n)\sqrt{2}, $$

so that

$$ X_{n+2} = 3X_n+4Y_n, \quad Y_{n+2} = 2X_n+3Y_n, \quad n \:\text{odd}, n \ge 1. $$

Finally, recall that $x=\frac{X-1}{2}$ and $y=Y$. $\blacksquare$

AT1089
  • 973
  • Good to see you sir on math stackexchange, also on quora – Paras Jul 08 '20 at 17:24
  • My students have been asking me to write on StackExchange for years. My second day on this forum. Transferring some of my Quora time to StackExchange time. – AT1089 Jul 08 '20 at 17:29
1

Recursion Based on Continued Fractions

Suppose that $$ \begin{align} m^2 &=n^2+(n+1)^2\\ &=2n^2+2n+1\\ &=2\left(n+\tfrac12\right)^2+\tfrac12\tag1 \end{align} $$ Then $$ \left(\frac{2m}{2n+1}\right)^2=2+\frac2{(2n+1)^2}\tag2 $$ At first glance, equation $(2)$ looks as if a continued fraction approximation for $\sqrt2$ should work. However, the continued fraction for $\sqrt2$ is $$ \sqrt2=(1;\overline{2})\tag3 $$ which means that each convergent has the property that $$ \frac1{4q^2}\le\left|\frac pq-\sqrt2\right|\le\frac1{2q^2}\tag4 $$ which is too close since $(2)$ and $(4)$ would imply $$ \begin{align} \frac2{(2n+1)^2} &=\left(\frac{2m}{2n+1}-\sqrt2\right)\left(\frac{2m}{2n+1}+\sqrt2\right)\\ &\le\frac1{2(2n+1)^2}\left(2\sqrt2+\frac1{2(2n+1)^2}\right)\\ &=\frac{\sqrt2}{(2n+1)^2}+\frac1{4(2n+1)^4}\tag{5a} \end{align} $$ which is equivalent to $$ (2n+1)^2\le\frac{2+\sqrt2}8\tag{5b} $$ This means that we need something larger than the usual continued fraction over-approximation. The usual over-approximations are in red: $$ \begin{array}{} &&1&\color{#C00}{2}&2&\color{#C00}{2}&2&\color{#C00}{2}&2&\color{#C00}{2}\\\hline 0&1&1&\color{#C00}{3}&7&\color{#C00}{17}&41&\color{#C00}{99}&239&\color{#C00}{577}\\ 1&0&1&\color{#C00}{2}&5&\color{#C00}{12}&29&\color{#C00}{70}&169&\color{#C00}{408} \end{array}\tag6 $$ Due to $(3)$, each row in $(6)$ is subject to the recurrence $$ a_k=2a_{k-1}+a_{k-2}\tag{7a} $$ and, since $\left(x^2-2x-1\right)\left(x^2+2x-1\right)=x^4-6x^2+1$, the red columns in $(6)$ are subject to the recurrence $$ a_k=6a_{k-1}-a_{k-2}\tag{7b} $$ The convergent (ratio of $\frac{\text{middle}}{\text{bottom}}$ elements) of each red column decreases with an increase to its term (top element). Since those terms are all $2$, we can increase the convergents by decreasing the terminal $2$ to a $1$. Decreasing the terminal $2$ simply subtracts the previous column, so we get the following over-approximations: $$ \frac{2m_k}{2n_k+1}=\frac{p_k}{q_k}\in\left\{\frac21,\frac{10}7,\frac{58}{41},\frac{338}{239},\dots\right\}\tag8 $$ Note that both $p_k$ and $q_k$ in $(8)$ also satisfy $\text{(7b)}$; furthermore, $m_k$ and $n_k$ are solutions to $(1)$.

The sequence in $(8)$ leads to the following Pythagorean Triples: $$ \begin{align}{} m^2&=n^2+(n+1)^2\\\hline 1^2&=0^2+1^2\\ 5^2&=3^2+4^2\\ 29^2&=20^2+21^2\\ 169^2&=119^2+120^2\\ &\,\,\vdots \end{align}\tag9 $$


Explicit Formulas

Using the standard solution for the recurrence relation $\text{(7b)}$ with initial conditions from $(8)$, we get $$ \begin{align} m_k&=\frac{\left(2+\sqrt2\right)\left(3+2\sqrt2\right)^k+\left(2-\sqrt2\right)\left(3-2\sqrt2\right)^k}4\tag{10a}\\ n_k&=\frac{\left(1+\sqrt2\right)\left(3+2\sqrt2\right)^k+\left(1-\sqrt2\right)\left(3-2\sqrt2\right)^k-2}4\tag{10b} \end{align} $$ which gives the values $$ \begin{array}{c|cc} k&0&1&2&3&4&5&6&7\\\hline m&1&5&29&169&985&5741&33461&195025\\\hline n&0&3&20&119&696&4059&23660&137903 \end{array}\tag{11} $$

robjohn
  • 345,667