Smooth surfaces that isn't the zero-set of $f(x,y,z)$ The zero-set of any smooth function $f(x,y,z)$ with a non-vanishing gradient is a smooth surface. I was wondering if the reverse is true: is every smooth surface in $E^3$ the zero-set of some smooth function? If not, what do the counterexamples look like?
I was thinking that a plane with a hole may qualify as a counterexample, but I have yet to prove it.
 A: Georges Elencwajg's "easy proof" is providing a "global solution" to your problem. Locally one can argue as follows: A smooth surface $S\subset{\mathbb R}^3$ is produced by a $C^1$-map
$${\bf g}:\quad(u,v)\mapsto\left\{\eqalign{x&=g_1(u,v)\cr y&=g_2(u,v)\cr z&=g_3(u,v)\cr}\right.$$ with $d{\bf g}(u,v)$ having rank $2$ at all points $(u,v)$ in sufficiently small neighborhoods $U$ of ${\bf p}$. We may assume that
$$\det\left[\matrix{g_{1.u}&g_{1.v}\cr g_{2.u}& g_{2.v}\cr}\right]\ne0\qquad\bigl((u,v)\in U\bigr)\ .$$
By the inverse function theorem it follows that there is a neighborhood $V$ of ${\bf q}=\bigl(g_1({\bf p}), g_2({\bf p})\bigr)$ and a $C^1$-inverse ${\bf h}'=(h_1,h_2)$ of ${\bf g}'=(g_1,g_2)$ mapping $V$ onto $U$. This mapping ${\bf h}'$ computes $(u,v)\in U$ for given $(x,y)$ in $V$. From this we can conclude that $S$ can be as well be presented by the map
$${\bf f}:\quad(x,y)\mapsto\bigl(x,y,\>g_3\bigl(h_1(x,y),h_2(x,y)\bigr)\bigr)\ .$$
Letting
$$g_3\bigl(h_1(x,y),h_2(x,y)\bigr)=:f(x,y)$$
the surface $S$ appears as solution set of the equation
$$z-f(x,y)=0\ .$$
A: More generally, a smooth embedded   closed hypersurface  $S\subset \mathbb R^n$, compact or not, is indeed the zero locus of a smooth function $F:\mathbb R^n\to \mathbb R$ satisfying $dF(s)\neq 0$ for all $s\in S$ .
Proof:
There exists an open covering $\mathscr U=(U_i)_{i\in I}$ of $\mathbb R^n$, smooth functions $f_i$ on $U_i$ and smooth nowhere zero functions $g_{ij}$ on $U_i\cap U_j$ satisfying $S\cap U_i=f_i^{-1}(0)$, $df_i(s)\neq 0$ for $s\in S\cap U_i$ and $f_i=g_{ij}f_j$ on $U_i\cap U_j$.
[This is easily seen to be equivalent to the more orthodox  definition of closed submanifold]
The $g_{ij}$'s form a cocycle and thus  define a smooth line bundle $L$ on $\mathbb R^n$ which, like all line bundles on the contractible manifold $\mathbb R^n$, is trivial.
So our cocycle is a coboundary, which means that we can  find non vanishing smooth functions $g_i$ on $U_i$ such that $g_{ij}=g_j. g_i  
^{-1}$ on $U_i\cap U_j$.
We then have $f_ig_i=f_jg_j$ on $U_i\cap U_j$ so that these funtions $f_ig_i$ on $U_i$ glue to a global smooth function $F:\mathbb R^n\to \mathbb R$ satisfying $F\vert U_i=f_ig_i$, and $F:\mathbb R^n\to \mathbb R$  is the required equation for $S$: $$S=F^{-1}(0) \;\text{and}\; dF(s)\neq 0 \; \text {for every } \;s\in S$$
Remarks
1) Every closed subset of $\mathbb R^n$, smooth or not,  is the zero set of a global smooth function (Whitney) but of course one can say nothing a priori on the gradient of that function on the subset if it is not smooth.   
2) This proof uses tools introduced more than 60 years ago in complex analysis ("solution of Cousin II problem").
It is a bit depressing that less than  1% of graduate students (my guess) could come up with such an easy proof and that (to my knowledge) zero textbook on differential geometry/topology (excluding those devoted to complex analysis specifically)  contain the relevant material for such a proof.   
3) Notice carefully that the covering $\mathscr U=(U_i)_{i\in I}$ must cover all of $\mathbb R^n$, not just $S$ !
The best way to ensure this is to add to the covering the open set $U_0=\mathbb R^n\setminus S$ and to use the smooth function $f_0=1$ to describe  the intersection $S\cap U_0=\emptyset=f_0^{-1}(0)$.  
Edit
The line bundle $L$ defined by the $g_{ij}$'s restricts to the normal bundle of $S$ in $\mathbb R^n$: $L|S=N_{S/\mathbb R^n}$ (cf. "First adjunction formula", Grauert-Fritzsche, page 215).
Since $L$ is trivial, so is its restriction to $S$ and thus $S$ has a trivial normal bundle which proves that $S$ is orientable.
Thus the above answer also contains  this answer, whose technique I have shamefully plagiarized here.
