Does there exists any systematic way to represent a number in ternary expansion?

Also, I have hard time trying to figure it out this:

Let $x = \sum \frac{a_k}{3^k} = 0.a_1a_2.... $

why is it that $x \in [0,1]$ belongs to the cantor set $C$ iff all its $a_k$ equal $0$ or $2$?

I would really appreciate if someone can explain this to me. Thanks

  • 1
    $\begingroup$ Are you familiar with the construction of the middle-thirds Cantor set, e.g., as sketched here? $\endgroup$ Sep 3, 2013 at 7:46

3 Answers 3


I hope the following procedure is "systematic" enough.

Start with $x\in [0,1]$. Define $a_1$ to be the greatest number in $\{ 0,1,2\}$ such that $\frac{a_1}3\leq x$; so $a_1=0$ if $x\in [0,1/3)$, $a_1=1$ if $x\in [1/3,2/3)$ and $a_1=2$ if $x\in [2/3,1]$. In each case you have $$\frac{a_1}3\leq x\leq \frac{a_1}{3}+\frac13\,\cdot$$ Assuming $a_1,\dots ,a_{n-1}$ have already been found (for some $n\geq 2$) with $$\sum_{k=1}^{n-1}\frac{a_k}{3^k}\leq x\leq \sum_{k=1}^{n-1}\frac{a_k}{3^k}+\frac{1}{3^{n-1}}\, ,$$ define $a_n$ to be the greatest number in $\{ 0,1,2\}$ such that $\sum_{k=1}^{n-1}\frac{a_k}{3^k}+\frac{a_n}{3^n}\leq x$. Then $$\sum_{k=1}^n\frac{a_k}{3^k}\leq x\leq \sum_{k=1}^{n}\frac{a_k}{3^k}+\frac{1}{3^{n}}\cdot $$ Indeed, if $a_n=0$ or $1$ then $a_n+1$ is still in $\{ 0,1,2\}$, so by the definition of $a_n$ you have in fact $x<\sum_{k=1}^{n-1} \frac{a_k}{3^k}+\frac{a_n+1}{3^n}=\sum_{k=1}^n\frac{a_k}{3^k}+\frac{1}{3^n}$; and if $a_n=2$ then you may write (by the induction hypothesis) $x\leq \sum_{k=1}^{n-1}\frac{a_k}{3^k}+\frac{1}{3^{n-1}}=\sum_{k=1}^{n-1} \frac{a_k}{3^k}+\frac{2}{3^{n}}+\frac{1}{3^n}=\sum_{k=1}^n\frac{a_k}{3^k}+\frac1{3^n}\cdot$

So, constructing your sequence in this way, you obviously get $x=\sum_{k=1}^ \infty \frac{a_k}{3^k}\cdot$

As you know, the ternary expansion is not necessarily unique. If you start with a number $x$ of the form $x=\sum_{k=1}^N\frac{b_k}{3^k}$ (finite sum), then the procedure gives you $a_1=b_1, \dots , a_N=b_N$ and $a_k=0$ for all $k>N$.

As for your second question, you already have a nice answer.


The Cantor set is constructed as the intersection of closed sets formed as follows:

first, let $$C_1=I_{1,1}\cup I_{1,2}$$ where $I_{1,1}=[0,1/3]$ and $I_{1,2}=[2/3,1]$. Even though it is still a little bit early convince yourself that those numbers in $I_{1,1}$ are precisely those whose first digit in ternary expansion $.d_1d_2...$ is 0 with the exemption of $1/3$ which can be written in ternary form in two different ways: $1/3=.1$ and $1/3=.0222222...$. If we admit only the second of this representations then there are no exemptions. Note that in the same fasion the numbers in $I_{1,2}$ are those that begin with the digit 2, then again, we can write $1=.2222222...$ in ternary coordinates.

Not let $C_2 = I_{2,1}\cup I_{2,2} \cup I_{2,3} \cup I_{2,4}$ where the intervals $I_{2,1},I_{2,2},I_{2,3},I_{2,4}$ stand for $[0,1/9],[2/9,1/3],[2/3,7/9],[8/9,1]$. As you can see we obtain two subintervals from each interval in the previous step by removing the middle third. The elements in $I_{2,j}$ for $j=1,2,3,4$ are precisely those with initial patterns $.00,.02,.20,.22$ respectively (once more we have to be careful with those number with two representations and chose the one that begins with lower digit, e.g., $2/9=.00222...$). Note also that $C_2 \subset C_1$.

Inductively, define $C_k$ a subset of $C_{k-1}$ as the union of the subintervals obtained by removing the middle thirds to each subinterval in $C_{k-1}$ This fixes the initial ternary digit patterns of an element in $C_k = \bigcap_{i=1}^k C_i$ up to the $k$th digit with only digits 0 and 2.

The Cantor set is precisely $\bigcap_{i=1}^\infty C_i$ and therefore its elements are precisely those whose digits are only $0's$ and $2's$.


I think the procedure to represent a number in ternary expansion is pretty much the same than representing it in any digit with the only caveat is that you might additionally require that no "tails of zeros" will be allowed in any number different from zero in order to obtain a "unique" representation. The previous answer gives a method.

For instance, in decimal expansion the number $1$ can be written as $.9999999...$ and $.05$ as $.049999...$. The tail of zeros can be replaced by reducing in a unit the preceding digit and then adding an infinite tail of the largest digit in the given expansion. So in base-$4$ you could write $.2=.1333...$.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .