The Cantor Sequence with Bits

The Cantor sequence is similar to the Cantor set but deals with integers. To construct it, start with the natural numbers , writing them in ternary notation as . Construct a binary sequence : if in ternary has only 0s or 2s, let ; otherwise let . This gives .
This Demonstration shows the Cantor sequence for the numbers from 0 to . You can scale and scan the sequence. The pixel colors code the digits: red for -1, green for 0, blue for 1, and gray for 2. Yellow mesh lines mark the bits of the Cantor sequence and purple mesh lines mark the selected position in the selected range. The positions are given as fractions and present the subrange of 81 digit values of integers for the scan.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


The Cantor set is constructed iteratively; starting with the closed unit interval , the open middle third is taken out, leaving the two closed intervals and . Then the middle thirds of those two intervals are taken out, leaving four intervals of length , and so on. The Cantor set is the limit (or intersection) of all such sets.
Here is a way to look at the Cantor set in terms of the base 3 (ternary) representation of numbers. In the unit interval numbers in base 3 have the form , where the are all possible combinations of the digits 0, 1 or 2. The numbers in the middle third of start with 0.1; the numbers in the middle thirds of and start with 0.01 and 0.21. In general, numbers in a middle third have the digit 1 somewhere in their ternary expansion. In other words, the Cantor set consists of numbers that only have 0 or 2 as ternary digits. Replacing the 2s with 1s in those expansions gives a representation of the Cantor set using binary numbers.


    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2017 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+