Given a nonnegative polynomial $p(x)$ on $\mathbb{R}$, does there exist some $k$ such that for some polynomials $f_1,\ldots ,f_k$ we have $p(x)=\sum_{i=1}^k(f_i)^2$?

I think yes, because of the nonnegative nature of $p(x)$, but am unable to prove. Any hints. Thanks beforehand.


Every nonnegative real polynomial is a sum of squares.

Let $p$ be a nonnegative real polynomial.

By the Fundamental Theorem of Algebra, $p=af_1^2 \cdots f_n^2 g_1 \cdots g_m$, where $a\in \mathbb R$, $f_i$ has degree $1$ and $g_j$ has degree $2$ and no real roots.

Now if $g$ is a monic real quadratic polynomial with no real roots, then $g(x)=(x+u)^2+v^2$, by completing the square.

An expression of $p$ as a sum of squares now follows from the Brahmagupta–Fibonacci identity.