Continuous functions with finitely many zeros I was studying this question: Continuous map $f : \mathbb{R}^2\rightarrow \mathbb{R}$,
where it is said that if  a continuous function $f(x)$ from $R^2$ to $R$ has only finitely many zeros, then $f(x)$ greater equal to $0$ for all $x$ or $f(x)$ is less equal to zero for all $x.$ The solution given there is too big to think during time constraint exams so I have thought as below .

My Thought: I thought the function like $f(x,y) = z$, as the function is continuous the function will give a surface in $R^3$ now if the function is sometimes positive and sometimes negative it must pass through the $x-y$ plane
Thus the surface intersects the $x-y$ plane making a curve on $x-y$ plane
hence the function has got infinite zero contradicting the hypothesis of having finite zero.
Is there any problem in my thinking?
 btw I am totally new here and I am not used to with latex so sorry
 A: You have a good idea, but it is not a solution yet. Suppose $p,q \in R^2$ and $f(p)<0<f(q).$ Let $\gamma:[0,1]\to \mathbb R^2$ be a continuous curve with $\gamma(0)=p, \gamma(1)=q.$ Then $f\circ \gamma$ is a continuous function from $[0,1]$ to $\mathbb R$ such that $f\circ \gamma(0)=f(p),$ $ f\circ \gamma(1)=f(q).$ By the intermediate value theorem, $f\circ \gamma(c)=0$ for some $c\in (0,1).$ Now there are infinitely many such paths from $p$ to $q$ that are pairwise disjoint except for the endpoints. Thus $f$ has infinitely many zeros in the plane.
A: There are simpler proofs in the second and fourth comments bellow the answer.

The proof of "sign change implies infinitely many zeros" can indeed be shortened: Suppose, without loss of generality, that $f(−1,0)<0$ and $f(1,0)>0$. By continuity of $f$, there is $\delta > 0$ such that $f(−1,y)<0$ and $f(1,y)>0$ for $|y|<\delta$. For each $y$ with $|y|<\delta$, the intermediate value theorem implies there is a zero of $f$ on the horizontal segment $[−1,1]\times\{y\}$.
– Andrew D. Hwang Dec 9 '13 at 13:02
I have a suggestion which might simplify the proof of $f$ changes sign $\implies f$ has infinitely many zeroes. Assume that $f(x)<0$ and $f(y)>0$. Then for every continuous path $\phi_{xy}$ starting at $x$ and ending at $y$ the continuous function $f\circ\phi_{xy}$ changes sign, and so it has a zero by the intermediate value theorem. (P.S.: I had overlooked the similar idea user86418 [Andrew] has submitted before me.)
– Giuseppe Negro Dec 9 '13 at 13:11

What you wrote isn't a proof, because it's not rigorous (how do you know that the intersection forms a curve? and what kind of curve (e.g. continuous)?) To turn your idea into a proof you want to do something like in Giuseppe's comment (and zhw.'s answer).
Andrew's comment gives you explicit paths from $x$ to $y$. Namely, you go straight up, straight across and then straight down.
P.S. It is not clear what form the set $f^{-1}(0)$ should take. The case we are most used to is where we get a curve but it is also possible for a function to be flat on a 2 dimensional set. For example
$$ f(x,y) = \begin{cases} 0 & x^2 + y^2 \le 1 \\ x^2 + y^2 - 1 & \text{otherwise} \end{cases}. $$
