
4D Julia Fractals (The Fourth Dimension)
Published: 26/03/2024
Yes, this is a four dimensional (4D) shape, represented in three dimensions anyway.
What you are looking at is a 4D Julia fractal, named after the French mathematician Gaston Julia, who studied it in the early 20th century.
In order to understand the 4D fractal, we first need to look at the 2D version, the Julia Set, which is defined by the iteration of a simple complex function:


In this function, Z is a complex number, while C is a constant complex parameter. We first begin with a value of Z0, and we then repeatedly add the function to create a sequence which looks like this:

Points in the complex or imaginary plane that undergo this sequence will either be classified as belonging to the set, or escaping away to infinity; the boundary that these points form is what gives the Julia set its self similar shape, which has a couple interesting properties;
The julia set is, like most fractals, self similar, which gives it that infinitely repeating pattern along its boundary. The Julia set is also extremely sensitive to changes in the C values of the function. It is important to note that specific values of C can also return the Mandelbrot set because, after all, it is based on the same function. The Julia set is also all connected, meaning that there are no separate islands or elements of the set at any time.
In order to implement this two dimensional (2D) fractal to a four dimensional (4D) space, we must implement the use of quaternions.
Chapter 2. Quaternions
Coordinates are the means of representing a point in space, either through distances or angles. Some of the most common types of coordinate systems are cartesian coordinates, spherical (polar) coordinates, and cylindrical coordinates. These systems can support up to three components.
Quaternions are a 4D (therefore being able to support up to four components) extension of the complex number system, first introduced in the 19th century by the mathematician William Rowan Hamilton. A quaternion is usually written in standard form as:

Quaternions can and often are written in vector form as well: Q = ( W, X, Y, Z ), where the following relations apply.

In standard form, Q is the quaternion, a, b, c, and d are real numbers, while i, j, and k are complex basis vectors (axis), which must satisfy the following relationships:

The main difference between standard and vector form is how much visible information they provide; While standard form provides a complete overview of all the complex and real components separately, vector form condenses these into single components. Due to its simplified format, vector form is what is commonly seen in modern 3D modelling softwares, but specific information can still be retrieved from it through some maths. It is important to note that ultimately, they function the same way and pose no variation in what they represent or can yield, only that one or the other may be more useful in different situations.
In order to implement quaternions to the Julia set and produce the 4D Julia fractal, we first have to generalise the original 2D iterative complex function to utilise quaternions rather than just complex numbers. This gives us the the following equation: f( Q ) = Q ^2 + C
Where Q is a quaternion and hence represents a point in four dimensional (4D) space, while C represents a constant quaternion.
Just like in the 2D Julia set, we begin with a value of Q0, before iterating it to produce a similar sequence:

Now, just like in the 2D version of the Julia set, points will either be classified as belonging to the set (fractal) or outside of it, hence escaping to infinity. Then, again like in the 2D version, the points at the boundary will create that beautiful fractal structure, as seen in the render.
Quaternion multiplication comes to be a little more complex than traditional multiplication, as it utilises many variables. In the Julia set function, the quaternion Q is squared, and therefore multiplied by itself. The square of a quaternion in standard form looks like this:

After the addition of the constant quaternion C to the iteration step, we finally obtain the Julia fractal equation: f( Q ) = Q ^2 + C
This is then recursed iteratively, in order to generate the Julia fractal.
Chapter 3. Enough maths! (Sort Of)
Now with all that out of the way, how can it be translated into a 3D software like Blender to create an image as I did?
We have to recall what has to be done. First define a starting point for the fractal to generate around; Q0, and then create the Julia fractal equation within blender geometry nodes through the use of a series of maths and vector maths nodes; f( Q ) = Q ^2 + C
To do this, I simply took the position node, which gives us the exact position of the object's origin, which can be changed if needed, but I kept that point centred in the object to avoid issues.
In order to set up the function itself, I was able to take it from my previous project, the 3D Mandelbulb fractal, which also uses the same equation, only it uses three dimensional spherical coordinates rather than quaternions. Then I simply created a quaternion vector by taking the three-tuple position node and adding an extra W input to it. Next up I set up the square function within the Julia fractal equation node group. I created the step by step process of the square function as it runs much faster as opposed to using one single power node ( Doing it manually makes Blender perform many simple calculations, while doing it automatically forces Blender to perform one huge operation).
As far as optimization goes, I simply applied the same method I used in the previous project, the 3D Mandelbulb Fractal.
Finally, just like in the Mandelbulb fractal, I set up a vector length node paired with a maths node set to less than, which lets me change and control the threshold at which points will be defined as escaped to infinity. Essentially it lets me decide where I want the boundary of the Julia fractal to be. With that, the model of the fractal was complete, and all that was left was some simple shading, lighting, and compositing, before I could render out the final image.
Sources Used:
Wikipedia - Quaternion
Wikipedia - Quaternions and spatial rotations
Britannica - Quaternion
Wikipedia - Julia set
Wikipedia - Mandelbrot set