Mandelbrot & Julia Fractals|
Mandelbrot & Julia Set Generator
Here is a simple Java applet to help you generate your own Mandelbrot and Julia sets:
Click “Generate Image” to view the fractal. You can click on the picture to recenter it or you can manually enter the central coordinates (x0, y0). Then you can zoom in by increasing the dpi. The max iterations has been set for optimal results when you are zoomed out. You will need to increase it if you zoom in a lot.
As an added feature, I have included an option for changing the power of the base equation. For example, power = 3 uses the equation zn+1 = zn3+zc instead of the conventional equation zn+1 = zn2+zc. You can use this feature to generate my favorite Julia Set by setting the method to "Julia Set" and setting xc = 0.5, yc = 0.05, power = 3.0.
Click here to view the source code.
How The Mandelbrot Set Works
The Mandelbrot Set is found by iterating the equation zn+1 = zn2+zc where z0 = 0. The number z is a complex number. We define the Mandelbrot Set to be the set of all complex numbers zc such that zn is finite as n goes to infinity.
There is a theorem which states that it will not be finite if the magnitude of zn ever exceeds 2.|
In order to generate an image, we must iterate this equation repeatedly for every value of zc in the complex plane.
For example, let's say we want to color a pixel at (-1,0.5). We start out with zc = -1+0.5i and z0 = 0 and proceed from there:
z1 = z02+zc = -1+0.5i
z2 = z12+zc = -0.25-0.5i
z3 = z22+zc = -1.1875+0.75i
z4 = z32+zc = -0.1529344-1.28125i
z5 = z42+zc = -2.61839+0.890381i
We stop here because the magnitude |z5| = 2.76564 > 2. We conclude that this point is unbounded and color code our pixel based on the required number of iterations n = 5. Then we repeat the whole process again for each pixel.
How The Julia Set Works
The Julia Set is very similar to the Mandelbrot Set. However, instead of plotting pixels for different values of zc, we assume zc is a given constant for all the pixels and we plot different values of z0. Therefore, there are infinite Julia Sets depending on what value you choose for zc.|
For example, let's say we want to color a pixel at (-1,0.5) for the Julia Set using the constant zc = -1.125+0.25i. We start out with z0 = -1+0.5i:
z1 = z02+zc = -0.375-0.75i
z2 = z12+zc = -1.54688-0.8125i
z3 = z22+zc = -0.60767+2.26367i
We stop here because the magnitude |z3| = 2.34381 > 2. We conclude that this point is unbounded and color code our pixel based on n = 3.