3D Mandelbrot Set, based on Daniel White’s formula for squaring a 3D hypercomplex number

This is my favorite hypercomplex fractal, based on Daniel White’s creative formula for squaring a 3D hypercomplex number by applying two consecutive rotations. I’m not sure how mathematically meaningful this is, but it is stunningly beautiful. Here is some Mathematica code demonstrating a simple way to render this 3D fractal as a depth map by slowly marching tiny cubes (voxels) toward the boundary:

`(* runtime: 1 minute, increase n for higher resolution *)`

n = 100; Norm[x_] := x.x; Square[{x_, y_, z_}] := If[x == y == 0, {-z^2, 0, 0}, Module[{a = 1 - z^2/(x^2 + y^2)}, {(x^2 - y^2)a, 2 x y a, -2 z Sqrt[x^2 + y^2]}]];

Mandelbrot3D[pc_] := Module[{p = {0,0, 0}, i = 0}, While[i < 24 && Norm[p] < 4, p = Square[p] + pc; i++]; i];

image = Table[z = 1.5; While[z >= -0.1 && Mandelbrot3D[{x, y, z}] < 24, z -= 3/n]; z, {y, -1.5, 1.5, 3/n}, {x, -2, 1, 3/n}];

ListDensityPlot[image, Mesh -> False, Frame -> False, PlotRange -> {-0.1, 1.5}]

### Links

- Mandelbrot Fractal 3D – colorful volumetric rendering, by Krzysztof Marczak
- 3D Mandelbrot, Coral Rift – rendering with global illumination, by Thomas Ludwig, see also the discussion on Fractal Forums

I had to write my own isosurface ray-tracer in order to render these fractals. The above image was made to look like a cloud of smoke using a volumetric technique described by Krzysztof Marczak. The image on the left was made using James Kajiya’s path tracing method for Global Illumination (GI).

### Global Illumination and Participating Media Links

- smallpt – Global Illumination in 99 lines of C++, by Kevin Beason
- MiniLight – simple global illumination renderer
- Subsurface Scattering – Wikipedia
- Subsurface Scattering – papers by Henrik Jensen, explains how to simulate subsurface scattering using photon mapping

Higher power variations of this fractal can be rendered based on the following formula:

{x,y,z}^{n} = r^{n}{cos(nθ)cos(nφ),sin(nθ)cos(nφ),-sin(nφ)}

r=sqrt(x^{2}+y^{2}+z^{2}), θ=atan(y/x), φ=atan(z/sqrt(x^{2}+y^{2}))

I get error in Mathematica: SetDelayed::write: Tag Norm in Norm[x_] is Protected.

You are using a newer version of Mathematica that already has Norm defined. Just remove that line and it should work (unless there are other changes to the newer version of Mathematica that I don’t know about).