TITLE: Does there exist a continuous function from [0,1] to R that has uncountably many local maxima?
QUESTION [28 upvotes]: Does there exist a continuous function from $[0,1]$ to $R$ that has uncountably many strict local maxima?

REPLY [14 votes]: For any local maximum $x$, there are rational numbers $r<x<s$ such that $f(a)<f(x)>f(b)$ for all $r<a<x<b<s$. If $y$ is some other local maximum satisfying this condition for the same rational numbers $r,s$, then assuming WLOG that $x<y$, the condition on $x$ implies that $f(x)>f(y)$ and the condition on $y$ implies $f(x)<f(y)$, a contradiction. Thus to any pair $(r,s)\in\Bbb Q^2$ there is at most one local maximum associated with it.
This implies that there is a surjection from a subset of $\Bbb Q^2$ to the set of local maxima, so there are countably many strict local maxima. As pointed out in the other answers, it is not necessary to assume $f$ is continuous.

This proof even extends to weak local maxima, although the theorem statement needs to be tweaked since a constant function would be a trivial counterexample. Given $f:\Bbb R\to\Bbb R$, let $M$ be the set of non-strict local maxima. Then $f(M)$ is countable. To prove it, let $x\in M_{r,s}$ if $x\in(r,s)$ and $f(a)\le f(x)$ for all $a\in(r,s)$. Then if $x,y\in M_{r,s}$ then $f(x)\le f(y)$ and $f(y)\le f(x)$, so $f(M_{r,s})$ is a subsingleton. Since $M=\bigcup_{r,s\in\Bbb Q}M_{r,s}$, it follows that $f(M)=\bigcup_{r,s\in\Bbb Q}f(M_{r,s})$ is countable.