# Countable and uncountable sets and functions on them

A function $f:R→R$ is given. Whenever we choose real numbers $a < b$ and set {$f(x) : a < x < b$} has a biggest element, we call this element local maximum of function $f$. Prove that a set of all local maximums of function $f$ is countable.

I think it's impossible to prove, because local maximum is defined as a "peak" on graph, that means the nearest values should be lower. Because I work on $D_f=R$, I can limit my local $D_f$ to however small interval I want and on most of these will have their own peaks. And then I can limit it even more etc. Thus there should be uncountable infinity of those peaks, or local maximums.

IMHO it would be provable only if the function $f$ were either rising or falling (or whatever the name is - I mean that no two x will have the same $f(x)$)

That is probably wrong, but I'm not sure why. What is the proof here, or at least how should I change my mindset to solve these kinds of tasks. I'm new to problematic of sets so I might be missing some important idea.

• You can show that if $x$ is the local maximum for $a<b$, then it is a local maximum for $a'<b'$ where $a',b'\in\Bbb Q$. – Asaf Karagila Feb 8 '16 at 8:25
• If f(a) or f(b) is larger then all f(x) then your set will not have a largest if it is a continuous function. – Q the Platypus Feb 8 '16 at 8:35
• You and other should note that your terminology is not the standard. Also note that you're not guaranteed that there's a maximum on each open interval, but that may be interpreted as a property of $f$. – skyking Feb 8 '16 at 10:08

For $a,b \in \mathbb{R}$ let $$m(a,b) := \begin{cases} \max_{x \in (a,b)} f(x) & , \text{ local maximum exists in } (a,b) \\ -\infty & , \text{ otherwise} \end{cases}.$$ The set we are interested in is $LM := \{ m(a,b) : a,b \in \mathbb R\} \setminus \{-\infty\}$. For any fixed $a,b \in \mathbb R$ with $m(a,b) > - \infty$ there exists (by definition) $$a < x_0 < b$$ such that $f(x_0) = m(a,b)$. Since in between two real numbers there always exists a rational number, we can find $\bar a, \bar b \in \mathbb Q$ such that $$a < \bar a < x_0 < \bar b < b.$$ Hence, $m(\bar a, \bar b) = m(a,b)$. Note that we can do this for all pairs $(a,b)$. Hence, every local maximum is identified with a pair $(\bar a, \bar b) \in \mathbb Q^2$. It follows that $$LM \subseteq \{m(\bar a, \bar b) : a,b \in \mathbb Q\} = \bigcup_{(\bar a,\bar b) \in \mathbb Q^2} \{m(\bar a, \bar b)\}$$ The right hand side is a countable union of finite sets. Hence, it is at most countable and thus the left hand side is also countable.
• One could also note that $LM$ might be infinite as we could for example let $f(x) = x$ if $x\in \mathbb N$ and $f(x)=0$ otherwise - then $LM$ would be $\mathbb N$. – skyking Feb 8 '16 at 10:10