Let $S$ be a metric space, $ f: S \to \Bbb R$ continuous. Define $Z(f) = \{p \in S : f(p) = 0 \}$. Prove $Z(f)$ is closed. Let $S$ be a metric space, $ f: S \to \Bbb R$ continuous. Define $Z(f) = \{p \in S : f(p) = 0 \}$. Prove $Z(f)$ is closed.
I've come up with a proof... I just would like to know if it is logical enough or it needs to be improved upon somehow. It seems very long for a simple idea.
Below is my proof: 
Must show $\Bbb R \setminus Z(f)$ is open.
$\quad \Bbb R \setminus Z(f)= \{x: f(x) \ne 0\} = \{x: f(x) > 0\} \cup \{x: f(x) <0\}$
It's enough to show $\{x: f(x) > 0\}$ is open if $f$ is continuous, because $\{x: f(x) < 0\} = \{x: -f(x) > 0\}$, and $-f$ is continuous if $f$ is continuous. 
So, let $x \in \Bbb R$ be such that $f(x) > 0$. There exists $\epsilon > 0$ such that $f(x) > \epsilon$.
Say $\epsilon = \frac{f(x)}{2}$, since $f$ is continuous, there exists $\delta >0$ such that
$\quad |f(x) - f(y)| < \epsilon = \frac{f(x)}{2}$ if $|x-y| < \delta$
then,
$\quad-\frac{f(x)}{2} < f(y) - f(x) < \frac{f(x)}{4}$
so,
$\quad f(y) > f(x) - \frac{f(x)}{2} = \frac{f(x)}{2} > 0$
since $y$ with $|y - x| < \delta$ is arbitrary, $(x - \delta, x + \delta) \subset \{x : f(x) > 0 \}$
Therefore $Z(f)$ is closed.
 A: Another way is to use sequential characterization, so let $(p_{n})\subseteq Z(f)$ be such that $p_{n}\rightarrow p$ in $S$, then continuity of $f$ gives $f(p_{n})\rightarrow f(p)$. But $f(p_{n})=0$, so $f(p)=0$, this shows that $p\in Z(f)$, we are done.
A: One alternate definition of continuous is that $f$ is continuous if the preimage of any open set is open. If we can use that, then the result of immediate since $(-\infty,0)\cup(0,\infty)$ is open.
Starting with the $\epsilon-\delta$ version of continuity, you can fairly easily prove the first definition. Let $U$ be an open set, and take $y\in U$. We want to show that $f^{-1}(U)$ contains a neighborhood of $x$ for any $x\in f^{-1}(y)$. Well, since $y\in U$ and $U$ is open, there is an $\epsilon$-ball around $y$ in $U$. By continuity, there exists $\delta>0$ such that the $\delta$-ball around $x$ maps into the $\epsilon$-ball around $y$.
A: There's nothing wrong with your proof, except that you have to take the complement of $Z(f)$ in $S$, not in $\mathbb{R}$. Nevertheless, I would've argumented something similar to Elliot's answer but more straightforward: another equivalent definition of continuous map is that the preimage of a closed set is closed. In this case, $Z(f)=f^{-1}(\{0\})$. Since $\{0\}$ is closed, you're done.
