You can read all about the Mandelbrot Set on Wikipedia.
This section describes the python scripts I have created to generate Mandelbrot and related images.
In the most recent version of the script I've done away with the distinction between Mandelbrot and Julia sets. The new code is generically four dimensional, and allows you to view 2D slices of the combined 4D Mandelbrot+Julia Set obect at any point in 4 space. These slices can be in any of the 6 planes defined by the centre point and two of the vectors (1,0,0,0), (0,1,0,0), (0,0,1,0) and (0,0,0,1). This actually makes the code simpler as we no longer need separate algorithms to generate the Mandelbrot and Julia sets.
The equation to iterate remains
which is iterated until it is obvious that the value of |Z| is approaching infinity (>2 will do) or until we reach the maximum number of iterations we are prepared to try.
In the original code we would set Z0 to (0,0) and vary (cx and cy) to generate a Mandelbrot set, or fix the 'c' value and vary Z0 to generate a Julia set.
The new code does away with this distinction; all 4 co-ordinates are considered equally and we can fix any 2 and vary the other 2. The Julia and Mandelbrot sets are just specific examples from a larger set of possibilities.
Now you choose a point in 4-space (zx,zy,cx,cy) and which of the 6 orthoganal planes you wish to display.
All the colouring schemes and palettes of the previous version are still supported.
The Mandelbrot source code consists of two files, Mandelbrot.py and MandelbrotDriver.py. (These were last Updated on the 11th October 2008.)
Mandelbrot.py contains the code for drawing the patterns, MandelbrotDriver.py provides a user interface for setting the values. This can be driven from a command window by typing it directly in (or as I prefer through a batch file) or from the Python IDE. You will also need the Bitmap code in WindowsBMP.py
Assuming you have you paths set up correctly you can run the driver from the command line, the syntax being
Or from within a python environment as
or by using a list, eg.
Parameters should be separated by spaces and the text in <brackets> should be replaced by actual values. Other characters must appear as shown and there should be no spaces inside parameters. So, for example;
or
will draw an image of the whole Mandelbrot set (up to 600 iterations) in a 1280x1024 bitmap called 'big.bmp', saved in the current directory.
The parameters are;
| −b<number> | The 'blob factor' that controls the level of detail when using the 'stars' or 'bands' colouring algorithm Typical values are quite small, say 0.001. | ||
| −c(<zx>,<zy>,<cx>,<cy>) | The centre of the image. zx, zy, cx and cy are floating point numbers. For instance around the point −c(0,−.875,−0.075,0.669) you can find images like this. | ||
|
|||
| −d<number> | Chooses a the drawing colour scheme (1-8). | ||
| −f<name> | The output file name, without path or extension, eg 'outfile'. Default value is 'mandelbrot' | ||
| −h | Shows some help on the parameters. | ||
| −i<number> | Sets the maximum number of iterations. The default value is 600. More on iterations. | ||
| −l<number> | Ouputs a message after every 'number' rows, allowing you to monitor the progress. Reassuring if you are drawing a very big/deep image. | ||
| −m<number> | Sets the Magnification. '1' is the whole image, values greater than one zoom in for greater detail. Default value is '1'. | ||
| −n | "No Draw". If this parameter is specified then the parameter values will be displayed but the image won't be drawn. | ||
| −p<path> | Sets the path of the output image. Defaults to the current directory. | ||
| −s<w>x<h> | Sets the image size. Default is 160 by 120, −s1280x1024 will create an image 1280 across and 1024 pixels down. | ||
| −t<plane><scheme> | The plane of the pattern
and the colouring algorithm to use. The 'plane' used to be the 'type', so
for backwards compatibility I have retained 'M' for planes parallel to the Mandelbrot plane
and 'J' for the planes containing the Julia sets. The other planes are identified using the
letters A - D. They are:
|
||
| −w(x,y) | Returns the position of the pixel at (x,y). The image isn't drawn. This will be a 'c' value for Mandelbrots and a 'Z' value for Julia sets. It can be used when deciding where to zoom in on a previously generated image. |
The following sequence of images shows progresive zooms as we search for an interesting location to display. The search images are only 160x120 so they can be generated quite quickly. The MandelbrotDriver '−w(<x>,<y>)' option can be used to locate the coordinates of an interesting point in an image. This can then be fed into the next iteration with a larger magnification, and the process repeated, producing a sequence like the one below.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
When we have found an interesting location, like the last image in the sequence, we can then create a higher resolution version.
These two images from the Mandelbrot plane centred around −c(0, 0, 0.27322626, 0.595153338) are from one of the AVIs on the animations page.
The Julia Sets reside on the planes doubly perpendicular to to the Mandelbrot plane. Doubly perpendicular as they only share one point in common. They can be drawn using the MandelbrotDriver '−tJ' option. The Julia set for a given 'c' value looks similar to the Mandelbrot around the same value of 'c' (at high zoom). This can be seen in these images for the 'c' value of (−0.3006818, 0.6600910). Settings:
−tM −c(0,0,0.3006818, 0.6600910)
−tJ −c(<x>,<y>,0.3006818, 0.6600910).
Where <x> and <y> represent the co-ordinates of the image centre. The first two are of the Mandelbrot set, the 3rd and 4th details of the corresponding Julia set. In both cases the pattern is built up from strands of detail radiating from 11 pointed intersections. Click on the images for more detail.
Below are some more Julia images for various 'c' values.
The following two Julia images (center and right) correspond to a point near the centre of the black circle at the centre of the Mandelbrot image (left), c = (0, 0, −0.505, 0.570).
Here the black sections are real, not the consequence of too few iterations. The next set of images is generated round the 'c' value (0, 0, −0.502875, 0.518925). The image on the left is the Mandelbrot, the 2nd and 3rd the corresponding Julia images. You can click on the Julia images for more detail.
This final set of images is an example of how you can find regions of the set that are too complicated to render clearly on a screen. The spiral pattern has 47 spokes radiating from a point. By choosing points in the "Seahorse Vallies", places on the Mandelbrot set where two black circles appear to meet, you can find spirals with any (odd) number of spokes you like.
| Visits since June 2008 | |
1461 - July 2009
674 - October 2008
|
|