Pell's Equation
Statement
For a positive integer that is not a perfect square, Pell's equation
has infinitely many integer solutions with . The fundamental solution — the smallest positive one — generates all others via the recurrence
The trivial solution always exists. The interesting content is that a non-trivial solution exists when is not a perfect square.
Visualization
Solutions to , generated from the fundamental solution :
| 0 | 1 | 0 | 1 |
| 1 | 3 | 2 | |
| 2 | 17 | 12 | |
| 3 | 99 | 70 | |
| 4 | 577 | 408 | |
| 5 | 3363 | 2378 |
Each row is produced by .
Proof Sketch
- Pigeonhole / continued fractions. Consider the continued fraction expansion of . Since is not a square, is irrational and its continued fraction is periodic (by Lagrange's theorem).
- Convergents satisfy the equation. The convergents of satisfy . A pigeonhole argument on the fractional parts of for yields integers with . Among these, by another pigeonhole step, one value of repeats; subtracting gives a solution to Pell's equation.
- Infinitely many solutions. If is the fundamental solution, the map sends solutions to solutions, producing infinitely many.
- Group structure. The set of positive solutions forms a free abelian group of rank 1, generated by the fundamental solution.
Connections
Pell's equation is closely connected to Pythagorean TriplesPythagorean TriplesComplete parametrisation of all integer solutions to a² + b² = c²Read more →, which arise from a related norm-1 condition over . The theory of solutions is an instance of the general theory underlying Quadratic ReciprocityQuadratic ReciprocityRelationship between solvability of quadratic congruences for two odd primesRead more →, where quadratic residues determine which primes split in .
Lean4 Proof
import Mathlib.NumberTheory.Pell
/-- The trivial solution (1, 0) always solves x² - dy² = 1. -/
theorem pell_trivial (d : ℕ) : (1 : ℤ)^2 - d * (0 : ℤ)^2 = 1 := by ring
/-- The fundamental solution (3, 2) solves x² - 2y² = 1. -/
theorem pell_3_2 : (3 : ℤ)^2 - 2 * (2 : ℤ)^2 = 1 := by norm_num
/-- For positive non-square d, a nontrivial solution exists.
Mathlib's `Pell.Solution₁.exists_pos_of_not_isSquare` gives a solution with x > 1, y > 0. -/
theorem pell_exists (d : ℕ) (hd_pos : 0 < d) (hd_sq : ¬IsSquare d) :
∃ a : Pell.Solution₁ d, 1 < a.x ∧ 0 < a.y :=
Pell.Solution₁.exists_pos_of_not_isSquare hd_pos hd_sq