Why is a polynomial $f(x)$ sum of squares if $f(x)>0 $ for all real values of $x$? 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).
 A: 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).
A: 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$$
