TITLE: Prove that a positive polynomial function can be written as the squares of two polynomial functions
QUESTION [24 upvotes]: Let $f(x)$ be a polynomial function with real coefficients such that $f(x)\geq 0 \;\forall x\in\Bbb R$. Prove that there exist polynomials $A(x),B(x)$ with real coeficients such that $f(x)=A^2(x)+B^2(x)\;\forall x\in\Bbb R$

I don't know how to approach this, apart from some cases of specific polynomials that turned out really ugly. Any hints to point me to the right direction?

REPLY [25 votes]: Consider roots of $f(x)$, as $f(x)\geq0,\forall x\in\mathbb{R}$, so $f(x)$ can be rewritten as following:
$$f(x)=a^2(x-a_1)^2\cdots(x-a_k)^2[(x-\alpha_1)(x-\bar{\alpha_1})]\cdots[(x-\alpha_l)(x-\bar{\alpha_l})]$$
Where $a,a_1,\cdots,a_k\in\mathbb{R},\alpha_1,\cdots,\alpha_l\in\mathbb{C}$.
Denote $g(x)=a(x-a_1)\cdots(x-a_k),h(x)=(x-\alpha_1)\cdots(x-\alpha_l)=h_1(x)+ih_2(x)$, then
\begin{align*}
f(x)&=g^2(x) \, h(x) \, \bar{h}(x)\\
&=g^2(x) \, [h_1(x)+ih_2(x)] \, [h_1(x)-ih_2(x)]\\
&=(g(x)h_1(x))^2+(g(x)h_2(x))^2
\end{align*}