Mandelbrot Set Program

Hello again. I would like to explain a bit the Sample programs of Fract, combined with a kind-of walk-though to generating some amazing pictures. For starters I would like to explain how to reach this image:

Basic newton set

So, in Fract there are three things: Programs that render the image, parameters that are injected into the program, and post-processing parameters like color palettes and light effect parameters. So, let’s get started:

How do you calculate a fractal like the Mandelbrot set?

It is fairly simple: Ingredients are a non-linear function (“Function“) and a start value (“z0“), which is a complex number, thus two dimensions. The function is defined over “z”, the only parameter, and some constant “c” that in our case contains the coordinates of the current pixel (scaled according to the “Scale” parameter). For the Mandelbrot Set, the function is “z^2 + c”.

The function is then repeatedly applied to its own return value, generating a sequence that starts with “z0”.

So, we calculate a sequence [z0, function(z0), function(function(z0)), …] and investigate properties of this sequence and paint the current pixel according to these properties. This is basically how fractals like the mandelbrot set work.

There are some such properties that can be investigated: The current position in the sequence is “n”, an integer number. The current value of the sequence (in mathematical terms “z[n]”) is “z”, the last one is “lastZ” (in mathematical terms “z[n-1]”) and the next one is “nextZ” (in mathematical terms “z[n+1]”).

We need to limit the length of these sequences obviously. This is done using the parameter “Maximum Iteration Count” (this is the maximum value of “n”). The higher it is, the more details are visible, but also the longer the calculation takes. Values should range between 100-5000, but in fractals like the Burning Ship fractal, lower values generate amazing patterns in the “lake” of the fractal.

This image uses a Maximum Iteration Count of 50

When we generate the orbit sequence [z0, f(z0), f(f(z0)), …], it might diverge to infinity. Since infinity is a difficult value, we define a “Bailout Radius” – if the absolute value of an item in the sequence exceeds this “Bailout Radius”, then the assumption is that the orbit sequence is unbounded and further calculations are stopped. In Fract I call points that lead to such a sequence unbound. The Color Palette that is used for such points is the “Palette for Ubound Points” or “Bailout Palette”.

In order to draw a point, there are three values (I admit, this can be a bit overwhelming): The “Bailout Value”, “Bailout Color Value” and “Bailout Height”. The last one is used for the depth perception. The Color Value is used to define the color. It is normalized to the range 0:0 – 1:1 which is the area of the color palette after which it repeats itself. Finally, “Bailout Value” is ideally the only one you need. It is assigned to “value”, and for “Bailout Color Value” simply reuse “value” and set “Bailout Height” to the real part of the value: “re value”. These are the defaults.

Per default, “Bailout Value” is “n” with a logarithmic transfer. Just using “n” will create an image with a constant color since “n” is an integer and the palette is normalized to 0-1 in both dimensions. A logarithmic transfer is advisable:

Mandelbrot Set with Bailout Value = log(n + 20.08)

There is a method to achieve a continuous gradient, provided that the fractal function is a polynomial function. It requires the maximum exponent in “Function” as input parameter which is 2 for the Mandelbrot Set. Then, the value “continuousAddend” is calculated. It ranges from 0 to 1 and represents the decimal part of “n”.

About the lake of the fractal: It contains all points that did not exceed the Bailout Radius and are therefore assumed to be bound. Many of these points will converge to a constant value (in the case of the Mandelbrot Set, these are all points in the heart curve). If the (absolute) difference of two neighbors in the orbit sequence is less than a threshold value (“Epsilon Radius”), then it is assumed that the sequence is convergent and the calculation is terminated. This is mainly a speed-up but it also can be used to draw interesting images.

Magnet 1 with a lake value “log(n + 20.08)” and an epsilon radius of 0.001

Note to self: It would be nice to be able to smoothen these stripes.

There are two parameters left: Julia Set switches to Julia Mode (the default mode is Mandelbrot Mode), meaning that “z0” is always set to “point”, and “c” is a constant value. Therefore, the parameter “z0” disappears and instead “Julia Set Parameter” appears.

Julia Sets resemple parts of the fractal scaled up. For this reason I recommend to center a fractal over an interesting point in Mandelbrot Mode, switch on Julia Set and then with a long tap open the context menu of “Julia Set Parameter” and select “Set to Center”. Reset the Scale afterwards. I will provide a video to show this.

A structure in the behind of the perpendicular mandelbrot set (use 3-finger gestures to staigthen out this distored area)
The corresponding Julia Set . Observe the small structure in the center.

I have to say, the Perpendicular Mandelbrot Set gives rise to lovely Julia Sets!

Last but not least, there is one parameter missing: “All Points are bound”. For certain fractals, eg Newton Sets, all sequences are bound. Thus, there is no bailout area. For the newton set on top, simply use the function “newton(z^3+c, z)”, “z0” should be “c” since “0” causes a division by 0. Select “All Points are bound” and for “Lake Value” use “argnorm nextZ” (which is the argument of nextZ, normalized to the range 0 – 1).

Or, another class of such unbound fractals are created by polynomial functions with negative exponents. While looking at the lovely Julia Set of the perpendicular mandelbrot set, I tried to negate the exponent. Now, look at that:

Juilia Set of the function “conj rabs z ^ -2 + c” with Maximum Iteration Count 60.

Congrats if you made it until here and I hope it was providing you with some new information.

Cheers, stay healthy 🙂

Karl

Leave a comment

Design a site like this with WordPress.com
Get started