TITLE: Nowhere monotonic continuous function
QUESTION [15 upvotes]: Does there exist a nowhere monotonic continuous function from some open subset of $\mathbb{R}$ to $\mathbb{R}$?
Some nowhere differentiable function sort of object?

REPLY [6 votes]: 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}).
$$

It's easy to see:

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

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.