# Sums of two squares in (certain) integral domains

While giving the first of eight lectures on introductory model theory and its applications yesterday, I stated Hilbert's 17th problem (or rather, Artin's Theorem): if $f \in \mathbb{R}[t_1,\ldots,t_n]$ is positive semidefinite -- i.e., non-negative when evaluated at every $x = (x_1,\ldots,x_n) \in \mathbb{R}^n$ -- then it is a sum of squares of rational functions. One naturally asks (i) must $f$ be a sum of squares of polynomials, and (ii) do we know how many rational functions are necessary? The general answers here are no (Motzkin) and no more than $2^n$ (Pfister). Then I mentioned that the case of $n=1$ is a very nice exercise, because one can prove in this case that indeed $f(t)$ is positive semidefinite iff it is a sum of two (and not necessarily one, clearly) squares of polynomials. Finally I muttered that this was a sort of function field analogue of Fermat's Two Squares Theorem (F2ST).

So I thought about how to prove this result, and I was able to come up with a proof that follows the same recipe as the Gaussian integers proof of F2ST. Then I realized that the key step of the proof was that a monic irreducible quadratic polynomial over $\mathbb{R}$ is a sum of two squares, which can be shown by...completing the square.

But then today I went back to the general setup of a "Gaussian integers" proof, and I came up with the following definition and theorem.

Definition: An integral domain $R$ is imaginary if $-1$ is a square in its fraction field; otherwise it is nonimaginary. (In fact I will mostly be considering Dedekind domains, hence integrally closed, and in this case if $-1$ is a square in the fraction field it's already a square in $R$, so no need to worry much about that distinction.) Note that nonimaginary is a much weaker condition than the fraction field being formally real.

(Definition: An element $f$ in a domain $R$ is a sum of two squares up to a unit if there exist $a,b \in R$ and $u \in R^{\times}$ such that $f = u(a^2+b^2)$.)

Theorem: Let $R$ be a nonimaginary domain such that $R[i]$ ($= R[t]/(t^2+1)$) is a PID.
a) Let $p$ be a prime element of $R$ (i.e., $pR$ is a prime ideal). Then $p$ is a sum of two squares up to a unit iff the residue field $R/(p)$ is imaginary.
b) Suppose moreover that $R$ is a PID. Then a nonzero element $f$ of $R$ is a sum of two squares up to a unit iff $\operatorname{ord}_p(f)$ is even for each prime element $p$ of $R$ such that $R/(p)$ is nonimaginary.

[Proof: Introduce the "Gaussian" ring $R[i]$ and the norm map $N: R[i] \rightarrow R$. Follow your nose, referring back to the proof of F2ST as needed.]

Corollaries: 1) F2ST. 2) Artin-Pfister for $n = 1$. 3) A characterization of sums of two squares in a polynomial ring over a nonimaginary finite field (a 1967 theorem of Leahey).

4) Let $p \equiv 3,7 \pmod{20}$ be a prime number. Then $p$ is a sum of two squares up to a unit in $\mathbb{Z}[\sqrt{-5}]$ but is not (by F2ST) a sum of two squares in $\mathbb{Z}$.

Finally the questions:

Have you seen anything like this result before?

I haven't, explicitly, but somehow I feel subconsciously that I may have. It's hard to believe that this is something new under the sun.

What do you make of the strange situation in which $R$ is not a PID but $R[i]$ is?

Note that one might think this impossible, but $R = \mathbb{R}[x,y]/(x^2+y^2-1)$ is an example. [Reference: Theorem 12 of http://math.uga.edu/~pete/ellipticded.pdf.] Do you have any idea about how one might go about producing more such examples, e.g. with $R$ the ring of integers of a number field (or a localization thereof)?

Addendum: As I commented on below, a good answer to the first question seems to be the paper

MR0578805 (81h:10028) Choi, M. D.; Lam, T. Y.; Reznick, B.; Rosenberg, A. Sums of squares in some integral domains. J. Algebra 65 (1980), no. 1, 234--256.

In this paper, they prove the theorem above with slightly different hypotheses: $R$ is a nonimaginary UFD such that $R[i]$ is also a UFD. Looking back at my proof, the only reason I assumed PID was not to worry about the distinction between $R/pR$ and its fraction field. Just now I went back to check that everything works okay with PID replaced by UFD. So the second question becomes more important: what are some examples to exploit the fact that $R[i]$, but not $R$, needs to be a UFD?

-
Pete, $R = {\mathbf Z}[\sqrt(-5)]$ is not an example since the ring of integers of ${\mathbf Q}(\sqrt(-5),i)$ is not $R[i]$ but something bigger: the ratio $(i + sqrt(-5))/2$ is an algebraic integer. The ring of integers in fact is ${\mathbf Z}[(i+\sqrt(-5))/2]$. If $K$ is a quadratic field unramified at 2 then the ring of integers of $K(i)$ is $R[i]$ where $R$ is the ring of integers of $K$. So you need $K = {\mathbf Q}(\sqrt{d})$ with $d \equiv 1 \bmod 4$. I don't believe the 4th corollary now except perhaps if you allow 1/2's, but I don't have a specific counterexample, say for $p=3$. –  KConrad Jul 8 '10 at 5:50
Clarify what you mean in the first question about having seen anything "like this result" before. Do you mean the specific application to Artin--Pfister? The proof is "follow your nose" as you say, copying the standard technique for deciding how a prime factors in a ring generated by a root of a polynomial by seeing how the polynomial with that root factors mod the prime (assuming the ring is generated by the root!). As for the second question, this "strange situation" is pretty common since lots of number fields with class number > 1 are inside a number field with class number 1. –  KConrad Jul 8 '10 at 5:57
@K: Hmm, I'm sure you're right. I worried about this point but thought I was OK since MAGMA told me that the discriminant of the number field $\mathbb{Q}(\sqrt{-5},\sqrt{-1})$ was equal to the discriminant of the minimal polynomial of $\sqrt{-1} + \sqrt{-5}$. I will retract the 4th corollary for now, although probably it can be fixed by inverting $2$... –  Pete L. Clark Jul 8 '10 at 5:58
@K: It seems like your first two comments are sort of at odds with each other: first, maybe you can help me get an explicit example of a quadratic field whose ring of integers $R$ satisfies this property, since the one I mentioned doesn't work. Also, by "lots" of number fields, do you mean "infinitely many"? Not provably, I'm sure. So then what? –  Pete L. Clark Jul 8 '10 at 6:02
In other news, a MATHSCINET search turns up the 1980 paper of Choi, Lam, Reznick and Rosenberg, which seems to contain closely related results. For them, both $R$ and $R[i]$ are UFDs. (I don't have online access to the paper, unfortunately.) So the most interesting aspect again seems to be the situation in which $R$ is not a UFD. –  Pete L. Clark Jul 8 '10 at 6:05

Let $K$ be a complex quadratic number field such that $K(i)$ has class number $1$. If $K$ has class number $\ne 1$, then $K(i)$ must be the Hilbert class field of $K$, which, in this case, coincides with the genus class field of $K$. By genus theory, the discriminant of $K$ must have the form $d = -4p$ for a prime number $p \equiv 1 \bmod 4$.

In these cases, the ring of integers in $K$ is $R = {\mathbb Z}[\sqrt{-p}]$, and the ring of integers in $L$ is ${\mathbb Z}[i, (1 + \sqrt{p})/2] \ne R[i]$.

Finding number fields of higher degree with this property seems to be an interesting problem; I can't think of an obvious approach in general, but if I find anything, I'll let you know.

Edit 1. The argument works for all imaginary number fields: if $R$ is the ring of integers in a number field $K$, and if $S = R[i]$ is the ring of integers in the extension $L = K(i)$, then disc$(L) = \pm 4$ disc$(K)^2$ (this is a simple determinant calculation: take an integral basis $\{\alpha_1, \ldots, \alpha_n\}$ for $K$; then $\{\alpha_1, \ldots, \alpha_n, i\alpha_1, \ldots, i\alpha_n\}$ is an integral basis for $L$).

On the other hand, if $L$ has class number $1$ and $K$ is not a PID, then $K$ has class number $2$ and $L$ is the Hilbert class field of $K$. This implies disc$(L) = \pm$ disc$(K)^2$.

The problem in the non-imaginary case is that $K(i)$ might be unramified at all finite primes, but not at infinity; in this case, $K$ has class number $2$ in the strict sense, yet its ring of integers is a UFD.

Remark 2. By looking at $p = \alpha^2 + \beta^2$ modulo $4$ it follows (unless I did something stupid) that primes $p \equiv 3, 7 \bmod 20$ are not sums of two squares in ${\mathbb Z}[\sqrt{-5}]$.

Edit 2. Your suggestion to look at rings $R[\frac12]$, where $R$ is the ring of integers of a quadratic number field, seems to work for $K = {\mathbb Q}(\sqrt{-17})$, which has a cyclic class group of order $4$. The ring $R[\frac12]$ has class number $2$ because $2$ is ramified and so generates a class of order $2$, and $S = R[\frac12,i]$ is the integral closure of $R[\frac12]$ in the extension $L = K(i)$. The ring $R[\frac12]$ has class number $2$, and $S$ is a UFD since $L$ has class number $2$, and its class group is generated by one of the prime ideals above $2$ (the ramified prime above $2$ in $K$ splits in $L$).

Edit 3. The corollary concerning sums of two squares in $R[\frac12]$ shows that primes $p \equiv 3 \bmod 4$ splitting in $K$ are sums of two squares up to units. In fact it follows from genus theory that the prime ideals above such $p$ are not in the principal genus, hence lie in the same class as the prime above $2$ or in its inverse. This implies that either $2p = x^2 + 17y^2$ or $8p = x^2 + 17y^2$, giving a representation of $p$ as a sum of two squares up to a unit (remember $2$ is invertible). Thus everything is working fine.

-
Thanks, Franz. I pretty much knew what you wrote in the first paragraph -- that's why I picked $\mathbb{Q}(\sqrt{-5})$ , because its genus field is obtained by adjoining $−1$ -- but combining this with your second observation is very helpful. Since you are especially knowledgeable about this sort of thing, here's a question: can you find such a domain $R$ as $\mathbb{Z}_K[\frac{1}{2}]$ -- i.e., same as above with $2$ inverted? Off the top of my head, I think that if $K = \mathbb{Q}(\sqrt{-5})$, the resulting ring is a PID. –  Pete L. Clark Jul 8 '10 at 13:17
I need more time to think this through - off the top of my head, Z_K[1/2] is principal for quadratic number fields with even discriminant if and only if the prime ideal above 2 generates the class group, which it does for your example (in that case, the resulting ring is even norm Euclidean). –  Franz Lemmermeyer Jul 8 '10 at 16:00
@Franz: right, that was my thinking as well. –  Pete L. Clark Jul 8 '10 at 17:01
If $R$ is the ring of integers of a number field, the class group of $R[1/2]$ is the quotient of the class group of $R$ by the subgroup generated by ideal classes of primes lying over 2. (More generally, the class group of a localization of $R$ is the quotient of the class group by the subgroup generated by primes that meet the multiplicative set at which you're localizing.) So $R[1/2]$ has class number 1 if and only if the primes lying over 2 generate the class group of $R$. –  KConrad Jul 8 '10 at 17:11
@Everyone -- it is a bit distressing to me that my question has many more upvotes than Franz's answer: an expert in algebraic number theory has generously devoted his time to analyzing my (2/3)-baked question, including doing computations that would not be so trivial for me, at least. What's not to upvote? I think that Franz's self-effacing preamble may have dissuaded people, so I have taken the liberty of removing it. –  Pete L. Clark Jul 9 '10 at 6:47