Hilbert's 17th Problem for smooth functions Consider an open subset $U \subseteq \mathbb{R}^n$ and a smooth function $f\colon U \longrightarrow \mathbb{R}$ with $f(x) \ge 0$ for all $x \in U$.
It is then known (if I remember correctly: by Michor?) that $f = g^2$ with a function $g$ which can be shown to be twice differentiable but not $C^2$ in general. In particular, a smooth square root does not exist in general.
My question is whether $f$ can be represented as a sum of squares of smooth functions, i.e. the smooth version of Hilbert's problem 17, and if so, what is the minimal number of squares needed?
 A: On $\mathbb R^1$ a non-negative smooth function is a sum of two squares of $C^m$-functions for each $m$ ($m=\infty$ does not follow):
Jean-Michel Bony, Sommes de carrés de fonctions dérivables, Bull. Soc. Math. France 133 (2005), no. 4, 619--639. (Zbl 1107.26008)
For algebras of matrices:
Yurii Savchuk and Konrad Schmüdgen, Positivstellensätze for algebras of matrices, Linear Algebra Appl. 436 (2012), no. 3, 758--788. (Zbl 05985527)
For square roots of function the following is the best answer up to now:
Jean-Michel Bony, Ferruccio Colombini, and Ludovico Pernazza, On square roots of class $C^m$ of nonnegative functions of one variable, Ann. Sc. Norm. Super. Pisa Cl. Sci. (5) 9 (2010), no. 3, 635--644. (Zbl 1207.26004)
A: Quoting from the introduction of Brumfiel's book Partially Ordered Rings and Semi-Algebraic Geometry (1979, CUP LMS Lecture Notes 37):

As a final remark on the birational interpretation of Artin's solution of Hilbert's 17th problem, consider a different category, that of smooth manifolds and smooth real valued functions.  Then Paul Cohen has shown me that (i) there exist nowhere negative smooth functions on any manifold which are not finite sums of squares of smooth functions (in fact, the zero set can be a single point) and (ii) given any nowhere negative smooth $f$, there are $h$, $g$, both smooth and $h$ not a zero divisor, such that $h^2f = g^2$.  The zero divisors are, of course, the smooth functions which vanish on some open set.

If the statement is correct ("on any manifold"), then there should be a counterexample on $\mathbb{R}$.  I would love to see how it is constructed!  But it does not seem to have been published, because in the 2005 paper ("Sommes de carrés de fonctions dérivables", Bull. Soc. Math. France, 133, 619–639) in which he proves (inter alia) that at least a $C^\infty$ function $f$ on $\mathbb{R}$ that is nonnegative can be written as $g^2 + h^2$ where $g$ and $h$ are $C^m$ for $m$ arbitrarily large but finite, Jean-Michel Bony mentions these counterexamples and asserts that, as far as he knows, they have not been published (he points to the aforementioned book, and also the book Real Algebraic Geometry by Bochnak, Coste and Roy, where a similar statement is attributed to P. Cohen and D. Epstein: see §6.6.4).
A: No. Let $f=z^6 + x^4 y^2 + x^2 y^4 − 3x^2 y^2 z^2$. By the AM-GM inequality, $f$ is nonnegative.
Suppose that $f=\sum  g_i^2$, with the $g_i$ smooth. Expand each $g_i$ in a Taylor series around $0$: $g_i = a_i + b_i(x,y,z) + c_i(x,y,z) + d_i(x,y,z) + O(|x|+|y|+|z|)^4$, with $a$, $b$, $c$ and $d$ homogenous polynomials of degrees $0$, $1$, $2$ and $3$.
Comparing terms of degrees $0$, $2$, $4$ and $6$ in a Talyor series around $0$, we see that $a_i=b_i=c_i=0$ and $z^6 + x^4 y^2 + x^2 y^4 − 3x^2 y^2 z^2 = \sum d_i(x,y,z)^2$. It is well known (see e.g. Wikipedia) that the left hand side is not a sum of squares of cubics.
