Continuity of a “level-set function” of a continuous function

Let $f:\mathbb{R}^2 \to \mathbb{R}$ be continuous. Suppose for any $x \in\mathbb{R}$, there exists a unique $y\in\mathbb{R}$ s.t. $f(x,y)=0.$ Define $g:\mathbb{R}\to\mathbb{R}$ s.t. $f(x,g(x))=0$ for all $x\in\mathbb{R}.$ Is $g$ such defined continuous?

My hunch is that the answer is yes, but I have some problem convincing myself. Let $x_0,y_0$ be s.t. $y_0=g(x_0)$ or $f(x_0,y_0)=0$. Let $\{x_n\}$ be any sequence that converges to $x_0$, and let $y_n := g(x_n)$ for all $n$, so that $f(x_n,y_n)=0$. Now by contradiction assume $y_n \not\to y_0$, then there is some $\epsilon>0$ s.t. there is an infinite subsequence $y_{n_k}$ s.t. $|y_{n_k}-y_0| \ge \epsilon$ for all $k$. I think this should lead to some contradiction, but I do not quite see how.

On the other hand, if the answer is in fact no---this is bit of a followup question---is there some convenient assumptions available that can be added to the problem to turn the answer into a yes?

• – Michael Hoppe Oct 4 '16 at 19:09
• @MichaelHoppe Thank you! The reference Kumagai (1980) mentioned there is particularly helpful. – Fang Jing Oct 4 '16 at 20:01

Following your beginning of proof, observe that if $(y_n)$ were a bounded sequence, by compactness you could extract a converging subsequence and obtain a contradiction. Thus the only way to make $g$ discontinuous is to have unbounded zeros.
A possibility is to consider the set $$E=\{0\}\cup \left\{\underline x=\begin{pmatrix} x\\y\end{pmatrix}:xy=1\right\}$$ and take the function $$f(x,y)=dist(\underline x, E)$$ which measures the distance from $E$. You can check that it has exactly one zero for every $x$, because the distance from a closed set is zero exactly on that set, and that $g$ is discontinuous at $x=0$. You can also make $f$ differentiable taking $f^2$.
Therefore a sufficient condition could be "the zeros are contained in a bounded stripe $\{|y|\leq M\}$ for some $M$".
If instead you require the function to be continuously differentiable, as noted in the comments the Implicit function theorem gives a sufficient condition, which in your case would be $\frac{\partial f}{\partial y}(x,y)\neq 0$ in all points where $f(x,y)=0$.