21.01.08 · number-theory / elementary

Pell equation and continued fractions

shipped3 tiersLean: none

Anchor (Master): Brahmagupta 628 CE *Brāhmasphuṭasiddhānta* ch. 18 §§64-75 (originator: the **samasa-bhavana** composition law $(x_1, y_1, N_1) \diamond (x_2, y_2, N_2) = (x_1 x_2 + D y_1 y_2, x_1 y_2 + x_2 y_1, N_1 N_2)$ that solves $x^2 - D y^2 = N$ by composition; the first general method for the Pell equation in any culture); Bhaskara II 1150 CE *Bījagaṇita* §§71-90 (**chakravala** cyclic algorithm — completes Brahmagupta's method to a guaranteed-terminating procedure, found by Jayadeva c. 1000 CE according to Udayadivakara's commentary); Brouncker-Wallis 1657-58 correspondence (Brouncker's continued-fraction-style solution method, Wallis's exposition in *Commercium Epistolicum* 1658); Euler 1765 *Novi Comm. Acad. Petrop.* 11, 28-66 (mis-attribution of the equation to John Pell, who never worked on it; correct continued-fraction algorithm for $\sqrt D$); Lagrange 1770 *Mém. Acad. Berlin* (1768) 24, 165-310 (first complete proof of solvability of Pell, periodicity of continued fraction of every quadratic irrational, full structure of solutions); Dirichlet 1837 *Werke* I, 313 + Dirichlet-Dedekind 1894 *Vorlesungen über Zahlentheorie* §§80-100 (pigeonhole proof of Pell solvability without continued fractions, structure of unit group of $\mathbb{Q}(\sqrt D)$); Liouville 1844 *C. R. Acad. Sci. Paris* 18, 883-885 + 910-911 (Liouville bound: algebraic irrational of degree $n$ cannot be approximated by rationals to order better than $n$; founding the theory of transcendence); Thue 1909 *J. reine angew. Math.* 135, 284-305 (Thue's improvement of Liouville from exponent $n$ to $n/2 + 1$); Siegel 1921 *Math. Z.* 10, 173-213 (Siegel's improvement to exponent $2 \sqrt n$); Roth 1955 *Mathematika* 2, 1-20 (Roth's theorem: for every algebraic irrational $\alpha$ and every $\varepsilon > 0$, only finitely many rationals $p/q$ satisfy $|\alpha - p/q| < q^{-2 - \varepsilon}$ — Fields Medal 1958); Lang 1962 *Diophantine Geometry* Ch. VII (modern algebraic treatment of Pell, units, and Roth); Cassels 1957 *An Introduction to Diophantine Approximation* (Cambridge Tracts 45) Ch. II-III; Khinchin 1964 *Continued Fractions* (Chicago); Hardy-Wright 2008 §§10-11

Intuition Beginner

The Pell equation is the integer equation for a fixed positive integer that is not a perfect square. The unknowns are positive integers, and the question is whether interesting solutions exist beyond the boring case . That boring pair always works; what we want is positive-integer pairs with .

A cattle problem. Bhaskara II's Bījagaṇita (1150 CE) poses, in a cattle-counting puzzle, the question: find positive integers with . Test small . For we need , so . The pair solves .

Bhaskara's actual cattle problems demanded much larger values. The famous case has minimal solution , — a -digit number found by chakravala in 1150 CE, then re-discovered by Brouncker in 1657 in response to a challenge from Fermat. For the small case the answer is : .

Why is required to be non-square? If is a perfect square, the left-hand side factors as , so the only integer solutions are with the signs matched. This gives and , the degenerate cases. So the equation is interesting exactly when is not a perfect square — and then it always has infinitely many positive-integer solutions, as Lagrange proved in 1770.

Solutions multiply. The deeper observation, going back to Brahmagupta in 628 CE, is that two solutions multiply to make a new solution. If and both solve , consider the product .

Writing and , the algebraic identity applied to the conjugate pair gives . So is another Pell solution. Iterating with a fixed minimal solution generates an infinite chain of solutions.

The minimal solution. Among all positive-integer Pell solutions with , there is a smallest one — the fundamental solution, denoted . Every other positive-integer solution is generated by multiplying by itself: the -th power gives the -th positive solution . So once the fundamental solution is in hand, every other solution is one matrix-multiplication away. The hard work is finding the fundamental solution — and this is where continued fractions enter.

Why does it matter? Pell equations are the elementary face of the unit group of the ring — the multiplicative group of elements with norm . The fundamental Pell solution is the fundamental unit, and the full solution group is generated by it.

Solving to find is, in disguise, computing the unit group of as the infinite cyclic group . This is the entry point to the theory of units in number fields, which culminates in the Dirichlet unit theorem (1846) for general number fields.

Visual Beginner

The Pell solutions are integer points on the hyperbola . For the hyperbola is , and the picture shows the first few lattice points on its right branch.

The picture captures the central structural fact: Pell solutions are integer points on a hyperbola, with consecutive solutions related by multiplication by the fundamental unit. The ratios are best rational approximations to in the sense that no rational with smaller denominator gets closer — the convergents of the continued-fraction expansion of . This is the geometric bridge between Pell, continued fractions, and Diophantine approximation.

Worked example Beginner

Find all positive-integer solutions of up to , and verify the multiplication law.

Step 1. Find the fundamental solution by inspection of small . For we need , no integer. For we need , so . The fundamental solution is therefore . Check: .

Step 2. Generate the next solution by the multiplication law. Compute , so . Check: .

Step 3. Generate the next solution. Compute , so . Check: .

Step 4. The next solution would be with , so we stop. The complete list of positive-integer solutions with is .

Step 5. Verify uniqueness by exhaustion. For each , compute and test whether it is a perfect square. The only values of in this range that give a perfect square are , matching our list. So the three solutions are the only ones in this range.

Step 6. Verify the multiplication law more explicitly. The recursion follows from .

Starting from : . From : . The recursion grows the solutions by a factor of at each step.

The same algorithm works for any non-square , but the fundamental solution can be astronomically large. For , the smallest case Fermat chose to challenge the English in 1657, the fundamental solution is — a -digit answer that Bhaskara II found by chakravala in 1150 CE without paper or modern arithmetic notation.

Check your understanding Beginner

Formal definition Intermediate+

We restate the Pell-equation setup precisely.

Definition (Pell equation). For a positive integer that is not a perfect square, the Pell equation is in positive integers . A pair with is a Pell solution. The fundamental solution is the solution with smallest , equivalently the solution with smallest subject to .

Definition (negative Pell equation). The equation is the negative Pell equation. Unlike the Pell equation, the negative Pell equation is not always solvable: solutions exist iff the period of the continued-fraction expansion of is odd (proved in the Key Theorem below).

Definition (generalised Pell equation). For non-zero, the generalised Pell equation is in integers . The set of solutions, when non-empty, is a finite union of orbits under the multiplicative action of the Pell unit group on .

Definition (continued fraction). For , the continued-fraction expansion is the sequence produced by the recursion $$ \alpha_0 = \alpha, \qquad a_n = \lfloor \alpha_n \rfloor, \qquad \alpha_{n + 1} = \frac{1}{\alpha_n - a_n} $$ (continuing as long as is not an integer). The are the partial quotients, all integers with for . The convergents are the rationals $$ \frac{p_n}{q_n} = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{\ddots + \cfrac{1}{a_n}}}} $$ computed by the linear recursion , with initial values , .

Definition (purely periodic and reduced quadratic irrationals). A real number is a quadratic irrational iff satisfies an irreducible quadratic polynomial with rational coefficients. The continued fraction is purely periodic with period iff for all , equivalently . A quadratic irrational is reduced iff and , where is the algebraic conjugate.

The convergents satisfy and the best-approximation property: for every rational with , , with equality only if . The cross-ratio identity holds for all .

Counterexamples to common slips

  • "The Pell equation has the degenerate solution counted as fundamental." The fundamental solution is the smallest positive-integer solution with , not the degenerate . The degenerate solution corresponds to the unit , not to a generator of the infinite-cyclic part of the unit group.

  • " negative gives an interesting Pell equation." False. For , the equation has only finitely many integer solutions (in fact at most four: when , and four solutions when ). The infinite-solution-set phenomenon is specific to indefinite quadratic forms — i.e., non-square.

  • "The continued-fraction expansion of every irrational is eventually periodic." False. Lagrange's theorem says has eventually-periodic continued fraction iff is a quadratic irrational. For algebraic numbers of degree or transcendental numbers like and , the continued fraction is non-periodic. (The continued fraction of has a pattern but is not periodic.)

  • "The negative Pell equation is always solvable for non-square." False. The negative Pell equation is solvable iff the period of 's continued fraction is odd. Examples: has period (odd), so is solvable: . has period (even), so is not solvable. has period (odd), solvable: . has period (even), not solvable. The criterion is a deep consequence of Lagrange's algorithm.

  • "The Liouville bound applies to all real numbers." False. Liouville's theorem applies only to algebraic numbers: if has degree , then for all rationals . For transcendental , no such bound exists — and Liouville used this to construct the first explicit transcendental numbers as those violating the bound for every .

Key theorem with proof Intermediate+

The signature theorem of this unit is Lagrange's theorem on the existence of Pell solutions via continued fractions. We prove it via the periodicity of quadratic-irrational continued fractions.

Theorem (Lagrange 1770, Pell solvability via continued fractions). Let be a positive integer that is not a perfect square. Let be the continued-fraction expansion, with period . Let be the convergents. Then:

(a) The continued fraction of is eventually periodic, with for all and .

(b) The convergent satisfies . If is even, is the fundamental Pell solution. If is odd, solves the negative Pell equation, and the fundamental Pell solution is .

(c) Every positive Pell solution is for some integer (with taken to be even).

Proof. We establish the three parts in sequence.

Step 1 — Periodicity of the continued fraction of . The expansion is generated by the recursion , , . We claim each is a quadratic irrational of the form with , , and (for ) is reduced.

Induction on . Base case : , so and ; is not reduced (since ), but the reducedness will hold for .

Inductive step. Suppose with . Then , and $$ \alpha_{n + 1} = \frac{1}{\alpha_n - a_n} = \frac{Q_n}{P_n - a_n Q_n + \sqrt D} = \frac{Q_n (a_n Q_n - P_n + \sqrt D)}{D - (P_n - a_n Q_n)^2}. $$ Set and . We must verify and . The first: . By the inductive hypothesis , and the other terms are multiples of , so and . The second: , so .

Reducedness for : we show and . The first is immediate since in the recursion. The second is a standard induction: if is reduced, then because , so , hence , and the sign is negative because .

Now the key finiteness: for reduced , the integers are bounded. Reducedness gives and . Adding: , so . Subtracting: , so . From , , so . From , , so . Combining: , and (from and a short manipulation). So each take only finitely many integer values.

Since the pair determines and there are only finitely many possible pairs, the sequence must repeat. The first repetition gives the period , and the algorithm is periodic from index onward.

The final identity is a standard consequence of the conjugation symmetry of the recursion (see Hardy-Wright §10.10).

Step 2 — Pell solutions from convergents. The convergents of the continued fraction of satisfy the basic identity $$ p_n^2 - D q_n^2 = (-1)^{n + 1} Q_{n + 1}, $$ where is the denominator in the recursion of Step 1. (Proof: induction on ; the base case gives , and the step uses the recursion together with .)

At : (since the period closes at index , so and the denominators match). Hence $$ p_{\ell - 1}^2 - D q_{\ell - 1}^2 = (-1)^\ell. $$

If is even, satisfies , a Pell solution.

If is odd, satisfies , a negative-Pell solution. Squaring the negative-Pell solution as an element of : . The norm is , so the rational and irrational parts form a Pell solution. The same is by the convergent identity applied at index (using from period- structure repeated twice).

Step 3 — Fundamental solution and complete generation. Suppose is any positive Pell solution with . We show for some . The best-approximation property of convergents says: for every rational with , must be a convergent of . From , we have , so (using for ). Hence is a convergent, , and since (the latter from ), .

The convergent identity shows is a Pell solution iff and is odd. Since holds exactly when the index is a multiple of (from periodicity), the Pell solutions are precisely for (with even, i.e., even when is odd and arbitrary when is even). The fundamental Pell solution is the one with smallest .

Bridge. Lagrange's theorem is the elementary face of the Dirichlet unit theorem: for the real quadratic field with non-square, the unit group of the ring of integers is where is the fundamental unit. The fundamental unit corresponds to the fundamental Pell (or negative-Pell) solution: when the negative-Pell equation is solvable, has norm and generates the Pell solutions; when it is not solvable, itself has norm and generates the Pell solutions directly. This is the first substantive instance of the general Dirichlet unit theorem (Dirichlet 1846), which gives the rank of the unit group of any number field as where are the numbers of real and complex embeddings. For real quadratic the rank is , so the free part is infinite cyclic, generated by the fundamental unit — Pell.

Exercises Intermediate+

Lean formalization Intermediate+

Mathlib provides scattered pieces of the Pell-and-continued-fractions infrastructure, but no unified pedagogical module.

-- Operative imports: Mathlib.NumberTheory.Pell,
-- Mathlib.NumberTheory.Zsqrtd.Basic,
-- Mathlib.Analysis.SpecialFunctions.ContinuedFractions

#check @Pell.xn
-- The x-coordinate of the n-th positive Pell solution for non-square D.

#check @Pell.yn
-- The y-coordinate of the n-th positive Pell solution.

#check @Pell.pell_eq
-- The Pell identity: xn^2 - D * yn^2 = 1 for all n.

#check @Pell.exists_pell_solution
-- Existence of a positive (y >= 1) Pell solution for non-square D > 0.

#check @Pell.is_fundamental
-- The fundamental Pell solution is the smallest positive solution.

#check @Zsqrtd.norm
-- The norm map N(a + b * sqrt d) = a^2 - d * b^2 on Z[sqrt d].

#check @Zsqrtd.norm_mul
-- Norm multiplicativity N(alpha * beta) = N(alpha) * N(beta).

#check @ContinuedFractions.convergents
-- The convergents p_n / q_n of a real-valued continued fraction.

#check @ContinuedFractions.bestApproximation
-- The best-approximation property of convergents.

The Mathlib formalisation covers the existence of the fundamental Pell solution, the cyclic structure of the solution set, the norm-multiplicative ring , and the basic theory of continued-fraction convergents. What Mathlib has not yet packaged as a unified pedagogical module: (i) Lagrange's periodicity theorem for the continued fraction of every quadratic irrational; (ii) the explicit algorithm reading the fundamental Pell solution off the convergent of immediately before the period closes; (iii) Dirichlet's pigeonhole proof of Pell solvability bypassing continued fractions; (iv) the chakravala algorithm of Brahmagupta-Bhaskara with constructive termination; (v) the criterion that the negative Pell equation is solvable iff the period of 's continued fraction is odd; (vi) the Liouville approximation bound and the Thue-Siegel-Roth tower. These are the formalisation gaps documented in the unit metadata Mathlib gap analysis.

Advanced results Master

Theorem 1 (Lagrange periodicity, 1770). For every quadratic irrational , the continued-fraction expansion is eventually periodic. Moreover, is purely periodic (i.e., ) iff is a reduced quadratic irrational: and [Lagrange 1770]. Proved in the Key Theorem above (Step 1) via finiteness of the integer parameters in the reduced form . The pure-periodicity characterisation is due to Galois (1828 Ann. de Gergonne 19, 294), generalising Lagrange's result.

Theorem 2 (Pell solvability, Lagrange 1770). For every non-square , the Pell equation has a positive-integer solution [Lagrange 1770]. Proved in the Key Theorem above as a corollary of Lagrange periodicity: the convergent of satisfies , so is a Pell solution when is even and is a Pell solution when is odd. This is the first complete proof in European mathematics — 620 years after Bhaskara II's chakravala (1150 CE).

Theorem 3 (cyclic structure of the Pell solution set). The positive-integer solutions of are exactly rational and irrational parts of for , where is the fundamental solution [Hardy-Wright 2008]. Proved as Exercise 5 above via the multiplication law and the ordering argument. The full unit group of the ring of integers (when is the full ring of integers, i.e., ) is where when the negative-Pell equation is unsolvable, and the smaller fundamental negative-Pell solution when it is solvable.

Theorem 4 (negative Pell criterion). The negative Pell equation has an integer solution iff the period of the continued-fraction expansion of is odd [Hardy-Wright 2008]. The direction follows from the convergent identity : when is odd, this gives , so is a negative-Pell solution. The direction uses the complete characterisation of Pell-type solutions as convergents (best-approximation analogue of the Key Theorem) plus a parity argument on . There are deep open questions about which have odd period: for prime with , the period is always odd (Pell solvable); for , the period is always even (not solvable); for composite the situation depends on the class group of (Stevenhagen 1993 conjecture: density of with odd period is approximately ).

Theorem 5 (Dirichlet unit theorem for real quadratic fields). For non-square, the unit group of the ring of integers of is where is the fundamental unit — the smallest unit [Dirichlet 1846]. Proved by Dirichlet 1846 Bericht Preuss. Akad. via the geometry of numbers and a pigeonhole argument analogous to Exercise 7 above. The general Dirichlet unit theorem for number fields (1846) says the unit group of has rank , where are the numbers of real and complex embeddings; for real quadratic this rank is and the fundamental unit generates the free part. Pell solvability for non-square is the elementary face of the rank- unit theorem for real quadratic fields.

Theorem 6 (chakravala algorithm; Jayadeva c. 1000, Bhaskara II 1150). The chakravala (cyclic) algorithm computes the fundamental Pell solution of for non-square in finitely many steps. Given a triple with (started from ), choose minimising subject to ; produce the new triple $$ \left(\frac{a m + D b}{|k|}, \frac{a + b m}{|k|}, \frac{m^2 - D}{k}\right). $$ Iteration terminates when , yielding the fundamental Pell solution [Bhaskara II 1150]. Termination requires a careful argument; the original chakravala texts use the Brahmagupta composition principle (Exercise 4) repeatedly to descend to . Modern proofs by Selenius (1975 Hist. Math. 2, 167) and Lenstra (2002 Mathematical Intelligencer 24, 22) show chakravala produces the fundamental solution in iterations on average — faster than the naive continued-fraction algorithm in many cases, and asymptotically as fast as the fastest known. Hankel 1874 called chakravala "the finest thing achieved in the theory of numbers before Lagrange".

Theorem 7 (Liouville approximation bound, 1844). If is an algebraic number of degree , there exists with for every rational with [Liouville 1844]. Proved as Exercise 8 above via the minimal-polynomial argument. Liouville's exponent is sharp only for (saturated by the convergents of every quadratic irrational, since ). For the exponent is far from sharp — improved by Thue, Siegel, Roth as below.

Theorem 8 (Thue-Siegel-Roth, 1909-1955). For every algebraic irrational and every , only finitely many rationals satisfy [Roth 1955]. The exponent is sharp by Dirichlet (Exercise 6), and the bound is the optimal universal exponent for algebraic irrationals. Thue 1909 [Thue 1909] proved exponent ; Siegel 1921 [Siegel 1921] improved to ; Roth 1955 [Roth 1955] reached the optimal , earning the Fields Medal 1958. The proof is ineffective: it bounds the number of approximating rationals but does not bound their height, so explicit bounds for Diophantine equations cannot be deduced. Baker 1966-67 Mathematika 13, 14 introduced linear forms in logarithms to give effective bounds at the cost of weaker exponents.

Synthesis. The Pell equation is the elementary face of the unit group of , the simplest interesting number field beyond itself. The fundamental Pell (or negative-Pell) solution is the fundamental unit, and the continued-fraction algorithm for is the constructive procedure for computing it. The same circle of ideas — continued fractions, periodicity, best approximation, Dirichlet pigeonhole — generalises in three directions:

(i) Algebraic direction (Dirichlet 1846, Minkowski 1896, Hasse-Minkowski 1923): the Dirichlet unit theorem for general number fields gives the rank of the unit group as , with the fundamental units generating the free part. The Minkowski geometry-of-numbers approach (1896 Geometrie der Zahlen) reproves Pell solvability via the lattice and Minkowski's convex-body theorem, generalising to lattices of arbitrary rank. The Hasse-Minkowski theorem (1923-24) classifies indefinite quadratic forms over via local-global principle, with the Pell equation as the rank- indefinite case.

(ii) Analytic direction (Liouville 1844, Thue 1909, Siegel 1921, Roth 1955): the Liouville bound and its improvements bound the rate at which algebraic numbers can be rationally approximated. The Pell convergents saturate the Liouville bound for quadratic , but for higher-degree algebraic numbers the Roth theorem (sharp) shows algebraic numbers are essentially as hard to approximate as random irrationals. Schmidt's subspace theorem (1972 Acta Math. 125, 189) generalises Roth to simultaneous Diophantine approximation, with deep applications to integral points on subvarieties of tori.

(iii) Geometric direction (Thue 1909, Siegel 1929, Mordell 1922, Faltings 1983): finiteness of integer solutions of Diophantine equations of degree . Thue's 1909 theorem says has finitely many integer solutions for irreducible binary of degree . Mordell 1922 conjectured (and Faltings 1983 proved, Fields Medal 1986) that every curve of genus over a number field has finitely many rational points. The Pell equation is precisely the boundary case — genus- curve with infinitely many integer points (in fact a -torsor for the unit group) — and the contrast with the higher-genus finiteness is the elementary entry point to arithmetic geometry.

The historical arc from Brahmagupta 628 CE to Roth 1955 is a -year story of one elementary equation generating ever-richer mathematics. Brahmagupta's composition principle (samasa-bhavana) is the embryonic form of norm multiplicativity in number fields. Bhaskara II's chakravala (1150 CE) is the embryonic form of Gauss's reduction theory of quadratic forms. Lagrange's continued-fraction proof (1770) is the embryonic form of the Dirichlet unit theorem. Liouville's bound (1844) is the embryonic form of Diophantine approximation theory. Roth's theorem (1955) is the optimal exponent — but the underlying object, , is the same one Brahmagupta solved in 628 CE.

The applied legacy is more modest than for quadratic reciprocity, but real. Pell-equation solutions provide best rational approximations to , used in computer algebra systems (Mathematica, SageMath, GAP) for symbolic manipulation of quadratic irrationals. The continued-fraction algorithm is the foundation for lattice-reduction algorithms (LLL 1982 generalises the Euclidean algorithm and continued fractions to higher-dimensional lattices), which underlie cryptanalysis of low-exponent RSA (Coppersmith 1996), the NTRU cryptosystem (1996), and the modern post-quantum cryptography candidates LWE and SIS. The Pell equation itself surfaces in continued-fraction factorisation (CFRAC, Brillhart-Morrison 1975), the precursor algorithm to the quadratic sieve.

Full proof set Master

Proposition 1 (Lagrange periodicity). Every quadratic irrational has eventually-periodic continued fraction.

Proof. See Step 1 of the Key Theorem above. The recursion has integer parameters bounded by a constant depending on , so the sequence of pairs takes only finitely many values, forcing the (hence the partial quotients ) to be eventually periodic.

Proposition 2 (Pell solvability via convergents). For non-square , the convergent of satisfies .

Proof. See Step 2 of the Key Theorem. The identity at uses (from the period closing at index ).

Proposition 3 (multiplication law for Pell solutions). If and are Pell solutions, so is .

Proof. See Exercise 4. Norm multiplicativity in : with , .

Proposition 4 (cyclic structure of Pell solutions). The positive Pell solutions form an infinite cyclic semigroup generated by the fundamental solution.

Proof. See Exercise 5. By Lagrange, every Pell solution is a convergent; by the ordering argument plus the multiplication law, every positive solution is for .

Proposition 5 (Dirichlet pigeonhole approximation bound). For every irrational , there exist infinitely many rationals with .

Proof. See Exercise 6. Pigeonhole on the fractional parts for in subintervals of .

Proposition 6 (Dirichlet pigeonhole proof of Pell solvability). For non-square , has a positive-integer solution.

Proof. See Exercise 7. By Proposition 5, there are infinitely many with . The integer values are bounded, so some non-zero is attained infinitely often. Pigeonhole on residues modulo yields two distinct pairs with the same residues, and the quotient has integer coordinates and norm , hence is a Pell solution.

Proposition 7 (negative Pell criterion). The equation has an integer solution iff the period of the continued fraction of is odd.

Proof sketch. Direction from Proposition 2 with odd giving . Direction : if is a negative-Pell solution, then by the convergent characterisation (analogous to Step 3 of the Key Theorem applied with the bound ), is a convergent . The convergent identity with value forces (so is a multiple of ) and even (so ). Hence for some with even, equivalently odd. For integer this forces both and odd, so is odd.

Proposition 8 (Liouville approximation bound). Algebraic of degree admits for all .

Proof. See Exercise 8. Minimal-polynomial argument: on one side; on the other side by the mean-value theorem.

Proposition 9 (Brahmagupta composition for ). If solves and solves , then solves .

Proof. Norm multiplicativity in : , and the product expands to . This is Brahmagupta's samasa-bhavana (628 CE), the foundational composition principle.

Connections Master

  • Divisibility, gcd, and the Euclidean algorithm 21.01.01. Shipped. The Euclidean algorithm for is the finite-arithmetic analogue of the continued-fraction algorithm for : both are based on the recursion "subtract the largest possible integer multiple, then invert". The convergents of any irrational satisfy the same cross-ratio identity that drives the Euclidean algorithm to a . The connection is the Stern-Brocot tree of best rational approximations.

  • Primes and the fundamental theorem of arithmetic 21.01.02. Shipped. Pell solvability for prime depends on the residue : for , the negative-Pell equation is always solvable (period odd, by a deep theorem); for , the negative-Pell equation is never solvable (period even). The bridge to 21.01.02 is the way prime-residue conditions modulo small integers control deep structural questions about .

  • Real numbers and completeness 02.04.01. Pending. The continued-fraction algorithm requires the floor function , which presupposes the order completeness of . Lagrange's periodicity theorem uses the Bolzano-Weierstrass theorem (every bounded sequence has a convergent subsequence) implicitly via the finiteness-of- argument. The Liouville approximation bound is a -continuity statement about the minimal polynomial; the Thue-Siegel-Roth tower uses sophisticated complex-analytic arguments (transcendence-degree arithmetic, the Schmidt subspace theorem).

  • Algebraic number fields and rings of integers 21.02.01. Pending. Pell solvability is the elementary face of the structure theory of the unit group of for non-square. The number field has ring of integers (if ) or (if ), and the unit group is the elementary instance of the Dirichlet unit theorem for general number fields.

  • Class groups and the ideal class group of 21.02.05. Pending. The Pell equation interacts with the class group of the real quadratic field : when (principal-ideal domain), the generalised Pell equation for a prime ideal generator behaves uniformly; when , the equation has multiple orbits of solutions corresponding to the ideal classes. The famous Cohen-Lenstra heuristics (1984) predict the distribution of class numbers and the density of with .

  • Dirichlet unit theorem 21.02.06. Pending. The Dirichlet unit theorem (Dirichlet 1846) gives the rank of the unit group of any number field as , with the free part generated by the fundamental units. For real quadratic the rank is and the fundamental unit is the fundamental Pell (or negative-Pell) solution. Pell is the simplest, most elementary case of the Dirichlet unit theorem.

  • Diophantine approximation 21.01.10 pending. Lateral. The continued-fraction theory of Pell extends to the general theory of Diophantine approximation: how well can a real number be approximated by rationals? The Dirichlet bound (Exercise 6 above) is the universal lower bound for infinitely many ; the Liouville bound (Exercise 8) is the upper bound for algebraic numbers; the Thue-Siegel-Roth tower gives the sharp for algebraic irrationals. The Khinchin metric theorem (1928): for almost every real (Lebesgue), the convergent denominators satisfy — Khinchin's constant.

  • Analysis prerequisites [02 analysis]. Lateral. Continued fractions converge to their limit at the rate — a quantitative version of the Cauchy criterion. The Lagrange periodicity proof uses the Bolzano-Weierstrass theorem (compactness of bounded sequences). The Liouville approximation bound uses the mean-value theorem from calculus. The Roth theorem (1955) uses the Thue-Siegel principle — a deep argument about heights of points on algebraic varieties, with the auxiliary polynomial constructed via Siegel's lemma (Cassels 1957 Diophantine Approximation Ch. III).

  • Continued-fraction expansions of fundamental constants. Lateral. The continued fraction of (Euler 1737) has a clean pattern but is non-periodic, so is non-quadratic by Lagrange. The continued fraction of (Brouncker 1655) has no known pattern, and the convergent (the Tsu Ch'ung-Chih approximation, c. 480 CE) agrees with to seven decimal places — explained by the large partial quotient . Hermite 1873 proved transcendental; Lindemann 1882 proved transcendental; both proofs descend from the Liouville-style arguments developed for Pell.

Historical & philosophical context Master

The Pell equation has the longest continuously-recorded history of any single equation in mathematics: years from Brahmagupta (628 CE) to Roth (1955).

Brahmagupta (628 CE) Brāhmasphuṭasiddhānta [Brahmagupta 628], ch. 18 §§64-75 introduced the samasa-bhavana (composition principle): from two solutions of and , produce one of . This is the embryonic form of norm multiplicativity in and the elementary face of all subsequent reciprocity-style composition principles. Brahmagupta showed that if is solved for , then composition yields a Pell solution, providing the first general method for Pell-type equations in any culture. Brahmagupta's worked examples in and similar moderate cases are correct to the digit.

Jayadeva (c. 1000 CE, lost work) and Bhaskara II (1150 CE) Bījagaṇita [Bhaskara II 1150], §§71-90 developed the chakravala (cyclic) algorithm completing Brahmagupta's composition to a guaranteed-terminating procedure. The chakravala algorithm produced Bhaskara's celebrated solution of as — a -digit answer found without paper or modern arithmetic notation, in the 12th century. The same answer was re-discovered in 1657 by Brouncker in response to Fermat's challenge. Hankel 1874 Zur Geschichte der Mathematik in Altertum und Mittelalter called chakravala "the finest thing achieved in the theory of numbers before Lagrange" (Lagrange's own proof of Pell solvability did not appear until 620 years later).

Fermat (1657) issued a public challenge in January 1657 to all European mathematicians: solve for and other carefully-chosen large values where the fundamental solution has many digits. The English mathematicians Brouncker and Wallis responded with a continued-fraction-style algorithm, with Brouncker computing the solution in a few weeks. Wallis published the correspondence in Commercium Epistolicum 1658 [Brouncker-Wallis 1657]. Fermat acknowledged the solutions but did not publicly prove solvability for all non-square ; his infinite descent proof, alluded to in a 1657 letter to Frenicle, is lost.

Euler (1730s-1765) [Euler 1765] developed the continued-fraction algorithm for , expanding and reading the fundamental Pell solution off the convergent immediately before the period closes. Euler also introduced the misattribution that has stuck: in his 1765 Novi Commentarii Academiae Scientiarum Petropolitanae paper he credited the equation to John Pell based on a misreading of Wallis's Algebra (1685, ch. 98) — Pell merely edited Brouncker's solution for printing. The name "Pell equation" has stuck despite Pell himself contributing nothing; the equation was solved by Brahmagupta in 628 CE, Bhaskara II in 1150 CE, Fermat in 1657, and Brouncker in 1658, all without Pell's involvement.

Lagrange (1770) Mémoires de l'Académie Royale des Sciences et Belles-Lettres de Berlin [Lagrange 1770] gave the first complete proof in European mathematics of Pell solvability for every non-square . Lagrange's two theorems: (i) periodicity of the continued-fraction expansion of every quadratic irrational; (ii) the convergent immediately before the period closes gives the fundamental Pell (or negative-Pell) solution. This was 620 years after Bhaskara II's chakravala — a delay reflecting the European mathematical isolation from Indian sources.

Galois (1828) Annales de Gergonne 19, 294 generalised Lagrange's result with the purely-periodic characterisation: the continued fraction is purely periodic iff is a reduced quadratic irrational (, ). Galois's result is the cleanest statement of the periodicity theorem and the basis for the modern proof in textbooks.

Dirichlet (1837 Werke I + Dirichlet-Dedekind 1894 Vorlesungen) [Dirichlet 1837] gave the pigeonhole proof of Pell solvability bypassing continued fractions: by the Dirichlet approximation theorem, there are infinitely many with ; the values are bounded, so some non-zero is attained infinitely often; pigeonhole on residues modulo produces two pairs whose quotient is a Pell solution. The same machinery gives the Dirichlet unit theorem (1846): the unit group of any number field has rank , with Pell as the rank- real-quadratic case.

Liouville (1844) [Liouville 1844] proved the Liouville approximation bound: algebraic of degree cannot be approximated by rationals to order strictly better than . Liouville used this to construct the first explicit transcendental numbers (with truncations giving approximations of arbitrarily high order). The Pell convergents saturate the Liouville bound for — quadratic irrationals are exactly the irrationals approximable to order but not to order .

Thue (1909) [Thue 1909] Crelle 135 improved the Liouville exponent from to . Thue's method introduced the auxiliary polynomial used in all later refinements. Siegel (1921) [Siegel 1921] Math. Z. 10 improved to , attaining the optimum of Siegel's variational argument. Roth (1955) [Roth 1955] Mathematika 2 reached the optimal , sharp by the Dirichlet bound. Roth received the Fields Medal 1958 for this result.

The Roth theorem is ineffective: it bounds the number of approximating rationals but not their height. Effective bounds had to wait for Baker (1966-67) [Roth 1955] Mathematika 13-14 and his theory of linear forms in logarithms — for which Baker received the Fields Medal 1970. The Liouville-Thue-Siegel-Roth-Baker tower is the canonical example of a research programme where each generation refined the previous bound, with the final endpoint (Roth's exponent ) being optimal but ineffective, motivating an entirely new theory (Baker) to recover effectivity.

The philosophical lesson of the Pell story: a single elementary equation, posed by Brahmagupta in the 7th century, generated the entire theory of units in number fields, Diophantine approximation, transcendence theory, and the modern framework of integral points on algebraic varieties. The Pell equation is the simplest interesting Diophantine equation with infinitely many integer solutions, and understanding it completely — through Lagrange's continued fractions and Dirichlet's pigeonhole — required ideas that turned out to be the embryonic forms of th-century algebraic and arithmetic geometry.

Bibliography Master

@book{Brahmagupta628,
  author    = {Brahmagupta},
  title     = {Br{\=a}hmasphu{\d{t}}asiddh{\=a}nta},
  year      = {628},
  note      = {Sanskrit, c. 628 CE. Chapter 18 (kuṭṭakādhyāya) §§64-75 develop the samasa-bhavana (composition principle) for $x^2 - D y^2 = N$: from solutions of $x^2 - D y^2 = N_1$ and $x^2 - D y^2 = N_2$, produce a solution of $x^2 - D y^2 = N_1 N_2$. The first general method for Pell-type equations in any culture. English: Colebrooke, Algebra with Arithmetic and Mensuration from the Sanscrit of Brahmegupta and Bháscara, London 1817 (reprinted Wiesbaden 1973).}
}

@book{BhaskaraII1150,
  author    = {{Bh{\=a}skara II}},
  title     = {B{\=\i}jaga{\d n}ita},
  year      = {1150},
  note      = {Sanskrit, c. 1150 CE. §§71-90 develop the chakravala (cyclic) algorithm completing Brahmagupta's composition principle to a guaranteed-terminating procedure for $x^2 - D y^2 = 1$. Famous worked example: fundamental solution of $x^2 - 61 y^2 = 1$ as $(1766319049, 226153980)$, found without paper or modern arithmetic notation. Hankel 1874 called chakravala 'the finest thing achieved in the theory of numbers before Lagrange'. English: Plofker, Mathematics in India, Princeton 2009, §5.4.2.}
}

@book{BrounckerWallis1658,
  author    = {Brouncker, William and Wallis, John},
  title     = {Commercium Epistolicum},
  publisher = {Oxford},
  year      = {1658},
  note      = {Fermat's January 1657 challenge to the English mathematicians: solve $x^2 - D y^2 = 1$ for $D = 61, 109, 149, \ldots$. Brouncker's continued-fraction-style algorithm produced the $D = 61$ solution $(1766319049, 226153980)$ in a few weeks; Wallis wrote the exposition. The first complete European treatment of the Pell equation, $500$ years after Bhaskara II's chakravala.}
}

@article{Euler1765,
  author  = {Euler, Leonhard},
  title   = {De usu novi algorithmi in problemate Pelliano solvendo},
  journal = {Novi Commentarii Academiae Scientiarum Petropolitanae},
  volume  = {11},
  pages   = {28--66},
  year    = {1765},
  note    = {Reprinted Opera Omnia I.3, 73-111. Euler's continued-fraction algorithm for $\sqrt D$, with the misattribution to John Pell based on a misreading of Wallis's Algebra (1685). The name 'Pell equation' has stuck despite Pell himself contributing nothing.}
}

@article{Lagrange1770,
  author  = {Lagrange, Joseph Louis},
  title   = {Solution d'un probl{\`e}me d'arithm{\'e}tique},
  journal = {M{\'e}moires de l'Acad{\'e}mie Royale des Sciences et Belles-Lettres de Berlin},
  volume  = {24},
  pages   = {165--310},
  year    = {1770},
  note    = {Originally presented 1768. Reprinted Oeuvres I, 671-731. First complete proof in European mathematics of Pell solvability for every non-square $D > 0$. Two theorems: (i) periodicity of the continued fraction of every quadratic irrational; (ii) the convergent before the period closes is the fundamental Pell solution. 620 years after Bhaskara II's chakravala.}
}

@book{DirichletDedekind1894Pell,
  author    = {Dirichlet, Peter Gustav Lejeune and Dedekind, Richard},
  title     = {Vorlesungen {\"u}ber Zahlentheorie},
  edition   = {4},
  publisher = {Vieweg},
  address   = {Braunschweig},
  year      = {1894},
  note      = {§§80-100 give Dirichlet's pigeonhole proof of Pell solvability bypassing continued fractions. The proof generalises to the Dirichlet unit theorem (1846) giving the rank of the unit group of any number field as $r_1 + r_2 - 1$, with Pell as the rank-$1$ real-quadratic case.}
}

@article{Liouville1844,
  author  = {Liouville, Joseph},
  title   = {Sur des classes tr{\`e}s {\'e}tendues de quantit{\'e}s dont la valeur n'est ni alg{\'e}brique, ni m{\^e}me r{\'e}ductible {\`a} des irrationelles alg{\'e}briques},
  journal = {Comptes Rendus de l'Acad{\'e}mie des Sciences de Paris},
  volume  = {18},
  pages   = {883--885 and 910--911},
  year    = {1844},
  note    = {Liouville's approximation bound: algebraic $\alpha$ of degree $n \geq 2$ cannot be approximated by rationals to order strictly better than $n$. Used to construct the first explicit transcendental numbers $\sum_k 10^{-k!}$. Founding result of transcendence theory.}
}

@article{Thue1909,
  author  = {Thue, Axel},
  title   = {{\"U}ber Ann{\"a}herungswerte algebraischer Zahlen},
  journal = {Journal f{\"u}r die reine und angewandte Mathematik},
  volume  = {135},
  pages   = {284--305},
  year    = {1909},
  note    = {Thue's improvement of Liouville: algebraic $\alpha$ of degree $n \geq 3$ is approximable to order at most $n/2 + 1 + \varepsilon$. Consequence: Thue equations $f(x, y) = c$ for $f$ irreducible binary of degree $\geq 3$ have only finitely many integer solutions.}
}

@article{Siegel1921,
  author  = {Siegel, Carl Ludwig},
  title   = {Approximation algebraischer Zahlen},
  journal = {Mathematische Zeitschrift},
  volume  = {10},
  pages   = {173--213},
  year    = {1921},
  note    = {Siegel's improvement of Thue: the approximation exponent for algebraic $\alpha$ of degree $n$ is at most $2 \sqrt n + \varepsilon$. The proximate predecessor of Roth's theorem.}
}

@article{Roth1955,
  author  = {Roth, Klaus Friedrich},
  title   = {Rational approximations to algebraic numbers},
  journal = {Mathematika},
  volume  = {2},
  pages   = {1--20},
  year    = {1955},
  note    = {Roth's theorem: for every algebraic irrational $\alpha$ and every $\varepsilon > 0$, only finitely many rationals $p/q$ satisfy $|\alpha - p/q| < q^{-(2 + \varepsilon)}$. The exponent $2$ is sharp by the Dirichlet bound. Roth received the Fields Medal 1958. Ineffective: bounds the number but not the height of approximating rationals.}
}

@book{HardyWright2008Pell,
  author    = {Hardy, G. H. and Wright, E. M.},
  title     = {An Introduction to the Theory of Numbers},
  edition   = {6},
  publisher = {Oxford University Press},
  year      = {2008},
  note      = {Revised by D. R. Heath-Brown and J. H. Silverman. Chapters X-XI develop the theory of continued fractions for real numbers and quadratic irrationals: the Euclidean expansion of rationals, the convergents $p_n/q_n$ with best-approximation property, Lagrange's periodicity theorem, the Pell equation and its complete solution via the convergents of $\sqrt D$, the generalised Pell equation, the negative Pell criterion.}
}

@book{NivenZuckermanMontgomery1991Pell,
  author    = {Niven, Ivan and Zuckerman, Herbert S. and Montgomery, Hugh L.},
  title     = {An Introduction to the Theory of Numbers},
  edition   = {5},
  publisher = {Wiley},
  year      = {1991},
  note      = {§§7.7-7.8 develop the Pell equation $x^2 - D y^2 = N$ for general $N$, the negative Pell criterion (solvable iff period of $\sqrt D$ is odd), the structure of solutions of the generalised Pell equation as a finite union of orbits under the Pell unit group.}
}

@book{Khinchin1964,
  author    = {Khinchin, Aleksandr Yakovlevich},
  title     = {Continued Fractions},
  publisher = {University of Chicago Press},
  year      = {1964},
  note      = {Translation by Scripta Technica from Tsepnye drobi (Moscow 1935; 3rd Russian edition 1961). Dover reprint 1997. §§I.1-9 basic algorithm and convergents; §§II.10-13 metric theory including Khinchin's constant $K_0 \approx 2.685$ and Markov spectrum; §§III.14-17 best rational approximations and quadratic-irrational characterisation. The canonical monograph on continued fractions.}
}

@book{Lang1962,
  author    = {Lang, Serge},
  title     = {Diophantine Geometry},
  publisher = {Interscience},
  year      = {1962},
  note      = {Chapter VII develops Pell equations, units in number fields, and the Liouville-Thue-Siegel-Roth tower from the algebraic-geometric viewpoint. The bridge from elementary continued-fraction theory to integral points on curves and the Mordell conjecture (Faltings 1983).}
}

@book{Cassels1957,
  author    = {Cassels, J. W. S.},
  title     = {An Introduction to Diophantine Approximation},
  series    = {Cambridge Tracts in Mathematics and Mathematical Physics},
  volume    = {45},
  publisher = {Cambridge University Press},
  year      = {1957},
  note      = {Reprinted 1965, Hafner. Chapters II-III develop approximation to algebraic numbers from Liouville through Thue, Siegel, and Roth, with explicit construction of the auxiliary polynomial used in the Thue-Siegel-Roth proofs and careful treatment of the ineffectivity issue.}
}

@book{Burton2010Pell,
  author    = {Burton, David M.},
  title     = {Elementary Number Theory},
  edition   = {7},
  publisher = {McGraw-Hill},
  year      = {2010},
  note      = {Chapter 14 §14.4 develops the Pell equation at the undergraduate Beginner-tier level: hand-computation of fundamental solutions for small $D$, the multiplication law for generating all solutions, statement of Lagrange's continued-fraction algorithm.}
}

@book{Stillwell2010,
  author    = {Stillwell, John},
  title     = {Mathematics and Its History},
  edition   = {3},
  publisher = {Springer Undergraduate Texts in Mathematics},
  year      = {2010},
  note      = {§5.4 develops Brahmagupta's Brāhmasphuṭasiddhānta (628 CE) and Bhaskara II's Bījagaṇita (1150 CE) on Pell with cattle-style worked examples and the historical chain Brahmagupta-Bhaskara-Brouncker-Lagrange-Dirichlet.}
}