Monday, March 4, 2013

Fractures and Fractals



A wintry day I saw cracks in our parking lot asphalt with salt crystallized around the cracks. The patterns looked nice and reminded me of fractals, and gave a nice topic for a small Processing program.

Move the mouse over the picture to see different patterns! Click to zoom in, right-click to zoom out.



This is a drawing of the Julia set. Moving the mouse changes the (complex) parameter of the fractal. If you middle-click, you see a picture of the Mandelbrot set. There is an interesting and beautiful connection between the Mandelbrot and Julia sets, which we will get to after a very brief description of how the fractals are drawn.

Both fractals are drawn by iterating a complex function: \[z_{n+1} = z_n^2 + c.\] Starting with a value \(z_0\), one can use the equation over and over to find a long sequence of \(z\)s. The fractals are images of the complex plane, where each point is colored depending on how the sequence \(z_n\) behaves. Depending on \(c\) and on the staring value \(z_0\), the magnitude of \(z_n\) either stays bounded or explodes when \(n\) grows. If the sequence explodes, the color is chosen according to how many iterations it took for \(|z_n|\) to become larger than some suitable constant.

For the Mandelbrot fractal one always starts with \(z_0 = 0\), and choose \(c\) according to the point one wants to color. In the Julia fractal, \(z_0\) is the complex coordinate of the point you want to color, while \(c\) is a parameter of the fractal kept fixed for the whole image. Moving the mouse cursor over the image above changes the parameter \(c\).

The connection between the Julia and Mandelbrot fractals is this: The parameter \(c\) of the Julia fractal corresponds to one point in the image of the Mandelbrot set. When \(c\) is inside the Mandelbrot set (the central area traditionally colored black), the corresponding Julia set is connected. Try different points! It seems that the Julia set keeps the looks (the curlyness and fuzzyness) of the place one chooses in the Mandelbrot set. Points at the edge of the Mandelbrot set tend to be the most interesting.

While drawing this fractal, I learned that the color map is the key to getting nice pictures. It took some tweaking to get a nice-looking result. Coloring by the logarithm of the iteration count seems to be a good idea. You can have a look at the fractal source code here. Finally, one can choose some other complex function to iterate. Simply changing \(z^2\) to \(z^3\) or \(z^4\) gives interesting results.

No comments:

Post a Comment

Newer Older Home
Related Posts Plugin for WordPress, Blogger...