Solid torus is a 3-manifold. I'm working on a problem from Munkres' Analysis on Manifolds, where I must show that a solid torus is a 3-manifold, and that the boundary of this manifold is the torus $T$.
Letting $g$ be the cylindrincal coordinate transformation defined by
$$
g(r,\theta,z)=(r\cos\theta,r\sin\theta,z),
$$
the solid torus is the image under $g$ of all triples $(r,\theta,z)$ for which $z^2\leq a^2-(r-b)^2$ for $0\leq\theta\leq2\pi$, and where $a$ is the half the "thickness" of the torus and $b$ is the radius of the torus.
The textbook asks to first represent the torus $T$ in Cartesian coordinates, and then use following fact:

Theorem: Let $\mathcal O$ be open in $\mathbf R^n$; let $f:\mathcal O\to\mathbf R$ be of class $C^r$. Let $M$ be the set of points $\mathbf x$ for which $f(\mathbf x)=0$; let $N$ be the set of points for which $f(\mathbf x)\geq0$. Suppose $M$ is non-empty and $Df(\mathbf x)$ has rank $1$ at each point of $M$. Then $N$ is an $n$-manifold in $\mathbf R^n$ and $\partial N=M$.

What I've done so far: I haven't gotten far, unfortunately. Reading the theorem, my guess is that we let $\mathcal O$ be an open set containing the solid torus, and construct some real-valued $C^r$ function $f$ so that $f(\mathbf x)>0$ if $\mathbf x$ is inside the torus, and $f(\mathbf x)=0$ if $\mathbf x$ lies on the surface of the torus, or outside the torus. The only function that comes to my mind right now is a distance metric $f(\mathbf x)=d(\mathbf x,T)$ that measures the distance between $\mathbf x$ and $T$ (the torus's surface), except this function doesn't handle the points outside of the torus correctly.
Is this general approach correct? If so, how should I represent $T$ in Cartesian coordinates, and how do I show that $Df(\mathbf x)$ has rank 1 at each point of $M$? I understand that $Df$ should be a $1\times3$ matrix, of course.
Thank you in advance.
 A: Let $g : \mathbb{R}_+^* \times\mathbb{S}^1\times \mathbb{R} \to \mathbb{R}^3\setminus (\{0\}\times\{0\}\times \mathbb{R})$ be the cynlindrical coordinates, say $g(r,e^{i\theta},z) = (r\cos\theta,r\sin\theta,z)$ It is a diffeomorphism.
Let $h : \mathbb{R}_+^* \times\mathbb{S}^1\times \mathbb{R} \to \mathbb{R}$ be the function defined by $h(r,e^{i\theta},z) = a^2 -(r-b)^2 - z^2$. It is a smooth function.
Consider $f : \mathbb{R}^3 \setminus\left(\{0\}\times\{0\} \times \mathbb{R} \right) \to \mathbb{R}$ defined by $f = h \circ g^{-1}$. Show it has rank $1$. Then $\overline{\mathbb{T}^3} = f^{-1}(\mathbb{R}^+)$ is a manifold with boundary $f^{-1}(\{0\})\simeq \mathbb{T}^2$.
A: In cartesian coordinate, a point $(x,y,z) \in \mathbb R^3$ belongs to the solid torus iff 
$$f(x,y,z) = a^2 - \left(\sqrt{x^2+y^2}-b\right)^2 - z^2 \ge 0$$
From there, you get
$$Df(x,y,z) = \begin{cases}
-\frac{2x}{\sqrt{x^2+y^2}}\left(\sqrt{x^2+y^2}-b\right)\\
-\frac{2y}{\sqrt{x^2+y^2}}\left(\sqrt{x^2+y^2}-b\right)\\
-2z
\end{cases}$$
Which is never vanishing as you can't have $x=y=z=0$ .
From there, you get the expected result. And the boundary of the solid torus... is the "surface torus".
