Cantor Comb Fractal Generator
Generate and visualize Cantor Comb fractals with adjustable iteration depth, colors, and bar thickness. Export high-resolution PNG images.
About
The Cantor Set, introduced by Georg Cantor in 1883, is constructed by iteratively removing the open middle third of every line segment. Starting from the unit interval [0, 1], the first iteration yields [0, 1/3] โช [2/3, 1]. After n iterations, 2n segments remain, each of length (1รท3)n. The resulting set is uncountably infinite yet has Lebesgue measure zero. Its Hausdorff dimension equals log2 รท log3 ≈ 0.6309. Miscounting iterations or misunderstanding the recursive removal can lead to incorrect fractal dimensions in academic work.
This tool computes the Cantor Comb (the two-dimensional visualization where each iteration level is drawn as a horizontal row of bars) up to 10 iterations (1024 segments). The rendering is exact. Bar widths at depth n are computed as W ร (1รท3)n where W is the total canvas width. Note: at iterations above 8, individual segments become sub-pixel on standard displays. Export at high resolution for print use.
Formulas
The Cantor Set is defined by recursive interval removal. At each step, the open middle third of every remaining segment is deleted.
C0 = [0, 1]
Cn+1 = Cn3 โช (2 + Cn3)
The total measure remaining after n iterations:
Ln = (23)n
Hausdorff dimension:
dH = log 2log 3 ≈ 0.6309
Where Cn is the Cantor set at iteration n, Ln is the total Lebesgue measure (length) of remaining segments, and dH is the Hausdorff (fractal) dimension quantifying the self-similar scaling.
Reference Data
| Iteration n | Segments 2n | Segment Length (1/3)n | Total Length Remaining | Removed Fraction | Gaps Created |
|---|---|---|---|---|---|
| 0 | 1 | 1.000000 | 1.000000 | 0.0% | 0 |
| 1 | 2 | 0.333333 | 0.666667 | 33.3% | 1 |
| 2 | 4 | 0.111111 | 0.444444 | 55.6% | 3 |
| 3 | 8 | 0.037037 | 0.296296 | 70.4% | 7 |
| 4 | 16 | 0.012346 | 0.197531 | 80.2% | 15 |
| 5 | 32 | 0.004115 | 0.131687 | 86.8% | 31 |
| 6 | 64 | 0.001372 | 0.087791 | 91.2% | 63 |
| 7 | 128 | 0.000457 | 0.058528 | 94.1% | 127 |
| 8 | 256 | 0.000152 | 0.039018 | 96.1% | 255 |
| 9 | 512 | 0.000051 | 0.026012 | 97.4% | 511 |
| 10 | 1024 | 0.000017 | 0.017342 | 98.3% | 1023 |
| โ | Uncountable | 0 | 0 (measure) | 100% | Dense |