# Why is a polynomial $f(x)$ sum of squares if $f(x)>0$ for all real values of $x$? [duplicate]

If a polynomial $f(x)>0$ for all real values of $x$, then $f(x)$ is sum of squares.
Why is this true ?
I understand that the roots of this $f(x)$ will be complex and hence will exist as conjugate pairs ( It is to be assumed that the $f(x)$ has real coefficients).

## marked as duplicate by Watson, user223391, астон вілла олоф мэллбэрг, Daniel W. Farlow, JonMark PerryJan 18 '17 at 5:59

• What does sum of squares mean? For example what if $f(x) = x^2 + x + 1$? – Ant Apr 22 '16 at 11:24
• @Ant Presumably $(x+\frac{1}{2})^2+(\frac{\sqrt3}{2})^2$. – almagest Apr 22 '16 at 11:26
• @Ant a suitable linear combination $\alpha^2(x+1)^2+\beta^2(x-1)^2$ should work fo all $x^2+cx+1$ with $-2\le x\le 2$, – Hagen von Eitzen Apr 22 '16 at 11:26

As $f(x)>0$, $f$ has no real roots, so all its roots are complex conjugates pairs : you can write :

$f(x) = \prod \limits_{i=1}^n (x - \lambda_i ) (x - \overline{\lambda_i})$ where all the $\lambda_i$ are non-real.

Then you write $\prod \limits_{i=1}^n (X - \lambda_i) = P(X) + i Q(X)$ where $P$ and $Q$ have real coefficients. Immediately you have $\prod \limits_{i=1}^n (X - \overline{\lambda_i}) = P(X) - i Q(X)$

Hence $f(x) = (P(x) + iQ(x))(P(x) - i Q(x))$ and thus $f(x) = P(x)^2 + Q(x)^2$.



In fact the result is the same if you only assume $f \geqslant 0$ : in this case you can prove that all the real roots are of even multiplicities (to prove this, for instance use a neighborhood of a real root ; if the multiplicity is odd, the sign will change).

• Cool! Very nice method and welcome to math.SE :-) – Ant Apr 22 '16 at 11:49

By induction on the degree (which of course must be even):

Assume $f(x)\ge 0$ for all $x\in \Bbb R$. Then $f$ has a global minumum, i.e., there exists $x_0\in \Bbb R$ with $f(x)\ge f(x_0)=:a\ge 0$ for all $x\in \Bbb R$. Consider $f_1(x):=f(x)-a$. If it is all zero, we are done. Otherwise, $x_0$ must be a multiple root (or we'd have sign change at $x_0$), i.e., $f_1(x)=(x-x_0)^2f_2(x)$ for some polynomial $f_2$ of degree $<\deg f$. We have $f_2(x)\ge 0$ for all $x\ne x_0$ and by continuity also for $x=x_0$. By induction hypothesis, $f_2$ is a sum of squares, say $f_2(x)=\sum g_i(x)^2$, and hence $$f(x)=\sqrt a^2+\sum \bigl((x-x_0)g_i(x)\bigr)^2$$