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?



Hilbert's 17th Problem for smooth functions
No. Let $f=z^6 + x^4 y^2 + x^2 y^4 − 3x^2 y^2 z^2$. By the [AM-GM inequality](http://en.wikipedia.org/wiki/AMGM), $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](http://en.wikipedia.org/wiki/Hilbert%27s_17th_problem)) that the left hand side is not a sum of squares of cubics.


