## Every polynomial in RR[x] which takes only nonnegative values is a sum of two squares

Let $p(x) \in \mathbb{R}[x]$ be a polynomial such that $p(c) \geq 0$ for all $c$. Prove that $p(x) = a(x)^2 + b(x)^2$ for some polynomials $a,b \in \mathbb{R}[x]$.

Note that $p(x)$ must have even degree. We proceed by induction on the degree of $p(x)$. Note as a lemma that if $h = a^2+b^2$ and $k = c^2 + d^2$ are sums of squares, then so is $hk$ since (evidently) $hk = (ac-bd)^2 + (ad+bc)^2$. We find this identity by rearranging and partially simplifying the factorization $hk = (a+bi)(a-bi)(c+di)(c-di)$.

The base case $p(x) = c$ is trivial; $p(x) = 0^2 + 0^2$ if $c = 0$ and $p(x) = (\sqrt{c}/2)^2 + (\sqrt{c}/2)^2$ if $c \neq 0$.

For the inductive step, suppose the result holds for all polynomials of degree $n$ and let $p(x)$ have degree $n+2$. Suppose $p(x)$ has a real root $c$. Now $p(x)$ is concave up on a sufficiently small neighborhood about $c$, so that $p^\prime(c) = 0$. In particular, $c$ is a root of $p$ of multiplicity at least 2. Say $p(x) = q(x)(x-c)^2$. Now $q(x)$ is a sum of two squares, and $(x-c)^2 = (x-c)^2 + 0^2$ is as well, so that by the lemma $p(x)$ is a sum of two squares. Suppose instead that $p(x)$ has no real roots. Instead, we have a complex root $z$. Since conjugation is a ring homomorphism, $\overline{z}$ is also a root of $p$. Letting $z = a+bi$, we see that $x^2+2ax + a^2+b^2 = (x+a)^2 + b^2$ is a factor of $p(x)$; say $p(x) = q(x)((x+a)^2 + b^2)$. Again, $p(x)$ is a sum of two squares.