The Pell Equation
The equation
over the integers for some nonsquare positive is known as the Pell equation. We consider a slighty more general variant of the equation:
Theorem: If is a nonsquare positive integer whose continued fraction expansion has a repeating portion of terms, then is a solution of
Proof: Let and . We have which means
and , whence
Rearranging, and equating rational and irrational parts yields
Eliminating :
Theorem: If is a solution of and are coprime then is a convergent of .
Proof: If , then
and the result follows from a theorem on the accuracy of convergents. We can explicitly verify the cases .
Theorem: If the th convergent of gives a solution of then where is the number of terms in the period of the expansion.
Proof: Define . It is enough to show when the th convergent gives a solution of the Pell equation: if are the smallest positive integers such that , then from the previous theorem, is the th convergent for some , and we would have , and also (otherwise we would have a smaller solution than since ).
We replace with in the equation since odd convergents are less than while even convergents are greater.
We have
which rearranges to
Applying gives
That is, is plus some integer. From our work on periodic continued fractions, we must have
Theorem: The expansion of for a nonsquare positive integer has the form
with repeating.
Proof: Considering the relationship between Euclid's algorithm and the computation of convergents, or directly from the recurrence relation, we have
In the proof of our first theorem on Pell equations, we found
if is a solution. Since , we have
If and are solutions to , observe if and only if . We use this in the following proof.
Theorem: If is the smallest positive solution of the equation , then all positive solutions are given by
where is odd for when the minus sign is chosen, and any integer when the plus sign is chosen.
Proof: Since , we find , thus indeed satisfies the equation if does.
First suppose the plus sign is chosen, and we have a standard Pell equation. Suppose is a solution such that
for some . Divide through by to obtain
where .
Replacing with and multiplying shows that is a (not necessarily positive) solution of the Pell equation. If then we have a smaller positive solution, contradicting the minimality of .
We have because and , as they are solutions of the Pell equation. We observe has the same sign as
Since we are done.
For the minus sign variant of the equation, we argue similarly, with and where is odd.