# A caboodle of Pell's equation in one? $x^2+y^2-5xy+5=0$

Find all the pairs of positive integers $$(x,y)$$ satisfying $$x^2 + y^2 - 5xy + 5 = 0 .$$

I don't know how to tackle this and I ended up summoning WolframAlpha which shows that there are infinitely many solutions. What's interesting is that there are (at least?) 12 general forms that looks like they all resemble the solutions to Pell's equation.

For example, the first general solution presented reads:

$$\begin{array} { r c l } x &=& \dfrac1{42} \Big [ 21 \left(55 - 12\sqrt{21} \right)^n - \sqrt{21} \left(55 - 12\sqrt{21} \right)^n + 21 \left(55 + 12\sqrt{21} \right)^n + \sqrt{21} \left(55 + 12\sqrt{21} \right)^n \Big ] \\ \phantom0 \\ y &=& \dfrac1{42} \Big [ 63 \left(55 - 12\sqrt{21} \right)^n - 13 \sqrt{21} \left(55 - 12\sqrt{21} \right)^n + 63 \left(55 + 12\sqrt{21} \right)^n + 13 \sqrt{21} \left(55 + 12\sqrt{21} \right)^n \Big] \end{array}$$ for $$n = 0,1,2,3\ldots$$.

Plugging $$n=0,1,2,3$$ gives the first few solutions

$$(x,y) = (1,3), (67,321), (7369,35307), (810523,3883449)$$

I tried converting these solutions to the form of $$X^2 - DY^2 = A$$ or something similar to Pell's equation but I got nothing.

Is it a coincidence that this innocuous-looking quadratic Diophantine equation is actually a caboodle of Pell's equation in disguise? If so, how can we derive them all?

• ObLink to Alpertron Jan 20, 2021 at 5:58
• It looks like Wolfram Alpha is using a fairly brutal approach, based on the CF (continued fraction) of $\sqrt{21}$, which has the fundamental solution (55, 12). That CF has a period of 6; more elegant CF-based approaches to this problem use things like $\frac{\pm1+\sqrt{21}}{10}$ and $\frac{\pm5+\sqrt{21}}{2}$, which have period 2. Jan 20, 2021 at 21:11
• Here is a short Sage / Python script that calculates solutions using the iteration formula in Will Jagy's answer. Jan 20, 2021 at 22:56
• And here's a script for a Binet-style formula: $$f_a(n) = \frac{(a-q^{-1})q^n - (a-q)q^{-n}}{r}$$ with $q=\frac{5+\sqrt{21}}2, r=q-q^{-1}=\sqrt{21}, a\in\{2,3\}$ Jan 21, 2021 at 17:09
• @PM2Ring note that this particular form is appropriate for Vieta Jumping, which is a special case of automorphism; from one solution $(x,y)$ we get a new one with $(x,y) \mapsto ( 5x-y, x)$ or $(x,y) \mapsto ( y, -x + 5y)$ so that all solutions can be mapped to two "fundamental" solutions, which then generate all. Note the two mappings have determinant $+1.$ Switching the variables has determinant $-1.$ Oh, and trace of either matrix is $5$ so the orbit obeys a $w_{n+2}= 5 w_{n+1} - w_n$ Jan 21, 2021 at 18:37

It's $$(5y-2x)^2-21y^2=-20$$, which is a Pell type equation.

I got that by completing the square:

$$x^2-5xy+y^2=-5\implies \left(x-\frac52y\right)^2-\frac{21}4y^2=-5\implies (5y-2x)^2-21y^2=-20$$.

So it's $$X^2-21Y^2=-20$$, with $$X=5y-2x$$ and $$Y=y$$.

• Solution of $X^2-21Y^2=-20$ is $(X,Y)=(13,3)$ and solution of $X^2-21Y^2=1$ is $(X,Y)=(55,12)$, so if $X^2-21Y^2=-20$ then also $(55X+21\cdot12\cdot Y)^2-(12X+55Y)^2=-20$, so solutions to $X^2-21Y^2=-20$ are $(X,Y)=(13,3), (1471, 321), (161797,35307),$ $(17796199,3883449),...$, so solutions to OP's equation are $(x,y)=(1,3), (67,321), (7369, 35307), (810523,3883449),...$ Jan 19, 2021 at 18:13

This sort of thing has a clear description in terms of Conway's topograph; I find it more convenient to use equivalent form $$u^2 + uv - 5 v^2.$$ The outcome for the original problem is sequences (note that the rule deals with every other element). For instance, $$5\cdot 9 - 2 = 43$$ and $$5 \cdot 14 -3 = 67$$

$$x_{n+4}= 5 x_{n+2} - x_n,$$ $$y_{n+4}= 5 y_{n+2} - y_n,$$

There are two interleaved subsequences.

$$\begin{array}{c} 1&1&2&3&9&14&43&67&206&321&987 &1538&4729& \ldots \\ 3&2&1&1&2&3&9&14&43&67&206&321&987&\ldots \\ \end{array}$$ Running the indices backwards leads to different solutions, but they are just transpositions of the ones above.

Let's see, given $$u^2 + uv - 5 v^2 = -5$$ and $$x=u+3v, y=v$$ gives $$x^2 - 5 xy + y^2 = -5$$ and the reverse holds as well

Apparently I drew one of these in 2016

Another quadratic Diophantine equation: How do I proceed?

How to find solutions of $x^2-3y^2=-2$?

Generate solutions of Quadratic Diophantine Equation

Why can't the Alpertron solve this Pell-like equation?

Finding all solutions of the Pell-type equation $x^2-5y^2 = -4$

If $(m,n)\in\mathbb Z_+^2$ satisfies $3m^2+m = 4n^2+n$ then $(m-n)$ is a perfect square.

Find all integer solutions for the equation $|5x^2 - y^2| = 4$

Positive integer $n$ such that $2n+1$ , $3n+1$ are both perfect squares

Maps of primitive vectors and Conway's river, has anyone built this in SAGE?

Infinitely many systems of $23$ consecutive integers

Finding integers of the form $3x^2 + xy - 5y^2$ where $x$ and $y$ are integers, using diagram via arithmetic progression

Small integral representation as $x^2-2y^2$ in Pell's equation

Solving the equation $x^2-7y^2=-3$ over integers

Solutions to Diophantine Equations

How to prove that the roots of this equation are integers?

Does the Pell-like equation $X^2-dY^2=k$ have a simple recursion like $X^2-dY^2=1$?

Find all natural numbers $n$ such that $21n^2-20$ is a perfect square.

To find all integral solutions of $3x^2 - 4y^2 = 11$

How do we solve pell-like equations?

• FWIW, Alpertron agrees that this is the only solution (apart from the obvious transposed and negated versions). Jan 20, 2021 at 20:47
• Readers unfamiliar with topographs may wish to look at the free preview of Alan Hatcher's Topology of Numbers. It has a great treatment of Farey sequences and their relationship to quadratic forms, Conway's Topograph, etc. Alan uploaded the latest version in December 2020 (I've started working through an earlier version...) Jan 20, 2021 at 20:55
• @PM2Ring some things about the topograph are not given enough prominence, at least as far as knowing we have all solutions to and indefinite binary form equal to a fixed target. A generator for the (oriented) automorphism does appear in the diagram; representatives of all solutions (under automorphism equivalence) must appear within the region of the diagram between the original form and its first perfect copy. In sum, the finite diagram provides a proof of a description of all solutions. Then the Fibonacci type sequences come from Cayley-Hamilton for that matrix. Jan 20, 2021 at 22:52
• Hatcher's diagrams look pretty good, but I guess he might be constructing them semi-manually. And even if he did have software that fully automates the process he probably wouldn't want to make it available. He places great importance on the value of drawing Farey & topograph diagrams by hand. Jan 20, 2021 at 23:21
• The whole kit and caboodle means the entire amount of things or the entire group of people being discussed. The word kit in the phrase the whole kit and caboodle is a reference to a soldier’s kit, which is the collection of supplies and personal items that a soldier carries with him. The word caboodle in the phrase the whole kit and caboodle is an alliteration of the word boodle. Boodle appears in the United States in the 1830s to mean a crowd of people, later evolving to mean a large amount of ill-gotten money. An older rendering of the phrase is the whole kit and boodle. Jan 21, 2021 at 17:54

The question as given is perfect for a technique from contest mathematics called Vieta Jumping. This is a special case of automorphism of quadratic forms. It has the virtue that it can be justified using nothing worse that the quadratic formula, and it does not require the use of square roots either. If we have a solution in positive integers to $$x^2 - 5xy + y^2 = -5$$ we get new ones using either $$(x,y) \mapsto (5y-x,y)$$ or

$$(x,y) \mapsto (x,5x -y)$$

Note that repeating one of the "jumps" twice in a row goes back to the original solution.

A "fundamental" solution is one that minimizes $$x+y$$ as much as possible. That is, fundamental when both $$x+y \leq 5y - x + y$$ and $$x+y \leq x +5x - y .$$ The first one becomes $$2x \leq 5 y,$$ the second $$2y \leq 5x .$$
Altogether, fundamental solutions are on the arc $$x^2 - 5xy + y^2$$ with $$\frac{2x}{5} \leq y \leq \frac{5x}{2}$$

As you can see, there are the two integer points between the slanted lines, those being $$(2,1)$$ and $$(1,2).$$ Every solution in positive integers reduces to one of these; in turn, jumping up from one of the fundamental solutions generates all solutions.

The linear recurrence $$w_{n+2} = 5 w_{n+1} - w_n$$ that applies to every other number in a sequence comes from the trace and determinant of $$\left( \begin{array}{r} 5 & -1 \\ 1 & 0 \\ \end{array} \right)$$ being $$5$$ and $$1.$$

The equation is symmetric and it is easy to see solutions if, for example, we solve for $$y$$.

$$x^2 + y^2 - 5xy + 5 = 0 \implies\quad y = \frac{5 x \pm \sqrt{21 x^2 - 20}}{2}\qquad |x|\ge 1$$

Note that the absolute value of $$x$$ must be at least $$1$$ for the radical to be non-negative and therfore, for $$y$$ to be real.

Given this equation, we can also see that there are $$2$$ $$y$$-values for every valid $$x$$. There are $$28$$ solutions for $$\space -50000\le x \le 50000.\quad$$ Here is that "sample" of $$\quad (x,y_1,y_2.)\quad$$

$$(-7369,-35307,-1538)\quad (-4729,-22658,-987)\quad (-1538,-7369,-321)\\ (-987,-4729,-206)\qquad (-321,-1538,-67)\qquad (-206,-987,-43)\\ (-67,-321,-14)\qquad (-43,-206,-9)\qquad (-14,-67,-3)\\ (-9,-43,-2)\quad (-3,-14,-1)\quad (-2,-9,-1)\quad (-1,-3,-2)\\ (1,2,3)\qquad (2,1,9)\qquad (3,1,14)\qquad (9,2,43)\qquad (14,3,67)\\ (43,9,206)\qquad (67,14,321)\qquad (206,43,987)\qquad (321,67,1538)\\ (987,206,4729)\qquad (1538,321,7369)\qquad (4729,987,22658)\\ (7369,1538,35307)\quad (22658,4729,108561)\quad (35307,7369,169166)$$

Note that all the negative $$x$$-values have positive counterparts and that we have a counterpart solution for $$x$$.

$$x = \frac{5 y \pm \sqrt{21 y^2 - 20}}{2}$$ so the $$x,y$$ values should be interchangeable.