Pell’s equation

Pell’s equation

Pell’s equation refers generally to the equation


where A is a positive integer not a square. This equation is now known to have an infiniteMathworldPlanetmathPlanetmath number of solutions in positive integers x and y.

Fermat, in 1657, proposed to English mathematicians that they find a method of solving this equation in general, for integral x and y. Fermat apparently already possessed a method, for doing so. According to [1], the Greeks and Indians had detailed knowledge of this problem; the solutions


were both known by Indian mathematicians B.C. In fact, the solution given above for A=92 is the smallest solution for this A, and was given by Brahmagupta (b. 598 A.D.) together with a method for its derivation. The cyclic method, described in detail below, was given by Bháscara Achárya (b. 1114 A.D.).

The English, notably Wallis, developed a different but provably almost identical method, presumably in response to Fermat’s challenge. Both methods produce, in time, all integral solutions to the equation.

As can be seen from the entry on Pell’s equation and simple continued fractionsMathworldPlanetmath, solutions of Pell’s equation can also be found by developing the continued fraction for A.

Here is a table of the minimum value of y for some values of A; a completePlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmath table for A<150 can be found in [1]:

A y
2 2
22 42
37 12
61 226153980
109 15140424455100
136 3
143 1

According to [1], Pell had nothing to do with the development of this problem or its solution; its attribution to Pell is due to an error on the part of Euler.

The Cyclic Method

The cyclic method relies on successive approximation and on a hope that the approximation process will converge. Of course, it can be proven that the process does converge and that it results eventually in all solutions of the Pell equationMathworldPlanetmath. The method relies on the well-known identityPlanetmathPlanetmath

(x2-Ay2)(w2-Az2)=(xw+Ayz)2-A(xz+yw)2 (1)

Given an equation


this identity can be used to produce another solution.

So, for example, let’s take the case A=22. Start by choosing x so that x2-2212 is as small in absolute valueMathworldPlanetmathPlanetmathPlanetmath as possible, i.e. x=5 and 52-2212=3. If we multiply that by the equation r2-2212=s, we get, using (1),


Remember that we are trying to find values so that the right-hand is 1. However, simply choosing a value of r that makes s as small as possible will not achieve any progress, since we will then have r=5 and s=3, so we will get a right-hand side of 9. Instead, we will choose r so that r+5 is divisible by 3; then 5r+22 must be divisible by 3 as well, so s is divisible by 3 and we may divide the resulting equation through by 9. To make r+50(mod3) we need r1(mod3). We want to make s as small as possible in magnitude subject to this condition, so we choose r=4 and then s=-6. The resulting equation, after dividing through by 9, is


We are not done, so let’s repeat the operationMathworldPlanetmath. Multiply again by r2-2212=s to get


and we must choose r such that 3r+140(mod2) (i.e. r0(mod2)) to make s as small as possible in magnitude. This happens for r=4,s=-6; substituting and dividing through by 22=4 we get


Repeating, we get


so 13r+610(mod3), or r3(mod3). Minimizing s leads to r=5, s=3, whence, dividing the result by 32=9 we get


and we are done. The sequenceMathworldPlanetmath of equations was


The fact that the sequence of differencesPlanetmathPlanetmath is palindromic is not an accident; it can be proven that this is always the case.

The English Method

The English method uses the same basic algorithm as the cyclic method, except that when choosing r, it the largest r such that r2<A, which s<0. Thus if two successive equations in this method are


it is clear that


and thus that K and k have different signs. So in the English method, the values of k alternate in sign.

For the case A=22, above, the sequence of equations is


In general, the English method results in the same solutions as the cyclic method, but it gets there more slowly - in the English method, an additional entry is inserted in between any two entries that have the same sign.


  • 1 H.M. Edwards, Fermat’s Last Theorem: A Genetic Introduction to Algebraic Number TheoryMathworldPlanetmath, Springer-Verlag 1977.
  • 2 B.L. van der Waerden, ”Pell’s Equation in Greek and Hindu Mathematics”, Russ. Math Surveys, 1976, 31 (5), 210-225.
  • 3 C.O. Selenius, ”Rationale of the chakravala process of Jayadeva and Bhaskara II”, Historia Mathematica, 2 (1975), 167-184.
Title Pell’s equation
Canonical name PellsEquation
Date of creation 2013-03-22 16:28:07
Last modified on 2013-03-22 16:28:07
Owner rm50 (10146)
Last modified by rm50 (10146)
Numerical id 8
Author rm50 (10146)
Entry type Topic
Classification msc 11D09