Can a function have a strict local extremum at each point? A problem given in Spivak's Calculus text is to show that a function $f:[a,b]\to \mathbb{R}$ cannot have a strict local maximum at each point. I will sketch the proof below the fold.
My question is: can a function $f:[a,b]\to \mathbb{R}$ have a strict local extremum at each point, perhaps a combination of strict local minima and maxima? 
If there did exist such a function, the sets $\{x: x\text{ a strict local maximum}\}$ and $\{x: x\text{ a strict local minimum}\}$ must both be dense, since if not, once we get our hands on an interval which contains only one type of extremum, the proof goes forward as before.
Addendum: Such a function, if it were to exist, could not be continuous on any nonempty open set, because I claim a continuous function with a local (non-strict) extremum at each point must be a constant, which is a contradiction, because a constant function has no strict extrema.

Proof that $f:[a,b]$ cannot have a strict local max at each point: Suppose $f$ is such a function. take any point $x_1$ in $[a,b]$ and surround it with an interval $[a_1,b_1]$ such that $0<b_1-a_1< \frac12 (b-a)$ such that $f(x)<f(x_1)$ for all $x\in [a_1,b_1]$. Now take any point in $[a_1,b_1]$ and get an interval $[a_2,b_2]$, again reducing the length by at least half, and so on. These intervals must have a common point $p$, which cannot be a local maximum, since it has points $x_i$ arbitrarily close to it such that $f(x)>p$.
 A: No.
It follows from the fact that a function can have only countably many strict local maxima and minima.
For proof, see Countability of local maxima on continuous real-valued functions
Part 1. Although continuousness is mentioned in the question, it isn't needed.
A: I think your inquiry comes from  Chapter 11 Question 71b) of Spivak's Calculus Edition IV, which reads as follows:

Suppose that every point is a local strict maximum point for $f$. Let $x_1$ be any number and choose $a_1 \lt x_1 \lt b_1$ with $b_1-a_1 \lt 1$ such that $f(x_1) \gt f(x)$ for all $x \in [a_1,b_1]$. Let $x_2 \neq x_1$ be any any point in $(a_1,b_1)$ and choose $a_1 \leq a_2 \lt x_2 \lt b_2 \leq b_1$ with $b_2-a_2 \lt \frac{1}{2}$ such that $f(x_2) \gt f(x)$ for all $x$ in $[a_2,b_2]$. Continue in this way, and use the Nested Interval Theorem (Problem 8-14) to obtain a contradiction.

It seems as though there are several typos in Spivak's proposed approach; however, the theme of the method is valid, and we can proceed as follows:

Suppose that every point in $\text{dom}(f)$ is a local strict maximum point of $f$. Consider an arbitrary $x_1$. By definition, there is a $\delta \gt 0$ such that for any $x \in (x_1 - \delta, x_1 + \delta) \setminus \{x_1\}$: $f(x_1) \gt f(x)$. Now, let $\delta_1 \lt\min\left(\delta,\frac{1}{1\cdot2}\right)$ and choose an $a_1,b_1 \in (x_1-\delta_1,x_1+\delta_1)\setminus \{x_1\}$ such that $a_1 \lt x_1 \lt b_1$. We see that for any $x \in [a_1,b_1] \setminus \{x_1\}$: $f(x_1) \gt f(x)$. Importantly, note that $x_1 \in [a_1,b_1]$ and $|a_1 - b_1| \lt \frac{1}{1}$.
Next, consider any $x_2 \in (a_1,x_1)$. By definition, there is a $\delta$ such that for any $x \in (x_2 - \delta, x_2+\delta) \setminus \{x_2\}$: $f(x_2) \gt f(x)$. Let $\delta_2 \lt\min\left(\delta, \frac{1}{2 \cdot 2},|x_1-x_2|,|a_1-x_2|\right)$ and choose an $a_2,b_2 \in (x_2-\delta_2,x_2 + \delta_2)\setminus\{x_2\}$ such that $a_2 \lt x_2 \lt b_2$. Note that $x_1 \notin [a_2,b_2]$ and $x_2 \in [a_2,b_2]$. Therefore, we can say that for all $x \in [a_2,b_2] \setminus \{x_2\}$: $f(x_2) \gt f(x)$. Further, from our definition of $\delta_2$, we have that: $\delta_2 \lt x_1 - x_2$. Because $x_1 \lt b_1$, we have $x_1 - x_2 \lt b_1 -x_2$. Together, we have $\delta_2+x_2 \lt b_1$. But $b_2 \lt x_2 + \delta_2$, so we conclude that $b_2 \lt b_1$. Similarly, we know that $-\delta_2 \gt a_1 - x_2$. This implies that $-\delta_2 + x_2 \gt a_1$, but $a_2 \gt x_2 -\delta_2$. Therefore, we must have $a_2 \gt a_1$, which means that $a_1 \lt a_2 \lt b_2 \lt b_1$, where $|a_2 - b_2| \lt \frac{1}{2}$.
We can continue in this fashion for any $n \in \mathbb N$, which allows us to make two intermediate conclusions:

*

*Noting that for any $n$ we have $0 \lt |a_n -b_n| \lt \frac{1}{n}$, we must have that $\displaystyle \lim_{n \to \infty} |a_n-b_n|=0$.


*Letting $I_n=[a_n,b_n]$, we have that for any $n$: $I_{n+1} \subset I_n$.
Under these conditions, we have that $\bigcap _{i=0}^\infty I_n \neq \emptyset$. In particular, we have that  $\bigcap _{i=0}^\infty I_n \neq \emptyset$ is a singleton. Call this element $x^*$. By assumption, $x^*$ is a local strict maximum point of $f$, which means there is a $\delta^*$ such that for all $x \in (x^*-\delta^*,x^*+\delta^*) \setminus\{x^*\}: f(x^*) \gt f(x)$ $\quad(\dagger_1)$.
However, note that by the Archimedean Property, there is an $n$ such that $\frac{1}{n} \lt \delta^*$. Consider the $I_n$ whose total length $|a_n-b_n| \lt \frac{1}{n}$. Because $x^* \in [a_n,b_n]$, it must be the case that all of $[a_n,b_n]$ fits inside $ (x^*-\delta^*,x^*+\delta^*)$. i.e. $[a_n,b_n] \subset (x^*-\delta^*,x^*+\delta^*)$. By construction, we know that all $x \in [a_n,b_n]\setminus {x_n}$ satisfy $f(x_n) \gt f(x) \quad (\dagger_2)$. More importantly, by construction, we also know that $x_n \notin [a_{n+1},b_{n+1}]$. This implies that $x_n \neq x^*$. $(\dagger_2)$ would therefore imply that $f(x_n) \gt f(x^*)$, which would contradict $(\dagger_1)$ because $x_n \in (x^*-\delta^*,x^*+\delta^*) \setminus\{x^*\}$.
So it must be the case that not every point in $\text{dom}(f)$ is a local strict maximum point of $f$.
