# Pell Equations via Continued Fractions

## Pell Equations Revisited

Recall that a Pell equation has the form

$$
x^2-Dy^2=1,
$$

where $D$ is a positive nonsquare integer.

$$
x^2-Dy^2=1
$$

Earlier we saw that such equations possess infinitely many integer solutions. Continued fractions provide the systematic method for finding them.

The key fact is that the continued fraction expansion of

$$
\sqrt D
$$

is periodic.

This periodicity produces rational approximations

$$
\frac pq
$$

for which

$$
p^2-Dq^2
$$

is very small. In favorable cases, it equals $1$ or $-1$, giving a solution of the Pell equation.

## Continued Fractions of Quadratic Irrationals

A fundamental theorem states:

**Theorem.** If $D$ is a positive nonsquare integer, then the continued fraction expansion of

$$
\sqrt D
$$

is eventually periodic. In fact,

$$
\sqrt D=[a_0;\overline{a_1,a_2,\dots,a_k}],
$$

where the block repeats forever.

For example,

$$
\sqrt2=[1;\overline2],
$$

$$
\sqrt3=[1;\overline{1,2}],
$$

$$
\sqrt5=[2;\overline4].
$$

This periodicity is the arithmetic source of Pell equation solutions.

## Convergents and Near-Solutions

Let

$$
\frac{p_n}{q_n}
$$

be the convergents of

$$
\sqrt D.
$$

Since convergents approximate irrational numbers extremely well,

$$
\left|
\sqrt D-\frac{p_n}{q_n}
\right|
<
\frac1{q_n^2}.
$$

Multiplying by $q_n$,

$$
|p_n-q_n\sqrt D|
<
\frac1{q_n}.
$$

Now consider

$$
p_n^2-Dq_n^2.
$$

Factoring,

$$
p_n^2-Dq_n^2
=
(p_n-q_n\sqrt D)(p_n+q_n\sqrt D).
$$

The first factor is very small, while the second is approximately

$$
2q_n\sqrt D.
$$

Hence the product remains bounded.

In fact, for infinitely many convergents,

$$
p_n^2-Dq_n^2=\pm1.
$$

Thus convergents naturally produce Pell equation solutions.

## Example: The Equation $x^2-2y^2=1$

The continued fraction expansion is

$$
\sqrt2=[1;\overline2].
$$

Its convergents are

$$
1,\frac32,\frac75,\frac{17}{12},\frac{41}{29},\dots
$$

Now compute:

$$
3^2-2(2^2)=9-8=1,
$$

$$
7^2-2(5^2)=49-50=-1,
$$

$$
17^2-2(12^2)=289-288=1.
$$

Thus

$$
(3,2),
\qquad
(17,12),
\qquad
(99,70),
\dots
$$

are solutions of the Pell equation.

The convergents alternate between producing $1$ and $-1$.

## Fundamental Solutions

Among all nontrivial positive solutions, the smallest solution is called the fundamental solution.

For

$$
x^2-2y^2=1,
$$

the fundamental solution is

$$
(3,2).
$$

Once the fundamental solution is known, all other solutions can be generated algebraically.

Indeed,

$$
(3+2\sqrt2)^2=17+12\sqrt2,
$$

$$
(3+2\sqrt2)^3=99+70\sqrt2.
$$

In general, if

$$
x_1+y_1\sqrt D
$$

is the fundamental solution, then all positive solutions arise from powers

$$
(x_1+y_1\sqrt D)^n.
$$

## Even and Odd Period Lengths

The parity of the continued fraction period controls whether the equation

$$
x^2-Dy^2=-1
$$

has solutions.

**Theorem.**

- If the period length of

$$
\sqrt D
$$

is even, then

$$
x^2-Dy^2=-1
$$

has no integer solutions.

- If the period length is odd, then the equation has integer solutions.

For example,

$$
\sqrt2=[1;\overline2]
$$

has period length $1$, which is odd. Indeed,

$$
1^2-2(1^2)=-1.
$$

Thus the negative Pell equation is solvable.

## Algebraic Interpretation

The Pell equation is naturally interpreted inside the quadratic field

$$
\mathbb{Q}(\sqrt D).
$$

Consider the algebraic integers

$$
x+y\sqrt D.
$$

Their norm is

$$
N(x+y\sqrt D)=x^2-Dy^2.
$$

Thus solving the Pell equation means finding units of norm $1$.

The fundamental solution generates infinitely many units, and continued fractions provide an explicit construction of these units.

This connection forms one of the earliest bridges between elementary number theory and algebraic number theory.

## Growth of Solutions

Solutions of Pell equations grow rapidly.

For example, the solutions of

$$
x^2-2y^2=1
$$

begin:

$$
(1,0),
(3,2),
(17,12),
(99,70),
(577,408).
$$

The growth is essentially exponential because each solution arises from powers of the fundamental unit.

This behavior contrasts sharply with linear Diophantine equations, whose solutions grow only linearly.

## Geometric Interpretation

The equation

$$
x^2-Dy^2=1
$$

defines a hyperbola.

The convergents of

$$
\sqrt D
$$

produce lattice points lying extremely close to the asymptotes

$$
x=\pm\sqrt D\,y.
$$

Thus continued fractions convert geometric approximation into exact integer solutions.

This interplay between approximation and exact arithmetic is one of the central themes of Diophantine analysis.

## Historical Importance

The connection between Pell equations and continued fractions was developed systematically by entity["people","Joseph-Louis Lagrange","French mathematician"].

His work showed that every Pell equation has infinitely many solutions and that continued fractions provide an explicit algorithm for finding them.

This achievement marked a major advance in number theory and became one of the foundational examples of how infinite processes can solve discrete arithmetic problems.

