The Cantor Function

The Devil's staircase: continuous and nondecreasing from 00 to 11, yet constant on every complementary interval, so f′=0f' = 0 on a set of total length 11. f(1)−f(0)=1≠∫01f′f(1) - f(0) = 1 \neq \int_0^1 f' — why the FTC needs more than differentiability almost everywhere.

f(x)=∑bk2−k,bk∈{0,1} from the ternary expansionf(x) = \sum b_k 2^{-k},\quad b_k \in \{0,1\}\ \text{from the ternary expansion}
f(1)−f(0)=1≠0=∫01f′f(1) - f(0) = 1 \neq 0 = \int_0^1 f'

Part of these learning paths

Examples & Exercises

Prove that the Cantor function ff is well-defined (the ambiguity of ternary expansions does not change its value), nondecreasing, and continuous on [0,1][0,1]. For instance, the two expansions 0.0222…3=0.130.0222\ldots_3 = 0.1_3 must both give f=1/2f = 1/2.

0.0222…3: N=∞, b=0.0111…2=12vs0.13: N=1, b1=1⇒f=120.0222\ldots_3:\ N = \infty,\ b = 0.0111\ldots_2 = \tfrac12 \qquad\text{vs}\qquad 0.1_3:\ N = 1,\ b_1 = 1 \Rightarrow f = \tfrac12
x<y, first differing digit m⇒f(x)≤S+2−m≤f(y)x < y,\ \text{first differing digit } m \Rightarrow f(x) \le S + 2^{-m} \le f(y)
∣f−fn∣≤2−n uniformly, fn piecewise linear⇒f continuous|f - f_n| \le 2^{-n}\ \text{uniformly},\ f_n\ \text{piecewise linear} \Rightarrow f\ \text{continuous}
Stage 3: C3C_3 has 8 intervals (=232^3) of total length (2/3)3=8/27≈0.29630(2/3)^3 = 8/27 \approx 0.29630 — the staircase is already the finished ff, with the flat step f=1/2f = 1/2 over (1/3, 2/3)(1/3,\,2/3) visible.
Show proof
  1. Ternary expansions are unique except at points k/3mk/3^m, which have exactly two: the terminating one 0.c1…cm−110.c_1\ldots c_{m-1}1 and the repeating-22 one 0.c1…cm−10222…30.c_1\ldots c_{m-1}0222\ldots_3. If some ck=1c_k = 1 with k<mk < m, both expansions see the first 11 at the same position, so the bb-sequences agree. Otherwise the terminating expansion has N=mN = m with bm=1b_m = 1, while the repeating-22 expansion has no 11 at all, giving bm=0b_m = 0 and bk=1b_k = 1 for k>mk > m — but ∑k>m2−k=2−m\sum_{k>m} 2^{-k} = 2^{-m}, so the totals agree. Example: 0.0222…30.0222\ldots_3 has N=∞N = \infty, hence b=0.0111…2=1/2b = 0.0111\ldots_2 = 1/2; 0.130.1_3 has N=1N = 1, hence b1=1b_1 = 1 and f=1/2f = 1/2. So ff is well-defined.
  2. The function ff is nondecreasing. Let x<yx < y and let mm be the first index where the (chosen) ternary expansions differ; then (cm(x), cm(y))(c_m(x),\, c_m(y)) is one of (0,1)(0,1), (0,2)(0,2), (1,2)(1,2). Write SS for the shared contribution of the first m−1m-1 digits. Case (0,1)(0,1): xx has bm=0b_m = 0 and tail at most ∑k>m2−k=2−m\sum_{k>m} 2^{-k} = 2^{-m}, so f(x)≤S+2−mf(x) \le S + 2^{-m}; yy sees its first 11 at mm, so f(y)=S+2−mf(y) = S + 2^{-m}. Case (0,2)(0,2): f(x)≤S+2−mf(x) \le S + 2^{-m} while yy has bm=1b_m = 1 and tail ≥0\ge 0, so f(y)≥S+2−mf(y) \ge S + 2^{-m}. Case (1,2)(1,2): f(x)=S+2−mf(x) = S + 2^{-m} and f(y)≥S+2−mf(y) \ge S + 2^{-m}. Endpoint ambiguity was already settled by well-definedness, so f(x)≤f(y)f(x) \le f(y).
  3. The function ff is continuous. On each closed rank-nn ternary interval II, ff varies by at most 2−n2^{-n}: if a 11 occurs among the nn digits the tails vanish and ff is exactly constant on II; otherwise f=∑k≤n(ck/2)2−k+tailf = \sum_{k\le n}(c_k/2)2^{-k} + \text{tail} with the tail between 00 and 2−n2^{-n}. Let fnf_n be the continuous piecewise-linear interpolant of ff at the endpoints k/3nk/3^n. For xx in a rank-nn interval [l,r][l,r], both f(x)f(x) and fn(x)f_n(x) lie in [f(l), f(r)][f(l),\,f(r)] (by monotonicity), an interval of length at most 2−n2^{-n}. Hence fn→ff_n \to f uniformly, and a uniform limit of continuous functions is continuous, so ff is continuous on [0,1][0,1]. Note f(0)=0f(0) = 0 and f(1)=1f(1) = 1 (reading 1=0.222…31 = 0.222\ldots_3).

Prove that ff is constant on every open interval complementary to the Cantor set. Conclude that f′=0f' = 0 at every point of the complement, which has total length 11.

(a,b) removed at stage m:a=0.c1…cm−113, b=0.c1…cm−123(a,b)\ \text{removed at stage } m:\quad a = 0.c_1\ldots c_{m-1}1_3,\ b = 0.c_1\ldots c_{m-1}2_3
x∈(a,b)⇒cm(x)=1⇒f(x)=∑k<mck22−k+2−m (constant)x \in (a,b) \Rightarrow c_m(x) = 1 \Rightarrow f(x) = \sum_{k<m}\tfrac{c_k}{2}2^{-k} + 2^{-m}\ \text{(constant)}
∑m≥12m−13−m=13∑m≥1(23)m−1=1\sum_{m \ge 1} 2^{m-1} 3^{-m} = \tfrac13\sum_{m\ge 1}\left(\tfrac23\right)^{m-1} = 1
Stage 5: C5C_5 has 32 intervals (=252^5) of total length (2/3)5=32/243≈0.13169(2/3)^5 = 32/243 \approx 0.13169 — the bars thin out, but the flat steps of the staircase (e.g. f=1/2f = 1/2 over (1/3, 2/3)(1/3,\,2/3)) stay put.
Show proof
  1. The complement of the Cantor set is the disjoint union of the removed open middle thirds. Each interval removed at stage mm has the form (a,b)(a,b) with a=0.c1…cm−113a = 0.c_1\ldots c_{m-1}1_3 (terminating) and b=0.c1…cm−123b = 0.c_1\ldots c_{m-1}2_3, where c1,…,cm−1c_1,\ldots,c_{m-1} contain no 11. Let x∈(a,b)x \in (a,b). Since x>ax > a, the mm-th ternary digit cannot be 00 (that would give x≤0.c1…cm−10222…3=ax \le 0.c_1\ldots c_{m-1}0222\ldots_3 = a); since x<bx < b, it cannot be 22 (that would give x≥0.c1…cm−12000…3=bx \ge 0.c_1\ldots c_{m-1}2000\ldots_3 = b). Hence cm(x)=1c_m(x) = 1, and with no 11 before it, N(x)=mN(x) = m. So f(x)=∑k<m(ck/2)2−k+2−mf(x) = \sum_{k<m}(c_k/2)2^{-k} + 2^{-m}, a constant independent of xx — ff is constant on every complementary interval. Numerically: f≡1/4f \equiv 1/4 on (1/9, 2/9)(1/9,\,2/9) and f≡1/2f \equiv 1/2 on (1/3, 2/3)(1/3,\,2/3).
  2. A function constant on an open interval has derivative 00 at every point of it (the difference quotient is identically 00). Hence f′(x)=0f'(x) = 0 at every point xx of the complement — the staircase is flat "almost everywhere".
  3. The total length of the complement sums the 2m−12^{m-1} intervals of length 3−m3^{-m} removed at stage mm: ∑m≥12m−13−m=13∑m≥1(2/3)m−1=13⋅11−2/3=1\sum_{m\ge 1} 2^{m-1}3^{-m} = \frac13\sum_{m\ge 1}(2/3)^{m-1} = \frac13\cdot\frac{1}{1-2/3} = 1. So the set where f′=0f' = 0 has length 11: the staircase climbs a total of 11 while moving only on the Cantor set, which has length 00.

Compute that f(1)−f(0)=1f(1) - f(0) = 1 yet ∫01f′=0\int_0^1 f' = 0, and prove that ff is therefore not absolutely continuous. This is why the Fundamental Theorem of Calculus needs a stronger hypothesis than "differentiable almost everywhere". (The definition of absolute continuity itself may be stated at idea level.)

AC:∀ε>0 ∃δ>0: ∑(yi−xi)<δ⇒∑∣f(yi)−f(xi)∣<ε\text{AC:}\quad \forall\varepsilon > 0\ \exists\delta > 0:\ \sum (y_i - x_i) < \delta \Rightarrow \sum |f(y_i) - f(x_i)| < \varepsilon
f(1)−f(0)=1,∫01f′=0  (since f′=0 a.e.)f(1) - f(0) = 1,\qquad \int_0^1 f' = 0\ \ (\text{since } f' = 0\ \text{a.e.})
∑Cn intervals(ri−li)=(23)n,∑(f(ri)−f(li))=1≮12\sum_{C_n\text{ intervals}} (r_i - l_i) = \left(\tfrac23\right)^n,\qquad \sum (f(r_i) - f(l_i)) = 1 \not< \tfrac12
Stage 4: C4C_4 has 16 intervals (=242^4) of total length (2/3)4=16/81≈0.19753(2/3)^4 = 16/81 \approx 0.19753 — ff climbs from 00 to 11 on these thin bars alone.
Show proof
  1. By problem 1, ff is continuous on [0,1][0,1] with f(0)=0f(0) = 0 and f(1)=1f(1) = 1, so f(1)−f(0)=1f(1) - f(0) = 1. On the other hand, Lebesgue's theorem says a monotone function is differentiable almost everywhere, and problem 2 gives f′=0f' = 0 wherever it exists — so f′=0f' = 0 a.e., and the (Lebesgue) integral ∫01f′=0\int_0^1 f' = 0.
  2. If ff were absolutely continuous, the Fundamental Theorem of Calculus would give f(1)−f(0)=∫01f′f(1) - f(0) = \int_0^1 f'. But 1≠01 \neq 0 — a contradiction. Hence ff is not absolutely continuous: continuity plus differentiability almost everywhere does not imply the FTC. "Differentiable almost everywhere" is not enough to recover a function by integration; absolute continuity is the sharp hypothesis.
  3. This can also be seen directly. Absolute continuity means: for every ε>0\varepsilon > 0 there is δ>0\delta > 0 such that any finite family of disjoint intervals with total length below δ\delta has total ∣f∣|f|-increment below ε\varepsilon. Take ε=1/2\varepsilon = 1/2. The 2n2^n intervals of CnC_n have total length (2/3)n→0(2/3)^n \to 0, eventually below any δ\delta. But ff is constant on the gaps between them and nondecreasing, so ∑i(f(ri)−f(li))=f(1)−f(0)=1≥ε\sum_i (f(r_i) - f(l_i)) = f(1) - f(0) = 1 \ge \varepsilon — every δ\delta fails. The Cantor set is nearly 00 in length yet covers all of [0,1][0,1] in ff-value (ff maps CC onto [0,1][0,1]).

4. Topology