By M.Xu mi KS

1. Introduction

In 1657, Pierre de Fermat challenged English mathematicians to find whole-number solutions to equations such as x2−61y2=1x^2-61y^2=1. The smallest solution turns out to be x=1766319049x=1766319049 and y=226153980y=226153980, which the Indian mathematician Bhāskara II had already found in the 12th century. Equations like this are named after the English mathematician John Pell, but only because Leonhard Euler mistakenly credited Pell with a solution found by William Brouncker.

The standard Pell’s equation is any Diophantine equation generally written in the form:

x2−ny2=1,(1)x^2 – ny^2 = 1, \tag{1}

where nn is a positive non-square integer, and we are interested in pairs of integer solutions (x,y)(x,y). We can also generalise the standard equation (1) by replacing 11 on the right-hand side with any other integer t≠1t \ne 1, i.e.,

x2−ny2=t.(2)x^2 – ny^2 = t. \tag{2}

The obvious solutions to equation (1) are (x,y)=(±1,0)(x,y)=(\pm1,0), and these are called the trivial solutions. In this article we will show that, given one non-trivial solution, a standard Pell’s equation (1) has infinitely many different solutions, and illustrate the method to find all its solutions; we then discuss some interesting properties of those solutions.

2. Why nn Must Be Non-Square

As stated previously, nn must be non-square. If nn is a non-zero square number, e.g., n=m2>0n = m^2 > 0 with m∈ℤ+m\in\mathbb{Z}^+, then x2−ny2=x2−(my)2x^2-ny^2=x^2-(my)^2, and the only pair of squares which differ by 11 are 00 and 11, so x2−(my)2=1⟹x=±1x^2 – (my)^2 = 1\implies x=\pm1 and y=0y=0, yielding only the trivial solutions.

Since only x2x^2 and y2y^2 appear in Pell’s equations, changing the sign of xx, of yy, or of both does not affect the equation. Therefore every integer solution (x,y)(x,y) has three corresponding solutions (x,−y)(x,-y), (−x,y)(-x,y) and (−x,−y)(-x,-y), and our study can be focused on solutions where xx and yy are both positive integers, which are called non-trivial solutions.

3. New Solutions from Old

Given the example equation x2−2y2=1x^2-2y^2=1, two positive solutions are (3,2)(3,2) and (17,12)(17,12), since 2y2+12y^2 + 1 is a square when y=2y=2 and y=12y=12, where 2y2+1=9=322y^2+1=9=3^2 and 2y2+1=289=1722y^2+1=289=17^2.

yy123456789101112
2y2+12y^2 + 1391933517399129163201243289
Square?×\times✓\checkmark×\times×\times×\times×\times×\times×\times×\times×\times×\times✓\checkmark

As another example, the equation x2−3y2=1x^2-3y^2=1 has positive solutions (2,1)(2,1), (7,4)(7,4), (26,15)(26,15), etc.

yy123456789101112131415
3y2+13y^2 + 1413284976109148193244301364433508589676
Square?✓\checkmark×\times×\times✓\checkmark×\times×\times×\times×\times×\times×\times×\times×\times×\times×\times✓\checkmark

Joseph Louis Lagrange proved that, as long as nn is not a perfect square, the standard Pell’s equation (1) has infinitely many distinct integer solutions. Searching by trial, as above, quickly becomes impractical, but there is a much better way to find new solutions.

Let (a,b)(a,b) and (c,d)(c,d) be two, not necessarily different, non-trivial solutions to a standard Pell’s equation, that is, a2−nb2=c2−nd2=1a^2 – nb^2 = c^2 – nd^2 = 1. We multiply them, and obtain

1=(a2−nb2)(c2−nd2)=a2c2+n2b2d2−na2d2−nb2c2=[(ac+nbd)2−2nabcd]−[n(ad+bc)2−2nabcd]=(ac+nbd)2−n(ad+bc)2.\begin{aligned} 1 &= (a^2-nb^2)(c^2-nd^2) \\ &= a^2c^2+n^2b^2d^2-na^2d^2-nb^2c^2 \\ &= [(ac+nbd)^2-2nabcd]-[n(ad+bc)^2-2nabcd] \\ &= (ac+nbd)^2-n(ad+bc)^2. \end{aligned}

This identity was first discovered by the Indian mathematician Brahmagupta around 628 AD. It gives us a new solution (ac+nbd,ad+bc)(ac+nbd,\,ad+bc), since, as a,b,c,d∈ℤ+a,b,c,d\in\mathbb{Z}^+, we have ac+nbd>aac+nbd>a, ad+bc>bad+bc>b, ac+nbd>cac+nbd>c and ad+bc>dad+bc>d. Notice that if either of the two solutions is the trivial solution instead, say (a,b)=(1,0)(a,b)=(1,0), then (ac+nbd,ad+bc)=(c,d)(ac+nbd,\,ad+bc)=(c,d), so we do not obtain a new solution. Repeating this process allows us to keep finding new solutions from existing old solutions. So, given just one non-trivial solution, we can generate infinitely many other distinct non-trivial solutions.

4. The Fundamental Solution

The fundamental solution is the minimal solution among all non-trivial solutions to a standard Pell’s equation (1), meaning the solution with the smallest positive yy (or, equivalently, the smallest positive xx). A rigorous proof of the existence of the fundamental solution to any standard Pell’s equation is not in the scope of this article. We can demonstrate some examples here, however.

The table below shows fundamental solutions to (1) for non-square nn from 22 to 1515:

nn235678101112131415
xx32958319107649154
yy21423163218041

The fundamental solutions to standard Pell’s equations may appear random. Sometimes they may be quite large even for a small nn, as in some of the examples in the table below:

nn606162108109110
xx31176631904963135115807067198624921
yy42261539808130151404244551002

5. Finding All Solutions

We can obtain all solutions to (1) from the fundamental solution. A rigorous proof that all solutions can be found this way relies on the minimality of the fundamental solution, and is beyond the scope of this article. Here we shall demonstrate how we obtain all solutions from the fundamental solution.

5.1 Iterative Formulas

If (u,v)(u,v) is the fundamental solution, i.e., (u,v)(u,v) is the minimal positive integer pair satisfying u2−nv2=1u^2-nv^2=1, then

{x=u2+nv2y=2uv→{x′=ux+nvyy′=vx+uy→{x′′=ux′+nvy′y′′=vx′+uy′, …\left\{ \begin{aligned} x &= u^2+nv^2\\ y &= 2uv \end{aligned} \right. \to \left\{ \begin{aligned} x’ &= ux + nvy\\ y’ &= vx + uy \end{aligned} \right. \to \left\{ \begin{aligned} x” &= ux’ + nvy’\\ y” &= vx’ + uy’ \end{aligned} \right. , \ \dots

will give us all pairs of ever-increasing solutions (u,v)(u,v), (x,y)(x,y), (x′,y′)(x’,y’), (x′′,y′′)(x”,y”), …. For example, for x2−2y2=1x^2-2y^2=1 with fundamental solution (u,v)=(3,2)(u,v)=(3,2), the first step gives (x,y)=(9+8,12)=(17,12)(x,y)=(9+8,\,12)=(17,12), and the next gives (x′,y′)=(3⋅17+2⋅2⋅12, 2⋅17+3⋅12)=(99,70)(x’,y’)=(3\cdot17+2\cdot2\cdot12,\ 2\cdot17+3\cdot12)=(99,70), matching the solutions found by trial in Section 3.

In fact all non-trivial solutions can be obtained in this iterative way. We shall rewrite the simultaneous recurrence formulas as:

xk+1=uxk+nvyk,(3)x_{k+1} = ux_k+nvy_k, \tag{3}
yk+1=vxk+uyk,(4)y_{k+1} = vx_k+uy_k, \tag{4}

where k∈ℤ+k\in\mathbb{Z}^+ and (x1,y1)=(u,v)(x_1,y_1)=(u,v). Sometimes we may extend the subscript kk down to 00 to include the trivial solution (x0,y0)=(1,0)(x_0, y_0)=(1,0).

The two simultaneous first-order linear recurrence formulas above can be rewritten as two separate second-order linear recurrence relations, in the sense that the sequences {xk}\{x_k\} and {yk}\{y_k\} appear decoupled. For {xk}\{x_k\}:

xk+2=uxk+1+nvyk+1=uxk+1+nv(vxk+uyk)=uxk+1+nv(vxk+u(xk+1−uxk)/(nv))=2uxk+1−(u2−nv2)xk=2uxk+1−xk.\begin{aligned} x_{k+2} &= ux_{k+1}+nvy_{k+1} \\ &= ux_{k+1}+nv(vx_k+uy_k) \\ &= ux_{k+1}+nv(vx_k+u(x_{k+1}-ux_k)/(nv)) \\ &= 2ux_{k+1}-(u^2-nv^2)x_k \\ &= 2ux_{k+1}-x_k. \end{aligned}

Similarly, for {yk}\{y_k\}, substituting xk=(yk+1−uyk)/vx_k=(y_{k+1}-uy_k)/v from (4) gives yk+2=2uyk+1−yky_{k+2} = 2uy_{k+1}-y_k. These formulas may be useful in situations where our interest is solely in one of the two sequences.

5.2 Closed-Form Formulas

In some other situations it may be more convenient to calculate solutions in closed form instead of using the iterative formulas above. This can be derived either from the two separate second-order recurrence formulas above, or from the simultaneous first-order recurrence relation. Here we show a quick way from the latter.

Adding n\sqrt{n} times (4) to (3):

xk+1+nyk+1=uxk+nvyk+nvxk+nuyk=(u+nv)xk+(nu+nv)yk=(u+nv)(xk+nyk).\begin{aligned} x_{k+1}+\sqrt{n}y_{k+1} &= ux_k+nvy_k+\sqrt{n}vx_k+\sqrt{n}uy_k \\ &= (u+\sqrt{n}v)x_k + (\sqrt{n}u+nv)y_k\\ &=(u+\sqrt{n}v)(x_k+\sqrt{n}y_k). \end{aligned}

If we treat xk+nykx_k + \sqrt{n}y_k as a new sequence (of real numbers rather than only integers), then it is a geometric sequence with ratio u+nvu+\sqrt{n}v and first term u+nvu+\sqrt{n}v. Therefore,

xk+nyk=(u+nv)k.(5)x_k+\sqrt{n}y_k = (u + \sqrt{n}v)^k. \tag{5}

Subtracting n\sqrt{n} times (4) from (3):

xk+1−nyk+1=uxk+nvyk−nvxk−nuyk=(u−nv)(xk−nyk).\begin{aligned} x_{k+1}-\sqrt{n}y_{k+1} &= ux_k + nvy_k – \sqrt{n}vx_k-\sqrt{n}uy_k\\ &=(u-\sqrt{n}v)(x_k-\sqrt{n}y_k). \end{aligned}

Again, we have another geometric sequence xk−nykx_k-\sqrt{n}y_k with ratio u−nvu-\sqrt{n}v and first term u−nvu-\sqrt{n}v. So,

xk−nyk=(u−nv)k.(6)x_k-\sqrt{n}y_k = (u-\sqrt{n}v)^k. \tag{6}

The closed-form formulas for xkx_k and yky_k can be obtained by adding and subtracting (5) and (6), then dividing by 22 and by 2n2\sqrt{n} respectively:

xk=(u+nv)k+(u−nv)k2,(7)x_k = \frac{(u+\sqrt{n}v)^k+(u-\sqrt{n}v)^k}{2}, \tag{7}
yk=(u+nv)k−(u−nv)k2n.(8)y_k = \frac{(u+\sqrt{n}v)^k – (u-\sqrt{n}v)^k}{2\sqrt{n}}. \tag{8}

5.3 Properties of the Closed-Form Formulas

Note that although there is an irrational number n\sqrt{n} in the closed-form formulas (7) and (8), it can be proved through mathematical induction that (xk,yk)(x_k,y_k) is always a pair of positive integers. In addition, we start with k∈ℤ+k \in \mathbb{Z}^+, but we can obtain the trivial solution (x0,y0)=(1,0)(x_0,y_0)=(1,0) by setting k=0k=0. It can be seen that (x1,y1)=(u,v)(x_1,y_1)=(u,v) is the fundamental solution. If kk is a negative integer instead, it can be seen that x−k=xkx_{-k}=x_k and y−k=−yky_{-k}=-y_k, which is still a pair of integers satisfying the standard Pell’s equation (1), only with a negative yy value. Combined with the sign changes from Section 2, these formulas actually give all the solutions to a standard Pell’s equation: every solution is ±(xk,yk)\pm(x_k,y_k) for some k∈ℤk\in\mathbb{Z}.

The term u+nv>1u+\sqrt{n}v>1 as u,v∈ℤ+u,v \in \mathbb{Z}^+, and this also implies that 0<u−nv<10<u-\sqrt{n}v<1, because u2−nv2=1⟺(u+nv)(u−nv)=1u^2-nv^2=1 \iff (u+\sqrt{n}v)(u-\sqrt{n}v)=1. Therefore, as kk increases, both elements of the solution pair (xk,yk)(x_k,y_k) grow exponentially. That is, for sufficiently large kk:

xk≈(u+nv)k2andyk≈(u+nv)k2n.x_k \approx \frac{(u+\sqrt{n}v)^k}{2} \qquad\text{and}\qquad y_k \approx \frac{(u+\sqrt{n}v)^k}{2\sqrt{n}}.

6. Approximating n\sqrt{n}

From (7) and (8) we can also derive a method to approximate the irrational number n\sqrt{n} with rational numbers. In fact, we can approximate it with the sequences {xk}\{x_k\} and {yk}\{y_k\} to any precision required. Dividing (7) by (8):

n≈xkyk=n×(u+nv)k+(u−nv)k(u+nv)k−(u−nv)k=n×((u+nv)k+(u−nv)k)×(u−nv)k((u+nv)k−(u−nv)k)×(u−nv)k=n×1+(u−nv)2k1−(u−nv)2k.\begin{aligned} \sqrt{n} \approx \frac{x_k}{y_k} &= \sqrt{n} \times \frac{(u+\sqrt{n}v)^k+(u-\sqrt{n}v)^k}{(u+\sqrt{n}v)^k – (u-\sqrt{n}v)^k} \\ &= \sqrt{n} \times \frac{((u+\sqrt{n}v)^k+({u-\sqrt{n}v})^k)\times({u-\sqrt{n}v})^k}{((u+\sqrt{n}v)^k-({u-\sqrt{n}v})^k)\times({u-\sqrt{n}v})^k} \\ &= \sqrt{n} \times \frac{1+(u-\sqrt{n}v)^{2k}}{1-(u-\sqrt{n}v)^{2k}}. \end{aligned}

Clearly, (u−nv)2k→0(u-\sqrt{n}v)^{2k} \to 0 as k→+∞k \to +\infty. That means n=limk→+∞⁡xk/yk\sqrt{n} = \lim_{k \to +\infty} x_k/y_k. Here is an example of using solutions to the standard Pell’s equation x2−2y2=1x^2-2y^2=1 to approximate 2\sqrt{2}:

kk(xk,yk)(x_k, y_k)xk/ykx_k/y_kDecimalError
1(3,2)(3, 2)3/23/21.5000000001.5000000008.58×10−28.58 \times 10^{-2}
2(17,12)(17, 12)17/1217/121.4166666671.4166666672.45×10−32.45 \times 10^{-3}
3(99,70)(99, 70)99/7099/701.4142857141.4142857147.22×10−57.22 \times 10^{-5}
4(577,408)(577, 408)577/408577/4081.4142156861.4142156862.12×10−62.12 \times 10^{-6}
5(3363,2378)(3363, 2378)3363/23783363/23781.4142136251.4142136256.25×10−86.25 \times 10^{-8}

In fact, the fractions xk/ykx_k/y_k are among the best possible rational approximations to n\sqrt{n}: they appear among the convergents of the continued fraction of n\sqrt{n}, which is also how fundamental solutions are usually found in practice.

7. Conclusion

Although this article has explored methods for finding all integer solutions to Pell’s equation, and their interesting properties, there remains much more to investigate. For example, a generalised Pell’s equation (2) may have no integer solutions at all, or it may have several distinct families of solutions, each combining a particular solution to (2) with the infinitely many solutions to its corresponding standard Pell’s equation (1). Why, and how? For another example, Lagrange’s proof that every standard Pell’s equation has a minimal non-trivial solution (in other words, the existence of the fundamental solution), alongside the use of continued fractions to find these fundamental solutions, offers further fascinating insights into the mathematics behind these equations.

References

Bradley, C. J. Introduction to Number Theory. United Kingdom Mathematics Trust, 2010.

Conrad, Keith. “Pell’s Equation, I.” University of Connecticut. https://kconrad.math.uconn.edu/blurbs/ugradnumthy/pelleqn1.pdf.

“Pell’s Equation.” Wikipedia, Wikimedia Foundation. https://en.wikipedia.org/wiki/Pell%27s_equation.

“Pell’s Equation and Its Importance.” Mathematics Stack Exchange. https://math.stackexchange.com/questions/583055/pells-equation-and-its-importance.


Leave a Reply

Trending