# Fractals/mandelbrot-numerics

mandelbrot-numerics is a library for advanced numeric calculations related with Mandelbrot set by Claude Heiland-Allen.
This is unofficial wiki about it, containing most of maximus/book 'lib' and 'bin' (but no rendering)
See:
* dictionary
* notation
* fork of the library
* Libraries by Claude Heiland-Allen
** exrtact various tools to manipulate EXR images compare with OpenExr
** kf-extras programs for manipulating output from Kalles Fraktaler 2
** mandelbrot-symbolics - symbolic algorithms related to the Mandelbrot set
** mandelbrot-graphics - CPU-based visualisation of the Mandelbrot set
** mandelbrot-text - parsing and pretty printing related to the Mandelbrot set

# Notation
## directories

* bin for programs
* lib for functions with 2 versions
** d for double precision
** r for arbitrary precision
* include

## precision

Precision here means precision of floating point numbers in the numerical computing.
It is a positive integer. It is a number of bits of binary number (

### Function names ( notation)

* double precision: m_d_*
** functions taking pointers to double _Complex use them for output
* arbitrary precision: m_r_*

### how to find precision ?

* start with minimal precision ( double = 53 bits )
* compute new precision = 53 + f(parameter) where parameter is a feature of the procedure ( for example minimal size of the component for m-interior ). In other words new precision is grater then 53

# Installation

" you need to "make install" mandelbrot-symbolics lib before trying anything with mandelbrot-numerics"

## dependencies

* pkg-config
* gmp (libgmp)
* mpfr (libmpfr)
* mpc (libmpc)
* haskell - ghc
* sndfile using : sudo apt-get install libsndfile1-dev
Gcc flags :
From console :

## git
### clone

From directory in which you want to clone git repo:

### compile

and from the same directory :
then to run do:
check :
result :
or
and check :
To set it permanently change file .profile

### test
## update
### git

From console opened in the mandelbrot-numerics directory :
If you made some local changes you can undu them :
then
Now install again

# how to use it

* to include library 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

## Misiurewicz point

* m-feature-database
* m-misiurewicz

### m-misiurewicz

usage:
Description
* uses preperiod of critical point
Examples using double precision
Using bits :

### m-feature-database
## m-describe

m-describe
* official page
* this procedure gives description of point c from the parameter plane.
Use without parameters:
gives usage description:
Check:
* point c = 0 = 0 +0*I= re+ im*I
* with precision = 53 bits
* max period= 20
* max iters = 100
output is :
Another example:

## shape

Versions
* m_d.shape.c
* m_r_shape.c
Description

## size
### atom domain

Atom domain size estimateformula from

### component size

Files:
* m-size.c
* m_d_size.c
** output: complex double size
* m_r_size.c
** output : mpc_t size
// mandelbrot-numerics -- numerical algorithms related to the Mandelbrot set // Copyright (C) 2015-2018 Claude Heiland-Allen // License GPL3+ http://www.gnu.org/licenses/gpl.html
Use without parameters:
gives usage description :
Parameters:
* precision
* nucleus ( complex number c )
* period
** positive integer
** string "double"
Results are 2 numbers is:
* cabs(size) = size and carg(size) = an orientation estimate
* mpc_abs(r, size, MPFR_RNDN); mpc_arg(t, size, MPFR_RNDN);
Code: $ m-size 53 -8.6915874972342078e-01 2.5565708568620021e-01 48 1.1864737161932281e-08 -5.9691937849660148e-01
my program splits it into magnitude and phase (in radians) for convenience, so the minibrot is 1.1865e-8 times the size of the period 1 continent, so multiply the view size of your initial view by this number to get the minibrot to appear about the same size.
Example usage:
output :
In other words:
Minibrot period 48

## period
### box-period

Computing period under complex quadratic polynomial
"But, the box period method detects the period of a *nucleus* within the box - if there is no nucleus there it will fail."
See:
* http://www.mrob.com/pub/muency/period.html

#### binaries

The result :
Example:

#### code

This is one file program using code extracted from Claude's library.

## m-interior

Interior coordinates in the Mandelbrot set
Steps: C is fixed throughout this process - it determines the pixel we want to colour.
The first step is to find a special z (maybe call it w) such that p iterations of z to z^2 + c starting from w, gets you back to w. This is the limit cycle attractor of c. This is done by m_d_attractor, using Newton's method to solve f_c^p(z) - z = 0.
Then to find the interior coordinate for c, take your w, and iterate it p times, calculating the derivative w.r.t. z:
z = w; dz = 1; for (int i = 0; i < p; ++i)
then the interior coordinate is simply dz after the loop. if |dz| < 1 then c is interior to a component of period p
you can colour pixels based on dz (eg angle -> hue, radius -> saturation)
for highlighting the edge you can optionally use the w to find the interior distance estimate (m_d_interior_de).

### Description

* from math.stackexchange
* blog
* "traced boundaries using Newton's method in two variables"
* theory
an algorithm to find points on the boundary 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 system of 2 equations:
${\begin{cases}F^{p}(z,c)=z\\{\dfrac {\partial }{\partial z}}F^{p}(z,c)=b\end{cases}}$
where:
* F is function ( complex quadratic polynomial)
* $F^{p}$ is iterated polynomial
* p is the period of the target component
* $b=re^{2\pi i\theta }$with |r|≤1.
* θ is the desired internal angle.
* First equation describes periodic point
* second equation describes attractive periodic point ( magnitude r of multiplier b is not grater then 1 )
The resulting c is the coordinates of the point on the boundary. It can also be modified to find points in the interior, simply set b=re2πiθ with |r|≤1.
The algorithm for finding numerically interior coordinate b by Claude:
* When c is outside the Mandelbrot set, give up now;
* For each period p, starting from 1 and increasing:
** Find z0 such that Fp(z0,c)=z0 using Newton's method in one complex variable;
** Find b by evaluating first derivative with respect to z at z0;
** If |b|≤1 then return b, otherwise continue with the next p.

### usage

Use without parameters:
gives usage
Input :
| parameter | variable | description |
| precision | int bits | number of binary digits = width of significant = precision. Here one can use : double or 53 ( for double numbers) positive integer = number of bits for MPFR |
| z-guess-re | double zre | real part of the initial guess z_0 for Newton method, use z = 0 |
| z-guess-im | double zim | |
| c-guess-re | double cre | real part of the initial guess c_0 for Newton method, use nucleus of given hyperbolic component |
| c-guess-im | double cim | imaginary part of c_0 |
| interior-r | double ir | Example |
| interior-t | double it | Example |
| period | int period | Period of given hyperbolic component |
| maxsteps | int maxsteps | Example |
Output:
* point c with given internal coordinate from hyperbolic componenet described by period and nucleus
* periodic point z (wucleus)
Example :
How to read it :
* z = 0.5 ( fixed point for c = 1/4)
* c = 0.25
General algorithm:
* choose period
* compute / choose center c from period = initial aproximation
* compute size of component with center c. Compute precision from size
* choose t = p/q and r
* compute

### code

Program m-interior from bin directory
Source code :
* mandelbrot-numerics/c/bin/ m-interior.c
* mandelbrot-numerics/c/lib/m_d_interior.c
* mandelbrot-numerics/c/lib/m_r_interior.c
Functions:
* m_d_interior(&z, &c, zre + I * zim, cre + I * cim, ir * cexp(I * twopi * it), period, maxsteps);
* m_r_interior(z, c, z, c, interior, period, maxsteps);

## m-interior-de

description

## m-attractor

to find a special z (maybe call it w) such that p iterations of z to z^2 + c starting from w, gets you back to w. This is the limit cycle attractor of c. It is done using Newton's method to solve f_c^p(z) - z = 0.
Finds one periodic z point ( point on dynamical plane ) near z-guess
* for :
** period
** c= c-re + c-im* i
* using Newton method with :
** z-guess = z-guess-re + z-guess-im* i ( initial aproximation of the root)
** maxima number of steps = maxsteps
* using number with width of significant = precision. Here one can use :
** double or 53
** positive integer = number of bits for MPFR
or
result :
The precision is set manually in m-attractor to let user experiment.

## m-exray-in

Parameter external ray:
* traced inward ( from infinity to the boundary )
* using Newton method

### Code

Source code:
* c/bin/m-exray-in.c = program showing usage of the library function
* c/lib/m_d_exray_in.c = double ( machine double precision ) version of procedure
* c/lib/m_r_exray_in.c = mpfr version of procedure = (dynamically changed as necessary) precision
variables :
* native ( if true then use double= native precision)
* precision (can be double , see arg_precision )
double version :
mpfr version :

## m-exray-out

Parameter external ray:
* traced outward ( from point c ( from exterior of Mandelbrot set ) to the infinity )
* using Newton method
checkin what ray
* crosses given c point
* land on that c point
arguments:
* precision: input string is converted to integer number, in bits "replace double with 1000 to use 1000 bits instead of native 53". It can be "double" string = native precision.
* c-re = real part of complex c
* c-im = imaginary part of complex c
* int sharpness ( replace 8 with 4 to be less sharp, but don't go too low or it may break )
* int maxdwell
* used only for formatting output (" if you have a desired (pre)period, use that to get the angle formatted nicely" )
** preperiod ( int)
** period (int)
usage :
Example
output ( only binary expansion of externala angle):
or full output:
Input :
Example:
result :
which is

## m-feigenbaum

"Estimate location of period 2P atom using size of period P island, use Newton's method to find its nucleus and size more precisely, repeat"
computes c centers of hyperbolic components for period doubling cascade on the real axis ( so imaginary part is 0):
* center for period 1 : c = 0 ( omitted)
* center for period 2 : c = -1
* center for period 2^2= 4 : c = -1.310702641336833008
* center for period 2^n
Small modification:
It seems that double precision is not enough

## m-feigenbaum3

"estimate location of tip of antenna (renormalized from -2+0i) of period P island using size estimate, from there find nucleus of period 3P island using Newton's method, repeat"
usage:

## m-nearest-roots

prints:
* period + 1
* distance

## nucleus

Example
Using mandelbrot-numerics code to find a period 20000 minibrot near c=i:
result:

## m-render-wakes

Draw wakes filled with solid color, uses mpq type from gmp library

# Images

* Wakes
* Wakes near the period 1 continent
* Wakes near the period 3 island
* Wakes along the main antenna
* Escape route 1/2

# References

* ↑ askubuntu question: package-was-not-found-in-the-pkg-config-search-path
* ↑ stackoverflow question: linux-error-while-loading-shared-libraries-cannot-open-shared-object-file-no-s
* ↑ stackoverflow question how-to-permanently-set-path-on-linux
* ↑ math.stackexchange question: perfect-circles-in-the-mandelbrot-set
* ↑ atom_domain_size_estimation by Claude Heiland-Allen
* ↑ deriving_the_size_estimate by Claude Heiland-Allen
* ↑ on_the_precision_required_for_size_estimates by Claude Heiland-Allen
* ↑ fractalforums.com : deepest-e10000
* ↑ math.stackexchange question test-for-membership-in-mandelbrot-bulb-of-period-n/1151953#1151953
* ↑ math.stackexchange question: what-is-my-method-of-rendering-the-mandelbrot-set-called
* ↑ interior_coordinates_in_the_mandelbrot_set
* ↑ practical_interior_distance_rendering
* ↑ mathoverflow question: algorithm-for-computing-external-angles-for-the-mandelbrot-set
* ↑ fractalforums.org : re-feigenbaum-stretch