Nowhere monotonic continuous function

Solution 1:

The Weierstrass function, mentioned in other answers, is indeed an example of a nowhere monotone function, meaning that $f$, even though continuous and bounded, is increasing at no point, decreasing at no point (and differentiable at no point as well). Details of this can be found in Example 7.16 in van Rooij, and Schikhof, A second course on real functions, Cambridge University Press, 1982.

That $f$ is increasing at $a$ means that there is a neighborhood $I$ of $a$ such that if $t<a$ is in $I$, then $f(t)\le f(a)$, and if $t>a$ is in $I$, then $f(t)\ge f(a)$. Thus, $f$ not increasing at $a$ iff any neighborhood of $a$ has points $t$ such that $(f(t)-f(a))(t-a)<0$. Being decreasing at $a$ can be stated similarly. See here.

We know that if $f$ is differentiable at $a$ and $f'(a)>0$ then $f$ is increasing at $a$, and if $f'(a)<0$, then $f$ is decreasing at $a$, so if a nowhere monotone function has a point $a$ in its domain where $f'(a)$ exists, then we must have $f'(a)=0$. It is indeed possible for a non-constant continuous increasing function $f$ to satisfy $f'(a)=0$ almost everywhere (we say that $f$ is singular). (Of course, if $f'(a)=0$ everywhere, then $f$ is constant.) The best known example of this phenomenon is Cantor's function, also known as the Devil's staircase (The link goes to O. Dovgoshey, O. Martio, V. Ryazanov, M. Vuorinen. The Cantor function, Expositiones Mathematicae, 24 (1), (2006), 1-37).

The above being said, note anyway that being increasing at a point is far from being increasing in a neighborhood of the point. If we require that $f$ is differentiable (and not constant), then there will be points $a$ where $f'(a)>0$ (so $f$ is increasing at $a$) or $f'(a)<0$ (so $f$ is decreasing at $a$). Nevertheless, as shown for example in Katznelson and Stromberg (Everywhere differentiable, nowhere monotone, functions, The American Mathematical Monthly, 81, (1974), 349-353) we can still find differentiable functions $f$ that are monotone on no interval. (I briefly state some properties of their example here; there used to be an accessible link to the paper, but apparently that is no longer the case.)

Solution 2:

I was writing up a "continuous" construction for another question that got deleted. Though very belated, this idea seemed sufficiently simple and self-contained to be worth posting.


Fix an arbitrary interval $[a, b]$, and let $f_{0}$ be an arbitrary non-constant affine function on $[a, b]$.

Inductively, if $f_{n}$ is a piecewise-affine function on $[a, b]$ (not constant on every interval), obtain $f_{n+1}$ by performing the following construction on each affine segment of the graph:

Let $(a_{1}, b_{1})$ and $(a_{2}, b_{2})$ be arbitrary points not lying on a horizontal or vertical line. Replace the (black) segment from $(a_{1}, b_{1})$ to $(a_{2}, b_{2})$ with the (blue) three-segment zig-zag path having vertices $$ (a_{1}, b_{1}),\qquad \bigl(\tfrac{1}{3}(a_{1} + 2a_{2}), \tfrac{1}{3}(2b_{1} + b_{2})\bigr),\qquad \bigl(\tfrac{1}{3}(2a_{1} + a_{2}), \tfrac{1}{3}(b_{1} + 2b_{2})\bigr),\qquad (a_{2}, b_{2}). $$ Recursive step for a continuous, nowhere-monotone function

It's easy to see:

  • The sequence $(f_{n})$ converges uniformly to a continuous function $f$ on $[a, b]$.

    Approximating a continuous, nowhere-monotone function

  • If $n$ and $k$ are non-negative integers, the functions $f_{n}$ and $f_{n+k}$ (and therefore $f_{n}$ and $f$) agree at every "$3$-adic point", i.e., every point of the form $a + \frac{m}{3^{n}}(b - a)$ with $0 \leq m \leq 3^{n}$. (Geometrically, the recursive construction does not change the values at the endpoints of each "affine segment".)

  • For each $n \geq 0$, and for $0 \leq m < 3^{n}$, the function $f_{n+1}$ (and therefore $f$ itself) is not monotone on $\bigl[a + \frac{m}{3^{n}}(b - a), a + \frac{m+1}{3^{n}}(b - a)\bigr]$.

    Every open subinterval of $[a, b]$ contains some interval of this form.

Solution 3:

Check my answer to this question:

Is this condition sufficient to ensure monotonicity of a function?

For that function, there are enough details so you can prove the following:

For any $x \in (0,1)$ and any $\epsilon >0$ there exists a $y$ so that $0< |x-y| < \epsilon$ and $f(x)=f(y)$.

That function is continuous, nowhere differentiable and the above result shows that it cannot be monotonic at any point, since it is not locally constant.