# Fractals/Iterations in the complex plane/Mandelbrot set interior

This book shows how to code different algorithms for drawing parameter plane  ( Mandelbrot set  ) for complex quadratic polynomial.

One can find different types of points / sets on parameter plane 

# Interior of Mandelbrot set - hyperbolic components

## The Lyapunov Exponent

Math equation :

$\lambda _{f}(z_{0})=\lim _{n\rightarrow \infty }{\frac {1}{n}}\sum _{i=0}^{n-1}\left(\ln \left|f'(z_{i})\right|\right)$ where :

$f'(x)={\frac {d}{dz}}f_{c}(z)=2z$ means first derivative of f with respect to z

• image and description by janthor 
• image by Anders Sandberg 

## absolute value of the orbit

# 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 sets

Color of point :

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

### bof60

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
• the smallest value z gets during iteration 
• illuminating the closest approach the iterates of the origin (critical point) make to the origin inside the set
• "Each pixel of each particular video frame represents a particular complex number c = a + ib. For each sequential frame n, the magnitude of z(c,n) := z(c, n-1)^2 + c is displayed as a grayscale intensity value at each of these points c: larger magnitude points are whiter, smaller magnitudes are darker. As n rises from 1 to 256, points outside the Mandelbrot Set quickly saturate to pure white, while points within the Mandelbrot Set oscillate through the darker intensities." Brian Gawalt 

Level sets of distance are sets of points with the same distance

if (Iteration==IterationMax)
/* interior of Mandelbrot set = color is proportional to modulus of last iteration */
else { /* exterior of Mandelbrot set = black */
color=0;
color=0;
color=0;
}
</source >

* fragment of code : fractint.cfrm from Gnofract4d <ref>[http://gnofract4d.sourceforge.net/ gnofract4d]</ref>

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
}

===bof61 or atom domains===
[[Fractals/Iterations in the complex plane/atomdomains|Full description]]

<gallery>
File:Mandelbrot Atom Domains Animation.gif|animation
file:MandelbrotOrbitInfimum.png|3D view of bof61
File:Bof61.png|2D view of BOF61
</gallery>

==Period of hyperbolic components==
[[Image:Mandelbrot Set – Periodicities coloured.png|right|thumb|period of hyperbolic components]]
Period of hyperbolic component of Mandelbrot set is a period of limit set of critical orbit.

Algorithms for computing [[Fractals/Mathematics/Period|period]]:
* direct period detection from iterations of critical point z = 0.0 on dynamical plane
* "quick and dirty" algorithm : check if <math>abs(z_n ) < eps   </math> 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 )<ref>[http://www.zet.agh.edu.pl/~galias/publ.html Rigorous Investigations Of Periodic Orbits In An Electronic Circuit By Means Of Interval Methods  by Zbigniew Galias]</ref>
* Floyd's cycle-finding algorithm <ref>[http://milan_va.sweb.cz/Mandelbrot/ Mandelbrot set drawing by Milan]</ref>
* the spider algorithm
* [[Fractals/Iterations in the complex plane/atomdomains|atom domain, BOF61]]
* [[Fractals/Iterations_in_the_complex_plane/Mandelbrot_set/mandelbrot#Period_detection|Period detection]]

==internal coordinate and multiplier map==
[[File:Mandelbrot Components.svg|thumb|right|Components of Mandelbrot set computed using multiplier map]]
[[File:Mandelbrot set - multiplier map.png|thumb|right|Mandelbrot set - multiplier map]]
[[Fractals/Iterations in the complex plane/def cqp#Multiplier map|definition]]
* interior coordinate <ref>[http://mathr.co.uk/blog/2013-04-01_interior_coordinates_in_the_mandelbrot_set.html interior_coordinates_in_the_mandelbrot_set by 	Claude Heiland-Allen]</ref><ref>[http://mathr.co.uk/blog/2014-11-02_practical_interior_distance_rendering.html practical interior_distance rendering by 	Claude Heiland-Allen]</ref><ref>[https://math.stackexchange.com/questions/1151489/test-for-membership-in-mandelbrot-bulb-of-period-n/1151953#1151953 math.stackexchange question: test-for-membership-in-mandelbrot-bulb-of-period-n/1151953#1151953]</ref>

The algorithm by Claude Heiland-Allen:
* check c
** When c is outside the Mandelbrot set
*** give up now
*** or use external coordinate
** when c is not outside (inside or on the boundary) : For each period p, starting from 1 and increasing:
*** Find periodic point z0 such that fp(z0,c)=z0 using [[Fractals/Iterations in the complex plane/periodic points#Newton method|Newton's method]] in one complex variable
*** Find b by evaluating first derivative with respect to z of fp  at z0
*** If |b|≤1 then return b, otherwise continue with the next p

===computing===

For periods:<ref>[https://www.mrob.com/pub/muency/brownmethod.html Brown Method by Robert P. Munafo, 2003 Sep 22. ]</ref>
* 1 to 3 explicit equations can be used<ref>[https://www.mrob.com/pub/muency/exactcoordinates.html Exact Coordinates by Robert P. Munafo, 2003 Sep 22. ]</ref>
* >3 it must be find using numerical methods

====period 1 ====
Start with [[Fractals/Iterations in the complex plane/Mandelbrot set/boundary#Solving system of equation for period 1|boundary equation]] :

c+(w/2)^2-w/2=0;

and solve it for w

<pre>
(%i1) eq1:c+(w/2)^2-w/2=0;
2
w    w
(%o1)                                                                                                        -- - - + c = 0
4    2
(%i2) solve(eq1,w);
(%o2)                                                                                        [w = 1 - sqrt(1 - 4 c), w = sqrt(1 - 4 c) + 1]
(%i3) s:solve(eq1,w);
(%o3)                                                                                        [w = 1 - sqrt(1 - 4 c), w = sqrt(1 - 4 c) + 1]
(%i4) s:map(rhs,s);
(%o4)                                                                                            [1 - sqrt(1 - 4 c), sqrt(1 - 4 c) + 1]
</pre>

so

w = w(c) =  1.0 - csqrt(1.0-4.0*c)

====period 2====
w = 4.0*c + 4;

==== period 3 ====

<math> c^3 + 2c^2 - (w/8-1)c + (w/8-1)^2 = 0</math>

It can be solved using Maxima CAS :

<pre>
(%i1) e1:c^3 + 2*c^2 - (w/8-1)*c + (w/8-1)^2 = 0;

3      2        w       w     2
(%o1)                c  + 2 c  + (1 - -) c + (- - 1)  = 0
8       8
(%i2) solve(e1,w);
(%o2) [w = (- 4 sqrt((- 4 c) - 7) c) + 4 c + 8, w = 4 sqrt((- 4 c) - 7) c + 4 c + 8]
</pre>

==== numerical aproximation====

<syntaxhighlight lang=c>
complex double AproximateMultiplierMap(complex double c, int period, double eps2, double er2){

complex double z;  // variable z
complex double zp ; // periodic point
complex double zcr = 0.0; // critical point
complex double d = 1;

int p;

// first find periodic point
zp =  GivePeriodic( c, zcr, period,  eps2, er2); // Find periodic point z0 such that Fp(z0,c)=z0 using Newton's method in one complex variable

// Find w by evaluating first derivative with respect to z of Fp at z0
if ( cabs2(zp)<er2) {

z = zp;
for (p=0; p < period; p++){
d = 2*z*d; /* first derivative with respect to z */
z = z*z +c ; /* complex quadratic polynomial */

}}
else d= 10000; //

return d;
}


### Internal angle

Method by Renato Fonseca : "a point c in the set is given a hue equal to argument

$arg(z_{n_{max}})=arctan{\frac {Im(z_{n_{max}})}{Re(z_{n_{max}})}}$ (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. "

#### Fractint

Fractint : Color Parameters : INSIDE=ATAN

colors by determining the angle in degrees the last iterated value has with respect to the real axis, and using the absolute value. This feature should be used with periodicity=0

### Internal rays

When $radius\,$ varies and $angle\,$ is constant then $c\,$ goes along internal ray . It is used as a path inside Mandelbrot set


double complex Give_c(double t, double r, int p){
/*
input :
InternalAngleInTurns = t in range [0,1]
p = period

output = c = complex point of 2D parameter plane
*/

complex double w = 0.0;
complex double c = 0.0;

t = t*2*M_PI; // from turns to radians
// point of unit circle
w = r* cexp(I*t);

// map circle to component
switch (p){

case 1: c = (2.0*w - w*w)/4.0; break;
case 2: c = (w -4.0)/ 4.0; break;

}
return c;
}


/* 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 Cx, Cy; /* C = Cx+Cy*i */
switch ( period ) {
case 1: // main cardioid
break;
case 2: // only one component
Cx = InternalRadius * 0.25*cos(t) - 1.0;
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;
int i; // number of point to draw

for(i=0;i<=iMax;++i){
DrawPoint(c,data);
}

return 0;
}


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

Internal angle :

$angle=1/6\,$ $0\leq radius\leq 1\,$ Point of internal radius of unit circle :

$w=radius*e^{i*angle}\,$ Map point $w$ to parameter plane :

$c={\frac {w}{2}}-{\frac {w^{2}}{4}}\,$ For $epsilon=0\,$ this is equation for main cardioid.

### Internal curve

When $radius\,$ is constant varies and $angle\,$ varies then $c\,$ 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 Cx, Cy; /* C = Cx+Cy*i */
switch ( period ) {
case 1: // main cardioid
break;
case 2: // only one component
Cx = InternalRadius * 0.25*cos(t) - 1.0;
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 memory 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;