Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 5 of 7
In 1979, Polish mathematician Benoît Mandelbrot began to study a class of fractals known as Julia sets. During this study, he discovered a fractal that has since been named after him. The Mandelbrot set fractal is defined as the set of all complex numbers c such that iterating z = z2 + c (where z is also a complex number) does not escape to infinity.
| Complex numbers |
|---|
| A complex number is a number derived from the complex plane. The complex plane is a two-dimensional area of points where the x coordinate consists of a real number and the y coordinate consists of an imaginary number -- a number multiplied by the square root of -1, known as i. Examples: 2 + 3i and -3 - 6i. A real number such as 7 is a complex number whose imaginary component is 0i. Similarly, an imaginary number such as 5i is a complex number whose real component is 0. |
Use the following algorithm to recursively generate the Mandelbrot set:
To see what the set looks like, check out Figure 5.

Figure 5. The Mandelbrot set.
In Figure 5, all points within the set are colored black; all points not within the set are colored white. The x axis serves as both the real number axis in the complex plane (with a minimum of -2.5 and a maximum of 1.5) and the horizontal pixel axis on the screen. The y axis serves as both the imaginary axis in the complex plane (with a minimum of -1.5 and a maximum of 1.5) and the vertical pixel axis on the screen.
Figure 5 does not indicate how many iterations were required to determine that a point is not in the Mandelbrot set. An iteration-based picture is achieved by assigning a non-black color to each iteration, and then displaying a point in this color when the point is found to not be in the set. All points with the same color require the same number of iterations to determine that they are not in the set, as Figure 6 illustrates.

Figure 6. Colors indicate the number of iterations to discover that a point is not in the Mandelbrot set.
I have created an applet that lets you explore the Mandelbrot set. (See the Resources section for MS.java and MS.html.) Along with the main MS class, this Swing-based applet contains MSPane, a subclass of JPanel. MSPane describes a component that presents the Mandelbrot set via its public void paintComponent(Graphics g) method, as shown in Listing 6.
Archived Discussions (Read only)