# A generalisation of Pell’s equation

We want to find the solutions to $(*)\qquad x^2+mxy+ny^2=1$

over the integers, where $m,n\in\mathbb Z$.

Let $\alpha$ and $\bar\alpha$ be the roots of $x^2+mx+n=0$. We can factorise $(*)$ as $(x-y\alpha)(x-y\bar\alpha)=1$. If $\alpha$ is rational, it must be an integer and then it is easy to find all solutions. So let us consider the more interesting case where $\alpha$ is not rational (i.e. $\sqrt{m^2-4n}\not\in\mathbb Z$).

Now a solution in the form $z=x-y\alpha$ to $(*)$ is a unit in the ring $\mathbb Z[\alpha]$. For $z=x-y\alpha\in\mathbb Z[\alpha]$, denote its conjugate by $\bar z=x-y\bar\alpha$. Then we have the multiplicative norm $N(z)=N(x-y\alpha)=z\bar z=x^2+mxy+ny^2$.

It follows that the solutions to $(*)$ form a subgroup $S$ of the multiplicative group of units of $\mathbb Z[\alpha]$.

Case 1: $m^2< 4n$. Then $(*)$ defines an ellipse, so there are at most finitely many solutions, i.e. $S$ is a finite subgroup of $\mathbb C^\times$. Hence $S$ is cyclic and every solution is of the form $\displaystyle x-y\alpha=\cos\frac{2\pi t}{k}+i\sin\frac{2\pi t}{k},\quad x-y\bar\alpha=\cos\frac{2\pi t}{k}-i\sin\frac{2\pi t}{k}$ $\displaystyle \Rightarrow 2x+my=2\cos\frac{2\pi t}{k}\in [-2,2]\cap\mathbb Z\Rightarrow \cos\frac{2\pi t}{k}\in\{0,\pm\frac 12,\pm1\}$ $\displaystyle\Rightarrow x-y\alpha\in\{\pm 1,\pm i, \frac{1\pm i\sqrt 3}{2}, \frac{-1\pm i\sqrt 3}{2}\}$.

Case 2: $m^2>4n$. Now $\alpha$ is real, so $S$ is a subgroup of $\mathbb R^\times$.

Claim. $S$ is not dense.

Proof. WLOG $S\neq\{\pm 1\}$. Then for $z=x-y\alpha\in S\backslash\{\pm 1\}$ we have $\displaystyle \left |z-\frac 1z\right |=|y(\alpha-\bar\alpha)|\ge |\alpha-\bar\alpha|=\sqrt{m^2-4n}=:\varepsilon> 1$.

Suppose that $1 is a solution. Then $\displaystyle \left |z-\frac 1z\right |=z-\frac 1z<\varepsilon-\frac 1\varepsilon<\varepsilon$,

impossible. Thus $S\cap (1,\varepsilon)=\emptyset$, i.e. $S$ is not dense. $\square$

It follows that $S$ is either $\{\pm 1\}$ or $\langle\delta\rangle\cup -\langle\delta\rangle$ for some $\delta>1$ (cf. ordering in groups, corollary 4). Therefore all solutions $(x,y)$ to $(*)$ are either just $(\pm 1,0)$, or are given by $\boxed{x-y\alpha=\pm (x_0-y_0\alpha)^k,\; k\in\mathbb Z}$

where $x_0-y_0\alpha$ is the least solution $>1$.

Corollary. (Dirichlet’s unit theorem for a real quadratic field) If $K$ is a real quadratic field, then $\mathcal O_K^*=\{\pm\varepsilon^n: n\in\mathbb Z\}$ for some $\varepsilon\ge 1$.