Periodicity of Continued Fractions for Quadratic Irrationals
Summary: Lagrange’s theorem (Additions II, Art. 34) states that the continued-fraction expansion of any quadratic irrational is eventually periodic. The proof shows that the auxiliary sequences appearing in the minimization of a binary quadratic form are bounded (by and respectively), forcing recurrence on a finite integer lattice.
Sources: additions-2
Last updated: 2026-05-10
Statement
Let be a real irrational satisfying a monic quadratic with integer coefficients,
Then the continued-fraction expansion is eventually periodic: there exist and such that
A CF that is purely periodic (i.e. ) corresponds to a “reduced” surd; otherwise there is a finite pre-period followed by the repeating block.
Lagrange’s Proof (Add. II, Arts. 33–34)
Setup. Run the binary-quadratic-form algorithm of Add. II, Art. 33 (see binary-quadratic-forms) on with root . This generates auxiliary integer sequences
with the fundamental identity
Step 1 — Eventual sign alternation (Art. 34, ¶1). After finitely many steps, two consecutive have opposite signs. From that point on, all alternate in sign.
Reason: The principal convergents alternate around , hence alternates in sign; multiplying by and accounting for the conjugate factor (where is the other root) shows alternates in sign once both factors stabilize.
Step 2 — Bound on (Art. 34, ¶2). Once the sign-alternating regime starts (at index ), the products are negative; by the fundamental identity,
so . Consequently , and since both are positive integers,
Step 3 — Pigeonhole (Art. 34, ¶3). The integer pair takes values in a finite set of size . By the pigeonhole principle, some pair recurs; let be the first index where the pair recurs at index . Then by the deterministic recurrence,
for all . The CF is therefore eventually periodic with period . ∎
The factor of 2 in the period (Lagrange takes rather than ) ensures the sign pattern of also matches at the boundary; the true period of may be either or depending on the surd.
Consequence: Pell Equation Always Solvable (Add. II, Art. 37)
Specializing to ( non-square positive), the form is with . Then , and after one full period , giving
This is the Pell solution. See pell-equation for the broader context.
Lagrange’s “Reverse Period” Observation
For the example (Add. II, Art. 40), the two roots
have CF expansions
(both period 6). The two periodic blocks are reverses of each other (read backwards: — matching ‘s block up to the boundary alignment). This is a general feature of conjugate quadratic surds, formalized later by Galois (1828) for purely periodic CFs.
Modern Statement and Converse
Galois–Lagrange theorem (modern): A real irrational has an eventually periodic CF expansion if and only if it is a quadratic irrational.
The “if” direction is Lagrange’s theorem above; the “only if” direction is straightforward (a periodic CF satisfies a quadratic equation by direct substitution). Galois (1828) proved that the CF is purely periodic iff and its conjugate satisfies — these are the reduced quadratic surds.
Length of the Period
The period length is bounded above by via the pigeonhole bound, but in practice it is much smaller. For with (Add. II, Art. 41 — see square-root-continued-fractions):
| range | typical period length |
|---|---|
| 2–20 | 1–4 |
| 21–60 | 4–10 |
| 61–99 | 5–18 |
| Maximum in this range | 18 (at ) |
The periods of exhibit a curious palindromic pattern: where is itself a palindrome.
Why the Theorem Was Needed
Before Lagrange:
- Pell-equation solvability had been established empirically by Fermat (in challenges to Wallis and Brouncker, ~1657) and worked out case-by-case by Brouncker, Wallis, and Euler.
- Existence in the general case was assumed but never proved.
- Euler’s iterative method (in ch2.0.7-pell-equation-method) finds the minimal solution but rests on the assumption that one exists.
Lagrange’s periodicity theorem is the missing existence proof, made rigorous by reducing the problem to a pigeonhole argument on a finite integer lattice.
Related pages
- add2-arithmetic-problems — full chapter context (Arts. 23–41)
- binary-quadratic-forms — the algorithm
- continued-fractions — CF basics
- convergents — convergent recurrences
- pell-equation — solvability via this theorem
- square-root-continued-fractions — Euler’s table illustrating periodicity
- infinite-descent — alternative proof technique (not used here)