Home page 
Mandelbrots and Julia Sets 
IntroductionYou 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. Top level view of the 4D object
Some 4D examples
The AlgorithmThe equation to iterate remains
Z_{n+1} = Z_{n}^{2} + c
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 Z_{0} to (0,0) and vary (cx and cy) to generate a Mandelbrot set, or fix the 'c' value and vary Z_{0} to generate a Julia set. The new code does away with this distinction; all 4 coordinates 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 4space (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 CodeThe 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
python MandelbrotDriver.py <parameters>
Or from within a python environment as
import MandelbrotDriver MandelbrotDriver.go ("<parameters>") or by using a list, eg.
import MandelbrotDriver args = ['s1280x1024', 'fbig'] MandelbrotDriver.go(args) 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;
python MandelbrotDriver.py s1280x1024 fbig
or
import MandelbrotDriver MandelbrotDriver.go('s1280x1024 fbig') 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;
Finding Interesting LocationsThe 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. Julia SetsThe 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) Where <x> and <y> represent the coordinates 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 2^{nd} and 3^{rd} 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. 


(c) John Whitehouse 2011
