Can there exist a non-constant continuous function that has a derivative of zero everywhere?

Somebody told me that there exists a continuous function with a derivative of zero everywhere that is not constant.

I cannot imagine how that is possible and I am starting to doubt whether it's actually true. If it is true, could you show me an example? If it is not true, how would you go about disproving it?


If it's differentiable at every point, then this can't happen. This follows from the mean value theorem:

If $f(x)$ is continuous on $[a,b]$ and differentiable on $(a,b)$, then for at least one point $c$ between $a$ and $b$, we have $$f'(c) = \dfrac{f(b)-f(a)}{b-a}.$$

If your $f(x)$ is not constant, but is differentiable everywhere, pick an $a$ and $b$ with $f(a)\neq f(b)$. By the MVT, we have $$f'(c) = \dfrac{f(b)-f(a)}{b-a} \neq 0$$ since $f(b) \neq f(a)$.

On the other hand, if you assert your function is differentiable only "almost everywhere" instead of "everywhere" (in a sense which can be made precise) and that the derivative "almost everywhere" is equal to $0$, then this can happen. The standard example is Cantor's function (also known as the Devil's Staircase). See http://en.wikipedia.org/wiki/Cantor_function.


Since there are no restrictions on the domain, it is actually possible. Let $f:(0,1)\cup(2,3)\to \mathbb R$ be defined by $f(x)=\left\{ \begin{array}{ll} 0 & \mbox{if } x \in (0,1) \\ 1 & \mbox{if } x\in (2,3) \end{array} \right.$