Find Units in $\mathbb{Z}[\sqrt{n}]$

Find all units in $\mathbb{Z}[\sqrt n] = \{a + b\sqrt n \mid a, b \in \mathbb Z \}$ and $n \in\mathbb N$, $n\ge 2$.

First let $c +d\sqrt n$ be a unit so $$(a +b\sqrt n)(c +d\sqrt n) = 1,$$ $$ac + bdn +(bc + ad)\sqrt n = 1.$$

What next?


Solution 1:

If $a+b\sqrt n$ is a unit, so is $a-b\sqrt n$; their inverses are conjugates. So $(a+b\sqrt n)(a-b\sqrt n)=a^2-nb^2$ is both an integer and a unit. Since $\frac{1}{m} \notin \mathbb{Z}[\sqrt n]$ for any $m$ in $\mathbb{Z}$ other than $\pm 1$, we are reduced to solving the equation $a^2-nb^2=\pm 1$. Since we can multiply the equation through by 1, changing the signs on $a$ and $b$, we are looking for the solutions to Pell's equation: $a^2-nb^2=1$.

Finding solutions to Pell's equation is a well-known (and fortunately solved) problem which is a bit too much for a math.SE answer post, so I'll leave you with a link to the wikipedia page:

http://en.wikipedia.org/wiki/Pell%27s_equation

Solution 2:

Since $a$, $b$, $c$, $d$, and $n$ are integers, the only way you can have $(ac + bdn) + (bc + ad)\sqrt n = 1$ is if $ac+bdn = 1$ and $bc+ad= 0$. This gives you two equations in $c$ and $d$. If you can solve for $c$ and $d$ in terms of $a$, $b$, and $n$, you will have an expression for the inverse of $a+b\sqrt n$. $a+b\sqrt n$ is a unit whenever this expression is well-defined and yields integers for $c$ and $d$.