When Is a Polynomial a Sum of Squares?

A square cannot be negative. Therefore a sum of squares cannot be negative either. This simple observation suggests a natural question: if a polynomial is never negative, must it be a sum of squares of polynomials?

The answer depends on how many variables we allow. In one variable, the answer is yes. In two or more variables, a remarkably simple counterexample shows that the answer is no.

1. The easy direction

Consider

P(x,y)=(x^2-y)^2+(xy-1)^2.

Clearly, P(x,y)\ge 0 for all real x,y. Expanding gives

P(x,y)=x^4+x^2y^2+y^2-2x^2y-2xy+1.

Although the expanded expression has negative terms, its sum-of-squares form proves nonnegativity immediately.

More generally, if

P(x_1,\ldots,x_n)=f_1(x_1,\ldots,x_n)^2+\cdots+f_k(x_1,\ldots,x_n)^2,

where the f_i are real polynomials, then P\ge 0 everywhere. Does every nonnegative polynomial admit such a representation?

2. Why one variable is special

For a real polynomial in one variable, the answer is yes. A nonzero polynomial that is nonnegative on the entire real line has a positive leading coefficient, and every real root has even multiplicity. Its other factors come from conjugate pairs of nonreal roots, producing positive quadratic factors.

Each positive quadratic is a sum of two squares, since

x^2+bx+c=\left(x+\frac b2\right)^2+\left(c-\frac{b^2}{4}\right),\qquad b^2-4c\lt 0.

The product of two sums of two squares is again a sum of two squares:

(a^2+b^2)(c^2+d^2)=(ac-bd)^2+(ad+bc)^2.

Consequently, every nonnegative real polynomial in one variable can be expressed as the sum of two squares of real polynomials (one square is enough in some cases).

3. A polynomial that changes the answer

Now consider the Motzkin polynomial:

M(x,y)=x^4y^2+x^2y^4+1-3x^2y^2.

At first sight, the negative term might suggest that the polynomial can become negative. But the arithmetic–geometric mean inequality gives

\frac{x^4y^2+x^2y^4+1}{3}\ge\sqrt[3]{x^4y^2\cdot x^2y^4\cdot1}=x^2y^2.

Thus

M(x,y)\ge 0\qquad\text{for every }x,y\in\mathbb R.

Equality occurs at (1,1),(1,-1),(-1,1),(-1,-1). In fact, these are its only real zeros.

And yet there are no real polynomials f_1,\ldots,f_k for which M=f_1^2+\cdots+f_k^2.

4. Why no polynomial sum of squares is possible

We can prove this without advanced algebra. Suppose, for a contradiction, that

M(x,y)=\sum_{j=1}^k f_j(x,y)^2.

Because M has total degree six, each f_j has degree at most three. Indeed, the highest-degree homogeneous parts of the squares cannot cancel over the real numbers.

Look first at the coefficient of x^6 in M. It is zero. On the right, that coefficient is the sum of squares of the coefficients of x^3 in the f_j. Therefore none of the f_j contains x^3. Similarly, none contains y^3.

Next set y=0. Since M(x,0)=1, we have

\sum_{j=1}^k f_j(x,0)^2=1.

A sum of squares of real polynomials can be constant only if every polynomial is constant. Hence no f_j has a pure x or x^2 term. Setting x=0 similarly rules out pure y and y^2 terms.

Only four monomials remain possible in each f_j:

f_j(x,y)=a_j+b_jxy+c_jx^2y+d_jxy^2.

But the coefficient of x^2y^2 in \sum_j f_j^2 is exactly

\sum_{j=1}^k b_j^2\ge0.

In M, that coefficient is -3. This is impossible. Our assumption was false.

The surprise: Nonnegativity and being a sum of polynomial squares are different properties in several variables.

5. What if rational functions are allowed?

The distinction between polynomials and rational functions matters. For example, the identity

(1+x^2)(1+y^2)=(1-xy)^2+(x+y)^2

illustrates how products of squares can be reorganized. More profoundly, Hilbert’s seventeenth problem asks whether every nonnegative real polynomial can be written as a sum of squares of rational functions. Artin proved that the answer is yes.

Thus the Motzkin polynomial cannot be a sum of polynomial squares, but it can be represented as a sum of squares of rational functions. That is a much subtler theorem than the elementary nonnegativity argument above.

6. Try it yourself

Exercise 1. Show that x^4+2x^2y^2+y^4 is a sum of squares. x^4+2x^2y^2+y^4=(x^2+y^2)^2.
Exercise 2. Prove x^4+y^4+1\ge x^2+y^2+x^2y^2.

Use a^2+b^2+c^2\ge ab+bc+ca with a=x^2,\ b=y^2,\ c=1. More explicitly, the difference equals

\frac12\bigl((x^2-y^2)^2+(y^2-1)^2+(1-x^2)^2\bigr).
Exercise 3. Find every zero of the Motzkin polynomial.

Equality in the arithmetic–geometric mean inequality requires x^4y^2=x^2y^4=1. Hence x^2=y^2=1, giving the four points (\pm1,\pm1).

Exercise 4. Why must each polynomial in a sum-of-squares representation of a degree-six polynomial have degree at most three?

Let d be the largest degree of any summand f_j. The homogeneous degree-2d part of \sum f_j^2 is the sum of squares of the leading homogeneous parts of the degree-d summands. It cannot vanish identically over the real numbers. Therefore the degree of the sum is 2d, so d\le3.

7. The bigger picture

For one-variable polynomials, nonnegativity guarantees a polynomial sum-of-squares representation. The Motzkin example shows that the same conclusion fails for polynomials in two variables. Allowing rational functions restores a general existence theorem, but changes the question.

This distinction plays an important role in real algebraic geometry and polynomial optimization: finding a sum-of-squares representation provides a concrete certificate that a polynomial is nonnegative, even though not every nonnegative polynomial has such a certificate.

Related Reading

For another surprising connection between sums of squares,
number systems, and algebra, see
Why Are 1, 2, 4, and 8 Special?.

The sums-of-squares story continues in Sums of Squares and Galois Theory, Sums of Squares and Laplace’s Equation and How Matrices Turn Quadratic Forms into Sums of Squares.

Further reading

Olga Taussky, “Sums of Squares,” The American Mathematical Monthly 77 (1970), 805–830, especially Section 8. Article on JSTOR.

Leave a Reply

Your email address will not be published. Required fields are marked *