Cantor set
The Cantor ternary set is a remarkable subset of the real numbers
named after German mathematician Georg Cantor who described the set
in 1883. It has the same cardinality as
The set can be constructed recursively by first considering the unit
interval
The recursion can be illustrated in python in the following way
import numpy as np
def transform_interval(x, scale=1.0, translation=0.0):
return tuple(map(lambda z: z * scale + translation, x))
def Cantor(n):
if n==0: return {(0,1)}
Cleft = set(map(lambda x: transform_interval(x, scale=1/3), Cantor(n-1)))
Cright = set(map(lambda x: transform_interval(x, translation=2/3), Cleft))
return Cleft.union(Cright)
print(Cantor(1))
{(0.6666666666666666, 1.0), (0.0, 0.3333333333333333)}
The following code displays the first 5 iterations of the algorithm
and clearly illustrates the self-similarity property in the sets
def intervalprint(x, n=240):
sym = n*[' ']
val = np.linspace(0, 1, num=n)
for interval in x:
idx = np.where((val >= interval[0]) & (val <= interval[1]))[0]
for i in idx:
sym[i] = u'\u2500'
st = ''.join(sym)
print(st)
x = list(map(Cantor, [0,1,2,3,4,5]))
for i in range(0, len(x)): intervalprint(x[i])
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
──────────────────────────────────────────────────────────────────────────────── ────────────────────────────────────────────────────────────────────────────────
─────────────────────────── ────────────────────────── ────────────────────────── ───────────────────────────
───────── ───────── ──────── ───────── ───────── ──────── ───────── ─────────
─── ─── ─── ─── ─── ── ─── ─── ─── ─── ── ─── ─── ─── ─── ───
─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
It is clear that
To see this, note that in the first step the open middle set
In this sense, we can think of the Cantor set just containing “dust”.
It can also be shown that the Cantor set can be represented as
Here we used Cantor’s Intersection Theorem: Let
Proof: For each