A CONTINUOUS AND
NOWHERE DIFFERENTIABLE
FUNCTION, FOR MATH 320
This note is a demonstration of some of the details in Abbott’s construction of a nowhere differentiable continuous function. The discovery of this theorem is often attributed to Weierstrass, who stunned
the mathematical community in 1872 with his construction of an infinite family of such examples (google ‘weierstrass nowhere differentiable
function’ for a rabbit hole!), though it seems to have been known to
Bolzano fifty years prior [Kle93, p. 201]. In the construction below,
we follow Abbot [Abb01, §5.4, p. 144] closely, filling in answers to the
exercises.
Theorem 1. There exists a function g : R → R that is nowhere differentiable and continuous.
The construction of the function is not hard, but analysis of the
function will require some care, so here we go. For each x ∈ R, choose
an l ∈ Z so that x ∈ [2l − 1, 2l + 1], and let h(x) = |x − 2l|. Note that
our definition of h is a bit unclear at odd integers, since, at x = 5 for
instance, we could choose either l = 2 or l = 3 (since 2(2)+1 = 2(3)−1).
On the other hand, the function h(x) is easily checked to be well-defined
(e.g. |5 − 2(2)| = |5 − 2(3)| in the example above). The graph of h is
below in Figure 1.
For each k ∈ N, let
hk (x) =
1
h(2k x).
k
2
Graphs of hk (x), for several small values of k, are pictured in Figure 2.
Since |h(x)| ≤ 1 for all x ∈ R, we have |hk (x)| ≤ 1/2k−1 for each k and
Figure 1. The graph of h(x).
1
2
A CONTINUOUS AND NOWHERE DIFFERENTIABLE FUNCTION
Figure 2. The graph of hk (x), for k = 1, 2, 3, 4
.
x. Thus the sum defined by
g(x) =
∞
X
hk (x)
k=0
converges absolutely by the comparison test, and g is a function defined
on R.
The problem remains to explore finer properties of g, like continuity
and differentiability. As we described in class, it is not hard to describe
hk (x) in terms of the binary expansion of x, and this perspective will
make our analysis easier. We make the following definition:
Definition. Given k ∈ N ∪ {0}, and x ∈ R with binary expansion
x = . . . a0 . a1 a2 . . . ak−1 ak ak+1 . . . ,
P∞
so that x = i=−∞ ai 2−i , let [x]k denote the real number with binary
expansion
[x]k := . 0 0 . . . 0 ak ak+1 . . . ,
P∞
so that x = i=k ai 2−i .
Lemma 2. If x has binary expansion as above, then we have
if ak = 0
[x]k
hk (x) =
1
− [x]k if ak = 1.
2k−1
Further, if x, y ∈ R have the same kth digit in their binary expansions,
then we have
[x]k − [y]k if ak = 0
hk (x) − hk (y) =
[y] − [x] if a = 1.
k
k
k
Proof. If the binary expansion of x is as above, then the binary expansion of 2k x is given by
2k x = . . . a0 a1 a2 . . . ak−1 ak . ak+1 . . . .
A CONTINUOUS AND NOWHERE DIFFERENTIABLE FUNCTION
3
In that case, h(2k x) is given by:
if ak = 0
ak . ak+1 ak+2 . . .
h(2k x) =
2 − ak . ak+1 ak+2 . . . if ak = 1.
Dividing by 2k shifts the decimal place back, and hk (x) is as claimed.
The second claim follows from the evident fact that (2−k−1 − [x]k ) −
(2k−1 − [y]k ) = [y]k − [x]k .
Note that it is immediate that any real number with a finite binary
expansion has hk (x) = 0 when k is bigger than the largest non-zero
index in the expansion of x. For instance, let xm = 1/2m . It is straightforward to check that [xm ]k = xm for k ≤ m, while [xm ]k = 0 for k > m,
so that the above lemma implies that
xm if k ≤ m
hk (xm ) =
0
if k > m,
and we have
g(xm ) =
∞
X
hk (xm ) =
k=0
m
X
k=0
xm =
m+1
.
2m
Plugging in to the difference quotient,
g(xm ) − g(0)
= 2m g(xm ) = m + 1.
xm − 0
We may conclude that g is not differentiable at 0. In fact, the case of
any dyadic rational is similar:
Lemma 3. Let c = p/2n be a dyadic rational. Then g is not differentiable at c.
Proof. Let c have binary expansion
c = . . . a0 . a1 a2 . . . ak−1 an ,
noting that the dyadic nature of c ensures that the binary expansion
is finite. Let xm = c + 2−m for each m. When m > n, the binary
expansions of xm and c are identical up to the mth place, in which xm
has a 1 where c has a 0. Thus, for k 6= m Lemma 2 implies that
[xm ]k − [c]k if ak = 0
hk (xm ) − hk (c) =
[c] − [x ] if a = 1.
k
m k
k
Even more, choose a value of k ≤ n. Since c and xm have the same
binary expansions up to the mth index, we have [xm ]k − [c]k = 2−m ,
4
A CONTINUOUS AND NOWHERE DIFFERENTIABLE FUNCTION
so that |hk (xm ) − hk (c)| = 2−m and hk (xm ) − hk (c) ≥ −2−m . When
n + 1 ≤ k < m, we have hk (xm ) = [xm ]k = 2−m , and hm (xm ) =
2−(m−1) − [xm ]m = 2−m .
As c and xm have binary expansions with
Pn 0’s after the nth and
mth
places,
respectively,
we
have
g(c)
=
k=0 hk (c) and g(xm ) =
Pm
k=0 hk (c). Thus we have
!
m
n
X
X
g(xm ) − g(c)
1
= −m
hk (xm ) −
hk (c)
xm − c
2
k=0
k=0
!
n
m
X
X
= 2m
hk (xm ) − hk (c) +
hk (xm )
k=0
≥ 2m
−
n
X
k=0
k=n+1
2−m +
m
X
!
hk (xm )
k=n+1
!
m
X
n
+
1
hk (xm )
≥ 2m − m +
2
k=n+1
n + 1 m − (n + 1)
m
≥2
− m +
= m − 2(n + 1).
2
2m
As m goes to ∞, the latter goes to ∞. This implies that
g(xm ) − g(c)
lim
m→∞
xm − c
1
is not a finite number , so we conclude
g(x) − g(c)
lim
x→c
x−c
isn’t finite either. Thus g is not differentiable at c.
Finally, we deal with the general case. Given c ∈ R with binary
expansion
c = . . . a0 . a1 a2 . . . ak−1 ak ak+1 . . . ,
let xm and ym be given by
xm = . . . a0 . a1 a2 . . . am−1 am ,
and ym = xm + 2−m , so that xm < c < ym for all m, and both {xm }
and {ym } converge to c. In fact, for technical reasons below, we will
only consider the values m where am = 0, i.e. the binary expansion of
c has a 0. Since c is non-dyadic (so that it doesn’t have a finite binary
1Technically,
the limit may either not exist or exist but be infinite. In either
case, it’s not finite.
A CONTINUOUS AND NOWHERE DIFFERENTIABLE FUNCTION
5
expansion), there must be infinitely may indices m for c with am = 0,
so despite this restriction we still obtain infinite sequences converging
to c.
For c non-dyadic, for each k ∈ N, 2k c is not an integer, so that
h is differentiable at 2k c, and thus hk is differentiable at c. By the
chain rule, we have h0k (x) = h0 (2k c). Since gm is the sum of functions
differentiable at c, gm is differentiable at c, and we have
m
m
X
X
0
0
gm (c) =
hk (c) =
h0 (2k c).
k=0
k=0
Relatedly, we have:
Lemma 4. For k ≤ m we have
hk (c) − hk (xm ) = h0 (2k c) · [c]m+1 , and
1
0 k
hk (ym ) − hk (c) = h (2 c) m − [c]m+1 .
2
Proof. The numbers xm and c have the same kth binary digits up to
the mth digit, so by Lemma 2 we have
[xm ]k − [c]k if ak = 0
hk (c) − hk (xm ) =
[c]k − [xm ]k if ak = 1,
for each k ≤ m. Moreover, since the digits of xm and c agree up to the
mth digit we have [c]k − [xm ]k = [c]m+1 .
When ak = 0, the number 2k c is between a pair of consecutive integers, the lesser of which is even. On this domain h has slope 1, so that
h0 (2k c) = 1. Similarly, if ak = 1 then 2k c is in a region where h has
slope −1, so that h0 (2k c) = −1. Putting this together for hk (c)−hk (xm )
yields the stated result.
The case for ym is similar, but we have to worry that adding 2−m
to xm may have changed many digits in its binary expansion, so that
it is not guaranteed that ym and c share the first m terms of their
binary expansion. This is where we use the technical remark above,
that we are only considering indices m where am = 0. For such ym ,
adding 2−m to xm only changes the mth binary digit. We conclude
that [c]k − [ym ]k = [c]m+1 − 2−m , and the same argument applies. These imply:
Lemma 5. For c non-dyadic, and xm and ym as above, we have
g(xm ) − g(c)
g(ym ) − g(c)
0
≥ gm
(c) ≥
.
xm − c
ym − c
6
A CONTINUOUS AND NOWHERE DIFFERENTIABLE FUNCTION
Proof. We apply Lemma 4 to the difference quotients:
g(xm ) − g(c)
1
=
(g(c) − g(xm ))
xm − c
[c]m+1
!
m
∞
X
X
1
=
hk (c) − hk (xm ) +
hk (c)
[c]m+1 k=0
k=m+1
≥
=
m
X
1
[c]m+1
m
X
hk (c) − hk (xm ) =
k=0
1
[c]m+1
m
X
h0 (2k c) · [c]m+1
k=0
h0 (2k c).
k=0
Similarly, we have:
1
g(ym ) − g(c)
= 1
(g(ym ) − g(c))
ym − c
− [c]m+1
2m
=
≤
=
=
1
2m
1
− [c]m+1
1
2m
1
− [c]m+1
1
2m
m
X
1
− [c]m+1
m
X
hk (ym ) − hk (c) −
k=0
m
X
∞
X
!
hk (c)
k=m+1
hk (ym ) − hk (c)
k=0
m
X
0
k
h (2 c)
k=0
1
− [c]m+1
2m
h0 (2k c).
k=0
0
Since gm
(c) =
m
X
h0 (2k c), we are done.
k=0
Lemma 6. Let c be a non-dyadic real number. Then g is not differentiable at c.
Proof. If g were differentiable at x = c, we would have
g(x) − g(c)
g(xm ) − g(c)
g(ym ) − g(c)
lim
= lim
= lim
.
x→c
m→∞
m→∞
x−c
xm − c
ym − c
Lemma 5 and the squeeze theorem now imply that
0
lim gm
(c) = g 0 (c).
m→∞
On the other hand we have
0
0
gm+1
(c) − gm
(c) = h0 (2m c),
A CONTINUOUS AND NOWHERE DIFFERENTIABLE FUNCTION
7
0
so that |gm+1 (c) − gm
(c)| = 1 for each m ∈ N, which violates the fact
0
that {gm (c)} is Cauchy.
Finally, we have:
Lemma 7. g is continuous on R.
Proof. Suppose that x and y share the same first m terms of their
binary expansions. In that case, |hk (x) − hk (y)| ≤ 2−m for k ≤ m, and
we have
∞
∞
X
X
hk (x) −
(y)
|g(x) − g(y)| = k=0
k=0
∞
∞
m
X
X
X
hk (y)
hk (x) −
=
hk (x) − hk (y) +
k=m+1
∞
X
k=0
≤
≤
m
X
k=0
m
X
k=0
|hk (x) − hk (y)| +
∞
X
k=m+1
∞
X
k=m+1
∞
X
|hk (x)| +
|hk (y)|
m=k+1
1
1
1
+
+
2m k=m+1 2k m=k+1 2k
m+1
1
m+3
+
2
·
=
.
2m
2m
2m
The latter goes to 0 as m goes to ∞ (think about why!). Thus, given
> 0, we may choose m large enough so that (m + 3)/2m < , and let
δ = 1/2m . If |x − y| < δ, then x and y share the first m terms of their
binary expansion, so that the above estimate applies and we have
m+3
|g(x) − g(y)| ≤
< .
2m
=
Proof of Theorem 1. By Lemmas 3 and 6, g is not differentiable at any
real number, and by Lemma 7 we know that g is continuous on R. References
[Abb01] Stephen Abbott. Understanding analysis. Undergraduate Texts in Mathematics. Springer-Verlag, New York, 2001.
[Kle93] Israel Kleiner. Functions: historical and pedagogical aspects. Sci. Ed.,
2(2):183–209, 1993.
© Copyright 2026 Paperzz