Fractals/Iterations in the complex plane/Mandelbrot set/mandelbrot

Speed improvements - optimisation =Symmetry= 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>
 * general optimization
 * Speed improvements by Robert Munafo
 * fractalforums : help-optimising-mandelbrot
 * The Computer Language Benchmarks Game
 * Koebe 1/4 theorem by claudiusmaximus
 * perturbation in Mandelbrot zoom

It can be used to speed up computations ( up to 2-times )

=Bailout test=

Instead of checking if magnitude ( radius = abs(z) ) is greater then escape radius ( ER):

$$ \sqrt{Z_x^2 + Z_y^2} < ER $$

compute square of ER:

ER2 = ER*ER

once and check :

$$ Z_x^2 + Z_y^2 < ER^2 $$

It gives the same result and is faster.

=interior detection= Interior detection method
 * time with detection versus without detection is : 0.383s versus 8.692s so it is 23 times faster !!!!

=Period detection= Period of Complex_quadratic_map - main article

"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

Cardioid and period-2 checking
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:


 * $$ (x+1)^2 + y^2 < \frac{1}{16} $$

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


 * $$ q = \left(x - \frac{1}{4}\right)^2 + y^2 $$
 * $$ q \left(q + \left(x - \frac{1}{4}\right)\right) < \frac{1}{4}y^2. $$

to determine if the point lies inside the main cardioid.

another description

See also
 * cardioid and bulb checking by 	Claude Heiland-Allen

Periodicity checking
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
 * period-2 bulb and cardioid checking

for a great speed up during deep zoom animations with a high maximum iteration value.

=References=
 * T Myers: Introduction to perturbation ...
 * interpretation-of-topology-optimization
 * Derivative Extrapolation From the Mandelbrot Set Glossary and Encyclopedia, by Robert Munafo, (c) 1987-2023.