Wear Mandelbrot

The Mandelbrot Set is formed by iterating a seed x-y pair of numbers, which represent a complex number, using the quadratic equation: z=(z*z)+z. The number of iterations, or the amount of “time”, this loop is performed defines whether the two values represent a point that belongs in the Mandelbrot Set – and for graphical purposes which colour to render the given pixel as.


Mandelbrot Set with the ‘Rainbow’ colours

  • Reaching the maximum number of iterations
  • The calculated value z becomes greater than a ‘breakout value’

If the number of iterations tends to infinity then the x-y pair of values is said to belong to the Mandelbrot Set. Programmatically this can be said to happen if the iterative loop reaches a pre-defined maximum number of iterations (for example, 255).

But if you render the Mandelbrot Set just as pixels that are ‘in’ or ‘out’ then you end up with a monochrome image that looks a bit like an island in a sea. Much like a coastline it’s possible to zoom in on any section and find more and more detail as you move in. More visually impressive is if you render the number of iterations that it takes to exceed a ‘breakout value’ (typically 4) as a colour. As you tend away from the Set the number of iterations decreases and you see bands of colour, almost as though the Mandelbrot set was a high mountain and the height drops as you move away from the set itself.

The Android Wear app calculates the Mandelbrot initially with a zoom level which shows the whole set. Tapping the screen zooms in, making the new centre the position where you tapped. In essence you are taking a subset of the original image and blowing it up to the full resolution of the screen again. The fractal nature of the Mandelbrot Set allows you to do this infinitely, although in practise eventually computers lack the accuracy to represent the numbers involved precisely enough, meaning that there’s a practical limit. Double-tapping will undo the last zoom and pull you out from the Mandelbrot.

Corresponding Julia set

Swiping up and down on the watch app will cycle through a handful of pre-defined colour pallets that we chose to show off the Set in its best light. Swiping to the left will use the centre of the current Mandelbrot Set to calculate a Julia Set and display it. A Julia set is a similar fractal pattern that is based on using a seed pair of values from the Mandelbrot Set and essentially using the same equation but offsetting using the value pairs. Swiping right will put you back at the same place you were in the Mandelbrot Set.

In many ways the smart watch form factor is ideal for the Mandelbrot because the screen only has a relatively small number of pixels, making rendering a screen’s-worth of pixels only take a second or two. High-end phones have around 27 times more pixels so the app on the phone (which we’ve developed but not released yet) takes substantially more time to calculate the Mandelbrot Set.

Footnote: I find it stunning to see how fast these Android Wear watches can render the Mandelbrot Set. When I was at school we were drawing these fractals using the BBC Model B computer and you could sit and watch each line being rendered. Now a whole screen pops up after barely a couple of seconds. The raw processing power that’s paired with a full colour display and small enough to fit on your wrist is impressive. (Jonathan Howell)