Is this condition sufficient to ensure monotonicity of a function?

Suppose $f:[a,b]\to\mathbb{R}$ is continuous and

$$\limsup_{h\to0}\frac{f(x+h)-f(x)}{h}\geq0$$

for every $x\in(a,b)$. Does it follow that $f$ increases monotonically on $[a,b]$?

It is a problem in the 4th edition of Royden's Real Analysis (Exercise 19, Ch. 6) to prove under these hypotheses that $f$ is in fact nondecreasing. But that problem is listed in the errata for the text, where it says to replace $\limsup$ with $\liminf$ (which obviously makes the problem much easier).

However, no counterexample is given in the errata, and I'm not sure whether it's false as stated or just hard to prove (or neither; maybe I'm just not seeing a simple solution!).


I think Weierstrass function is a counterexample.

Also, consider the following example:

Let $f:[0, \frac{1}{12}] \rightarrow {\mathbb R}$ be defined the following way:

$f(0.a_1a_2\ldots a_n\ldots)=0.b_1b_2b_3\ldots b_n\ldots$

where $b_i=0$ if $a_i=a_{i+1}$ and $b_i=1$ otherwise.

Then for each $x$ and each $\epsilon_1, \epsilon_2 >0$ it is easy to find a $y$ so that $0< |x-y| < \epsilon_1$ and $|f(x)-f(y)|<\epsilon_2$.

This shows that $f$ is not increasing and that the limit is $\geq 0$.

P.S. This is actually the first example of continuous non-differentiable function I saw.

Edited: The following example is actually easier to work with:

If we change a litle the function, namely $b_i=0$ if $a_i-a_{i+1}\in \{0, \pm 1 , \pm 9\}$ and $b_i=1$ otherwise it is easy to show that for each $x$ and each $\epsilon>0$ it we can find a $y$ so that $0< |x-y| < \epsilon$ and $f(x)=f(y)$.

This simple fact ensures that the function is a counterexample.

Added Here are the worked details, change a little more the function to make everything work smootly:

Consider the following example:

Let $f:[0, \frac{1}{2}] \rightarrow {\mathbb R}$ be defined the following way:

$f(0.a_1a_2\ldots a_n\ldots)=0.b_1b_2b_3\ldots b_n\ldots$

where $b_i=0$ if $a_{2i-1}-a_{2i} \in \{0, \pm 1 , \pm 9\}$ and $b_i=1$ otherwise.

To make things clear, whenever a number $x$ has two decimal representations we use the $.a_1a_2\ldots a_n0000.000\ldots$ one.

We show that for each $x \in [0, \frac{1}{2}]$ and each $\epsilon >0$ we can find a $y$ so that $0< |x-y| < \epsilon$ and $f(x)=f(y)$.

Pick an $m$ so that $\frac{1}{10^{2m}} < \epsilon$.

Let $x=.a_1a_2\ldots a_n\ldots$.

We define $y=.a_1a_2\ldots a_{2m}ba_{2m+2}\ldots$ where

$$b=\begin{cases} a_{2m+2} & \text{if $a_{2m+1}-a_{2m+2} \in \{\pm 1 , \pm 9\}$} \\ 1 & \text{if $a_{2m+1}=a_{2m+2}=0$} \\ a_{2m+1}-1 & \text{if $a_{2m+1}=a_{2m+2} \neq 0$} \\ a_{2m+1}+2 & \text{if $a_{2m+1} \in \{0,1\}$ and $a_{2m+1}-a_{2m+2} \notin \{0, \pm 1 , \pm 9\}$} \\ a_{2m+1}-2 & \text{otherwise} \end{cases} $$

We only change $x$ in the $2m+1$ possition no matter what $a_{2m+1}, a_{2m+2}$ are we have at least one choice left for $b$ to produce the same value of the function.

Then $y \neq x$, $|y-x|\leq \frac{1}{10^{2m}}$ and $f(x)=f(y)$. This shows both that the functions is not increasing and that

$$\limsup_{x \to x_0} \frac{f(x)-f(x_0)}{x-x_0} \geq 0 \,.$$