Is there an analog of Fermat’s Two Squares theorem over polynomial rings $\Bbb Z[x]$ by considering a version for non-negative polynomials? 


Fermat two squares says primes $p$ is sum of two squares iff $-1$ is quadratic residue mod $p$. Is there a sum of two squares formulation over polynomial rings using quadratic residues?



Fermat’s Two Squares for polynomials
$\def\QQ{\mathbb{Q}}$Yes. From [this answer](https://mathoverflow.net/a/82294/297), I learn of the following result of [Davenport, Lewis and Schinzel](http://www.ams.org/mathscinet-getitem?mr=163880):



> 
> If $f(x)$ is a polynomial with integer coefficients such that every
>  arithmetic progression contains an integer $n$ for which $f(n)$ is a
>  sum of squares, then $f(x) = u(x)^2+v(x)^2$ where $u$ and $v$ are
>  polynomials with integer coefficients.
> 
> 
> 


In particular, if $f(n)$ is a sum of squares for all $n$, then $f(x) = u(x)^2+v(x)^2$.




---


I believe what actually comes out of the proof is the following criterion. Write $f(x) = c g(x)^2 \prod\_j h\_j(x)$ with $c \in \QQ$ and the $h\_j$ distinct monic irreducible polynomials. Let $K\_j$ be the field $\QQ[\alpha]/h\_j(\alpha)$. Then $f(x)$ is a sum of squares if and only if 


* $c$ is a sum of squares and
* $\sqrt{-1}$ is in the field $K\_j$ for all $j$.


The point is that, by a theorem of Bauer (see e.g. [Theorem 2.6 here](http://math.stanford.edu/~conrad/249BPage/handouts/cfthistory.pdf)), if $\sqrt{-1}$ is NOT in $K\_j$ then one can find a prime $p \equiv 3 \bmod 4$ such that $h\_j$ has a root $\bar{u}$ mod $p$. By some elementary arguments (see the paper) one can lift $\bar{u}$ to an integer $u$ so that $f(u)$ is divisible by $p$ exactly once, showing that $f(u)$ is not a sum of squares.


If your goal were to use this to check that a given polynomial is a sum of squares, you'd want an effective version of Bauer's theorem. This is more or less the same as an effective version of the Cebatarov density theorem. Such exist, but there are better ways to check whether one number field contains another. 


More precisely, consider the question of whether $L$ contains a subfield isomorphic to $K$, for $K$ and $L$ number fields. My understanding (and this is NOT an area I am very knowledgeable about) is that one first generates lots of primes $p$ in search of a prime which splits in $L$ but not in $K$. If one finds such a prime, the answer is "NO" and you are done. However, I believe that, if the search fails, it is worth switching to other methods long before one has searched far enough for the failed search to constitute a proof that $K \subseteq L$.


