When does 'positive' imply 'sum of squares'?

For many examples of this kind, see Olga Taussky, "Sums of squares", Amer. Math. Monthly 77 (1970) 805-830.


An element of $\mathbb{R}[x]$ is a sum of two squares if it is nonnegative as a function on $\mathbb{R}$. This can be seen by noting that its real roots have even multiplicity, its irreducible quadratic factors are of the form $(x-a)^2+b^2$, a product of sums of two squares is a sum of two squares, and a square times a sum of two squares is a sum of two squares.

See Qiaochu's question on Hilbert's 17th problem for what happens in more than one variable.


A very nice example, due to Motzkin, found I think after the publication of Taussky's American Math. Monthly paper referred to in the answer by Michael Lugo, is

$$x^2y^4 + x^4y^2 +1 - 3 x^2y^2$$

which can be written as a sum of four (even three) rational squares

$$ \frac{x^2y^2(x^2 + y^2 -2)^2(x^2 + y^2 +1) +(x^2 - y^2)^2} {(x^2 + y^2)^2},$$

yet is not a sum of squares of polynomials. (I learnt this example in a talk by K. Schmudgen.)