## Complex Cantor sets

Every real number in the interval [0,1] can be written in binary as ${\sum_{k=1}^\infty c_k(1/2)^k}$ where each coefficient ${c_k}$ is either 0 or 1. Another way to put this: the set of all possible sums ${\sum_{k=1}^\infty c_kb^k}$ for b = 1/2 is a line segment.

What is this set for other values of “base” b, then? Let’s stick to |b| < 1 for now, so that the series converges. Nothing interesting happens for real b between 1/2 and 1; the segment grows longer, to length b/(1-b). When b is between 0 and 1, we get Cantor sets, with the classical middle-third set being the case b = 1/3.

There is no need to consider negative b, because of a symmetry between b and -b. Indeed, up to scaling and translation, the coefficients can be taken from {-1, 1} instead of {0, 1}. Then it’s obvious that changing the sign of b is the same as flipping half of coefficients the other way — does not change the set of possible sums.

Let’s look at purely imaginary b, then. Here is b = 0.6i

Why so rectangular? The real part is the sum of ${c_kb^k}$ over even k, and the imaginary part is the sum over odd k. Each of these yields a Cantor type set as long as ${|b|^2 < 1/2}$. Since the odd- and even-numbered coefficients are independent of each other, we get the product of two Cantor sets. Which changes into a rectangle when  ${|b| \ge \sqrt{1/2}}$:

(I didn’t think a full-size picture of a solid rectangle was necessary here.)

This is already interesting: the phase transition from dust to solid (connected, and even with interior) happens at different values in the real and imaginary directions: 1/2 versus ${\sqrt{1/2}}$. What will happen for other complex values? Using complex conjugation and the symmetry between b and -b, we reduce the problem to the quarter-disk in the first quadrant. Which still leaves a room for a lot of things to happen…

It’s clear that for |b| < 1/2 we get a totally disconnected set — it is covered by 2 copies of itself scaled by the factor of |b|, so its Hausdorff dimension is less than 1 when |b| is less than 1/2. Also, the argument of b is responsible for rotation of the scaled copies, and it looks like rotation favors disconnectivity… but then again, the pieces may link up again after being scaled-rotated a few times, so the story is not a simple one.

The set of bases b for which the complex Cantor set is connected is a Mandelbrot-like set introduced by Barnsley and Harrington in 1985. It has the symmetries of a rectangle, and features a prominent hole centered at 0 (discussed above). But it actually has infinitely many holes, with “exotic” holes being tiny islands of disconnectedness, surrounded by connected sets. This was proved in 2014 by Calegari, Koch, Walker, so I refer to Danny Calegari’s post for an explanation and more pictures (much better looking than mine).

Besides “disconnected to connected”, there is another phase transition: empty interior to nonempty interior. Hare and Sidorov proved that the complex Cantor set has nonempty interior when  ${|b| > 2^{-1/4}}$; their path to the proof involved a MathOverflow question The Minkowski sum of two curves which is of its own interest.

The pictures were made with a straightforward Python script, using expansions of length 20:

import matplotlib.pyplot as plt
import numpy as np
import itertools
n = 20
b = 0.6 + 0.3j
c = np.array(list(itertools.product([0, 1], repeat=n)))
w = np.array([b**k for k in range(n)]).reshape(1, -1)
z = np.sum(c*w, axis=1)
plt.plot(np.real(z), np.imag(z), '.', ms=4)
plt.axis('equal')
plt.show()

Since we are looking at partial sums anyway, it’s not necessary to limit ourselves to |b| being less than 1. Replacing b by 1/b only scales the picture, so the place to look for new kinds of pictures is the unit circle. Let’s try a 7th root of unity:

The set above looks sparse because many points overlap. Let’s change b to something non-algebraic:

What’s with the cusps along the perimeter?

## Playing with iterated function systems

After Colin Carroll posted several fractal experiments with Matlab, I decided to do something of the sort. One difference is that I use Scilab, an open-source alternative to Matlab.

The first experiment: drawing the Sierpinski carpet using the Chaos Game. Namely, given a finite family of strict contractions $f_1,\dots,f_r\colon \mathbb R^2\to \mathbb R^2$ and an initial point $p_0$, plot the sequence $p_{n+1}=f_{j_n}(p_n)$, where $j_n \in \{1,\dots,r\}$ is chosen randomly at each step. To simplify matters, let $f_j$ be the similarity transformation with scaling factor $s\in (0,1)$ and the fixed point $v_j$.

A canonical example is: $v_1,v_2,v_3$ are the vertices of equilateral triangle, $s=1/2$. This produces the fractal known as the Sierpinski gasket. For a different example, set $s=1/3$ and let $v_1,\dots,v_8$ be the vertices of square together with midpoints of its sides. The resulting fractal is known as the Sierpinski carpet.

This image was obtained by calling the scilab function given below as Scarpet(1/3, 100000). The function is essentially a translation of Colin’s code to scilab. Caution: if you copy and paste this code, watch out for line breaks and encoding of quote marks.

function Scarpet(scale,steps)
b=1-scale;
x = [1,0,-1,-1,-1,0,1,1];
y = [1,1,1,0,-1,-1,-1,0];
sides=length(x);
point = zeros(steps,2);
vert = grand(1,steps,'uin',1,sides);
for j = 2:steps
point(j,:) = scale*point(j-1,:) + b*[x(vert(j)),y(vert(j))];
end
plot(point(:,1),point(:,2),'linestyle','none','markstyle','.','marksize',1);
endfunction

Regardless of the choice of initial point $p_0$, the set of cluster points of the sequence $(p_n)$ is exactly the invariant set $K$, namely the unique nonempty compact set such that $K=\bigcup_{j=1}^r f_j(K)$. This is proved, for example, in the book Integral, Probability, and Fractal Measures by Gerald Edgar.

The scaling factor $s=1/3$ for the carpet is chosen so that the images of the original square under the eight similarities touch, but do not overlap. With a smaller factor the fractal looks like dust (a totally disconnected set), while with $s\ge 1/2$ it becomes a solid square. The intermediate range $1/3 is tricky: I think that $K$ has measure zero, but can’t even prove that it’s nowhere dense.

It’s also possible to draw $K$ in the opposite way, by removing points rather than adding them. To this end, let $P$ be the convex hull of the set $\{v_1,\dots,v_r\}$; that is, a solid convex polygon. It’s not hard to see that $K\subset P$. Therefore, $\bigcup_{j=1}^r f_j(K)\subset \bigcup_{j=1}^r f_j(P)$, but since the set on the left is $K$ itself, we get $K\subset \bigcup_{j=1}^r f_j(P)$. By induction, $K=\bigcap_{n=1}^{\infty} P_n$ where $P_0=P$ and $P_{n+1}=\bigcup_{j=1}^r f_j(P_n)$.

The above example is ifs(3,3/5,11), calling the Scilab code below.

function ifs(sides,scale,steps)
b=1-scale; t=2*%pi*(1:sides)/sides; x=cos(t); y=sin(t);
xpols=x'; ypols=y';
for j=2:steps
xpols=scale*xpols; ypols=scale*ypols;
xpolsnew=[]; ypolsnew=[];
for k=1:sides
xpolsnew=[xpolsnew xpols+b*x(k)*ones(xpols)];
ypolsnew=[ypolsnew ypols+b*y(k)*ones(ypols)];
end
xpols=xpolsnew; ypols=ypolsnew;
end
a=gca(); a.data_bounds=[-1,-1;1,1];
[m,n]=size(xpols);
xfpolys(xpols,ypols,ones(n,1))
endfunction

The final example is an “upper bound” for the fat pentagonal fractal that Colin created with the Chaos Game: the points $v_1,\dots,v_5$ are the vertices of regular pentagon, and $s=1/2$. The function was called as ifs(5,1/2,8). Again, I think that the invariant set has measure zero, but can’t even prove that the interior is empty. (Or find a reference where this is already done.)