Tutorials › Measure Theory › Defining the Cantor Function by Ternary Digits

Non-Measurable Sets and the Cantor Function · Tutorial 155 of 798

Defining the Cantor Function by Ternary Digits

Translate a point’s allowed ternary digits into binary digits to define and compute the Cantor function on the Cantor set.

Advanced 10 min read

What You'll Learn

  • Represent Cantor-set points using ternary digits restricted to 0 and 2
  • Define the Cantor function on the Cantor set by digit replacement
  • Verify that the restricted ternary coding gives a well-defined function
  • Compute exact function values from finite and infinite digit patterns
  • Use a digit prefix to bound the function value
  • Avoid confusing ternary place values with binary place values

From Ternary Addresses to Binary Values

The middle-third Cantor set is built by repeatedly removing open middle thirds from \([0,1]\). Each point that remains can be described by a ternary expansion using only the digits \(0\) and \(2\). The Cantor function’s digit rule turns that description into a number in \([0,1]\): replace every ternary \(0\) by binary \(0\), and every ternary \(2\) by binary \(1\), keeping the digit positions the same. The two expansions use different place values, so the replacement changes the number.

Here we define the function on the Cantor set itself. The digit rule is enough to calculate its value at any point whose Cantor-set address is known. In particular, the rule handles infinite digit strings by interpreting them as convergent series; it does not require the output to have a finite binary expansion.

Definition: Let \(C\subseteq[0,1]\) be the middle-third Cantor set. Write a point \(x\in C\) in its Cantor-set ternary coding \(x=\sum_{n=1}^{\infty}\frac{2a_n}{3^n}\), where each \(a_n\in\{0,1\}\). Define the Cantor function on \(C\) by \(F(x)=\sum_{n=1}^{\infty}\frac{a_n}{2^n}\). Equivalently, if \(x=0.a_1'a_2'a_3'\ldots{}_3\) with \(a_n'\in\{0,2\}\), then \(F(x)=0.b_1b_2b_3\ldots{}_2\), where \(b_n=0\) when \(a_n'=0\) and \(b_n=1\) when \(a_n'=2\).

The sequence notation in the definition avoids a potential place-value confusion. A ternary digit \(2\) in position \(n\) contributes \(2/3^n\) to \(x\); after replacement, a binary digit \(1\) in that position contributes \(1/2^n\) to \(F(x)\). The operation is a rule on digits, not a claim that the input and output have the same numerical value.

Why the Coding Defines a Function

At the \(n\)th stage of the Cantor construction, every retained interval is labelled by a word of length \(n\) whose entries are \(0\) or \(1\): entry \(0\) records a left-third choice, and entry \(1\) records a right-third choice. Its points have the corresponding first \(n\) ternary digits \(0\) or \(2\). These labels are nested as the construction continues. The coding of \(x\in C\) is the resulting infinite sequence.

Proposition: Every \(x\in C\) has exactly one representation \(x=\sum_{n=1}^{\infty}2a_n/3^n\) with \(a_n\in\{0,1\}\). Consequently, the digit rule defines a single value \(F(x)\) for every \(x\in C\).

Proof. At every finite stage, a point of \(C\) belongs to exactly one retained interval: distinct retained intervals at that stage are disjoint, and their union contains \(C\). The interval containing \(x\) determines its successive left-or-right choices. Thus \(x\) determines a sequence \((a_n)\) of zeros and ones. The interval determined by its first \(n\) choices has length \(3^{-n}\), which tends to zero. The nested intervals therefore specify one point. The left-or-right construction gives that point as the limit of its ternary partial sums, hence as \(\sum_{n=1}^{\infty}2a_n/3^n\).

To check uniqueness directly, suppose two different sequences \((a_n)\) and \((a'_n)\) gave the same number, and let \(k\) be their first differing index. Interchanging the sequences if necessary, suppose \(a_k=0\) and \(a'_k=1\). The difference of their coded values is \(\frac{2}{3^k}+\sum_{n>k}\frac{2(a'_n-a_n)}{3^n}\). The tail is at least \(-\sum_{n>k}2/3^n=-1/3^k\), so the entire difference is at least \(1/3^k>0\). It cannot be zero. Thus the restricted coding is unique. Since each series \(\sum a_n/2^n\) converges to a number in \([0,1]\), the rule assigns exactly one such value to every \(x\in C\). \(\square\)

For clarity, convergence of the output series follows from \(0\le a_n/2^n\le1/2^n\) and \(\sum_{n=1}^{\infty}1/2^n=1\). The all-zero code gives \(F(0)=0\), while the all-one code gives \(F(1)=\sum_{n=1}^{\infty}1/2^n=1\).

Reading Values from Digit Prefixes

A finite initial block of ternary digits already determines a useful interval containing the function value. Let the first \(n\) coding digits be \(a_1,\ldots,a_n\), and let \(k=\sum_{j=1}^{n}a_j2^{n-j}\), the integer represented by those digits in base two. The output begins with that binary prefix. The remaining digits can contribute at most \(1/2^n\).

Proposition: If \(x\in C\) has coding digits \(a_1,a_2,\ldots\), and \(k=\sum_{j=1}^{n}a_j2^{n-j}\), then \(\displaystyle F(x)=\frac{k}{2^n}+\sum_{j=n+1}^{\infty}\frac{a_j}{2^j}\), and consequently \(\displaystyle \frac{k}{2^n}\le F(x)\le\frac{k+1}{2^n}\).

Proof. Split the defining convergent series for \(F(x)\) after its \(n\)th term. The finite part satisfies \(\sum_{j=1}^{n}a_j/2^j=k/2^n\), by the definition of the binary integer \(k\). The remaining terms are nonnegative, so their sum is at least zero. They are bounded above by \(\sum_{j=n+1}^{\infty}1/2^j=1/2^n\). Adding these lower and upper bounds to \(k/2^n\) proves both inequalities. \(\square\)

Worked Example: A Point with a Finite Ternary Address

Compute \(F(x)\) for \(x=0.02_3\), followed by zeros. Its ternary value is \(x=0/3+2/3^2=2/9\), so the coding digits are \(a_1=0\), \(a_2=1\), and \(a_n=0\) for every \(n\ge3\). Replacing the ternary digits \(0,2,0,0,\ldots\) by binary digits \(0,1,0,0,\ldots\) gives

$$ F(x)=0.0100\ldots{}_2=\frac{0}{2}+\frac{1}{2^2}=\frac14. $$

Check: the input calculation gives \(2/3^2=2/9\), and the output calculation gives \(1/2^2=1/4\). The first two binary digits have \(k=1\), so the prefix bound is \(1/4\le F(x)\le2/4\). The calculated value \(1/4\) is in that interval, and the zero tail makes it its lower endpoint.

Worked Example: A Three-Digit Ternary Address

Take \(x=0.202_3\), followed by zeros. Its input value is \(2/3+0/3^2+2/3^3=18/27+2/27=20/27\). The ternary digits \(2,0,2\) become binary digits \(1,0,1\); therefore

$$ F(x)=0.101_2=\frac12+\frac{0}{4}+\frac18=\frac58. $$

Check: the first three output digits represent \(k=1\cdot2^2+0\cdot2+1=5\), so the prefix bound is \(5/8\le F(x)\le6/8\). The remaining input and output digits are all zero, so the output is exactly the lower endpoint \(5/8\). This agrees with the direct binary-place-value calculation.

Worked Example: An Infinite Repeating Address

Consider the point with ternary coding \(0.020202\ldots{}_3\). The nonzero ternary digits are in even positions, so \(x=\sum_{j=1}^{\infty}2/3^{2j}\). This geometric series has first term \(2/9\) and ratio \(1/9\), giving \(x=(2/9)/(1-1/9)=1/4\). The digit replacement gives \(F(x)=0.010101\ldots{}_2\). Its nonzero terms are \(1/2^2,1/2^4,1/2^6,\ldots\), and therefore

$$ F(x)=\sum_{j=1}^{\infty}\frac{1}{2^{2j}} =\frac{1/4}{1-1/4} =\frac13. $$

Check: substituting the geometric-series values gives \((2/9)/(8/9)=1/4\) for the input and \((1/4)/(3/4)=1/3\) for the output. As a prefix check, the first four output digits are \(0101\), representing \(k=5\); hence \(5/16\le F(x)\le6/16\). Since \(1/3\) lies between these bounds, the prefix check is consistent with the exact sum.

A Place-Value Pitfall

A common error is to keep the ternary digit \(2\) unchanged and then read the result as a binary numeral. For the point \(x=0.02_3=2/9\), this incorrect procedure gives \(0.02_2\). But a binary expansion has only digits \(0\) and \(1\), so \(0.02_2\) is not a valid binary numeral. Even if one mistakenly treated its second digit as contributing \(2/4\), that would give \(1/2\), not the function value.

The correction is to apply the specified digit replacement before evaluating the output: \(0.02_3\) becomes \(0.01_2\), and \(0.01_2=1/4\). The input uses powers of \(1/3\), while the output uses powers of \(1/2\). Each calculation must be made with its own base.

The definition here concerns \(F\) on \(C\) and uses the restricted ternary coding with digits \(0\) and \(2\). It does not require interpreting other ternary expansions of the same real number. In particular, the relationship between such expansions at Cantor endpoints is a separate issue. The digit rule on \(C\) supplies the basic values; the finite-prefix estimate provides a quick way to check them without summing every remaining digit.

Check Your Understanding

Use the digit replacement rule, and show the place-value calculation that supports each answer.

  1. For \(x=0.2000\ldots{}_3\), find \(x\) and \(F(x)\).
  2. For \(x=0.2200\ldots{}_3\), write the binary output and compute its exact value.
  3. Show that the ternary coding \(0.002002002\ldots{}_3\) gives \(x=1/13\), and compute the corresponding value of \(F(x)\).
  4. If the first three coding digits are \(1,0,1\), find the integer \(k\) in the prefix bound and state the resulting interval for \(F(x)\).
  5. Explain why keeping the digit \(2\) unchanged cannot produce the binary output required by the definition.