So what is a Buddhabrot anyway?

a Buddhabrot
(click picture to enlarge)
Trying to put interesting pictures on my walls, I recently started experimenting with rendering Buddhabrots. While those witnessing my experiments uttered some “wows” and “beautifuls” (and some “uhm aha?”) nobody seemed to know exactly what those pictures actually show and so I decided to write this article to point people to instead of explaining it all over again πŸ™‚

Complex numbers

Fractals like the Mandelbrot and Buddhabrot are rendered using Complex numbers. So what are those? Everyone knows Natural numbers: 0, 1, 2, 3, 4, … With those numbers comes a set of operations like addition and multiplication. However, subtraction poses a problem: 2-4 has no result in the set of natural numbers since there are no negative numbers in that set!
The set of Integers (…, -3, -2, -1, 0, 1, 2, 3, …) of which the natural numbers are a subset doesn’t have this problem with subtraction but it does have one with division. There are combinations of integers, which if divided by each other have no result in the set of integers like 5/2, for example. If we extend the set of integers to allow for any division of integers (all but the division by zero), we arrive at the set of Rational numbers, which is the set of all fractions. Notice that fractions are numbers that consist of two parts: a numerator and a denominator. Operations like addition, subtraction, multiplication and division have to be properly defined to work consistently on those two-element numbers and hopefully you remember the following rules for addition and multiplication from school:
\frac{a}{b} + \frac{c}{d} = \frac{a \cdot d + c \cdot b}{b \cdot d} for addition and \frac{a}{b} \cdot \frac{c}{d} = \frac{a \cdot c}{b \cdot d} for multiplication
Too abstract? Just compare with these examples:
\frac{1}{2} + \frac{3}{4} = \frac{1 \cdot 4 + 3 \cdot 2}{2 \cdot 4} = \frac{4 + 6}{8} = \frac{10}{8} = \frac{5}{4} and \frac{1}{2} \cdot \frac{3}{4} = \frac{1 \cdot 3}{2 \cdot 4} = \frac{3}{8}

But again, there are operations on this set of numbers that have no solution in the rational numbers. There is for example no fraction that can represent the square root of 2. While that is not a problem in the real and practical world around us – everything you can count and divide can be represented with fractions aka rational numbers – mathematicians came up with the set of Real numbers that also allows for numbers like the square root of 2.

Enough? No! Being able to take square roots of 2 is nice but what about the square root of -2? Or just -1? Unless you attended a higher maths course in school something like \sqrt{-1} was either something that made you recheck your calculations or write down “no solution”. Also, the solution of most pocket calculators when fed with the square root of a negative numbers is “error”.
Time for Imaginary units and Complex numbers! Just like governments coming up with new forms of taxes when money runs out, mathematicians come up with new numbers when the existing ones don’t suffice. In this case, there is just one addition though: the imaginary unit i. Just define i^2 := -1 and you can take square roots of negative numbers: \sqrt{-1} = i, \sqrt{-2} = i \cdot \sqrt{2} and so on.
Complex numbers are Real numbers amended by the imaginary unit and just like fractions they consist of two elements. A real part and an imaginary part and so every complex number \mathbf{c} can be written as a sum of a real and an imaginary part: \mathbf{c} = a + b \cdot i. Notice that a and b are real numbers whereas the \mathbf{c} is a complex one which I have written in bold face to distinguish between real and complex numbers. i is of course the imaginary unit as explained above.
So how does one add and multiply two complex numbers? That’s actually normal algebra! Let’s consider two complex numbers \mathbf{x} and \mathbf{y} with their respective real and imaginary parts a, b and r, s such that \mathbf{x} = a + b \cdot i and \mathbf{y} = r + s \cdot i.
Then we have that \mathbf{x} + \mathbf{y} = (a + b \cdot i) + (r + s \cdot i) = (a + r) + (b + s) \cdot i or in other words: The sum of two complex numbers is the sum of their real parts and their imaginary parts respectively. Example: (1 + 2 \cdot i) + (3 + 4 \cdot i) = (1 + 3) + (2 + 4) \cdot i = (4 + 6 \cdot i)

Multiplication is just as easy but you have to remember that i^2 = -1 in order to understand the following chain of equations:
\mathbf{x} \cdot \mathbf{y} = (a + b \cdot i) \cdot (r + s \cdot i) = a \cdot r + a \cdot s \cdot i + b \cdot i \cdot r + b \cdot i \cdot s \cdot i = a \cdot r + a \cdot s \cdot i + b \cdot i \cdot r - b \cdot s = (a \cdot r - b \cdot s) + (a \cdot s + b \cdot r ) \cdot i . Again an example, ommiting the intermediate steps: (1 + 2 \cdot i) \cdot (3 + 4 \cdot i) = (1 \cdot 3 - 2 \cdot 4) + (1 \cdot 4 + 2 \cdot 3 ) \cdot i = (-5 + 10 \cdot i)
If algebra wasn’t your favourite in school all you need to know about complex numbers (as needed for the explanation of a Buddhabrot fractal) is that even while they consist of two parts (real and imaginary) they can be added, multiplied (subtracted and divided) by using the known (and easy) operations of addition, multiplication, subtraction and division on real numbers.

Now that complex numbers and the basic operations on them are no mystery anymore, we can look at how they are used in rendering fractals.

The Mandelbrot set

Since complex numbers have two components a single complex number can be represented as a point on a two-dimensional plane (take a look at this illustration on Wikipedia: ).

Now let’s take a look at the following (complex) function: \mathbf{z}_{n+1} := {\mathbf{z}_n}^2 + \mathbf{c} where \mathbf{z} and \mathbf{c} are complex numbers. Additionally we define that \mathbf{z}_0 is \mathbf{0} that is both, the real and the imaginary part are 0.
What does that mean? For any complex number \mathbf{c} we get a sequence of complex numbers \mathbf{z}_0, \mathbf{z}_1, \mathbf{z}_2, \mathbf{z}_3, … as defined by the “recursion” above. In each step you take the result of the previous step, square it and add some complex number \mathbf{c}. You take the result, square it and again add \mathbf{c}
Instead of complex numbers we can also talk about points on the two-dimensional (complex) plane. So what can happen for any given point \mathbf{c} when one does iterate repeatedly and calculates all the \mathbf{z}_n? Basically two things: the sequence of \mathbf{z}_n can be bounded which means that you however often you iterate (however big the n becomes) the resulting points will always lie in some area on the two-dimensional plane. Or the sequence is unbounded which means that the \mathbf{z}-points tend to go further and further away from the origin and that you can define no area in such a way that it will contain all the points with none of the points finally being outside of that area.

Now comes the Mandelbrot set: The Mandelbrot set is the set of all complex numbers (points) \mathbf{c} for which the sequence \mathbf{z}_{n+1} := {\mathbf{z}_n}^2 + \mathbf{c} with \mathbf{z}_0 = \mathbf{0} is bounded.
It’s that simple πŸ™‚ Just take a look at all the pictures of the Wikipedia Mandelbrot set article: The Mandelbrot set is the black area and the beauty of the Mandelbrot renderings comes from the colourization of those points which are just outside the boundary of the Mandelbrot set.
In this case the colour depends on the number of iterations that were necessary until the recursion function \mathbf{z}_{n+1} := {\mathbf{z}_n}^2 + \mathbf{c} created values for \mathbf{z} which lie outside some previously specified region.

The Buddhabrot set

Knowing what the Mandelbrot set is one can easily explain the Buddhabrot picture from the top of this article. For that, we look at those points, which are not in the Mandelbrot set. Remember that those are the points \mathbf{c} for which the continued iteration of \mathbf{z}_{n+1} := {\mathbf{z}_n}^2 + \mathbf{c} leads to \mathbf{z}-points that are further and further away from the origin. However, how do those values for \mathbf{z} look like, before they “fly away” out of any bounds? The answer: they look like a Buddhabrot πŸ˜‰

To create a Buddhabrot you take values for which the Mandelbrot recursion is unbounded. Then you iterate them over and over through the Mandelbrot recursion and for each step (for each of the \mathbf{z}_n) you draw a point on your picture. If there is already a point, you draw a slightly brighter point. You repeat this over and over again for different starting values and in the end you get a Buddhabrot.

How this works in detail and how one does know if the recursion is bounded or unbounded is stuff for another article. Be patient and come back to check πŸ™‚

  1. I might not like algebra, but I do like the buddhabrot! Are you going to print it out and hang it on your wall?

    • In the end: yes! But not the one you see. I’m working on a gigapixel rendering which allows for highly detailed “zooms”. I’ll write another article about the technicalities of actually producing such an image and will then hopefully present more beautiful renderings.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Trackbacks and Pingbacks: