Iterated Function System Discovered 1874 / 1883 Dimension log 2 / log 3 ≈ 0.631

The Cantor Set

The simplest fractal in this book: remove the middle third, forever, and end up with a set that is simultaneously almost nothing and just as big as everything.

History

The construction now named after Georg Cantor was actually published a decade earlier by Henry John Stephen Smith in 1874, as an example of a nowhere-dense set with positive structure; Cantor rediscovered and popularised it in 1883 while developing his theory of transfinite sets. He wasn’t trying to draw a pretty picture — he needed a rigorous example of an infinite, uncountable set of real numbers with total length zero, to sharpen his young theory of the infinite.

Anecdote

Cantor’s set theory was, in its day, deeply controversial. Poincaré called it “a disease” mathematics would one day recover from, and Cantor’s own teacher Leopold Kronecker campaigned for years to keep his papers out of print. Cantor suffered repeated bouts of depression some historians link to this professional isolation.

Construction

Start with [0,1][0,1]. Remove the open middle third. Remove the middle third of what’s left. Repeat forever:

C0=[0,1],Cn+1=Cn3(Cn3+23)C_0 = [0,1], \qquad C_{n+1} = \frac{C_n}{3} \cup \left(\frac{C_n}{3} + \frac{2}{3}\right)

Concretely: C1=[0,13][23,1]C_1 = [0,\tfrac13] \cup [\tfrac23,1] (the middle third (13,23)(\tfrac13,\tfrac23) is gone), then C2=[0,19][29,39][69,79][89,1]C_2 = [0,\tfrac19] \cup [\tfrac29,\tfrac39] \cup [\tfrac69,\tfrac79] \cup [\tfrac89,1] — each of C1C_1‘s two intervals loses its own middle third. CnC_n is always a union of 2n2^n closed intervals, each of length 3n3^{-n}; the Cantor set itself is whatever remains after doing this forever.

Because CC is built from N=2N=2 copies of itself scaled by r=1/3r=1/3, its similarity dimension is D=log2/log30.631D = \log 2/\log 3 \approx 0.631 — strictly between a point and a line.

Cool Fact

The Cantor set has Lebesgue measure zero — the total length removed sums to exactly 1 — yet it’s uncountable, with the same cardinality as [0,1][0,1] itself. A set can be simultaneously “almost nothing” by one measure and “just as big as everything” by another.

PLAY → NOTICE → EXPLAIN

How can length vanish while points remain?

Move through the construction. At stage n there are 2ⁿ intervals, each of length 3⁻ⁿ, so the total remaining length is (2/3)ⁿ.

Intervals16
Each length1/81
Total length16/81 ≈ 0.1975
Notice: the total length tends to zero, because (2/3)ⁿ → 0. Yet no finite stage is empty, and the limiting set contains uncountably many points. “Length zero” does not mean “nothing there.”

Python implementation

Pseudocode first

Algorithm in one glance Recursive
Keep the two outer thirds
cantor(a, b, depth) {
    if (depth == 0) return {[a,b]}
    third = (b-a)/3
    return {[a,b]} + cantor(left third) + cantor(right third)
}

The executable version keeps the same shape; shared plotting/export details live in fractalfair_helpers.py.

from fractalfair_helpers import staircase_figure

def cantor(depth, a=0.0, b=1.0):
    if depth == 0:
        return [(a, b, 0)]
    third = (b-a)/3
    return ([(a,b,depth)]
            + cantor(depth-1, a, a+third)
            + cantor(depth-1, b-third, b))

def draw(depth=7):
    return staircase_figure(cantor(depth), depth)
λThe Same Idea in Haskell
cantorBars :: Int -> (Double, Double) -> [(Double, Double, Int)]
cantorBars depth (a, b) = (a, b, depth) : rest
  where
    rest | depth == 0 = []
         | otherwise  = cantorBars (depth-1) (a, a + third)
                      ++ cantorBars (depth-1) (b - third, b)
    third = (b - a) / 3
Cantor set staircase

Figure: Seven levels of the staircase. Notice how the gaps, not the bars, are where the self-similar structure actually lives.