Showing range is countable Let $f: \mathbb{R} \to \mathbb{R}$.  For every $x \in \mathbb{R}$, there exists $\delta$, for every $y \in N(x, \delta)$ ($N$ stands for neighborhood) $f(y) \geq f(x)$.
Show that the range of $f$ is countable.
 A: In other words, $f$ has a local minimum everywhere. More generally, the same result holds if $f$ has a local extremum everywhere; according to this (Problem 2010-4/B), the result can be found in several places in the literature (a proof is also provided).
Interestingly, as a corollary in the case where $f$ is further continuous, we get an answer to this question (note my answer given there).
EDIT (elaborating on the second part): Suppose that $f:\mathbb{R} \to \mathbb{R}$ is continuous and has a local extremum everywhere. From the latter property, it follows that the range of $f$ is countable. Hence we conclude from the intermediate value theorem that $f$ must be constant (for otherwise the range would be uncountable, a contradiction).
A: Suppose $a$ is in the range of $f(x)$. Then if $x_0$ is any number such that $f(x_0) = a$, one can find an interval $[b,c]$ containing $x_0$ with $b$ and $c$ rational such that $f(x) \geq a$ on $[b,c]$. Thus $a \mapsto (b,c)$ gives a mapping from the range of $f(x)$ to ${\mathbb Q} \times {\mathbb Q}$, and this mapping is clearly injective. Hence the range of $f$ is countable.
