Show that, conversely, if $M \subset \mathbb{R}^3$ is a compact and connected submanifold with the proper $$ \left.(x d x+y d y+z d z)\right|_M=0, $$ then $M$ is one of the spheres centered at the origin.
My attempt: Consider a smooth function $f(x,y,z): \mathbb{R}^3 \to \mathbb{R}^1$ such that $(i^*df)_p = (df|_M)_p(V_p) = 0, \forall V_p \in T_p M$. If such $f$ does exists, then $df|_M = \sum_{i=1}^3\frac{\partial f}{dx^i} dx^i = x dx + y dy + z dz = 0$ and I can integrate to get the defining equation for the sphere. But I don't know how to prove the existence of such $f$. Any suggestions?
Thanks in Advance!
You're overthinking it: since $M$ is connected, ${\rm d}(x^2+y^2+z^2)|_M = (x\,{\rm d}x+y\,{\rm d}y+z\,{\rm d}z)|_M=0$ means that $x^2+y^2+z^2$ is constant on $M$ so, when $M$ is a surface, it must also be an open subset of the sphere $S$ of corresponding radius. Then compactness of $M$ says that it is also closed in $S$, and then connectedness of $S$ yields $M=S$.
If we do not assume that $M$ is a surface, there are counter-examples (such as a point, or a great circle).