# How do we solve pell-like equations?

I need to find all solutions $$(x,y)∈Z^2$$ to the Pell-like equation $$x^2-21y^2= 4$$

Method I used to solve above problem:-

I solved the pell-equation $$x^2-21y^2= 1$$ and calculated the possible solutions to the equation and further multiplied the above equation with the initial equation, i.e, $$x^2-21y^2= 4$$.

But I am still not able to figure out what should I do next? Could someone help me out in this problem?

• The least primitive solution is $(x,y)=(5,1)$. See this post. Aug 3, 2020 at 16:56
• Could you please explain it in detail? Aug 3, 2020 at 16:57

This pictorial method is introduced in CONWAY and further discussed in HATCHER. There is also an intuitive book by Weissman with lots of pictures.

Here is the topograph diagram, showing solutions in a fundamental region as well as the automorphism generator. As integer column vectors, all (well, fundamental) solutions to $$x^2 - 21 y^2 = 4$$ are $$\left( \begin{array}{c} 2 \\ 0 \end{array} \right) \; \; , \; \; \left( \begin{array}{c} 5 \\ 1 \end{array} \right) \; \; , \; \; \left( \begin{array}{c} 23 \\ 5 \end{array} \right) \; \; . \; \;$$ For each of the three, multiply arbitrarily many times by $$A = \left( \begin{array}{cc} 55 & 252 \\ 12 & 55 \\ \end{array} \right) \; \; . \; \;$$ The first three such vectors are $$\left( \begin{array}{c} 110 \\ 24 \end{array} \right) \; \; , \; \; \left( \begin{array}{c} 527 \\ 115 \end{array} \right) \; \; , \; \; \left( \begin{array}{c} 2525 \\ 551 \\ \end{array} \right) \; \; . \; \;$$

The next three such vectors are $$\left( \begin{array}{c} 12098 \\ 2640 \end{array} \right) \; \; , \; \; \left( \begin{array}{c} 57965 \\ 12649 \end{array} \right) \; \; , \; \; \left( \begin{array}{c} 277727 \\ 60605 \\ \end{array} \right) \; \; . \; \;$$

Put another way, if we put all such $$x_n$$ and $$y_n$$ in two ordered sequences, $$2, 5, 23, 110, 527, 2525, 12098, 57965, 277727, 1330670, 6375623, 30547445, \ldots$$ $$0, 1, 5, 24, 115, 551, 2640, 12649, 60605, 290376, 1391275, 6665999, \ldots$$ Cayley-Hamilton tells us $$x_{n+6} = 110 x_{n+3} - x_n ,$$ $$y_{n+6} = 110 y_{n+3} - y_n .$$

Ummm. The continued fraction was not guaranteed to show all the solutions because 4 is larger than half the square root of 21, but this time we are lucky:

Method described by Prof. Lubin at Continued fraction of $\sqrt{67} - 4$

$$\sqrt { 21} = 4 + \frac{ \sqrt {21} - 4 }{ 1 }$$ $$\frac{ 1 }{ \sqrt {21} - 4 } = \frac{ \sqrt {21} + 4 }{5 } = 1 + \frac{ \sqrt {21} - 1 }{5 }$$ $$\frac{ 5 }{ \sqrt {21} - 1 } = \frac{ \sqrt {21} + 1 }{4 } = 1 + \frac{ \sqrt {21} - 3 }{4 }$$ $$\frac{ 4 }{ \sqrt {21} - 3 } = \frac{ \sqrt {21} + 3 }{3 } = 2 + \frac{ \sqrt {21} - 3 }{3 }$$ $$\frac{ 3 }{ \sqrt {21} - 3 } = \frac{ \sqrt {21} + 3 }{4 } = 1 + \frac{ \sqrt {21} - 1 }{4 }$$ $$\frac{ 4 }{ \sqrt {21} - 1 } = \frac{ \sqrt {21} + 1 }{5 } = 1 + \frac{ \sqrt {21} - 4 }{5 }$$ $$\frac{ 5 }{ \sqrt {21} - 4 } = \frac{ \sqrt {21} + 4 }{1 } = 8 + \frac{ \sqrt {21} - 4 }{1 }$$

Simple continued fraction tableau:
$$\begin{array}{cccccccccccccccccc} & & 4 & & 1 & & 1 & & 2 & & 1 & & 1 & & 8 & \\ \\ \frac{ 0 }{ 1 } & \frac{ 1 }{ 0 } & & \frac{ 4 }{ 1 } & & \frac{ 5 }{ 1 } & & \frac{ 9 }{ 2 } & & \frac{ 23 }{ 5 } & & \frac{ 32 }{ 7 } & & \frac{ 55 }{ 12 } \\ \\ & 1 & & -5 & & 4 & & -3 & & 4 & & -5 & & 1 \end{array}$$

$$\begin{array}{cccc} \frac{ 1 }{ 0 } & 1^2 - 21 \cdot 0^2 = 1 & \mbox{digit} & 4 \\ \frac{ 4 }{ 1 } & 4^2 - 21 \cdot 1^2 = -5 & \mbox{digit} & 1 \\ \frac{ 5 }{ 1 } & 5^2 - 21 \cdot 1^2 = 4 & \mbox{digit} & 1 \\ \frac{ 9 }{ 2 } & 9^2 - 21 \cdot 2^2 = -3 & \mbox{digit} & 2 \\ \frac{ 23 }{ 5 } & 23^2 - 21 \cdot 5^2 = 4 & \mbox{digit} & 1 \\ \frac{ 32 }{ 7 } & 32^2 - 21 \cdot 7^2 = -5 & \mbox{digit} & 1 \\ \frac{ 55 }{ 12 } & 55^2 - 21 \cdot 12^2 = 1 & \mbox{digit} & 8 \\ \end{array}$$

After this one must still apply the automorphism matrix arbitrarily many times...

• List all the solutions? Aug 4, 2020 at 17:53
• Explain it more clearly Aug 4, 2020 at 17:53

Given $$x^2-21y^2= 4$$ we can see $$(5,1)$$ as an easy solution where $$5^2-21= 4$$. Another observation is

$$x^2-21y^2= 4\implies \frac{x^2-4}{21}=y^2=\frac{x-2}{p}\cdot\frac{x+2}{q}\quad \text{ where }\quad p|x-2\quad\land\quad q|x+2$$

The factors of $$21$$ are $$1,3,7,21$$ and trying the cofactors $$(1,21)$$ we get conflicting answers for what is x.

$$x-2=1\implies x=3\quad \land \quad x+2=21\implies x=19 \lor\\ x-2=21\implies x=23\quad \land \quad x+2=1\implies x=-1$$

but the other two cofactors do yield consistent results for what is x.

$$x-2=3\implies x=5\quad \land \quad x+2=7\implies x=5$$ and this fits our desire to have integers that, multiplied, yield a square.

$$\frac{x-2}{3}\cdot\frac{x+2}{7}=\frac{5-2}{3}\cdot\frac{5+2}{7} =\frac{3}{3}\cdot\frac{7}{7}=\frac{21}{21}=1=y^2$$ Only positive integers have been used in this demonstration but the results are the same with $$(-5,-1)$$ because, multiplied, they become positive.

$$\therefore x^2-21y^2= 4\implies x=\pm5\quad y=\pm 1$$