(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:

for addition and for multiplication

Too abstract? Just compare with these examples:

and

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 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 . Just define and you can take square roots of negative numbers: 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 can be written as a sum of a real and an imaginary part: . Notice that and are real numbers whereas the is a complex one which I have written in bold face to distinguish between real and complex numbers. 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 and with their respective real and imaginary parts and such that and .

Then we have that or in other words: The sum of two complex numbers is the sum of their real parts and their imaginary parts respectively. Example:

Multiplication is just as easy but you have to remember that in order to understand the following chain of equations:

. Again an example, ommiting the intermediate steps:

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: where and are complex numbers. Additionally we define that is that is both, the real and the imaginary part are 0.

What does that mean? For any complex number we get a sequence of complex numbers , … as defined by the “recursion” above. In each step you take the result of the previous step, square it and add some complex number . You take the result, square it and again add …

Instead of complex numbers we can also talk about points on the two-dimensional (complex) plane. So what can happen for any given point when one does iterate repeatedly and calculates all the ? Basically two things: the sequence of 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 -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) for which the sequence with 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 created values for 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 for which the continued iteration of leads to -points that are further and further away from the origin. However, how do those values for 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 ) 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 π

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.

Keep us updated! β