Measure Theory
The Devil's Staircase: A Continuous Climb with Zero Derivative Almost Everywhere
The devil's staircase is the graph of the Cantor function, a continuous non-decreasing map c : [0,1] → [0,1] whose derivative is zero at almost every point. It is exactly flat on the middle-third intervals removed to build the Cantor set, and those intervals have total length 1 — so the entire climb from c(0) = 0 to c(1) = 1 is carried by the Cantor set, a set of Lebesgue measure zero. The consequence is blunt: ∫01 c′(x) dx = 0 while c(1) − c(0) = 1, so the fundamental theorem of calculus fails for it.
- Also calledCantor function, Cantor-Vitali function
- First publishedGeorg Cantor, 1884, Acta Mathematica 4, 381-392
- The mapc : [0,1] to [0,1], continuous, non-decreasing, onto
- Derivativec'(x) = 0 on a set of Lebesgue measure 1
- Where the rise livesthe Cantor set: measure 0, dimension log 2 / log 3 = 0.6309
- What it breaksintegral of c' is 0, but c(1) - c(0) = 1
Watch the 60-second explainer
A condensed visual walkthrough — narrated, captioned, under a minute.
What the devil's staircase is
The devil's staircase is the graph of the Cantor function c : [0,1] → [0,1]. Three facts about it are easy to state and hard to hold in the head at once. It is continuous at every point — no jumps, no gaps. It is non-decreasing and onto, so it starts at c(0) = 0, finishes at c(1) = 1, and passes through every value in between. And its derivative is zero almost everywhere: there is a set of Lebesgue measure 1 on which c is provably, exactly flat.
The three are compatible because “almost everywhere” is a statement about measure, not about how many points there are. The flat part of the domain is the union of the open middle-third intervals thrown away in the construction of the Cantor set; their lengths sum to exactly 1. What survives is the Cantor set C, which has length 0 but is uncountable — it has the same cardinality as the whole real line. All of the climbing is compressed onto C.
The sharpest way to say what this costs is to write the fundamental theorem of calculus and watch it break. The derivative c′ exists and equals 0 off the measure-zero set C, so it is Lebesgue integrable with ∫01 c′(x) dx = 0. But c(1) − c(0) = 1. The two sides of the fundamental theorem differ by the whole rise of the function.
Where it came from. Georg Cantor published the function in 1884, in De la puissance des ensembles parfaits de points (Acta Mathematica 4, 381–392), as a counterexample in the theory of integration; the underlying set had appeared in his 1883 Grundlagen, and a nowhere-dense set of the same flavour had been built a decade earlier by H. J. S. Smith in 1874. Vitali's work on absolute continuity in 1905 is why the function is sometimes called the Cantor–Vitali function. The nickname “devil's staircase” was carried into general use by physics and dynamical systems, where the same shape turns up as a mode-locking plot; Per Bak's 1986 Physics Today article was titled “The Devil's Staircase”.
Building it: middle thirds and dyadic treads
The construction runs in rounds, and each round does the same thing to every surviving piece: delete the open middle third. Round 1 removes (1/3, 2/3) from [0,1]. Round 2 removes (1/9, 2/9) and (7/9, 8/9) from the two survivors. Round 3 removes four intervals of length 1/27, and so on. The Cantor set C is what is never removed.
The staircase is built in the same rounds. Start with the straight ramp c0(x) = x, then define
cn+1(x) = ½ cn(3x) on [0, 1/3], ½ on [1/3, 2/3], ½ + ½ cn(3x − 2) on [2/3, 1].
Each cn is piecewise linear. It is flat on every interval removed so far — the treads — and it climbs with slope (3/2)n on each of the 2n surviving intervals. After n rounds there are exactly 2n − 1 treads, and their heights are the dyadic rationals k/2n: the first tread sits at 1/2 over (1/3, 2/3), the next two at 1/4 over (1/9, 2/9) and 3/4 over (7/9, 8/9).
The treads never move once they appear, because cn+1 reproduces every tread of cn. On a surviving interval, cn and the limit c are both monotone and agree at the two endpoints, where they differ by 2−n; so ‖cn − c‖∞ ≤ 2−n. The convergence is uniform, and a uniform limit of continuous functions is continuous. That single inequality is the whole proof that the devil's staircase has no jumps in it.
The slopes are worth a number. At n = 10 the rising segments are already at slope (3/2)10 ≈ 57.7; at n = 20, ≈ 3325. In the limit the rise is infinitely steep on a set that has no length at all — which is the same statement as “c′ = 0 almost everywhere”, read from the other side.
Why the treads use up all the length
Round m cuts 2m−1 intervals, each of length 3−m, so it removes 2m−1/3m = ½(2/3)m of the line. Adding rounds gives a geometric series:
| Round m | Gaps cut | Length of each | Removed this round | Running total |
|---|---|---|---|---|
| 1 | 1 | 1/3 | 0.3333 | 0.3333 |
| 2 | 2 | 1/9 | 0.2222 | 0.5556 |
| 3 | 4 | 1/27 | 0.1481 | 0.7037 |
| 4 | 8 | 1/81 | 0.0988 | 0.8025 |
| 5 | 16 | 1/243 | 0.0658 | 0.8683 |
| 6 | 32 | 1/729 | 0.0439 | 0.9122 |
| 10 | 512 | 1/59049 | 0.0087 | 0.9827 |
The closed form is the point: after n rounds the survivors are 2n intervals of length 3−n, total length (2/3)n, so the removed length is 1 − (2/3)n. Letting n → ∞ gives
∑m≥1 2m−1/3m = ½ · (2/3)/(1 − 2/3) = 1.
So the Cantor set has Lebesgue measure exactly 0, and the flat treads of the staircase account for all of the interval's length. The animation shows the first six rounds and the counter reaching 0.912; the jump from there to exactly 1 is the limit of the series, not something any finite picture can show. The picture displays partial sums; the series proves the claim.
Measure zero is not the same as small. Every point of C has a ternary expansion using only the digits 0 and 2, and every such expansion gives a point of C, so C is in bijection with the set of infinite binary strings and has cardinality 2ℵ0 — the cardinality of the continuum. C is also compact, perfect (no isolated points) and nowhere dense. Its Hausdorff dimension is log 2 / log 3 ≈ 0.6309, the self-similarity dimension of a set made of 2 copies of itself scaled by 1/3.
Where the rise actually happens
There is a closed formula, and it is the cleanest description of the function. Write x in base 3. If x lies in the Cantor set then x = ∑i≥1 ai 3−i with every ai either 0 or 2, and
c(x) = ∑i≥1 (ai/2) · 2−i.
In words: read the ternary digits, halve each one, and reinterpret the result in binary. Off the Cantor set, c is constant on the removed interval, equal to its value at either endpoint (the two endpoints agree, which is exactly why the definition is consistent).
A worked value. 1/4 = 0.020202… in base 3, which uses only 0s and 2s, so 1/4 is in the Cantor set. Halving the digits gives 0.010101… in base 2, which is 1/3. So c(1/4) = 1/3. Likewise 1/3 = 0.0222…3 maps to 0.0111…2 = 1/2, matching the first tread.
Now the derivative, at a point x of the Cantor set. The level-n triadic interval containing x has length 3−n, and c varies by exactly 2−n across it. Taking y to be whichever endpoint of that interval is further from x in value gives |c(y) − c(x)| ≥ 2−n−1 with |y − x| ≤ 3−n, so the difference quotient is at least ½(3/2)n. That blows up as n grows, so c has no finite derivative at any point of the Cantor set. Off C, c is locally constant and c′(x) = 0. There is no third case.
The same computation explains the failure that matters for integration. c maps the Cantor set, of measure 0, onto the whole of [0,1], of measure 1. A function that can inflate a null set into a set of full measure fails Luzin's property (N), and property (N) is precisely what separates absolutely continuous functions from merely continuous ones of bounded variation.
The theorem it breaks, and the theorem it does not
Lebesgue's differentiation theorem for monotone functions (1904) says that a monotone function on [a,b] is differentiable at almost every point. The Cantor function obeys it — c′ exists a.e. and equals 0 — and simultaneously shows that this is all the theorem gives you. Knowing a derivative exists almost everywhere tells you nothing about recovering the function from it.
The Lebesgue form of the fundamental theorem of calculus is an equivalence, not an implication: for F on [a,b],
F(x) − F(a) = ∫ax F′(t) dt for every x in [a,b] holds if and only if F is absolutely continuous.
The quantifier is load-bearing. Matching at the far endpoint alone is not enough: glue a rising copy of the staircase on [0,1] to a falling one on [1,2] and the result has F(2) − F(0) = 0 = ∫02 F′, yet it is nowhere near absolutely continuous. It is the identity holding on every subinterval that pins F down.
The Cantor function is continuous, and it is of bounded variation with total variation exactly 1 (it is monotone with rise 1). What it is not is absolutely continuous. The Banach–Zarecki theorem (Banach and Zarecki, 1925) makes the gap precise: F is absolutely continuous exactly when it is continuous, of bounded variation, and satisfies Luzin's property (N). The devil's staircase has the first two and fails the third, and that single missing hypothesis is the whole distance between 0 and 1.
Read through the Lebesgue decomposition, the Stieltjes measure dc generated by the staircase is a probability measure that is singular continuous: it has no atoms (c is continuous, so no point carries positive mass) yet it is concentrated on the Cantor set, which Lebesgue measure ignores. It is the standard exhibit for the third leg of the decomposition — the one that is neither discrete nor given by a density.
Two smaller failures follow. c is uniformly continuous but not Lipschitz, since the difference quotients on C are unbounded. And its exact modulus of continuity is Hölder with exponent α = log 2 / log 3 ≈ 0.6309: |c(x) − c(y)| ≤ |x − y|α for all x, y, and no larger exponent works, because across a level-n triadic interval the ratio 2−n/(3−n)α is exactly 1.
Numbers and identities worth knowing
Self-affinity. The construction is encoded in three identities that determine c completely: c(x/3) = c(x)/2, c((x+2)/3) = (1 + c(x))/2, and c = 1/2 on [1/3, 2/3]. A fourth, the reflection c(x) + c(1 − x) = 1, follows and says the staircase is symmetric about its centre.
Its integral. Averaging the reflection identity over [0,1] gives ∫01 c(x) dx = 1/2 immediately — no fine structure required.
The length of the graph is exactly 2. For a continuous monotone function the graph length is ∫√(1 + f′2) plus the singular part of its variation. Here f′ = 0 a.e., contributing 1, and the singular variation is the full rise, another 1. The level-n approximation has length √(1 + (4/9)n) + 1 − (2/3)n, which is 1.916 at n = 6 and rises to 2. Because the graph is rectifiable, it has Hausdorff dimension 1: the curve is self-affine but it is not fractal in dimension. The fractional dimension 0.6309 belongs to the Cantor set on the axis beneath it, not to the staircase.
As a probability distribution. c is the cumulative distribution function of X = ∑k≥1 2ξk3−k, where the ξk are independent fair coin flips. X has mean 1/2 and variance ∑k≥1 9−k = 1/8 (standard deviation ≈ 0.354). It has no density and no atoms: a perfectly ordinary random variable that neither a probability mass function nor a probability density function can describe.
It is deaf to Riemann–Lebesgue. The Fourier transform of the Cantor measure is μ̂(t) = eit/2 ∏k≥1 cos(t/3k). Evaluate at t = 2π·3n: every factor with k ≤ n becomes cos of a multiple of 2π, namely 1, and the tail is the same fixed product for every n, of modulus ≈ 0.371. So |μ̂(t)| does not tend to 0 at infinity and the Cantor measure is not a Rajchman measure — another symptom of having no density.
Where devil's staircases show up
Dynamical systems. Plot the rotation number of the circle map θ ↦ θ + Ω − (K/2π) sin(2πθ) against the drive parameter Ω and you get a staircase: the rotation number locks onto a rational p/q over a whole interval of Ω (a mode-locked plateau, the base of an Arnold tongue) and moves only on a thin set in between. At the critical coupling K = 1 the staircase is complete — the plateaux have full measure — and the leftover set has a fractal dimension measured numerically at about 0.87 (Jensen, Bak and Bohr, 1983–84). This is where the name entered common use.
Condensed matter. The same shape governs commensurate–incommensurate transitions: the Frenkel–Kontorova model of atoms on a periodic substrate, and the ANNNI model of competing Ising interactions studied by Bak and von Boehm (1980), both produce staircases of locked ratios as a field or temperature is swept. Bak and Bruinsma (1982) then showed that a one-dimensional Ising chain with long-range convex repulsion gives a complete staircase, its plateaux filling the whole parameter axis. Per Bak's survey “The Devil's Staircase” (Physics Today 39(12), 1986) collected these.
Probability and analysis. Singular continuous distributions appear in random series with lacunary supports, in the spectral theory of quasiperiodic Schrödinger operators (the almost Mathieu operator has a Cantor spectrum — the “Ten Martini” problem, proved by Avila and Jitomirskaya in 2009), and in self-similar measures generally.
Variants worth knowing. Run the construction removing middle intervals of shrinking proportion instead of a fixed third and you get a fat Cantor set (the Smith–Volterra–Cantor set): still compact, still nowhere dense, still totally disconnected, but of positive measure — so nowhere density and measure are independent properties. Replacing the fair coin by a biased one gives a whole family of singular staircases indexed by p. And Minkowski's question mark function ?(x) is singular in the same way while being strictly increasing: it has ?′ = 0 almost everywhere with no flat interval anywhere, which shows that the flat treads, vivid as they are, are a feature of this particular construction rather than a requirement of singularity.
| Function on [0,1] | Continuous? | Derivative | ∫ f′ vs f(1) − f(0) |
|---|---|---|---|
| f(x) = x | Yes — Lipschitz, absolutely continuous | f′ = 1 at every point | 1 = 1 — the theorem holds |
| Cantor function c (devil's staircase) | Yes — Hölder with exponent 0.631, not Lipschitz | c′ = 0 on a set of measure 1; no finite derivative on the Cantor set | 0 ≠ 1 — the theorem fails |
| Heaviside step H(x − 1/2) | No — one jump, at x = 1/2 | H′ = 0 except at x = 1/2 | 0 ≠ 1 — the rise is a jump, not a climb |
| Minkowski question mark ?(x) | Yes — and strictly increasing, no flat stretch anywhere | ?′ = 0 almost everywhere | 0 ≠ 1 — singular like c, but with no tread to point at |
| Weierstrass function W(x) | Yes — everywhere, and of unbounded variation | Differentiable at no point at all | Not defined — W′ exists nowhere |
Frequently asked questions
How can a function climb from 0 to 1 if its derivative is zero almost everywhere?
Because "almost everywhere" means "outside a set of Lebesgue measure zero", and the entire climb is compressed onto such a set. The devil's staircase is genuinely, exactly flat on the removed middle-third intervals, whose lengths total 1/3 + 2/9 + 4/27 + ... = 1. What is left over is the Cantor set, of measure 0, and that is where every bit of the rise happens. The derivative simply never sees it: at every point of the Cantor set the difference quotients are unbounded, so no finite derivative exists there at all.
Is the devil's staircase continuous, and is it differentiable?
It is continuous at every point. The level-n approximations c_n satisfy sup|c_n - c| <= 2^-n, so they converge uniformly, and a uniform limit of continuous functions is continuous. It is in fact Holder continuous with exponent log 2 / log 3 = 0.6309, and that exponent is sharp, so it is not Lipschitz. As for differentiability: c'(x) = 0 at every point outside the Cantor set, which is a set of measure 1, and at every point of the Cantor set the difference quotient over the level-n triadic interval is at least (1/2)(3/2)^n, which blows up, so no finite derivative exists there.
Why does the fundamental theorem of calculus fail for the Cantor function?
Because the Lebesgue form of the theorem is an equivalence, and it asks for more than a match at the endpoints: F(x) - F(a) equals the integral of F' over [a,x] for every x in the interval if and only if F is absolutely continuous. The Cantor function is continuous and of bounded variation with total variation 1, but it is not absolutely continuous. The Banach-Zarecki theorem (1925) identifies exactly what is missing: Luzin's property (N), the requirement that null sets map to null sets. The Cantor function maps the measure-zero Cantor set onto all of [0,1], so it fails property (N), and the two sides of the fundamental theorem differ by the full rise of 1.
What is the length of the Cantor set, and how can it be uncountable?
Its Lebesgue measure is exactly 0. Round m of the construction removes 2^(m-1) intervals of length 3^-m, so after n rounds the survivors measure (2/3)^n, which tends to 0; equivalently the removed lengths form a geometric series summing to 1. It is uncountable all the same: a point is in the Cantor set precisely when it has a base-3 expansion using only the digits 0 and 2, which puts the set in bijection with the infinite binary strings, giving it the cardinality of the continuum. Measure and cardinality are different kinds of size. Its Hausdorff dimension is log 2 / log 3 = 0.6309.
Is the devil's staircase strictly increasing?
No. It is non-decreasing, and it is constant on every one of the countably many removed intervals, which is what makes the treads visible. Singularity does not require flat stretches, though: Minkowski's question mark function is strictly increasing on [0,1] and yet has derivative zero almost everywhere, so it is singular with no tread anywhere to point at. The flat treads are a feature of the middle-thirds construction rather than of singular functions in general.
Is the graph of the devil's staircase a fractal, and how long is it?
The graph has arc length exactly 2: one unit of horizontal travel plus one unit of vertical rise, since for a continuous monotone function the length is the integral of sqrt(1 + f'^2) plus the singular part of the variation, here 1 + 1. The level-6 approximation already has length 1.916. Because the graph is rectifiable, its Hausdorff dimension is 1, so despite being self-affine it is not fractal in the dimensional sense. The fractional dimension log 2 / log 3 = 0.6309 belongs to the Cantor set on the horizontal axis, not to the curve above it.