The Fractal Programs Quaternion and HyperComplex

Download: Quaternion.zip   HyperComplex.zip

The program "Quaternion" draws the Mandelbrot- and Julia sets for a family of iterations of the form z → z2/2 + αz4/4 + ρ, where α is a real parameter and z and ρ represent a quaternion instead of a complex number which is usually the case. Quaternions can be regarded as 4-dimensional numbers, in the same way as complex numbers can be regarded as 2-dimensional numbers. The fractal lies in the 4-dimensional space, but we must restrict ourselves to look at the part lying in a 3-dimensional subspace. In this space we imagine a plane parallel with the x,y-plane and by which we intersect the fractal and see the part of it lying back (or "below") the plane. The picture is in grey tones, and the intensity of the light is determined by the distance "down" to the fractal (that is, the boundary):

The program does not presuppose experience with the other fractal programs. The brief instructions should be printed out and consulted when using the program. When you start the program, the Mandelbrot set for α = 0 is drawn. This is (apart from being double the size) the quaternion-version of the usual Mandelbrot set, that is, the Mandelbrot set for the family of iterations z → z2 + ρ, where z and ρ are complex numbers.

All operations are carried out using the keys and by entering values. Three decimal numbers determine the nuance af the colour: the luminosity (lum), an exponent (exp) and a displacement (add)(which not must exceed 0.9). You can scroll up and down in these numbers - after pressing Shift, you can scroll in smaller steps. The program is closed by pressing Esc twice. The cursor must be inside the window when operating:

To change the section, place the cursor below the numbers and press one of the keys 4-9; a rectangle will appear. Its position is managed using keys 4-7 and its size using keys 8 and 9. The position is fine-adjusted by the arrow keys and the size is fine-adjusted after pressing key 0. The rectangle is removed using key Z if, by mistake, you have got it ahead.

A new drawing is started using key 1 and stopped by pressing any (random) letter or numerical key. If you want to zoom in quickly, you can, after a sufficiently large portion of the picture has been drawn, press key 8 several times.

The maximum number of iterations can be adjusted by keys 2 and 3. The number is adjusted automatically when zooming, but it can be necessary to adjust it manually. If the interior (the white) is indistinct, the number must be increased, and as the interior is drawn slowly when the maximum iteration number is large, you can provisionally increase the speed by lowering the number.

The intersection plane parallel with the basic plane (the x,y-plane) is given by the height h. This is initially set at 1, and it is adjusted by key H or L. Key H is aimed at the height relative to the former height (e.g. 0.5 if half of the height is wanted), and key L is aimed at the real height. For the Mandelbrot set the height must be positive, as we are not interested in the part lying under the x,y-plane (because the Mandelbrot set is symmetric around the basic plane and abates on the opposite side). The nuance of the colour is calculated by consecutive estimations of the distance to the boundary and, on the basis of these estimations, approximations in steps becoming smaller and smaller. The smallest step is determined by a decimal number called step. This number is adjusted using key G, and it can for instance be 1 for a quick drawing and 0.001 for the final picture. The thickness of the boundary (thickness) is adjusted using key R. If the boundary is too thin, e.g. 0.2, the sequence of approximation may jump past the fractal (giving a black dot); this can be prevented by making the boundary coarser, e.g. 1, or by diminishing the number step.

The parameter α is adjusted using key A. In the pictures above α is 0. Here α is 1 and the section is from a locality where two large domains meet one another in a vertex:

In the complex case, this locality would look like this:

By keying Q the actual picture is saved, and a saved picture is returned to the screen by keying W.

Pressing the key S produces a txt document named "formula" containing all the information relating to the Mandelbrot set. When such a document exists, the program draws this Mandelbrot set when it is started (therefore its name must be changed, e.g. by adding a digit, if it is not to be drawn). Pressing the key D produces a file named "mandel", which besides the information contains the picture so that it appears instantly.

By keying J you go from the Mandelbrot set to the Julia sets of the formula. A Julia set is associated to every point in the plane, and the most interesting ones are those associated to points on the boundary of the Mandelbrot set. The point in the centre of the window is shown, and it can be moved using keys 4-7 and (in size and steps of one pixel) using the arrow keys. We imagine that when the point lies inside the Mandelbrot set (that is, in the white area), then it lies at the same height as the intersection plane, otherwise it lies at the same height as the boundary of the Mandelbrot set. Following this key 1 starts the drawing of the Julia set, and from now on the procedure is the same as for the Mandelbrot sets, but now the height h of the plane of the intersection can be negative (but not smaller than -2). Keying J again brings you back to the Mandelbrot set.

Pressing key S when a Julia set is on the screen produces a txt document named "julia" containing all the information relating to the Julia set. When such a document exists, the program draws this Julia set when started. Pressing key D produces a file named "julia" (but with another icon), which, in addition to the information, contains the picture.

This Julia set is for α = 0 and a point in the Sea Horse Valley - it is twisted in a strange way, but near the plane with height 0 (the basic plane), we find the familiar shapes from the Sea Horse Valley:


The intersection of the Mandelbrot set with the complex plane (that is, the basic plane) is the corresponding complex Mandelbrot set, and this lies symmetrically around the x-axis (because the coefficients in our formula are real). The quaternion-Mandelbrot set (in the 3-dimensional space) is obtained by rotating the complex Mandelbrot set around the x-axis. The boundary of the Mandelbrot set is thus a rotary symmetric fractal "surface" where the x-axis is the generator, and it consists consequently of circles around the x-axis. The Julia set associated to a point in the complex plane (that is, of height 0) also consists of circles around the x-axis. But for a point outside the complex plane the Julia set consists of closed curves or segments of curves lying ascrew in relation to the x-axis. In these fractal surfaces the structure is only fractal in one direction: in the direction orthogonal to this it will have the true character of a curve - a phenomenon also known from the non-complex fractals, see the site Attractor.

If the point of the Julia set belongs to the inside of the Mandelbrot set, the Julia set has one inner Fatou domain for α = 0 and two inner Fatou domains for α ≠ 0. By pressing key K, the inner domain is also drawn. This drawing is slow because the iteration is now towards an attracting cycle of finite points. The iteration stops when a point is within a given distance from a (given) point in that cycle. This distance is: the number precision multiplied by "the width of the section" divided by 100. The precision is adjusted by key T. Initially the precision is set to 0.5, but often it has to be reduced, possibly to 0.01, at the same time as the maximum iteration number is increased. These two numbers must match each other, otherwise there will be flaws in the colouring. The drawing takes place in the same way as before: we estimate the distance to the boundary and work our way down in steps that gradually become smaller and smaller. There is not much to see in an inner domain, as the left picture shows:


Note the touch of threads in the middle and along the sides. The reason why the approximation stops here is that we have hit one of the points that is iterated directly into the cycle (instead of converging towards the cycle). The so-called field lines issue from these points and they end on the Julia set. A field line is orthogonal to the equipotential surfaces, which are the loci for the points of constant iteration number. We do not notice them here, as we do not colour in the usual way. A field line is determined by a direction (outgoing from the given point in the cycle) - see the site RatioField. In the right-hand picture we have drawn field lines, or rather: we have filled the domains between regularly situated field lines. The number of field lines and their thickness are chosen using keys F and E, respectively (the thickness is relative: thickness 1 means that the whole interior is filled up). If the field lines do not run precisely coherently, the precision number (key T) must be diminished and the maximum iteration number (keys 2 and 3) increased. The little circle around one of the points in the cycle, which in the complex case stops the iteration, must now be replaced by a little sphere, and the field lines are constructed on the basis of regularly situated domains on this sphere. As such, we choose the domains that result from a regularly decomposition of the equator circle and from the projection onto this. The field lines above lie in a domain that is very deformed, however in a more regular domain they can be quite decorative:

The technique used to draw the field lines is, however, a little complicated. Drawing is done by working our way down in as large steps as possible, but now it must be examined if a field line is hit. As the steps initially are large, we risk jumping past the field line, therefore we must (by a trial iteration) examine if a field line is in our way, and if so, alter the further procedure. If a field line is in our way, we must go forward in smaller steps, and when it is hit, we must go forwards and backwards in smaller and smaller steps, in order to find the precise point of intersection with the field line. This takes time, nevertheless the picture is drawn faster when the domain is filled with field lines, because these lines mean we do not have to work down further. The steps we go down are usually (that is, when we disregard field lines) half of the estimated distance, and we may now have to reduce the steps. By keying V you can enter an entire number by which the steps are to be divided. For some motives you can get a faultless picture with a small number (e.g. 2), other motives require a large number (e.g. 15), and the drawing can be very slow. For this motif, where α = -4, the drawing is faultless when the steps are divided by 6:

By pressing key P the picture is redrawn in a chosen size and rendered as a BMP file (to the folder with the program). The width in pixels (e.g. 2000) is entered. File to picture and File to average picture mean that the creation of a file named "pre_pict" is commenced. "Average" means that four times as many points are involved and that the average value is used. By this procedure, the often sharp character of the boundary is lessened - as well as dots arising from impossible calculations. The drawing can be interrupted by Pause and continued by restarting the program. When the drawing is finished the program closes and "pre_pict" is converted to a true BMP file named "pict".

By pressing key P during the creation of the file "pre_pict", a picture named "pict0" of the portion of the picture that has been drawn so far is produced. It can be used to test the quality of the large picture, or it can be used instead of this if the motif is upright, in this case the motif is to be placed in the left side of the window and the drawing is stopped when, for instance, half of the window has been drawn.

The document "formula and julia" explains the meaning of the numbers in the documents "formula" and "julia" (there must be the indicated spaces between the lines and there may not be other empty spaces). When you have acquired some experience in the meaning of the numbers (especially the light and the precision), you can adjust the numbers in "formula" or "julia" instead of doing this through the program.

Here is α = 0.25:

By using the arrow keys in the number keyboard, the window can be displaced on the desktop - the position is saved in a txt document named "pos". Pressing Del during the drawing closes the window until the drawing is finished (also when a large picture is being drawn - in this period the program can only be closed via Ctrl+Alt+Del).


The program "HyperComplex" is analog with the program "Quaternion", but here calculations are not based on quaternions, but on pairs of complex numbers, the so-called hypercomplex numbers. Now we operate with two formulas instead of one - and in return they only involve complex numbers. The simplest expression we can imagine is this:

(z, w) → (z2 + ρ1, w2 + ρ2)

where z and w are complex variables and ρ1 and ρ2 are complex parameters. For every pair (ρ1, ρ2) this mapping (from the 4-dimensional space into itself) determines a Julia set. As we only see a part of the Julia set, namely the part lying in a 3-dimensional subspace, the Julia set is not (as in the complex case) clearly self-similar, but it has features which are a combination of the structure of the Julia sets for the iteration z → z2 + ρ for the two ρ-values ρ1 and ρ1. In the 4-dimensional space of pairs of parameters (ρ1, ρ2), we can construct a Mandelbrot set (on the basis of the critical points (0, 0) and ∞). As the basic plane in this space, we choose the "diagonal", which consists of the points of the form (z, z). And as the 3-dimensional subspace to which we must restrict ourselves, we choose the space spanned by the basic plane and a line orthogonal to it. Such a line is determined by a point of the form (e, -e), where e is a complex number of norm 1, and such a number e is again determined by an angle α, which is now our parameter and which is measured in degrees. As before, we intersect the fractal with a plane parallel to the basic plane (z, z) and having a given distance h from it (which means that it passes through the point h(e, -e)), and we see the fractal in the direction against the plane (z, z). Contrary to the fractals constructed with quaternions, which are curved in the direction towards the observer, our new fractals are rectilinear. Here is an example of what the Julia set associated to the point of the Mandelbrot set with the largest height looks like:

The hypercomplex fractals are most interesting at the localities where these rectilinear structures from different (orthogonal) directions meet. But as there is uncleanness in the picture precisely at these locations, we must content ourselves with looking at the pattern from some distance. This picture is for α = 0 and from the top of an isthmus coming up through the See Horse Valley - the uncleanness is discernible along the central line in the picture:

This picture (for α = 45 degrees) clearly shows the reason for the phenomenon: the Mandelbrot set is the intersection of two Mandelbrot sets:

There are localities where there is no collision at all between orthogonal structures, or where the collision is only visible after strong zooming, as for instance here (the angle is 10 degrees):

Also for this family of iterations we can see the interior of the Julia sets and draw field lines in it. The attracting cycle is the product of the cycles for the two iterations z → z2 + ρ1 and z → z2 + ρ2. A sequence of iterations is stopped when a point is within the given distance (determined by the number precision) of the (given) pair (z*, w*) in the product of the two cycles. In order to draw the field lines, we have to choose a regular decomposition of the product of two circles. This product is a torus, and we can divide it into regular parts in the following three ways: we can divide one or the other of the circles into regular intervals, or we can map the torus onto a circle by taking the sum of the associated angles, and regard the dividing up of the torus determined by the dividing up of the circle into regular intervals. The last decomposition is our primary; by pressing key N you go to the next decomposition (the number is shown in the editing window). The primary decomposition results in field lines which closely resemble those seen in the quaternion case:

Half of the field lines are missing in the two other decompositions of the torus; you can only see the field lines which hit the Julia set from the left-hand and right-hand sides respectively. Compare these two pictures of the same locality where the primary decomposition is used in the left picture and a secondary decomposition is used in the right:


In this Julia set (for angle 45 degrees) we clearly see the course of the field lines in a secondary decomposition of the torus:

When the height of the point (ρ1, ρ2) is 0, that is, when the point lies in the basic plane (z, z), and ρ1 = ρ2, the Julia set lies symmetrically around the basic plane, and it has a uniform fractal structure. When ρ1 = ρ2 is real (here -0.5), the Julia set lies symmetrically around both the x-axis and the y-axis, and if we look at two intersections with heights that are opposite numbers (here 0.75), we can see the same place from the front and from the back:


Examples - Quaternion

Julia, α = 0 - the motif has been shown above, but here we have drawn some more field lines and changed the section a little:

Julia, α = 0.123:

Julia, α = -4:

Julia, α = 0:

Julia, α = 8:

Examples - HyperComplex

Julia, α = 90 degrees, here is the same motif with the primary and a secondary decomposition of the torus respectively:

Julia, α = 45 degrees:

Julia, α = 0 degrees, the Julia set point is near the apex of the cardioid of a mini-mandelbrot on the main antenna:

The fractal site

Updated: June 2020

This site is a subsection of juliasets.dk