Fractals/mandelbrot-graphics

Library and c programs for CPU-based visualisation of the Mandelbrot set by Claude Heiland-Allen[1]


InstallEdit

DependenciesEdit

shared librariesEdit

ldd m-render
	linux-vdso.so.1 =>  (0x00007ffcae4e7000)
	libmandelbrot-graphics.so => /home/a/opt/lib/libmandelbrot-graphics.so (0x00007fb8f9a12000)
	libcairo.so.2 => /usr/lib/x86_64-linux-gnu/libcairo.so.2 (0x00007fb8f96df000)
	libmandelbrot-numerics.so => /home/a/opt/lib/libmandelbrot-numerics.so (0x00007fb8f94cf000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb8f92b2000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb8f8ee9000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb8f8bdf000)
	libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007fb8f89bd000)
	libpixman-1.so.0 => /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007fb8f8715000)
	libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007fb8f84d1000)
	libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fb8f8227000)
	libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007fb8f8002000)
	libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007fb8f7dfd000)
	libxcb-render.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007fb8f7bf3000)
	libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fb8f79d1000)
	libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007fb8f77c6000)
	libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fb8f748c000)
	libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fb8f727a000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fb8f705f000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fb8f6e57000)
	libmpc.so.3 => /usr/local/lib/libmpc.so.3 (0x00007fb8f6c3e000)
	libmpfr.so.4 => /usr/local/lib/libmpfr.so.4 (0x00007fb8f69db000)
	libgmp.so.10 => /usr/local/lib/libgmp.so.10 (0x00007fb8f6764000)
	/lib64/ld-linux-x86-64.so.2 (0x0000564eca780000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb8f6560000)
	libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fb8f6336000)
	libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fb8f6132000)
	libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fb8f5f2b000)
objdump -p m-render | grep NEEDED
  NEEDED               libmandelbrot-graphics.so
  NEEDED               libcairo.so.2
  NEEDED               libmandelbrot-numerics.so
  NEEDED               libpthread.so.0
  NEEDED               libc.so.6
objdump -p m-stretching-cusps | grep NEEDED
  NEEDED               libmandelbrot-graphics.so
  NEEDED               libcairo.so.2
  NEEDED               libmandelbrot-numerics.so
  NEEDED               libm.so.6
  NEEDED               libgmp.so.10
  NEEDED               libpthread.so.0
  NEEDED               libc.so.6

gitEdit

git clone https://code.mathr.co.uk/mandelbrot-graphics.git

and in the directory containing mandelbrot-graphics:

 make -C mandelbrot-graphics/c/lib prefix=${HOME}/opt install
 make -C mandelbrot-graphics/c/bin prefix=${HOME}/opt install

hen to run do:

 export LD_LIBRARY_PATH=${HOME}/opt/lib

check :

echo $LD_LIBRARY_PATH

result :

 /home/a/opt/lib

or

 export PATH=${HOME}/opt/bin:${PATH}

check :

    echo $PATH

To set it permanently change file :

  • .profile[2]
  • /etc/ld.so.conf.d/*.conf[3]

updateEdit

gitEdit

From console opened in the mandelbrot-graphics directory :

 git pull

If you made some local changes you can undu them :

 git checkout -f

then

 git pull

Now install again

namesEdit

mEdit

prefix m is from Mandelbrot

r/dEdit

prefix r or d in name describes precision

  • d = double precision
  • r = arbitrary precision

examples:

 m_d_attractor(double _Complex *z_out, double _Complex z_guess, double _Complex c, int period, int maxsteps)
 m_r_attractor(mpc_t z_out, const mpc_t z_guess, const mpc_t c, int period, int maxsteps)

How to use it ?Edit

procedures in lib directoryEdit

  • C source should *only* have #include <mandelbrot-numerics.h>
  • compile and link with pkg-config: see mandelbrot-numerics/c/bin/Makefile for an example
  • quickest way to get started is to just put your file in mandelbrot-numerics/c/bin and run make


m_d_transform_rectangularEdit

 m_d_transform *rect = m_d_transform_rectangular(w, h, c, r); //

where :

  • w = width in pixels
  • h = height in pixels
  • c = center of the image ( complex number )
  • r = radius of the image ( double number

m_d_interiorEdit

find points c of the Mandelbrot set, given a particular hyperbolic component and the desired internal angle. It involves Newton's method in two complex variables to solve[4]

 

where

  •  
  •  
  • p is the period of the target component
  •   the desired internal angle
  • r is internal radius   . When r = 1.0 point is on the boudary. When r = 0 point is in the center of component ( = nucleus)
  •   is a multiplier of point c

Hyperbolic componnet is descibed by

  • period
  • nucleus

Syntax

 extern m_newton m_d_interior(double _Complex *z_out, double _Complex *c_out, double _Complex z_guess, double _Complex c_guess, double _Complex interior, int period, int maxsteps) 
 
 

Input:

  • z_guess
  • c_guess ( usually nucleus of choosen hyperbolic component)
  • interior ( multiplier)
  • period
  • maxstep

Output:

  • c is the coordinates of the point ( c_out)
  • z is periodic point ( z_out)
  • result (m_newton) descibes how Newton algorithm has ended : m_failed, m_stepped, m_converged. It is deined in ~/mandelbrot-numerics/c/include/mandelbrot-numerics.h


Examples of use:

 m_d_interior(&z, &half, nucleus, nucleus, -1, period, 64);
 m_d_interior(&z, &cusp, nucleus, nucleus, 1, period, 64);
 m_d_interior(&z, &third2, -1, -1, cexp(I * twopi / 3), 2, 64);

programs in bin directoryEdit

List :

~/mandelbrot-graphics/c/bin$ ls -1a *.c

result :

m-cardioid-warping.c   
m-render.c             
m-subwake-diagram-b.c
m-dense-misiurewicz.c  
m-stretching-cusps.c   
m-subwake-diagram-c.c
m-feigenbaum-zoom.c    
m-subwake-diagram-a.c


MoebiusEdit

Moebius transformation

./moebius
find point c of component with period = 2 	 multiplier = -0.4999999999999998+0.8660254037844387	 located near c=  -1.0000000000000000+0.0000000000000000
find point c of component with period = 4 	 multiplier = -1.0000000000000000+0.0000000000000000	 located near c=  -1.3107026413368328+0.0000000000000000
find point c of component with period = 4 	 multiplier = -0.4999999999999998+0.8660254037844387	 located near c=  -1.3107026413368328+0.0000000000000000
find point c of component with period = 8 	 multiplier = -1.0000000000000000+0.0000000000000000	 located near c=  -1.3815474844320617+0.0000000000000000
find point c of component with period = 8 	 multiplier = -0.4999999999999998+0.8660254037844387	 located near c=  -1.3815474844320617+0.0000000000000000
find point c of component with period = 2 	 multiplier = -0.5000000000000004-0.8660254037844384	 located near c=  -1.0000000000000000+0.0000000000000000
find point c of component with period = 2 	 multiplier = -0.8090169943749476-0.5877852522924730	 located near c=  -1.0000000000000000+0.0000000000000000
find point c of component with period = 2 	 multiplier = -0.7071067811865477-0.7071067811865475	 located near c=  -1.0000000000000000+0.0000000000000000
find point c of component with period = 2 	 multiplier = -0.6548607339452852-0.7557495743542582	 located near c=  -1.0000000000000000+0.0000000000000000
find point c of component with period = 3 	 multiplier = -1.0000000000000000+0.0000000000000000	 located near c=  -1.7548776662466927+0.0000000000000000
find point c of component with period = 3 	 multiplier = 1.0000000000000000+0.0000000000000000	 located near c=  -1.7548776662466927+0.0000000000000000
find point c of component with period = 6 	 multiplier = -1.0000000000000000+0.0000000000000000	 located near c=  -1.7728929033816239+0.0000000000000000
find point c of component with period = 6 	 multiplier = -0.4999999999999998+0.8660254037844387	 located near c=  -1.7728929033816239+0.0000000000000000
find point c of component with period = 12 	 multiplier = -1.0000000000000000+0.0000000000000000	 located near c=  -1.7782668211110817+0.0000000000000000
find point c of component with period = 12 	 multiplier = -0.4999999999999998+0.8660254037844387	 located near c=  -1.7782668211110817+0.0000000000000000

m-furcation-rainbowEdit

  For non-real C you can plot all the limit-cycle Z on one image, chances of overlap are small.  You can colour according to the position along the path.  
  In attached I have coloured using hue red at roots, going through yellow towards the next bond point in a straight line through the   interior coordinate space (interior coordinate is derivative of limit cycle).  
  I have just plotted points, so there are gaps.  Perhaps it could be improved by drawing line segments between Z values, but I'm not 100% sure if the first Z value found will always correspond to the same logical line, 
  and keeping track of a changing number of "previous Z" values isn't too fun either. Claude[5]


Run:

 /m-furcation-rainbow 13.png  "1/3" "1/3" "1/3"

m-dense-misiurewiczEdit

 
Zoom around principal Misiurewicz point for periods from 2 to 1024

Program is based on m-render.c from mandelbrot-graphics.

It draws series of png images

cardioid warpingEdit

 
Conformal Warping Around The Cardioid In The Mandelbrot Set

The exterior of the cardioid in the Mandelbrot set is warped to give the appearance of rotation.

The transformation is built up from smaller components, including:

  • mapping of the cardioid to a circle
  • Moebius transform of the circle to a straight line
  • linear translation (which is animated)
  • the inverses of the linear translation
  • the inverse of Moebius transform of the circle to a straight line

These transformations and their derivatives (for distance estimator colouring) are described here: https://mathr.co.uk/blog/2013-12-16_stretching_cusps.html

The program to render the animation was implemented in C using the mandelbrot-graphics library found here: https://code.mathr.co.uk/mandelbrot-graphics The program is found in the repository as c/bin/m-cardioid/warping.c https://code.mathr.co.uk/mandelbrot-graphics/blob/60adc5ab8f14aab1be479469dfcf5ad3469feea0:/c/bin/m-cardioid-warping.c

What it the relation between x and internal angle ?

HairnessEdit

 
Zoom About Feigenbaum Point In The Mandelbrot Set Showing Hairiness

m-stretching-cuspsEdit

 
Unrolled main cardioid of Mandelbrot set

One can add usage description :

if (! (argc == 7)) {
    printf("no input \n");
    printf("example usage :  \n");
    printf("%s re(nucleus) im(nucleus) period t_zero t_one t_infinity  \n", argv[0] );
    printf("%s 0 0 1 1/2 1/3 0  \n", argv[0] );
    return 1;
  }


example usage :

 m-stretching-cusps 0 0 1 1/2 1/3 0

Input

  • parent component
    • re(nucleus)
    • im(nucleus)
    • period
  • internal angles of 3 child components:
    • t0
    • t1
    • tinfinity


Test result:

 P0 = -7.5000000000000000e-01 1.2246467991473532e-16
 P1 = -1.2499999999999981e-01 6.4951905283832900e-01
 Pinf = 2.5000000000000000e-01 0.0000000000000000e+00

and image out.png


duble r = 0.5; // proportional to the number of components on the strip, 
 /*
  r = 0.5 gives 4 prominent components counted from period 1 to one side only 
  r = 1.0 gives 10 components
  r = 1.5 gives 15
  r = 2.0 gives 20 ( one can see 2 sides of cardioid ?? because it is near cusp)
  r = 2.5 gives 26
  r = 5.0 gives 50 



It uses:

  • determinats (m_d_mat2 from mandelbrot-numerics library)) for computing the coefficients a,b,c,d of the Moebius transformation[6]
  • m_d_transform_moebius3 function for Moebius transformation defined by 3 points


m-stretching-cusps 0 0 1 1/2 1/3 0
parent component with period = 1 and nucleus = 0.0000000000000000e+00 0.0000000000000000e+00
child component with with internal angle tzero = 1/2 and nucleus c = zero = -7.5000000000000000e-01 1.2246467991473532e-16  
child component with with internal angle tone = 1/3 and nucleus c = one = -1.2499999999999981e-01 6.4951905283832900e-01
child component with with internal angle tinfinity = 0 and nucleus c = infinity = 2.5000000000000000e-01 0.0000000000000000e+00
Moebius coeficients
	a = -0.5000000000000002 ; -0.8660254037844387
	b = 1.4999999999999998 ; -0.8660254037844390
	c = 0.5000000000000002 ; 0.8660254037844387
	d = 1.4999999999999998 ; -0.8660254037844388

image 1_0.500000.png saved
filename = period_r

m-renderEdit

It is a base program for others.

This fragment of code describes how to use it :

int main(int argc, char **argv) {
  if (argc != 8) {
    fprintf(stderr, "usage: %s out.png width height creal cimag radius maxiters\n", argv[0]);
    return 1;
  }

example use will be :

  m-render a.png 1000 1000  -0.75  0 1.5 10000

The result is Mandelbrot set boundary using DEM

 
Baoundary of Mandelbrot set

m-streching-feigenbaum.cEdit

m-subwake-diagram-aEdit

 
m-subwake-diagram-a

m-subwake-diagram-bEdit

 
m-subwake-diagram-b

m-subwake-diagram-cEdit

 
m-subwake-diagram-c

ReferencesEdit

  1. mandelbrot-graphics - CPU-based visualisation of the Mandelbrot set by Claude Heiland-Allen
  2. stackoverflow question how-to-permanently-set-path-on-linux
  3. ubuntu environment Variables
  4. Interior coordinates in the Mandelbrot set by Claude Heiland-Allen
  5. fractalforums.org : tri-furcation-and-more
  6. Explicit determinant formula for Moebius transformation from wikipedia