This book shows how to code different algorithms for drawing parameter plane ^{[1]} ( Mandelbrot set ^{[2]} ) for complex quadratic polynomial ^{[3]}.

One can find different types of points / sets on parameter plane ^{[4]}

## Contents

**Exterior of Mandelbrot set**Edit

**Boundary of Mandelbrot set**Edit

**Interior of Mandelbrot set** - hyperbolic componentsEdit

## The Lyapunov ExponentEdit

Math equation :^{[5]}

where :

means first derivative of f with respect to z

See also :

- image and description by janthor
^{[6]} - image by Anders Sandberg
^{[7]}

## Interior distance estimationEdit

## absolute value of the orbitEdit

```
# Hypercomputing the Mandelbrot Set? by Petrus H. Potgieter February 1, 2008
n=1000; # For an nxn grid
m=50; # Number of iterations
c=meshgrid(linspace(-2,2,n))\ # Set up grid
+i*meshgrid(linspace(2,-2,n))’;
x=zeros(n,n); # Initial value on grid
for i=1:m
x=x.^2+c; # Iterate the mapping
endfor
imagesc(min(abs(x),2.1)) # Plot monochrome, absolute
# value of 2.1 is escape
```

### internal level setsEdit

Color of point :

- is proportional to the value of z is at final iteration.
- shows internal level sets of periodic attractors.

### bof60Edit

Image of bof60 in on page 60 in the book "the Beauty Of Fractals".Description of the method described on page 63 of bof. It is used only for interior points of the Mandelbrot set.

Color of point is proportional to :

- the smallest distance of its orbit from origin
^{[8]}^{[9]} - the smallest value z gets during iteration
^{[10]} - illuminating the closest approach the iterates of the origin (critical point) make to the origin inside the set

Level sets of distance are sets of points with the same distance^{[11]}

```
if (Iteration==IterationMax)
/* interior of Mandelbrot set = color is proportional to modulus of last iteration */
else { /* exterior of Mandelbrot set = black */
color[0]=0;
color[1]=0;
color[2]=0;
}
```

- fragment of code : fractint.cfrm from Gnofract4d
^{[12]}

bof60 { init: float mag_of_closest_point = 1e100 loop: float zmag = |z| if zmag < mag_of_closest_point mag_of_closest_point = zmag endif final: #index = sqrt(mag_of_closest_point) * 75.0/256.0 }

## Period of hyperbolic componentsEdit

Period of hyperbolic component of Mandelbrot set is a period of limit set of critical orbit.

Algorithms for computing period:

- direct period detection from iterations of critical point z = 0.0 on dynamical plane
- "quick and dirty" algorithm : check if then colour c-point with colour n. Here n is a period of attracting orbit and eps is a radius of circle around attracting point = precision of numerical computations
- "methods based on interval arithmetic when implemented properly are capable of finding all period-n cycles for considerable large n." (ZBIGNIEW GALIAS )
^{[13]} - Floyd's cycle-finding algorithm
^{[14]} - the spider algorithm
- atom domain, BOF61

## Multiplier mapEdit

### Internal angleEdit

Method by Renato Fonseca : ^{[15]} "a point c in the set is given a hue equal to argument

(scaled appropriatly so that we end up with a number in the range 0 - 255). The number z_nmax is the last one calculated in the z's sequence. "

### Internal raysEdit

When varies and is constant then goes along internal ray. It is used as a **path** inside Mandelbrot set

```
/* find c in component of Mandelbrot set
uses complex type so #include <complex.h> and -lm
uses code by Wolf Jung from program Mandel
see function mndlbrot::bifurcate from mandelbrot.cpp
http://www.mndynamics.com/indexp.html
*/
double complex GiveC(double InternalAngleInTurns, double InternalRadius, unsigned int period)
{
//0 <= InternalRay<= 1
//0 <= InternalAngleInTurns <=1
double t = InternalAngleInTurns *2*M_PI; // from turns to radians
double R2 = InternalRadius * InternalRadius;
double Cx, Cy; /* C = Cx+Cy*i */
switch ( period ) {
case 1: // main cardioid
Cx = (cos(t)*InternalRadius)/2-(cos(2*t)*R2)/4;
Cy = (sin(t)*InternalRadius)/2-(sin(2*t)*R2)/4;
break;
case 2: // only one component
Cx = InternalRadius * 0.25*cos(t) - 1.0;
Cy = InternalRadius * 0.25*sin(t);
break;
// for each period there are 2^(period-1) roots.
default: // safe values
Cx = 0.0;
Cy = 0.0;
break; }
return Cx+ Cy*I;
}
// draws points to memmory array data
int DrawInternalRay(double InternalAngleInTurns , unsigned int period, int iMax, unsigned char data[])
{
complex double c;
double InternalRadius;
double RadiusStep; // between radius of points
int i; // number of point to draw
RadiusStep = 1.0/iMax;
for(i=0;i<=iMax;++i){
InternalRadius = i * RadiusStep;
c = GiveC(InternalAngleInTurns, InternalRadius, period);
DrawPoint(c,data);
}
return 0;
}
```

Example : internal ray of angle =1/6 of main cardioid.

Internal angle :

radius of ray :

Point of internal radius of unit circle :

Map point to parameter plane :

For this is equation for main cardioid.

### Internal curveEdit

When is constant varies and varies then goes along internal curve.

```
/* find c in component of Mandelbrot set
uses complex type so #include <complex.h> and -lm
uses code by Wolf Jung from program Mandel
see function mndlbrot::bifurcate from mandelbrot.cpp
http://www.mndynamics.com/indexp.html
*/
double complex GiveC(double InternalAngleInTurns, double InternalRadius, unsigned int period)
{
//0 <= InternalRay<= 1
//0 <= InternalAngleInTurns <=1
double t = InternalAngleInTurns *2*M_PI; // from turns to radians
double R2 = InternalRadius * InternalRadius;
double Cx, Cy; /* C = Cx+Cy*i */
switch ( period ) {
case 1: // main cardioid
Cx = (cos(t)*InternalRadius)/2-(cos(2*t)*R2)/4;
Cy = (sin(t)*InternalRadius)/2-(sin(2*t)*R2)/4;
break;
case 2: // only one component
Cx = InternalRadius * 0.25*cos(t) - 1.0;
Cy = InternalRadius * 0.25*sin(t);
break;
// for each period there are 2^(period-1) roots.
default: // safe values
Cx = 0.0;
Cy = 0.0;
break; }
return Cx+ Cy*I;
}
// draws points to memmory array data
int DrawInternalCurve(double InternalRadius , unsigned int period, int iMax, unsigned char data[])
{
complex double c;
double InternalAngle; // in turns = from 0.0 to 1.0
double AngleStep;
int i;
// int iMax =100;
AngleStep = 1.0/iMax;
for(i=0;i<=iMax;++i){
InternalAngle = i * AngleStep;
c = GiveC(InternalAngle, InternalRadius, period);
DrawPoint(c,data);
}
return 0;
}
```

### Boundaries of hyperbolic componentsEdit

### Centers of componentsEdit

**Video**Edit

see 3D

**Speed improvements - optimisation**Edit

- general optimization
- Speed improvements by Robert Munafo
- fractalforums : help-optimising-mandelbrot
- The Computer Language Benchmarks Game
- Koebe 1/4 theorem by claudiusmaximus

## SymmetryEdit

The Mandelbrot set is symmetric with respect to the x-axis in the plane :

colour(x,y) = colour(x,-y)

its intersection with the x-axis ( real slice of Mandelbrot set ) is an interval :

<-2 ; 1/4>

It can be used to speed up computations ( up to 2-times )^{[16]}

## Bailout testEdit

Instead of checking :

compute ER2 once and check :

It gives the same result and is faster.

## Period detectionEdit

"When rendering a Mandelbrot or Julia set, the most time-consuming parts of the image are the “black areas”. In these areas, the iterations never escape to infinity, so every pixel must be iterated to the maximum limit. Therefore, much time can be saved by using an algorithm to detect these areas in advance, so that they can be immediately coloured black, rather than rendering them in the normal way, pixel by pixel. FractalNet uses a recursive algorithm to split the image up into blocks, and tests each block to see whether it lies inside a “black area”. In this way, large areas of the image can be quickly coloured black, often saving a lot of rendering time. ... (some) blocks were detected as “black areas” and coloured black immediately, without having to be rendered. (Other) blocks were rendered in the normal way, pixel by pixel." Michael Hogg ^{[17]}

```
// cpp code by Geek3
// http://commons.wikimedia.org/wiki/File:Mandelbrot_set_rainbow_colors.png
bool outcircle(double center_x, double center_y, double r, double x, double y)
{ // checks if (x,y) is outside the circle around (center_x,center_y) with radius r
x -= center_x;
y -= center_y;
if (x * x + y * y > r * r)
return(true);
return(false);
// skip values we know they are inside
if ((outcircle(-0.11, 0.0, 0.63, x0, y0) || x0 > 0.1)
&& outcircle(-1.0, 0.0, 0.25, x0, y0)
&& outcircle(-0.125, 0.744, 0.092, x0, y0)
&& outcircle(-1.308, 0.0, 0.058, x0, y0)
&& outcircle(0.0, 0.25, 0.35, x0, y0))
{
// code for iteration
}
```

### Cardioid and period-2 checkingEdit

One way to improve calculations is to find out beforehand whether the given point lies within the cardioid or in the period-2 bulb. Before passing the complex value through the escape time algorithm, first check if:

to determine if the point lies within the period-2 bulb and

to determine if the point lies inside the main cardioid.

### Periodicity checkingEdit

Most points inside the Mandelbrot set oscillate within a fixed orbit. There could be anything from ten to tens of thousands of points in between, but if an orbit ever reaches a point where it has been before then it will continually follow this path, will never tend towards infinity and hence is in the Mandelbrot set. This Mandelbrot processor includes periodicity checking (and p-2 bulb/cardioid checking) for a great speed up during deep zoom animations with a high maximum iteration value.

## Perturbation theoryEdit

Very highly magnified images require more than the standard 64-128 or so bits of precision most hardware floating-point units provide, requiring renderers use slow "bignum" or "arbitrary precision"^{[18]} math libraries to calculate. However, this can be sped up by the exploitation of perturbation theory^{[19]}. Given

as the iteration, and a small epsilon, it is the case that

or

so if one defines

one can calculate a single point (e.g. the center of an image) using normal, high-precision arithmetic (*z*), giving a *reference orbit*, and then compute many points around it in terms of various initial offsets epsilon-zero plus the above iteration for epsilon. For most iterations, epsilon does not need more than 16 significant figures, and consequently hardware floating-point may be used to get a mostly accurate image.^{[20]} There will often be some areas where the orbits of points diverge enough from the reference orbit that extra precision is needed on those points, or else additional local high-precision-calculated reference orbits are needed. This rendering method, and particularly the automated detection of the need for additional reference orbits and automated optimal selection of same, is an area of ongoing, active research. Renderers implementing the technique are publicly available and offer speedups for highly magnified images in the multiple orders of magnitude range.^{[21]}

# More tutorials and codeEdit

- in Basic see Mandelbrot Dazibao
- in Java see Evgeny Demidov
- in C see Linas Vepstas
- in C++ see Wolf Jung page,
- in Factor program by Slava Pestov
- in Gnuplot see Tutorial by T.Kawano
- in Lisp (Maxima) see :
- in Octave see wikibooks or another verion by Christopher Wellons

- How to Plot the Mandelbrot Set By Hand
- comparison of various languages :
- Computer Language Benchmarks Game : Compare the performance of ≈30 programming languages using ≈12 flawed benchmarks for 4 different combinations of OS/machine.
- rosettacode
- Fractal Benchmark in Ruby, Io, PHP, Python, Lua, Java, Perl, Applescript, TCL, ELisp, Javascript, OCaml, Ghostscript, and C by Erik Wrenholt
- in PDL, IDL, MATLAB, Octave, C and FORTRAN77 by Xavier Calbet

- ASCI graphic :
^{[22]}- ASCII Graphics at Mu-Ency by Robert P. Munafo
- using scripting languages by Warp
- Fractal Benchmark by Theo Wollenleben
- using Lisp on Bill Clementson's blog

- 3D

# ReferencesEdit

- ↑ parameter plane in wikipedia
- ↑ Mandelbrot set in wikipedia
- ↑ complex quadratic polynomial in wikipedia
- ↑ reenigne blog : mandelbrot-set-taxonomy
- ↑ The logistic equation by Didier Gonze October 4, 2013
- ↑ Ljapunov Exponent and mandelbrot set by janthor
- ↑ Image by Anders Sandberg
- ↑ Fractint : Misc. Options and algorithms
- ↑ Java™ Number Cruncher: The Java Programmer's Guide to Numerical Computing By Ronald Mak
- ↑ Firefly Application Help by Terry W. Gintz
- ↑ Fractint doc by Noel Giffin
- ↑ gnofract4d
- ↑ Rigorous Investigations Of Periodic Orbits In An Electronic Circuit By Means Of Interval Methods by Zbigniew Galias
- ↑ Mandelbrot set drawing by Milan
- ↑ The Mandelbrot set by Renato Fonseca
- ↑ How to use symetry of set
- ↑ FractalNet by Michael Hogg
- ↑ arbitrary precision at wikipedia
- ↑ perturbation theory in wikipedia
- ↑ "Superfractalthing - Arbitrary Precision Mandelbrot Set Rendering in Java". http://www.fractalforums.com/announcements-and-news/superfractalthing-arbitrary-precision-mandelbrot-set-rendering-in-java/.
- ↑ "Kalles Fraktaler 2". http://www.chillheimer.de/kallesfraktaler/.
- ↑ ASCII graphic