Pell's Equation

Graduate Depth 32 in the knowledge graph I know this Set as goal
Unlocks 4 downstream topics
diophantine pell continued-fractions

Core Idea

Pell's equation x² − Dy² = 1, where D is a non-square positive integer, always has infinitely many positive integer solutions. Solutions arise via the periodic continued fraction expansion of √D, and the fundamental solution generates all others via multiplication in ℚ(√D).

Explainer

Pell's equation x² - Dy² = 1 asks for integer points on a hyperbola that are in an extraordinarily precise sense "close to √D." To see why, rewrite the equation as x/y ≈ √D: if (x, y) is a solution, then (x/y)² ≈ D, so x/y is a rational approximation to √D with error |x/y - √D| ≈ 1/(2y²√D). Your prerequisite — continued fractions — provides exactly the tool for finding such best-rational-approximations systematically.

The continued fraction expansion of √D is eventually periodic for any non-square positive integer D. For example, √2 = [1; 2, 2, 2, ...] and √3 = [1; 1, 2, 1, 2, ...]. The convergents p_n/q_n of this expansion are the best rational approximations to √D: no fraction with a smaller denominator gets closer. The connection to Pell's equation is that the convergents at the end of each complete period satisfy p_n² - Dq_n² = ±1 exactly — and among those, every other period gives +1. The fundamental solution (x₁, y₁) is the smallest positive solution, always found at the first period completion.

A concrete example: for D = 2, the continued fraction is [1; 2, 2, ...] with period 1, and the first convergent is p₁/q₁ = 3/2. Check: 3² - 2·2² = 9 - 8 = 1. ✓ For D = 3, the period is [1; 1, 2], so the first convergent at period-end is 2/1, but 4 - 3 = 1, giving (2, 1). Check: 4 - 3·1 = 1. ✓ The algorithm is completely mechanical once you can compute the periodic continued fraction.

Once you have the fundamental solution (x₁, y₁), all others are generated by a remarkable algebraic structure. Think of ε₁ = x₁ + y₁√D as an element of the algebraic number system ℚ(√D). The equation x² - Dy² = 1 is equivalent to (x + y√D)(x - y√D) = 1, meaning these elements have norm 1. Multiplying two norm-1 elements gives another norm-1 element: ε₁ⁿ = xₙ + yₙ√D yields the n-th solution (xₙ, yₙ). For D = 2: ε₁ = 3 + 2√2, so ε₁² = 17 + 12√2, giving (17, 12). Check: 17² - 2·12² = 289 - 288 = 1. ✓ The continued fraction finds the seed; the algebraic structure of ℚ(√D) generates the infinite family.

Practice Questions 5 questions

Prerequisite Chain

Longest path: 33 steps · 157 total prerequisite topics

Prerequisites (1)

Leads To (1)