Saturday, June 25, 2011

Mandelbulb, 3D fractal maths, and me.

For the last few days, I've been trying to understand the mathematics behind the 3D Mandelbrot, the Mandelbulb. Apparently it works in exactly the same way as the 2D Mandelbrot, except where you had the "complex plane" before, upon which all points are mapped, you now have "hypercomplex space" ...

But unfortunately, I have yet to even begin to understand how it all works. Hell, I'm not even sure about how, in 2D fractals, i=sqrt(-1) ... This simply seems impossible to me, yet it all works when the maths is applied. I have a feeling that if I truly do want to understand such things, I would need to take a few steps back, go restudy the last few years of High School maths and then continue on to University level maths. But there's no way I can do that. The idea actually entices me because I've always loved mathematics and problem solving. So when it's combined with concepts like eternity and chaos, I REALLY get interested, but for now and for the foreseeable future, I just don't have the time.

But, for anyone who cares to try on their own, here's the Mandelbulb formula from Daniel White's site (One of the original discoverers of the 3D MAndelbulb). I tried using this as a starting point to further discover how it all worked, and failed:

What's the formula of this thing?

There are a few subtle variations, which mostly end up producing the same kind of incredible detail. Listed below is one version. Similar to the original 2D Mandelbrot, the 3D formula is defined by:

z -> z^n + c

...but where 'z' and 'c' are hypercomplex ('triplex') numbers, representing Cartesian x, y, and z coordinates. The exponentiation term can be defined by:

{x,y,z}^n = r^n { sin(theta*n) * cos(phi*n) , sin(theta*n) * sin(phi*n) , cos(theta*n) }
r = sqrt(x^2 + y^2 + z^2)
theta = atan2( sqrt(x^2+y^2), z )
phi = atan2(y,x)

And the addition term in z -> z^n + c is similar to standard complex addition, and is simply defined by:

{x,y,z}+{a,b,c} = {x+a, y+b, z+c}

The rest of the algorithm is similar to the 2D Mandelbrot!
Looking at this, my brain just said to me, "Now hold on a minute Jody, do you REALLY need to do this?" No, indeed, I did not. But I searched a bit more and found this page of his, that explains things as best can be done in laymen's terms. This was ok for me... I don't understand the maths, really, but I know more or less how it works, and that's good enough for me.

So after my disillusionment, I thought "Oh well" and jumped straight into Mandelbulb 3D. There are quite a few more 3D Fractal programs which I'll list soon on a "Downloads" page but for our purposes, I'll use Mandelbulb 3D, written by some brilliant guy I only know, through, by the name Jesse.

The first thing I decided to do was try to locate and render an image I'd seen on Daniel White's site, the "Cave of Lost Secrets" :

And this is what I managed to do:

Pretty close! But not sure why it's not the same exactly... Could be that they're two different locations? Or maybe they're somehow rendered differently using different software? Not sure... I'm hoping the good fellas over at will be able to help me with this.

But ok, so, in the next few posts I'll get into what I've learnt so far about how to use Mandelbulb 3D. This is where the funstuff starts :)


  1. I'm a fractal fan but not particularly good at math, so I've always had a little difficulty understanding how these images are formed. Your post and links were really helpful, thanks!

    The Mandelbulb is amazing... I've seen images of it many times since it was first discovered back in 09, but it still makes me say "wow".

  2. Complex numbers are defined in the 2D plane, the expression x + iy, where i = sqrt (-1)
    This definition makes it possible consistent with the usual complex operations (addition, multiplication, division, power, etc.)
    The polar form in the plane x = r cos(theta); y = r sin(theta), allows to the resort complex exponential (elementary mathematics)
    x + iy = r [cos(theta) + i sin(theta)] = r exp (i theta)
    Thus operations, among others, exponentiation is simply:
    (x + i y)^n = (r^n) exp (i n theta)
    ie module power and turn on the angle.
    It happens that there are no complex numbers in a 3D equivalent, then White and Nylander performed a trick, mathematically incorrect, but graphically attractive on the 3D space coordinates to the point P, given by (x, y, z) with its spherical polar form is
    x = r sin(theta)cos(phi); y = r sin(theta)sin(phi); z = r cos(theta)
    Iteration I define a "pseudo power"((n)), because here, in 3D, it is not possible what was done in 2D, by the relationship
    P --> P^((n)) + C
    P(x, y, z)^((n)) = P[(r^n)sin(n theta)cos(n phi),(r^n)sin(n theta)sin(n phi),( r^n)cos(n theta)]
    ie module power and turn on all angles.
    The merit is that with higher values of n and efficient rendering and mastery of graphic techniques, Mandelbulb 8 animation is spectacular.
    But inner points, holow and solid, are a mistery for me
    Please, how all the inner points (holow and solid) into Mandelbulb are defined?