How to calculate and display the Mandelbrot Set


The Mandelbrot Set is defined as the set of complex numbers {z0} which remain bounded (i.e. stay within a specified distance from the origin, R0) however many times we perform the Mandelbrot map defined by:
zn+1 = zn2 + z0

For example, z0 = 1 is not a member of the set because z1 = 2, z2 = 5, z3 = 26, etc, i.e. divergent. However, z0 = i is a member of the set because z1 = -1+i, z2 = -i, etc, i.e. bounded.

The Mandelbrot Plot is a two-dimensional graphical representation of the Mandelbrot Set in which points in the complex plane are coloured according to how many iterations of the Mandelbrot map it took before divergence is observed. It is obtained as follows:

For each point z0 in a chosen region of the complex plane, determine the number of iterations of the Mandelbrot map we need to take z0 outside a distance R0 from the origin. Denote this as pathLength(z0).

Define a function Colour(q) that maps pathLength(z0) to one of a set of chosen colours. For example:

Define: q = pathLength(z0) / Max {pathLength(z0) }
For 0 < q < 0.2, let Colour = Red
For 0.2 ≤ q < 0.4, let Colour = Magenta
For 0.6 ≤ q < 0.8, let Colour = Blue, etc.

Thus, for each divergent point z0 we obtain a colour which denotes the number of iterations before it diverged. We then simply plot these colours as a function of z0 using our favourite graphics package.

The following shows how the algorithm to calculate pathLength(z0) may be implemented in a high level computer language (C++, VisualBasic, etc.)

Set:
R0 = 3
iterLimit = 1000

For x0 = -5 to 5 in small increments (e.g. 0.1)
For y0 = -5 to 5 in small increments (e.g. 0.1)

Initialise:
x=x0
y=y0
iterCount = 0
hasDiverged = false

While hasDiverged = false and iterCount < iterLimit
Add 1 to iterCount

Set:
a = x
b = y

Calculate:
x = a2 - b2 + x0
y = (2 × a × b) + y0
r = √(x2 + y2)

If r > R0 Then
Set:
hasDiverged = true
pathLength(x0, y0) = iterCount
End if
End while
Next y0
Next x0

To view the Mandelbrot plot at higher levels of magnification, select a region near to fractal boundaries (i.e. areas where there are abrupt changes in colour) and using, a smaller scale, repeat the process. Do this over and over again to zoom in and see the rich complexity of the Mandelbrot set. An interesting variant on the Mandelbrot plot is the Buddhabrot, so called because it resembles the traditional image of Buddha.

© James Travers 2012


Other articles

Keeping Leopard Geckos

Leopard geckos are one of the easiest exotic pets you can own and with care and attention these cute little reptiles can live up to twenty years.

Discover France

Some of the most enchanting towns and cities in Europe are to be found in France, a country with an incredible cultural and architectural heritage. The food's pretty good as well.

Best of French cinema

Discover the absolute best that French cinema has to offer, from eternal classics of the 1930s to today's auteur masterpieces.



Other things to look at


Copyright © frenchfilms.org 1998-2024
All rights reserved



All content on this page is protected by copyright