# Listening to the Mandelbrot set

2017-12-31 math composition

Okay, it's New Year's Eve, I'm overdue to write this week's Web log entry, and the topic I wanted to write about is held up because of (among other things) a package that apparently was stolen from my front porch after it was "delivered" during my vacation and I
*told* them not to mail it so early but blah blah blah... Instead of the exciting mystery topic, let's dig into the back catalog again and think about how to *listen to the Mandelbrot set*.

Here's the Mandelbrot set. It should be pretty familiar to many of you.

Without going into a lot of detail, the idea here is that if you take a complex number
*z*, square it, add another complex number *c*, and then keep doing that (alternately square your number, and add *c*), what happens? If you start with *z* and *c* large-ish, you can expect that the numbers will just get bigger and bigger, escaping to infinity. If you start with them small-ish, they may instead get locked into a fixed point (like *z*=*c*=0), or a loop of just a few repeating values, or even do some complicated thing that does not actually repeat but also never escapes to infinity. You can draw a picture of what happens for different combinations of *z* and *c*; there are different ways to do that which give different kinds of pretty pictures, but the one above in particular is where you always start wit *z*=0 and then test different values of *c*. Each pixel corresponds to a different value of *c* (bearing in mind these are complex numbers, so each "number" corresponds to a two-dimensional location). The black "snowman" shape represents values of *c* for which the process does not escape to infinity; other points are given colours depending on how long it takes them to go outside a certain fixed-size circle, after which it's proven that they necessarily just keep spiralling outward forever.

Zooming into the image reveals an endless variety of interesting details, including an infinite number of shrunk-down near-copies of the whole thing. This kind of self-similarity at different scales is typical of fractals.

How could we turn this into sound?

Here's one idea. Remember Lissajous figures? You put sine waves into the X and Y coordinates of an oscilloscope in X-Y mode, and depending on the relationship between the sine waves, you get different shapes on the display. For two sine waves at the same frequency, you get an ellipse that shows the phase relationship (fat like a circle: 90 degrees; thin like a line: 0 degrees; other shapes in between: other phase angles). For two waves at different but harmonically related frequencies, you get more complicated shapes.

So... what if we could generate a pair of signals such that when you fed them into the X and Y coordinates of an oscilloscope, the resulting display would trace out the complicated boundary of the Mandelbrot set?

At a glance it may seem completely hopeless that we could ever do such a thing. Just for a start, it's not obvious that the Mandelbrot set consists of one single piece ("connectedness" is the relevant mathematical property). Maybe we could start drawing it, go around one of the islands making up the set, return to our starting point, and find that we'd left out a lot of interesting details. It turns out that that is not a problem - it actually is a single piece, so there is a single boundary we could trace that would outline it perfectly. But the boundary is of infinite length! So if we want to draw it, proceeding at a finite speed in terms of length covered per unit time, it will take forever. Even if there's a way around that, the shape is also, as implied by the exercise of zooming in on pictures of it, an extremely complicated curve. It's not obvious that we can compute this entire curve in any useful way even with a lot of computer assistance.

Fortunately, the mathematicians come to the rescue here. Remember I said that the Mandelbrot set is connected - it has just one piece. That was proved by Douady and Hubbard in the 1980s, and the way they did it involved proving the existence of a sequence of functions that converge on the Mandelbrot set boundary, starting with a plain circle and then getting wigglier and wiggler as they wrap more and more closely around the infinitely wiggly object. They just proved that
*such curves exist* with certain properties, but Jungreis subsequently came up with an algorithm allowing the curves to really be computed. There's a useful links page by Adam Majewski summarizing the computational algorithm; from there you can link to discussions, academic references, and so on. (UPDATE: The page is no longer online, but I have updated my link to point to a Wayback Machine archived version of it.)

The important formula looks like this:

This is a mapping from the area of the complex plane outside the unit circle, to the area outside the Mandelbrot set. There is an infinite sequence of real numbers
*b _{m}* defining the function; then it takes as input a complex number

*z*and produces as output a complex number

*ψ*(

*z*). The formula technically is not supposed to apply to the unit circle itself, but we can do a bit of handwaving and take a limit, and say that if we let

*z*range over a circle achingly close to the unit circle, then

*ψ*(

*z*) will run around the complicated boundary of the Mandelbrot set

*in the same time*. And the numbers

*b*can be calculated by an algorithm that, although annoying, is reasonably implementable (source code in a few languages on Majewski's page).

_{m}
It even gets better. The formula for
*ψ*(*z*), you may observe, is a polynomial with real coefficients in *z*^{-1}. To compute one of the two parts of the output (without loss of generality let's say the imaginary part), we need to know the imaginary parts of:

*z*(a point that runs around the unit circle in some fixed time)*z*^{-1}(same thing in the opposite direction)*z*^{-2}(going around the unit circle twice as fast)*z*^{-3}(going around the unit circle three times as fast)- ...

These functions are just a harmonically related set of sine waves. We mix them with strengths determined by
*b _{m}* and get the desired Mandelbrot-tracing function. The coefficients

*b*, even if they look mysterious, are just a Fourier analysis of the function that would trace a Mandelbrot-shaped Lissajous figure! And this is what the real and imaginary parts of that function look like, computed to the level of detail I figured would be sufficient for musical purposes:

_{m}

Plotting these two against each other, they do indeed look more or less as they should:

Here's what it sounds like.

That's a sort of interesting drone, but not really too exciting all by itself. (Real part in the left channel, imaginary in the right, but note I resynthesized it in Csound without the phase information, so the actual waveforms if you look at them in a wave editor will not match the plots above.)

Back in 2013 I played with this some more and used it as the basis for a more finished composition called Silver Ratio. Here I'm using additive synthesis with Csound's "oscbank" opcode, and applying a fair bit of modulation to the individual partials for a fatter, pad-style sound. And I didn't write down all of what I did, so can't comment on it in a whole lot of detail. At this point I'd say it's more "inspired by" the sound of tracing out the Mandelbrot set and associated Julia set fractals, rather than a literally accurate recreation of the boundary functions. But still, a fun thing to play with.

Have a happy New Year!

◀ PREV Modular synthesis intro, part 3: How to get started || Modular synthesis intro, part 4: Some pitfalls NEXT ▶