# What are the integers $n$ such that $\mathbb{Z}[\sqrt{n}]$ is integrally closed?

I was recently reading about integral ring extensions. One of the first examples given is that $\mathbb{Z}$ is integrally closed in its quotient field $\mathbb{Q}$. Another is that $\mathbb{Z}[\sqrt{5}]$ is not integrally closed in $\mathbb{Q}(\sqrt{5})$ since for example $(1+\sqrt{5})/2\in\mathbb{Q}[\sqrt{5}]$ is integral over $\mathbb{Z}$ as a root of $X^2-X-1$, but $(1+\sqrt{5})/2\notin\mathbb{Z}[\sqrt{5}]$.

Now I'm curious, can we find what are all integers $n$ such that $\mathbb{Z}[\sqrt{n}]$ is integrally closed (equal to its integral closure in its quotient field)?

One thing I do know is that unique factorization domains are integrally closed, so I think rings like $\mathbb{Z}[\sqrt{-1}]$, $\mathbb{Z}[\sqrt{-2}]$, $\mathbb{Z}[\sqrt{2}]$ and $\mathbb{Z}[\sqrt{3}]$ are integrally closed, as they are Euclidean domains, and thus are UFDs. But can we say what all integers $n$ are such that $\mathbb{Z}[\sqrt{n}]$ is integrally closed? Thanks!

-
Dear yunone, Did you try answering this yourself, working from the definitions? It's not that hard, and would be a very good exercise. Regards, – Matt E Jan 20 '12 at 2:06

Let's assume that $n$ is squarefree. I think it would be best to explore this without using knowledge of the answer. You want to find the integers in $\mathbf Q(\sqrt n)$. These are elements which satisfy a quadratic with integer coefficients. Every element looks like $a + b\sqrt{n}$ for some $a, b \in \mathbf Q$.

Recall that the conjugate of this element will be $a - b\sqrt n$. So it certainly satisfies $(X - a - b\sqrt n)(X - a + b\sqrt n) = X^2 - 2aX + a^2 - nb^2.$ You need the coefficients $-2a$ and $a^2 - nb^2$ to lie in $\mathbf Z$. (You might recognize these as the trace and norm.) If this is the case, then as $(2a)^2 - n(2b)^2$ is an integer (divisible by $4$) and $n$ is squarefree, it follows that $2b \in \mathbf Z$ as well.

At this point, it makes sense to work mod $4$: we know that this last expression vanishes there, and the only squares are $0$ and $1$. For example, if $n \equiv 2$ then $(2a)^2$ and $(2b)^2$ must both be congruent to $0$, and it follows that $a$ and $b$ are in $\mathbf Z$.

-
Thank you Dylan, I get that $(2a)^2-n(2b)^2$ is an integer, but why does that imply $2b$ is an integer? I only conclude $n(2b)^2$ is an integer. After that, I understand the rest of the argument. – yunone Jan 20 '12 at 6:41
@yunone Well, anything in the denominator of $(2b)^2$ would be a square, and hence can't be canceled by $n$. Does that make sense? – Dylan Moreland Jan 20 '12 at 14:13
Oh yes, that's clear now. Thanks. – yunone Jan 21 '12 at 22:06
Why do you need those coefficients to be in $\mathbb{Z}$? Why can´t $a-b \sqrt{n}$ be the root of another polynomial? – Pedro A. Castillejo Apr 29 '14 at 16:37

$\mathbb Z[\sqrt{n}]$ is integrally closed in $\mathbb Q(\sqrt{n})$ ($n\in\mathbb Z$, $n\neq1$) if and only if $n$ is square free and $n$ is not congruent to $1$ mod $4$ (or $n$ is a perfect square, in that case we have $\mathbb Z$ and $\mathbb Q$; thanks Arturo).

Moreover, if $n\equiv1 \pmod 4$, then $\mathbb Z[\frac{1+\sqrt{n}}{2}]$ is integrally closed in $\mathbb Q(\sqrt{n})$.

Sketch of proof of why $\mathbb Z[\sqrt{n}]$ is integrally closed in $\mathbb Q(\sqrt{n})$ for $n$ a square free number not congruent to $1$ modulo $4$. Let $\mathcal O$ be the set of integers numbers in $\mathbb Q(\sqrt{n})$. We can see that $\mathbb Z[\sqrt{n}]\subseteq\mathcal O$ (looking for suitable polynomials).

Let $\alpha=p+q\sqrt{n}\in\mathcal O-\mathbb Z$ with $p,q\in\mathbb Q$. $\alpha$ is a root of the polynomial $$f(x)=(x-\alpha)(x-\bar\alpha)=x^2-2px+(p^2-nq^2).$$ But $f(x)$ is monic and of minimal degree (with coefficients in $\mathbb Q$), so it has to divide to the monic polynomial $g(x)\in\mathbb Z[x]$ which $g(\alpha)=0$. This implies that $f(x)\in\mathbb Z[x]$, thus $2p,\; p^2-mq^2\in\mathbb Z$. Now, you should prove that $p$ and $q$ are in $\mathbb Z$ since $n\equiv 2,3\pmod4$.

-
Well, aren't you missing the cases where $n$ is a perfect square? In that case, $\mathbb{Z}[\sqrt{n}]=\mathbb{Z}$ and $\mathbb{Q}(\sqrt{n}) = \mathbb{Q}$... – Arturo Magidin Jan 20 '12 at 4:20
Thank you emiliocba. Do you mind explaining why the first statement is actually true? I've been trying to prove it myself, but have gotten stuck. I did realize that in the case where $n\equiv 1\bmod 4$, then writing $n=4k+1$, $\frac{1+\sqrt{n}}{2}$ is a root of $X^2-X-k$, but even then I'm note sure how to ensure $\frac{1+\sqrt{n}}{2}\notin\mathbb{Z}[\sqrt{n}]$. Also, how does one see the cases where $n$ is square free and $n\equiv 2,3\pmod{4}$? – yunone Jan 20 '12 at 4:26
I added how to prove it for $n\equiv 2,3\pmod4$. – emiliocba Jan 20 '12 at 5:08
Thanks for adding that emiliocba, I appreciate the help. – yunone Jan 20 '12 at 5:42

Here's an extremely low-level way of doing it, just using the definition and some easy integer computations.

We may write $n=d^2m$, where $d$ and $m$ are integers, and $m$ is square free. Then $\mathbb{Q}(\sqrt{n}) = \mathbb{Q}(\sqrt{m})$, and $$\mathbb{Z}[\sqrt{n}] = \{a + db\sqrt{m}\mid a,b\in\mathbb{Z}\}.$$

If $m=1$, then $\mathbb{Z}[\sqrt{n}]=\mathbb{Z}$, $\mathbb{Q}(\sqrt{n}) = \mathbb{Q}$, so $\mathbb{Z}[\sqrt{n}]$ is integrally closed in $\mathbb{Q}[\sqrt{n}]$.

Assume then that $m\neq 1$.

If $d^2\gt 1$, then $\sqrt{m}\in\mathbb{Q}(\sqrt{n})$, and satisfies $x^2-m\in\mathbb{Z}[x]$, but is not in $\mathbb{Z}[\sqrt{n}]$. So we may assume $d^2=1$; that is, $n$ is squarefree.

Now assume that $a=\frac{p}{q} + \frac{r}{s}\sqrt{n}\in\mathbb{Q}(\sqrt{n})$ ($n$ squarefree, $n\neq 1$), $\gcd(p,q)=\gcd(r,s)=1$, $q\gt 0$, $s\gt 0$, is integral over $\mathbb{Z}$. If $r=0$, then $a\in\mathbb{Q}$, so by virtue of being integral it lies in $\mathbb{Z}\subseteq\mathbb{Z}[\sqrt{n}]$.

If $r\neq 0$, then $a$ satisfies the polynomial $$\left( x - \frac{p}{q}-\frac{r}{s}\sqrt{n}\right)\left(x - \frac{p}{q}+\frac{r}{s}\sqrt{n}\right)$$ that is, $$x^2 - \frac{2p}{q}x + \frac{p^2}{q^2}-\frac{r^2n}{s^2}.$$ For $a$ to be integral, this must have integer coefficients. In particular, $q|2p$, and so either $q=1$ or $q=2$.

If $q=1$, then we must have $s^2|n$. Since $n$ is squarefree, this requires $s=1$. So if $q=1$, then the element must be in $\mathbb{Z}[\sqrt{n}]$ and we are fine.

Can $q=2$? If $q=2$, then we need $$\frac{p^2}{4} - \frac{r^2n}{s^2} = \frac{p^2s^2 - 4r^2n}{4s^2}\in\mathbb{Z}.$$ Therefore, $4|p^2s^2$; since $q=2$, then $p$ is odd, so $4|s^2$, and so $s=2k$ is even. We have $$\frac{4p^2k^2 - 4r^2n}{16k^2} = \frac{p^2k^2-r^2n}{4k^2}\in\mathbb{Z}.$$ Now, both $p$ and $r$ are odd, so $p^2\equiv r^2\equiv 1\pmod{4}$; since $4$ divides $p^2k^2-r^2n$, and $p^2k^2-r^2n\equiv k^2-n\equiv 0\pmod{4}$, then remembering that $n$ is square free (hence not congruent to $0$ modulo $4$) we conclude that $n\equiv 1\pmod{4}$.

So the only way in which $\mathbb{Z}[\sqrt{n}]$ with $n$ squarefree can fail to be integrally closed is if $n\equiv 1\pmod{4}$. And indeed, if $n\equiv 1 \pmod{4}$, then we can take $p=r=1$, $q=s=2$, and we get that $\frac{1}{2}+\frac{1}{2}\sqrt{n}$ is integral but not in $\mathbb{Z}[\sqrt{n}]$.

In summary: if $n=d^2m$ with $m$ square free, then:

1. If $m=1$, then $\mathbb{Z}[\sqrt{n}]=\mathbb{Z}$ is integrally closed in $\mathbb{Q}(\sqrt{n}) = \mathbb{Q}$.
2. If $m\gt 1$ and $d^2\gt 1$, then $\mathbb{Z}[\sqrt{n}]$ is not integrally closed in $\mathbb{Q}(\sqrt{n})$, witnessed by $\sqrt{m}$.
3. If $d^2=1$, and $n\not\equiv 1\pmod{4}$, then $\mathbb{Z}[\sqrt{n}]$ is integrally closed in $\mathbb{Q}(\sqrt{n})$.
4. If $d^2=1$ and $n\equiv 1\pmod{4}$, then $\mathbb{Z}[\sqrt{n}]$ is not integrally closed in $\mathbb{Q}(\sqrt{n})$, witnessed by $\frac{1}{2}+\frac{1}{2}\sqrt{n}$.

So $\mathbb{Z}[\sqrt{n}]$ is integrally closed if and only if $n$ is a perfect square, or $n$ is square free, different from $1$, and not congruent to $1$ modulo $4$.

-
Thanks Arturo, low level seems to be my level. Out of curiosity, when you say assume $m>1$, would it also be ok to just assume $m\neq 1$, in order to take care of the cases where $n<0$? I don't think anything breaks, but I just wanted to be sure. – yunone Jan 20 '12 at 5:41
@yunone: Oops, that should indeed be $m\neq 1$, not $m\gt 1$. – Arturo Magidin Jan 20 '12 at 5:42