TITLE: Are continuous functions monotonic for very small ranges?
QUESTION [15 upvotes]: So I am wondering, if we have a continuous function $f : A \to B$, does a range $[x, x + h]$ exist for each $x\in A$ , $h = h(x)>0$ so that $f$ is monotonic in that range?

REPLY [4 votes]: Here's an explicit, elementary construction of a continuous but nowhere monotone function, without any appeal to differentiability:
The construction proceeds in phases, with the invariant that after phase $k$, we have chosen finitely many points of the function's graph, such that

The horizontal distance between two neighboring points is at most $2^{-k}$, and
The slope of the straight line between neighboring points is $\pm\frac{k}{k+1}$, with the sign alternating.

In phase $0$, select the points $(0,0)$ and $(1,0)$
In phase $k\ge 1$, insert two new points between every two neighboring known points $p$ and $q$. Suppose the slope from $p$ to $q$ is positive (namely $\frac{k-1}{k}$); the negative case is the same with opposite signs. Now draw parallel lines of slope $\frac{k}{k+1}$ through $p$ and $q$, and intersect them with the line of slope $-\frac{k}{k+1}$ through the midpoint $\frac12(p+q)$. The two intersections are our two new points. Since $\frac{k}{k+1}>\frac{k-1}{k}$, the two new points will appear in the right order.
After $\omega$ phases, we have selected values for our function at a dense set of $x$ values in $[0,1]$, and restricted to this set the function is uniformly continuous, due to the slope invariant. Therefore it can be uniquely extended to a continuous function $[0,1]\to\mathbb R$.
The extended function is non-monotonic in every open interval. Namely, after finitely many of the phases, at least three points in the interval will have been chosen. If $a,b,c$ are such three consecutive points, $f(b)$ will either be larger than both of $f(a)$ and $f(c)$ or smaller than both of them; in either case $f$ is not monotone in the interval.