# Solutions to Pell’s Equation

A Pell’s equation has one trivial solution, \( (x,y)=(1,0) \),
corresponding to solution \( z=1 \) of equation \( N(z)=1 \). But if we
know the smallest *non-trivial* solution, then we can derive
all the solutions. This is what the following statement claims.

** Theorem 2 **

If \( z_0 \) is the minimal element of \( \mathbb{Z}
[\sqrt{d}] \) with \( z_0> 1 \) and \( N(z_0)=1 \), then all the elements
\( z\in\mathbb{Z}[\sqrt{d}] \) with \( Nz=1 \) are given by \( z=\pm z_0^n \),
\( n\in\mathbb{Z} \).

Suppose that \( N(z)=1 \) for some \( z> 0 \). There is
a unique integer \( k \) for which \( z_0^k\leq z< z_0^{k+1} \). Then the
number \( z_1=zz_0^{-k}=z\overline{z_0}^k \) satisfies \( 1\leq z_1< z_0 \)
and \( N(z_1)=N(z)N(z_0)^{-k}=N(z)=1 \). It follows from the
minimality of \( z_0 \) that \( z_1=1 \) and hence \( z=z_0^k \).

** Corollary **

If \( (x_0,y_0) \) is the smallest solution of the
Pell’s equation with \( d \) given, then all natural solutions \( (x,y) \)
of the equation are given by \( x+y\sqrt{d}=\pm(x_0+y_0\sqrt{d})^n \),
\( n\in\mathbb{N} \).

Note that \( z=x+y\sqrt d \) determines \( x \) and \( y \) by the formulas
\( x=\frac{z+\overline{z}}2 \) and \( y=\frac{z-\overline{z}}{2\sqrt
d} \). Thus all the solutions of the Pell’s equation are given by
the formulas \[ x=\frac{z_0^n+\overline{z_0}^n}2\quad\mbox{i}\quad
y=\frac{z_0^n-\overline{z_0}^n}{2\sqrt d}.\]

** Example **

The smallest non-trivial solution of the equation
\( x^2-2y^2=1 \) is \( (x,y)=(3,2) \). Therefore for every solution
\( (x,y) \) there is an integer \( n \) such that \( x+y\sqrt d=\pm(3+
2\sqrt2)^n \). Thus \[ x=\frac{(3+2\sqrt2)^n+(3-2\sqrt2)^n}2,\quad
y=\frac{(3+2\sqrt2)^n-(3-2\sqrt2)^n}{2\sqrt2}.\]

Now we will show that every Pell’s equation indeed has a
non-trivial solution.

** Lemma 1 (Dirichlet’s theorem) **

Let \( \alpha \) be an
irrational number and \( n \) be a positive integer. There exist
\( p\in\mathbb{Z} \) and \( q\in\{1,2,\dots,n\} \) such that
\( \left|\alpha-\frac pq\right|< \frac1{(n+1)q} \).

The stated inequality is equivalent to
\( |q\alpha-p|< \frac1{n+1} \).

Let, as usual, \( \{x\} \) denote the fractional part of real \( x \).
Among the \( n+2 \) numbers \( 0 \), \( \{\alpha\} \), \( \{2\alpha\} \),
\( \dots \), \( \{n\alpha\} \), \( 1 \) in the segment \( [0,1] \), some two will differ
by less than \( \frac1{n+1} \). If such are the numbers \( \{k\alpha\} \)
and \( \{l\alpha\} \), it is enough to set \( q=|k-l| \); and if such are
\( \{k\alpha\} \) and 0 or 1, it is enough to set \( q=k \). In either
case, \( p \) is the integer closest to \( k\alpha \).

** Lemma 2 **

If \( \alpha \) is an arbitrary real number, then there
exist infinitely many pairs of positive integers \( (p,q) \)
satisfying \( \left|\alpha-\frac pq\right|< \frac1{q^2} \).

This lemma immediately follows from Dirichlet’s theorem.

** Theorem 3 **

A Pell’s equation has a solution in the set of positive
integers.

Applying Lemma 2 to \( \alpha=\sqrt{d} \), we see that
there exists an integer \( n \) with \( |n|< 2\sqrt{d}+1 \) such that the
equation \( x^2-dy^2=n \) has infinitely many positive integral
solutions \( (x,y) \). It follows that there are two different ones,
say \( (x_1,y_1) \) and \( (x_2,y_2) \), that satisfy \( x_1\equiv x_2 \) and
\( y_1\equiv y_2 \) {\rm (mod \( n \))}. Denote \( z_1=x_1+y_1\sqrt{d} \) and
\( z_2=x_2+y_2\sqrt{d} \) and assume \( z_1> z_2 \). Then \( z_0=z_1/z_2> 1 \)
is an element of \( \mathbb{Z}[\sqrt{d}] \) of norm 1 and corresponds
to a non-trivial solution \( (x_0,y_0) \) of the Pell’s equation.