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.
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 . Remove the open middle third. Remove the middle third of what’s left. Repeat forever:
Concretely: (the middle third is gone), then — each of ‘s two intervals loses its own middle third. is always a union of closed intervals, each of length ; the Cantor set itself is whatever remains after doing this forever.
Because is built from copies of itself scaled by , its similarity dimension is — strictly between a point and a line.
The Cantor set has Lebesgue measure zero — the total length removed sums to exactly 1 — yet it’s uncountable, with the same cardinality as 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)ⁿ.
Python implementation
Pseudocode first
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)
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
Figure: Seven levels of the staircase. Notice how the gaps, not the bars, are where the self-similar structure actually lives.