### Fractals Blow my Mind! (Part #2)

Today I will delve into more detail (as promised!) about how to use the iterative equation to determine which points belong or don’t belong to a mathematical set. I will use the equation recursively on each point to test if it ever escapes the set, and if so, to record how many iterations it takes to do so. It is possible to zoom into a fractal to infinity, but the processing power required to do so greatly surpasses the abilities of my puny brain, and my post-homework time; instead, just watch this video and be baffled.

I am learning here as well, so bear with me. I will try to simplify my explanation as much as possible, which will eventually be used in my independent assignment. The end purpose of this guide is to draw the Mandelbrot set by hand, understand how it is done, and be able to appreciate the sheer complexity of fractals.

Let’s get right to it, shall we? As I said in my last post, start off by drawing a Cartesian plane with a scale of 0.5, extending to 2 in all directions. In the center of the 9×9 grid should be the origin (0, 0i), like so:

Now, for the tricky part involving calculations; don’t give up all hope just yet, and you will have a beautiful fractal to post on your wall, or whatever you see fit. This will take a while, and a lot of paper, so be prepared to give up some precious time if you actually want to draw it. If not, just read on and enjoy!

Start off with the equation , in which the C is the constant complex number, the point on the grid which we are testing. The Z is the result of the iterations, and starts off as zero, or (0, 0i). There are actually 2 Z’s in the equation, second is the initial Z, which would start at 0, and the first is the “new” Z, the result of the iteration. After doing , the second Z would simply be that point. After that, the Z would be equal to the old Z squared, plus the C. Then you have that result, which would be squared again and then add C. On and on it goes!

For a point to belong to the set, the magnitude of Z must never exceed 2. Either it will continue fluctuating between 0 and 2 no matter how many times you iterate, in which case it belongs to the set and can be labelled so. Else it will eventually expand to infinity after a set number of iterations, in which case it does not belong to the set. The number of iterations is only important if you want to add shading, which shows extra detail that would not be visible otherwise.

Choose a point that you want to know if it belongs to the set. For this example I will start with the top left square (-2, 2i). First determine the magnitude of this number by squaring both the x and y values, adding them, and finding the square root of their sum.

In this case the magnitude would be approximately 2.82. Therefore, the point does not belong to the set, and the iteration count is 0, since it is greater than 2 even before one pass.

**Point (-2, 2i) — Part of the set: No, Iteration count: 1, Color: Red**

Now let’s try the center square, (0, 0).

Obviously 0 is less than 2, and will never increase beyond 2. Therefore this point is part of the set.

**Point (0, 0i) —**** part of the set: Yes, ****Iteration count: 0, Color: Blue or Black**

And how about a slightly harder one? Let’s do (-1.5, 1)

Would you look at that, the magnitude (Z) is not 0, but it is still less than 2. Now I promised we would get to use the equation , and now is our chance to do the second pass, or iteration, using that equation. This is where the trickiest calculations come into play. Here you need to first off square the result of the previous iteration, which is simply (-1.5, 1), by using the multiplication shortcut .

Now we can simply add the x’s and y’s together, and get a complex number in (x, y) format as the result. Then we simply calculate the magnitude of that number to see if it is greater than 2.

At last the point (-1.5, 1) has escaped the Mandelbrot set after a total of 2 iterations. Now that point can be labelled on the Cartesian plane, and the iteration count can also be recorded.

**Point (-1.5, 1) — Part of the set: No, Iteration Count: 2, Color: Green**

What I have just shown you here, can be repeated for any point on the Cartesian plane, no matter how precise it is. To complete this fractal, continue using the equation on each of the 81 individual point on the grid. As you calculate each point, record the iteration count and whether or not it is part of the set in a neat table, to simplify the task of coloring in the fractal.

A quick note here, in this case its quite obvious which points will or won’t escape the set, but it won’t always be that easy. When calculating many precise points, an iteration limit must be set, which if exceeded, means that it will never reach infinity. This limit is the maximum number of times that the point will be iterated through the equation, after which the point is assumed to never increase. Also, some points will form a pattern or alternate between two values; if this happens, it can be assumed that the point will never increase past 2.

Once all the points in the grid have been calculated and you have determined:

A. whether or not it belongs to the set, and

B. how many iterations it has taken to escape,

An example of the fluctuation of some points being iterated through the equation. The red one remains in the set ( under 2) past the threshold, but the blue one surpasses 2 and exponentially increases towards infinity soon after.

you can proceed to the fun part, coloring it in! Start off by choosing a color for points that belong to the set, preferably black, and then a seperate gradient for each quantity of iterations, from at least 0 to 3 iterations. Color in each square with its specific color, and you will have a beautiful fractal of the Mandelbrot Set!

The end result! Quite beautiful, yet it does look somewhat plain and lacking in detail. However, there is a solution to this problem.

I have already spent more than enough time on this blog post, but if you want to further continue this project I’ll let you do it on your own. Simply draw out a new grid with more points and a smaller scale, I recommend 17×17 with a scale of 0.25 or even 21×21 with a scale of 0.2. In other words, you are increasing the resolution, and decreasing the point size. I’m warning you though, The amount of work increases exponentially with an increase in the amount of points, so be prepared to give up a lot of time! Send me your results and I might even feature it here on my blog!

If I was a computer (which sadly, I am not), I would be able to increase the resolution to millions of points, and draw this out in a matter of seconds. I could also add these beautiful colors and be able to zoom in anywhere to nearly infinite detail. Unfortunately, it would take you years to do it on your own; that is why I’m providing you with a program to do it for you, which you can download here: http://www.chaospro.de/cpro40.exe

Enjoy and try out that colorcylcing mode! — Patrick