# Fundamental unit of the quadratic integer ring $\mathbb{Z}[\sqrt{n}]$

I looked in other questions but I didn't find any answers regarding quadratic integer rings. Apologies if I missed it.

Given the ring $\mathbb{Z}[\sqrt{n}]$ where $n$ is a square-free positive integer, I would like to find the fundamental unit (i.e. some $a + b\sqrt{n}$ such that $\langle a + b\sqrt{n}\rangle = \mathbb{Z}[\sqrt{n}]^\times$, the units of $\mathbb{Z}[\sqrt{n}]$). I do know if I take the smallest $y$ such that $ny^2$ is of the form $x^2 \pm 1$, I get a unit, $x + y\sqrt{n}$. After all, we have $ny^2 = x^2 \pm 1$, so $ny^2 - x^2 = \pm 1$, meaning that $N(x + y\sqrt{n}) = x^2 - ny^2 = \mp 1$ ($N$ is just a standard Euclidean function). Since this particular Euclidean function is also multiplicative we know that any power of $x + y\sqrt{n}$ is also a unit. However, this is where I get stuck. Is this $x + y\sqrt{n}$ indeed a fundamental unit? If so, how do I show it can generate all units? If not, how do I find the actual fundamental unit?

• See here on MSE, for $n=2$. For the algorithm in general, see here. Sep 21, 2016 at 12:57
• By the way, try $n=9199$ in the algorithm. This is from Milne's lecture notes in algebraic number theory. Sep 21, 2016 at 13:18
• Thanks very much for those links. My lack of knowledge shows, as I assumed that the method and/or result to find it for $\mathbb{Z}[\sqrt{n}]$ would differ (however slightly) from finding the solution for $\mathbb{Q}[\sqrt{n}]$. Both those links are very illuminating. Sep 21, 2016 at 17:33
• Note that $\mathbb{Z}[\sqrt n]$ is only the ring of integers of a real quadratic field when $n\equiv_41$. Aug 25, 2017 at 8:19

A very practical way to obtain the fundamental unit of a real quadratic field is as follows:

for $\Bbb Q(\sqrt d)$ we have $$a_n+b_n\sqrt d=(a_1+b_1\sqrt d)^n\Rightarrow b_{n+1}=a_1b_n+b_1a_n$$ This implies that the sequence $\{b_n\}$ is strictely increasing because $a_1,b_1,a_n,b_n$ are positive. Hence we can see at the sequence $d,2^2d,3^2d,4^2d,....$ and stop at the first term for which $db^2$ is such that $a^2-db^2=\pm1$ for some integer $a$. In this case the $a$ and $b$ are the searched $a_1$ and $b_1$ of the fundamental unit. This method as far as I know is due to Pierre Samuel.

Examples.- (1) For $\Bbb Q(\sqrt6)$ we have $6\cdot1=6;\space6\cdot2^2=24=5^2-1$ then the fundamental unit of $\Bbb Q(\sqrt6)$ is $5+2\sqrt6$.

(2) For $\Bbb Q(\sqrt7)$ we have $7\cdot3^2=63=8^2-1$ so the f. u. is $8+3\sqrt7$

• But how do we know that all units have this form? Maybe there is a unit that is not a power of the unit we have found (I mean I know that this is not the case, but I don't know how to prove it)
– kubo
Sep 16 at 10:43
• @kubo The unit $a_1+b_1\sqrt d$ is called fundamental because it is a generator of the group of all the units when it has rank $1$. Look at Dirichlet's unit theorem. Sep 17 at 14:25
• How does this extend precisely to cases where $d \equiv 1$ mod $4$? For example, if we apply the algorithm above to $d = 5$, we get the unit $2 + \sqrt{5}$, but the fundamental unit is $\frac{1 + \sqrt{5}}{2}$, right? Oct 10 at 12:34
• @Anakhand: for $d=5$ the f. u. is $9-4\sqrt5$. Try to solve the equation $x^2-5y^2=1$ (or $-1$)and look at the answer in Wolfram. Oct 11 at 14:27
• @Piquito $(1/2)^2 - (\sqrt{5}/2)^2 = 1/4 - 5/4 = -1$, so $(1 + \sqrt{5})/2$ satisfies the equation but is not generated by $9 - 4\sqrt{5}$. As far as I understand, $9 - 4\sqrt{5}$ is the fundamental unit of $\mathbb{Z}[\sqrt{5}]$, but not of $\mathbb{Q}(\sqrt{5})$, because the ring of algebraic integers here is $\mathbb{Z}[\frac{1+\sqrt{5}}{2}]$, not $\mathbb{Z}[\sqrt{5}]$. In fact $\mathbb{Z}[\sqrt{5}]^\times$ is of index 3 in $\mathbb{Z}[\frac{1+\sqrt{5}}{2}]^\times$. Am I missing something? Oct 11 at 14:39

In the case of a real quadratic field, the fundamental unit is the smallest unit of the form $x + y \sqrt{d}$ such that $x \geq 0$ and $y \geq 1$. To see this, note that if $x + y \sqrt{d} > 1$ is a unit, we have that $x^2 - dy^2 = \pm 1$. Assume that $x$ and $y$ had different signs, then we would have

$$x + y \sqrt{d} = \frac{\pm 1}{x - y \sqrt{d}}$$

and $|x - y \sqrt{d}| \geq 1$ since $x$ and $-y$ have the same sign. This is a contradiction, therefore $x$ and $y$ are both nonnegative in $x + y \sqrt{d}$. Since the fundamental unit is the smallest unit greater than $1$, it follows that we may simply look at units of the form $x + y \sqrt{d}$ where $x, y$ are nonnegative, which reduces the problem to a necessarily finite brute force search.

While Dirichlet's unit theorem necessarily implies that the above found unit must be the fundamental unit, there is a more elementary proof of this fact. Assume that $\varepsilon$ is the smallest unit greater than $1$, and $x$ is any unit greater than $1$. We want to show that $x$ is a power of $\varepsilon$. Since the sequence $a_n = \varepsilon^n$ diverges, there is a greatest integer $n$ such that $a_n = \varepsilon^n \leq x$. Then, $x/\varepsilon^n$ is a unit $\geq 1$, but it is less than $\varepsilon$ since $x < \varepsilon^{n+1}$. By the definition of $\varepsilon$, the only unit in the interval $[1, \varepsilon)$ is $1$, so it follows that $x = \varepsilon^n$.

A more sophisticated algorithm to find the fundamental unit involves continued fractions, see these lecture notes for further information.

• I just want to say that as somebody who's still working on fully grasping the Dirichlet unit theorem I really appreciate your simple proof! Sep 21, 2016 at 17:42

It certainly has been discussed on MSE how to find a fundamental unit for the unit group of the ring of integers of a real quadratic number field $\mathbb{Q}(\sqrt{n})$. A nice survey, how to use continued fractions, and a table with examples for squarefree $n\le 21$ is given here.

Remark: The ring of integers in $\mathbb{Q}(\sqrt{n})$ is not always $\mathbb{Z}(\sqrt{n})$. This is only true for $n\equiv 2,3\bmod 4$. For the remaining case $n\equiv 1 \bmod 4$ (note that $n$ is squarefree), it is slightly different. An example here, with $n=141$ is discussed here on MSE. The result is as follows: since $\sqrt{141}=[11,\overline{1,6,1,22}]$, we have that $95+8\sqrt{141}$ is a fundamental unit!

• I had assumed that the ring of integers would always be trivial. Thanks for pointing out that it isn't! Sep 21, 2016 at 17:36
• Sorry, that's an absolutely terrible way of wording it. I was referring to the fact that the ring is only $\mathbb{Z}[\sqrt{n}]$ for $n \equiv 2, 3 \mod 4$, not trivial in the normal sense. In my head I just called that trivial. My bad! Sep 21, 2016 at 20:06
• No problem, I understood it now. Sep 21, 2016 at 20:09