Countability of local maxima on continuous real-valued functions I am working through a bank of previous exams and couldn't figure a problem out to my satisfaction.


  Let $f(x) : \mathbb{R} \to \mathbb{R}\,$ be a continuous function.
  
  
  Show that $f$ can have at most countably many strict local maxima.
  Assume that $f$ is not monotone on any interval. Then show that the local
  maxima of $f$ are dense in
  $\mathbb{R}$.
For each $\delta&gt;0$, the set of all $x\in\mathbb{R}$ such that $f(y)&lt;f(x)$ for all $y$ with $0&lt;|x-y|&lt;\delta$ is countable.  This can be seen by noting that the set contains at most one element of the interval $[k\frac{\delta}{2},(k+1)\frac{\delta}{2}]$ for each integer $k$, and these intervals cover $\mathbb{R}$.  The set of strict local maxima is a countable union of such sets, for example taking $\delta=\frac{1}{n}$ as $n$ ranges over the positive integers.
Suppose that $f$ is a continuous function that is not monotone on any interval.  We want to show that $f$ has a local maximum in every interval.  The argument is the same if the interval is $(0,2)$, so to slightly reduce notation let's work there.  Note that not being monotone in any interval means that each interval contains pairs $x_1&lt;x_2$ and $y_1&lt;y_2$ such that $f(x_1)&lt;f(x_2)$ and $f(y_1)&gt;f(y_2)$.  So $(0,1)$ contains a pair $x_1&lt;x_2$ such that $f(x_1)&lt;f(x_2)$, and $(1,2)$ contains a pair $y_1&lt;y_2$ such that $f(y_1)&gt;f(y_2)$.  Because $f$ is continuous, there is a point $x_0\in [x_1,y_2]$ where $f$ has its maximum value.  Because $f(x_2)&gt;f(x_1)$ and $f(y_1)&gt;f(y_2)$, $x_0$ is not an endpoint of $[x_1,y_2]$.  Therefore $f$ has a local maximum at $x_0$.
For #1, prove that you can find disjoint intervals around each local maximum. Then pick a rational number in each interval.

Edit: This answer is wrong but the comments below are instructive, so I'll leave it here.