# An applet illustrating a continuous, nowhere differentiable function

Open any calculus book and you will find a discussion about how differentiability implies continuity, but continuity does not imply differentiability. The absolute value function is the standard example of a continuous function that is not differentiable (at $x=0$).

The inquisitive student may ask: how bad can continuous, nondifferentiable functions get? Can we make a function nondifferentiable at an infinitely many points? At a dense collection of points? At every point?

This is the topic in the Real Analysis class I’m teaching right now. Surprisingly, there are functions that are continuous everywhere, but differentiable nowhere! More surprisingly, it is possible to give an explicit formula for such a function.

Weierstrass was the first to publish an example of such a function (1872). It appears that Bolzano had an example as early as 1830, but it wasn’t published until much later.

The example I gave in class is called the Blancmange function (and the graph is called the Takagi fractal curve).

Let $h(x)$ be the sawtooth function equal to $|x|$ on $[-1,1]$ and repeated periodically elsewhere.

Let $h_n(x)=h(2^n x)/2^n$.

Then $g(x)=h_0(x)+h_1(x)+h_2(x)+\cdots$, the graph of which is shown below, is a continuous and nowhere differentiable. I created a Geogebra applet to help the students visualize the construction of this function. Although this seems like a crazy example, it turns out that most continuous functions are nowhere differentiable (there is a technical meaning for “most”). The nice functions that we see every day in our calculus classes are rare.

1. The applet is great!

Another interesting example arises when the series is made alternating:
f(x)=h_0(x)-h_1(x)+h_2(x)-h_3(x)+\cdots

I did not try to prove that f is nowhere differentiable, but since its graph is nowhere rectifiable, chances are that it is. However, the graph of f does not contain any cusps that are prominent in the graph of g. Formally, the oscillation of f on any interval [a,b] does not exceed C*|f(a)-f(b)|, where C is a universal constant. Geometrically, this means that the graph of f is a quasi-arc.

Inspired by your applet, I created a similar one for the alternating series (linked).

1. Beautiful! Thank you for sharing your modified version of the function. I like it very much.

2. Glad you liked it!. A correction to what I wrote: the oscillation of f on any interval [a,b] does not exceed C*(|a-b|+|f(a)-f(b)|).

2. drj11 says:

nice.

Your graph has a suspiciously straight section at around x =0.7

1. I noticed that there are a few weird spots on it. I don’t think it is my fault… I’ll blame Geogebra :-)

3. Kate Nowak says:

There’s a Facebook app called “what mathematical function are you?” And if you answer with all the most sociopathic, disturbed responses, it tells you you are a Weierstrass function. That thing is UGly.

I was a tangent function. I don’t remember why and excuse me, I just saw something shiny.

1. Excellent! I’d try it out, but I’m terrified of Facebook apps. I have this irrational fear that when I do one quiz, some unknown app-writer will suddenly start browsing photos of my kids… (What kind of function does that make ME?)

4. Kumar says:

How about “R(x) = 1 if x is rational and 0 otherwise”?

1. That function would be nowhere continuous (and hence nowhere differentiable).