The post Mandelbulb Introductions appeared first on woofractal.com.

]]>Years went by, and I moved on to 3d graphics programming, working on sky simulations, level of detail rendering, special effects, etc. and those early experiments with fractals fell back into my memory. I moved on from computer games when I needed a proper job, but continued programming in my spare time for a number of years, this time focusing on non-realtime graphics.

After a number of years of messing around with raytracers I eventually started to explore distance estimators and sphere tracing, learning about how to create simple mathematical functions that can describe complex implicit structures, and then transform those structures into detailed 2d renders. And if you’ve taken a similar journey to me, it’s only a matter of time before you start to come across fractal objects.

The easier fractal objects to come up with are self-similar, and based on simple geometric rules, or on space folding and cutting. The mandelbulb though, is something quite different. I like to think of this type of fractal as an “emergent” fractal. The formula that generates it is simple, and the shape it generates is not predictable from the way the formula is created. The mandelbulb is really the successor to that earlier 2d fractal that I used to watch slowly building on my IBM XT, the mandelbrot.

The discovery of the mandelbulb had occurred some years before I came across it, in the late 2000s. A guy called Daniel White became obsessed with an obscure branch of mathematics and computer graphics, and started out on the search to find a three dimensional emergent fractal, which exhibited some of the aspects of the mandelbrot.

At this point people had generated the following types of 3d fractals:

Daniel wasn’t particularly happy with these fractals, they had the appearance of “whipped cream” and didn’t show increasing detail as you zoomed into them. What Daniel was looking for was a formula that created infinite detail, that could be zoomed into repeatedly where you kept finding shadows of the original fractal at greater and greater zooms. And eventually he found what he was looking for.

The basic mathematics of the mandelbulb are very similar to the mandelbrot. You take a hypercomplex number of the form

`z = θi + ϕj + k`

You take this number, raise it to a power and add a constant.

`z`_{n+1} = z_{n}^{8} + c

If those iterations tend towards infinity, then that point is outside the fractal, if they remain within the unit 2 sphere, then that point is inside the fractal. This time around we don’t colour points that are outside the fractal as we do in the mandelbulb.

And a magical fractal appears:

If you’d like to read more about the journey that Daniel took to find these fractals, there’s a great writeup on his website at (https://www.skytopia.com/project/fractal/mandelbulb.html).

To render this fractal people initially used 2d slices to get a sense of the compelxity that existed within the formula, and then stepped on from that to a voxel rendering system that evaluated the formula for stability at the centre of each voxel cell. This allowed satisfying initial results that allowed fractal enthusiasts to verify that there is indeed emergent complexity within this fractal structure.

Shortly after this a number of developers started to use a technical called raymarching with distance estimation to render these fractals in a far more efficient way. In fact, so efficient that they quickly reached a point where it was possible to do near-realtime exploration of these fractals. These days WebGL allows us to have true realtime rendering in the browser, and if you want to take a look, just click the image below to take a look at the viewer that I’ve but together.

There are a few things about these fractals that make them a convincing extension to the mandelbrot fractal. Firstly, there’s a truly infinite amount of detail within the fractal. If you zoom in you can see the same sort of shapes repeating with variations and additional similar detail all the way down to the limits of the floating point accuracy of your GPU (and much deeper if you abandon the realtime approaches).

And if you change the formula to use a power of 2, instead of a power of 8, you’ll find the familiar mandelbrot fractal lying on the horizontal plane of the mandelbulb.

When you get deeply into fractals you’ll find that there are surprising connections between different types of emergent fractal. The same kind of patterns keep popping up. One of the most unusual and surprising connections is that along the x-axis of the mandelbulb, you can find the logistic map, if you plot the values of sequential iterations on a single plot. And now that we’ve found the mandelbrot on the xy plane of the mandelbulb, we can assume that we will once again find the logistic map along the single axis of this three dimensional fractal.

The final interesting aspect of the mandelbulb, is that there are corresponding juliabulb fractals, in the same way that the mandelbrot fractal has corresponding julia sets. In this case the starting condition is based on the 3d coordinate of the fractal, but the constant used in the iteration is fixed at a 3d vector specified by the user. Here’s an example of the julia set using a starting coordinate of (0.6, 0.2, 0.7).

Ultimately then, did this fully satisfy the fractal mathematicians that were seeking their 3d mandelbrot? Originally not so much, there was a feeling that the “whipped ice-cream” elements of the fractal should have more continuous detail:

In the mandelbrot fractal we don’t see these continuous elements on the edge of the mandelbrot set, as there’s continuous detail at every level of zoom. There’s also a sense that the variance of the zoomed in details isn’t quite as varied as the mandelbrot fractal. And there aren’t the lightning fork details that we see in the mandelbrot either.

But for me, I’m satisfied that this is close enough. And with further advanacements in fractal graphics, particularly with hybrid fractals, this mandelbulb structure became instrumental in the explosion of interest in three dimensional fractals that kicked off ever since.

If you’d like to explore the fractal in more detail, please take some time to mess about with the mandelbulb viewer.

And keep an eye out for further articles where I’ll explore some of the further applications of this mathematics in generating beautiful 3d fractals.

The post Mandelbulb Introductions appeared first on woofractal.com.

]]>The post Mandelbrot Orbits appeared first on woofractal.com.

]]>As I mentioned in an earlier article, the Mandelbrot fractal is based around a single simple formula, which is often represented using complex numbers. I won’t bore you with complex number theory, because it’s irrelevant to the fractal. For now just think about each iteration of the formula as a function which acts on a 2 dimensional point in space.

For each iteration of the Mandelbrot formula a simple formula is used which takes the x,y position on the fractal as an input, and is iterated multiple times.

The pseudocode for the mandelbrot is

```
newx = x*x – y*y + cx;
newy = 2*x*y + cy;
```

Now we carry on doing this series of calculations and see what happens to the x and y coordinates. Specifically we’re watching to see whether or not this formula exceeds the circle of radius 2. If it does, then the x and y coordinates will rapidly accelerate away from the centre with each following iteration, the formula is unstable with the cx and cy values that we entered. If the iteration continues to stay within that circle, then we assume the formula is stable.

To colour the fractal we then colour the stable points a fixed colour (normally black). And for all points with an unstable formula, we colour the point based on how many iterations of the formula it took before it exceeded the radius 2 circle.

We can look at this visually to observe how the x and y coordinates behave on each iteration. First up lets take a look at a stable point inside the main cardioid of the Mandelbrot.

As you can see, not much going on… The box on the top left shows each iteration point up to a total of 32 iterations. The first black dot in the middle is 0,0. This goes immediately left to about -0.3, 0.05, and then rapidly hones into a stable coordinate in the white dot.

If I move the cursor close to the edge with the main cardioid something interesting starts to happen.

This time around the iteration points rapidly move out to the coordinates at the edge of the main cardioid, but instead of settling down to a single point, they start oscillating around in a circle. This formula may still remain stable under large numbers of iterations, but it may also start to escape the boundary. We don’t know until we continue to iterate the formula.

Now for something really strange I’ll move the cursor into the main bulb of the fractal (the large circle to the left of the main cardioid).

This time around the formula rapidly becomes stable once again, but now it has two stable locations which it continues to oscillate between.

And if we move into the bulb to the left of this one…

…we suddenly have 4 stable locations within the formula.

I’d strongly advise you to try this yourself by following this link to try it in realtime on your browser.

The next thing to mention is that the really interesting orbits within the formula happen close to the edges of stability. If we move the cursor within a sidebulb, and close to the edge, the orbits can start to make very elaborate patterns.

But what remains really difficult to predict, is whether or not a sequence of positions will remain stable within the radius of 2, or whether it will become unstable. And the only real way to find out is to carry on iterating that formula, and the more you iterate, the more likely you are to find that an orbit is unstable in the longer term.

For example, here’s a fractal with an iteration count of 256.

All of the points in black here have an orbit which is stable up to 256 iterations. Now lets change the fractal to use 512 iterations and see what happens.

The colour palette has changed a bit, but if you look at the black areas of the fractal you can see that there is now a much more clearly defined circular boundary to the dark areas, and previously black pixels now have a colour. Any pixels that are now coloured represent a Mandelbrot orbit which became unstable between 256 and 512 iterations.

You can continue upping the iteration count which will continue to uncover more points on the fractal with unstable iterations, but there are some points within this fractal that will never become unstable. That’s the fundamental beauty of the Mandelbrot fractal.

The post Mandelbrot Orbits appeared first on woofractal.com.

]]>The post Mandelbrot Locations appeared first on woofractal.com.

]]>Firstly lets start with the most obvious features. The very large black area is known as the main cardioid. The word cardioid comes from the Greek for “heart” which makes a certain amount of sense when you look at it.

To the left of the main cardioid you have a perfect circle known as “the main bulb”. There are many of these circles around the main cardioid, and then again around the main bulb, and then again and again as you zoom into the edges of each of the circles.

The next obvious feature that people talk about is “the valley of the seahorses”. This sits between the main cardioid and the main bulb, where the two coloured areas of the manelbrot start fo move towards each other. The name comes from the resemblance of the swirly areas to a seahorse.

These valleys occur whenever a bulb grows out of the edges of the cardoid or a sub-bulb, and they each have that characterstic swirlyness.

Moving back to a sidebulb, you’ll notice that there are “antennae” that move away from each bulb. These antenna have interesting properties. For example, if you look at the sub-bulb at the top of the main cardoid you’ll notice that it has 3 antennae (including the one pointing back at the bulb). We’ll come back to these another time, but you’ll notice that different sidebulbs have different numbers of antennae.

Another named area of the mandelbulb is Elephant Valley. This is on the right handside of the mandelbulb, where the main cardoid turns in towards the origin. The name comes from the resemblance of the antennae to the trunks of elephants.

One area that has a unique feel on the mandelbulb is to the left of the main bulb as you track along the antennae going horizontally left towards the -2 boundary. At this point the antennae are very long and closely resemble lightning.

The mandelbulb itself occurs within the edges of the mandelbulb wherever you look in the fractal. Sometimes it’s slightly warped or squished, but it’s always recognisable. Here’s an example from zooming in deeper into the fractal.

The Julia fractals are a set of fractals closely related to the mandelbrot, which I may come back to some other time. What’s somewhat surprising is that there are areas within the main mandelbrot which look just like julia fractals. Here’s an example found from zooming around the map.

If you’d like to explore the mandelbrot in more detail, feel free to use the mandelbrot viewer available on this site. Happy exploring!

The post Mandelbrot Locations appeared first on woofractal.com.

]]>Continue readingMandelbrot Origins

The post Mandelbrot Origins appeared first on woofractal.com.

]]>The mandelbrot was first studied by the mathematicians Robert W Brooks and Peter Matelski in 1978. The very first image you’ll find of the set is this one, first published by the pair.

Further study was then carried out by Benoir Mandelbrot, and the fractal eventually become synonymous with his work and became known as “the Mandelbrot set” from the mid 1980s.

Renderings of the fractal became commonplace in the 80s, and it’s easy for you to personally build your own Mandelbrot images using freely available software.

This helped the Mandelbrot to become embedded in popular culture, and it also formed the foundation for a set of mathematics that was popularly coined as Chaos Theory.

If you’ve seen Jurassic Park you may remember the droplet scene, where “mathematician” Malcolm, played by Jeff Goldblum talks about how a droplet that starts on the same place of Ellie’s hand will take different routes dependent on variables such as the hairs on the back of her hand, etc. etc. The point of the example is that in certain systems, small variations in initial conditions can lead to significantly different outcomes.

Another common example is the Butterfly Effect. The origins go back to early weather simulations where researchers discovered that very small changes in initial conditions could lead to vastly different forecasts within a day or two’s time. The butterfly effect refers to the idea that a butterfly flapping it’s wings could change the condition of the atmosphere in a subtle way, which could then lead to a significant weather event like a Tornado in a different country, weeks later.

The Mandelbrot is similarly related to chaos theory as it’s a great example of how very small changes in initial conditions (in this case the x,y coordinate) can have a massive effect on the output of an iterated formula. If you zoom in to the fractal you’ll find that moving a very small amount in the x or y coordinate can be the difference between the formula terminating almost immediately (blue in this case), or continuing forever (black).

The other aspect of the Mandelbrot is it’s fractal nature. There are two aspects to this. Firstly the Mandelbrot is self-similar, i.e. the pattern of the original Mandelbrot appears again and again within the fractal itself.

The second aspect of fractals are that they’re infinitely detailed. You can continue zooming into a fractal until you reach the limits of the accuracy of the numbers you’re using in the calculations that generate the image. And with a proper arbitrary precision implementation you can zoom in for as long as you like, constantly finding more and more detail.

The really amazing aspect of the Mandelbrot is the simplicity of the formula which generates these images, but I’ll talk about that in another post!

The post Mandelbrot Origins appeared first on woofractal.com.

]]>Continue readingIntroduction to Mandelbrot Viewer

The post Introduction to Mandelbrot Viewer appeared first on woofractal.com.

]]>In the 1990s I remember the speeds increasing so that it only took a few seconds to render the fractal, and eventually it became possible to render the mandelbrot in realtime, at low resolution, using a bunch of clever hacks. By the 2000s you could render a near-realtime fractal using a standard computer program with a tight loop written in C++. Today the same program runs at lightning speed on a GPU, but fast enough in javascript to be a very useable fractal viewer.

So here’s a quick screenshot of the fractal viewer I’ve put together for this website:

To navigate the fractal you’ll need a mouse and keyboard (no touch controls yet). The keyboard controls are: Arrow keys to move around, Shift-Up or Shift-Down to zoom, numbers 1-5 to change the palette. The mouse controls are: Click and drag to move, mousewheel to zoom.

Once you’ve found your bearings there’s a few menus on the top left that allow you to tweak and view various things.

First up the settings menu:

At the top you have basic information about the canvas size, the mode (more later), the X and Y coordinates and the zoom level. The Settings panel largely controls the colouring of the fractal.

Smooth shading eliminates the bands you see in a basic mandelbrot fractal

aaEnabled multisamples each point on the screen to give a smoother resultant renderer

Offset and Multiplier control the gradient used to render the fractal. Increasing the multiplier will use the gradient multiple times, offset will change the starting point of the gradient (0->1).

Julia mode switches the whole system to a Julia rendered

The Max Iterations text input controls how many times we iterate the mandelbrot formula. Default is 256. Increasing this number increases the time it takes to render the fractal, but reveals more detail that you won’t have seen before.

Fullscreen is useful if you’re trying to render a specific size for instagram etc.

Next up we have the Julia Selector:

The Julia selector screen is used to select the julia x/y parameters when changing the fractal viewer over to Julia Mode. If you zoom out on the mandelbrot you can run the mouse cursor around the edge of the mandelbrot set to see the different types of julia sets that correspond to those coordinates. I’ll talk about this in more detail another time.

And finally we have the Orbit Viewer:

The orbit viewer shows you visually what is happening during each iteration of the mandelbrot formula. The circle shows the circle of radius 1. We flag a point as having escaped when it exceeds the circle of radius 2.

You can click the “Select Orbit Mode” to toggle between orbit updates on click, or when you move the mouse. It’s quite interesting to explore when you zoom out on the fractal as the orbits show definite patterns which I’ll discuss in a seperate article.

**Other Tricks**

The mandelbrot viewer can also be linked to with a query string so that you can share a specific part of the mandelbrot fractal with other folks. As you navigate around the fractal the URL updates, so just copy and paste that into twitter if you’d like to share a specific location.

I’ll probably continue to tweak the application from time to time, so apologies if these instructions are slightly out of date.

Here’s a few links that take you to specific parts of the mandelbrot. Elephant Valley, Seahorse Valley, The Main Bulb and a sub-mandelbrot. Happy viewing!

The post Introduction to Mandelbrot Viewer appeared first on woofractal.com.

]]>