## Monday, December 17, 2012

### A three dimensional fractal in 3D

The video below is a fractal. It is also three dimensional. It has also been rendered from two different locations very close to each other. Therefore, you can also see it in three dimensions.

If you're not used to using YouTube's 3d capabilities then don't worry, this guy has a tutorial video explaining how to see the full three-dimensionality of the video without the need for glasses. It's just like magic eye in reverse, basically (though I'm not sure how good it is for your eye muscles).

If you liked that you should read the description of how the Mandelbulb was discovered. The Mandelbulb was made by people looking for a three dimensional analogue of the well known Mandelbrot set. If you don't know what the Mandelbrot set is, first watch this video, then read about what you just saw at Wikipedia.

None of the Mandelbulb, or the Mandelbrot set or the 3d fractal (a Mandelbox) shown above were designed by a human mind. All of the complexity found in the images comes about from defining structures in two or three dimensional space as the set of points that are or are not solutions to relatively simple mathematical algorithms. For example, the algorithm describing the Mandelbrot set can be described in just one line:
"... the Mandelbrot set is the set of values of c in the complex plane for which the orbit of 0 under iteration of the complex quadratic polynomial $$z_{n+1} = z_n^2 + c$$ remains bounded".
All of the complexity you can see in the entire ten minutes of the Mandelbrot set video I linked to above is defined in that one simple sentence.

1. The last sentence of this post is a bit of a fib. The colours in the Mandelbrot set would require one more line to define. And, also, there is a lot of creativity and imagination that goes into the rendering of the three dimensional fractals. The shading, the lighting, the colouring is all chosen by a human. However, the basic point stands, which is that the shape of the structures is defined very simply.

2. For a layman the maths is over my head I'm afraid - but the effect is cool.

1. I refuse to accept that, at least for the Mandelbrot set. Just because it takes a little bit of thought doesn't mean it is over your head. If you don't try you will definitely never understand it.

To determine whether "c" is in the set, firstly you just need to square c (i.e. $$c\times c$$, so 2-->4 1-->1 0.9-->0.81, etc) and then add c to the result (i.e. $$c\times c+c$$, so 2-->6, 1-->2, 0.9-->1.71). Then you just keep repeating that process. Square the number you were left with at the end of the first step and add c to it. If the set of numbers that you make just keeps getting bigger, then c does not belong to the Mandelbrot set. If it doesn't, then c does. Simple.

So, zero does belong, one doesn't, etc...

The only thing that makes this more complicated is that it uses complex numbers. But, at least in this application, complex numbers are not difficult. You just write a complex number as $$c=a+b\times i$$ and remember that $$i^2=-1$$ (and a and b are just the ordinary "real" numbers you are used to).

I know that upon reading that you will feel intimidated and believe that it is "over your head" but sit down, read it through slowly, pick a few examples of complex numbers, and see whether they belong to the Mandelbrot set. If you are capable of the arithmetic involved in writing a budget, you are capable of the arithmetic here. It is only through doing and thinking that anyone understands anything. (try $$c=0.5+0.2i$$ and $$c=0+i$$ to see whether they belong... and ask questions if you don't follow any step)

3. OK you lost me at i squared = -1 How do I calculate i so that I can then calculate c? I don't know how to calculate the square root of a negative number. I am a layman :(

1. Cool, you're trying to nut it out.

OK, that's a good question. You should treat $$i$$ as its own thing, you can't work out what it is. $$i$$ is a number just as much as 3 is.

That is to say, $$c$$ has a real component (i.e. $$a$$ ) and an imaginary component (i.e. $$b$$ ). The $$i$$ tells you what part of $$c$$ is the imaginary part. For plotting the Mandelbrot set, the "imaginary" axis is the vertical "y" axis and the "real" axis is the horizontal "x" axis .

Now, to calculate $$c^2$$ you go $$c^2=(a+bi)^2=a^2+2abi+(bi)^2$$. As I mentioned earlier, $$a$$ and $$b$$ are just ordinary real numbers (that is, the numbers you are used to in every day life). And, the only added complication is that $$i^2=-1$$. So, $$c^2=a^2-b^2 + 2ab i$$. That is, the real part of $$c^2$$ is $$a^2-b^2$$ and the imaginary part is $$2ab$$.

I hope that helps, if it doesn't, please keep trying to nut it out and ask more questions. If it does, take out a piece of paper and try all sorts of initial values for $$a$$ and $$b$$. Make a graph and give points a red dot if they are in the Mandelbrot set and a blue dot if they aren't and explore (remember $$a$$ tells you $$c$$'s x-coordinate and $$b$$ tells you $$c$$'s y-coordinate.

4. Yep got all the maths in this post. Now I'll have to try and put it all together for the last paragraph....