A *Pell’s equation*
is a diophantine
equation of the form \(x^2-dy^2=1\), \(x,y\in\mathbb{Z}\), where
\(d\) is a given natural number which is not a square.

An equation of the form \(x^2-dy^2=a\) for an integer \(a\) is usually
referred to as a *Pell-type equation*.

An arbitrary quadratic diophantine equation with two unknowns can be reduced to a Pell-type equation. How can such equations be solved? Recall that the general solution of a linear diophantine equation is a linear function of some parameters. This does not happen with general quadratic diophantine equations. However, as we will see later, in the case of such equations with two unknowns there still is a relatively simple formula describing the general solution.

Why does the definition of Pell’s equations assume \(d\) is not a square? Well, for \(d=c^2\), \(c\in\mathbb{Z}\), the equation \(x^2- dy^2=a\) can be factored as \((x-cy)(x+cy)=a\) and therefore solved without using any further theory. So, unless noted otherwise, \(d\) will always be assumed not to be a square.

The equation \(x^2-dy^2=a\) can still be factored as \[(x+y\sqrt d) (x-y\sqrt d)=a.\] In order to be able to make use of this factorization, we must deal with numbers of the form \(x+y\sqrt d\), where \(x,y\) are integers. This set is denoted by \(\mathbb{Z} [\sqrt d]\). An important property of this set is that the sum and product of two of its elements remain in the set (i.e. this set is really a ring).

In terms of these concepts, the equation \(x^2-dy^2=a\) can be rewritten as \[N(z)=a,\quad\mbox{where }z=x-y\sqrt{d}\in \mathbb{Z}[\sqrt{d}].\] In particular, the Pell’s equation becomes \(N(z)=1\), \(z\in\mathbb{Z}[\sqrt{d}]\). We continue using these notation regularly.

Since \(z\) is a solution to a Pell-type equation if and only if so is \(-z\), we always assume w.l.o.g. that \(z > 0\).