# Continuous functions that attain local extrema at every point

Let $f:[0,1]\to\mathbb R$ is a continuous function, and for all $x\in [0,1]$, $f(x)$ is either a local maximum or a local minimum. Then prove that $f$ is a constant.

Here is what I have tried, I don't know whether it is correct:

Assume $f$ is not a constant, by continuity, there exist $x_1$, $x_2$ such that $f(x_1)=m$ is a global minimum and $f(x_2)=M$ is a global maximum. Now if $m\ne M$, choose any $c\in(m,M)$ and define

$$x_0=\sup (x\in[x_1,x_2]:f(x)<c)$$

Then we have $f(x_0)$ NOT a local minimum nor a local maximum (since according to the definition of $x_0$, there are always some points $<c$ in the left neighborhood of $x_0$ and the points in right neighborhood are always $>c$). Contradiction arises and so $f$ must be a constant.

• I would probably just use the intermediate value theorem to get the existence of $x_0$ such that $f(x_0) = c$. – dannum Nov 24 '15 at 15:50
• I mean that can the function be extremely weird that it is locally constant everywhere but not constant as a whole. – Y.H. Chan Nov 24 '15 at 15:54
• In a right neighorhood of $x_0$, $f$ could attain the value $c$. – user60589 Nov 24 '15 at 15:56
• there is a function locally constant on a dense open set of measure $1$, yet not constant on $[0,1]$, Cantor staircase. But it is not a counterexample to the above problem, just shows one needs to be more careful with the proof. Hint: Use a nested sequence of intervals. – Mirko Nov 25 '15 at 1:39
• err, can't you just say that $f'(x)=0$? – tp1 Nov 25 '15 at 5:16

It is a funny countable vs uncountable argument, I least expected that. My hint (in the comments) to use a nested sequence of intervals only made me confused. (But it made me think that if $C$ is the union of all open intervals on which $f$ is locally constant then $f(C)$ is countable. I tinkered a bit with ideas like considering cases, whether $[0,1]\setminus C$ contains an open interval (then the proof by the OP works), or whether $C$ is dense, looked at $f([0,1])\setminus f(C)$ and at some point figured it was easier than that and I may formally forget about $C$, and ignore some irrelevant details.)

So say $f$ were not constant, hence $f([0,1])=[m,M]$ with $m<M$. For each $y\in[m,M]$ pick $x_y\in[0,1]$ with $f(x_y)=y$. Let $X=\{x_y:y\in[m,M]\}$. In other words we picked a set $X\subset[0,1]$ such that the restriction of $f$ to $X$ is one-to-one and onto $[m,M]$.

Let $T=\{x\in X: f$ has a local maximum at $x\}$ and $S=\{x\in X: f$ has a local minimum at $x\}$. Since $X=T\cup S$ and (cardinality) $|X|=|[m,M]|=\mathfrak c = 2^{\aleph_0}$, at least one of $T$ and $S$ is uncountable. Say $T$ is uncountable.

For each $x\in T$ pick $n_x\in\mathbb N$ such that $f(x)\ge f(z)$ whenever $z\in(x-\dfrac1n,x+\dfrac1n)\cap[0,1]$. Let $T_n=\{x\in X: n_x=n\}$. Clearly $T=\bigcup\limits_{n\in\mathbb N} T_n$, hence there is an $n$ for which $T_n$ is uncountable.

Then $T_n$ must have a limit point, i.e. a $t\in[0,1]$ such that every neighborhood of $t$ contains infinitely many elements of $T_n$. Hence we may pick two different points $p,q\in T_n$ each very close to $t$ and hence (absolute value) $|p-q|<\dfrac1n$. But this means $f(p)\le f(q)$ and $f(q)\le f(p)$, thus $f(p)=f(q)$, contradicting that the restriction of $f$ to $X$ were one-to-one.

• That's interesting. So there can be only countable many maximal and minimal values. But there are functions which are nowhere constant and have uncountable many local maxima like the Takagi function. – user60589 Nov 25 '15 at 12:46
• @user60589 Thank you for the link to the BGN paper in your answer, as well as for commenting here on Takagi function (new to me, need to think why it has uncountably many local maxima). In your answer I do not quite follow that "Thus the image of $f$ consists of all the existing minima and maxima of the $U_x$." (is it supposed to be obvious, or perhaps there are details in the paper that I need to look at, or I may figure it on my own; aren't "intermediate" values between maxima and minima also supposed to be in the image). – Mirko Nov 25 '15 at 16:03
• I haven't read it but in this paper there is a proof that the set of maximal points of the Takagi function has Hausdorff-Dimension $1/2$. – user60589 Nov 25 '15 at 16:41
• I was a imprecise. Hope now it is better. The value $f(x)$ is the minima or maxima of $U_x$ by choice of $U_x$ that's all. – user60589 Nov 25 '15 at 16:50
• @user60589 I read your answer one more time, I had forgotten to use that every $x$ is a local max or min point, which explain why the image of $f$ is the set of all local max or min values of $f$. Then use that a connected countable set of reals must be a singleton. Thank you! – Mirko Nov 25 '15 at 17:18

One reason why I quite like the problem is that it starts with a nice magic trick (a misdirection if you like). Since it is posed for continuous functions one immediately starts by thinking about that, when in fact you should be simply investigating the nature of the set of local extrema. As others have pointed out it is just a countable vs. uncountable situation that resolves the problem. Continuity just jumps in at the last moment to finish the argument.

I don't have any seriously new ideas but I would like to remind readers of a standard device in real variable arguments that works quite simply here too. It is worth keeping in your toolkit and has been used many, many times. So this is essentially the same proof as the others but with more of a real-variable feel, than a topological one.

Lemma. Let $f:\mathbb{R}\to\mathbb{R}$ and let $E$ be the set of points at which $f$ has a local maximum or a local minimum. Then there is a denumerable decomposition of $E$ into a sequence of sets $\{E_n\}$ such that $f$ is constant on each $E_n$.

Proof. Let $A$ be the set of points where $f$ has a local maximum. For each $x\in A$ there is a $\delta(x)>0$ so that $f(z)\leq f(x)$ for all $z\in (x-\delta(x),x+\delta(x))$.
Define the collection $$A_{nj} = \left\{ x\in A: \frac{1}{n} \leq \delta(x) < \frac1{n-1} \right\} \cap \left[ \frac{j}n, \frac{j+1}n \right)$$ for $n=1,2,3 \dots$ and $j=0, \pm 1, \pm 2, \pm 3, \dots$.

Suppose that $x$ and $y$ with $x<y$ belong to the same set $A_{nj}$. Then $$0< y-x < \frac1n \leq \delta(x) \implies f(y) \leq f(x)$$ while $$0< y-x < \frac1n \leq \delta(y) \implies f(x) \leq f(y) .$$ Thus $f$ is constant on each set $A_{nj}$. The same argument handles the set of points where $f$ has a local minimum. QED

Then, in order to misdirect our easily mislead students, we pose the problem this way:

Problem. Suppose $f:[0,1]\to\mathbb{R}$ is a continuous function and every point of $(0,1)$ with at most countably many exceptions is either a local maximum or a local minimum. Must $f$ be constant on $[0,1]$?

I am by no means an historian of mathematics, but that has never stopped me from speculating on the sources of ideas in analysis. I can trace this little technique back at least to

Beppo Levi, Richerche sulle funzioni derivate, Atti della Accademia Reale (Nazionale) dei Lincei, (1906).

So, as a particularly lazy historian, I am going to award the title to the Italian mathematician Beppo Levi [1875-1961] (not, it should be noted, one of the Marx brothers).

Theorem (Levi) Suppose that $f:\mathbb{R}\to\mathbb{R}$ has at each point $x$ of a set $E$ a finite right-derivative $f_+'(x)$ and a finite left derivative $f_-'(x)$. Then $f_-'(x)=f_+'(x)$ at all but countably many point of $E$.

His proof is just this (expressed similarly to the technique above). We can analyze the set where $f_-'(x)<f_+'(x)$ by considering the set
$$E^r= \{x\in E: f_-'(x)< r < f_+'(x)\}$$ for rationals $r$.

For each $x\in E^r$ there is a $\delta(x)>0$ so that $[f(z)-f(x)/[z-x]> r$ for all $z\in (x,x+\delta(x))$
and at the same time $[f(z)-f(x)/[z-x]< r$ for all $z\in (x-\delta(x),x)$.

Define the collection $$A_{nj} = \left\{ x\in E^r: \frac{1}{n} \leq \delta(x) < \frac1{n-1} \right\} \cap \left[ \frac{j}n, \frac{j+1}n \right)$$ for $n=1,2,3 \dots$ and $j=0, \pm 1, \pm 2, \pm 3, \dots$.

Now show that there cannot be two or more points in any set $A_{nj}$. That means that $E^r$ is countable and hence (since the rationals are countable) the set $\{x\in E: f_-'(x) < f_+'(x)\}$ is countable.

A very nice simple proof but, more importantly, a technique that can be and has been used a great many times.

For any $x\in [0,1]$ there is a open set $U_x \subset [0,1]$ such that $f$ restricted to $U_x$ is minimal or maximal at $x$. Thus the image of $f$ consists of all the existing minimal and maximal values of $f$ restricted the $U_x$.

Now since $[0,1]$ has a countable base we can choose the $U_x$ in a way that only countable many of them are distinct.

This shows that the image of $f$ is countable, but since it is also connected it has to be a point.

I found this proof here.

• Do indeed follow the link that @user60589 provided if you find the question interesting. It is to the paper by Behrends, Geschke, and Natkaniec, Functions for which all points are local extrema. Real Anal. Exchange 33 (2008), no. 2, 467–470. The question was asked in a Problem Session in the Czech Republic in 2006. It is curious that no-one has found an earlier reference. The question seems deceptively "obvious" until you come done to writing up a proof. The suggestion by the OP fails quickly, but so too does any shallow first attempt. – B. S. Thomson Nov 26 '15 at 0:35