Make attractive pictures of

Mandelbrot and Julia sets


Ultra Fractal


programs for Ultra Fractal inspired of the technique of

The RatioUF program

This program can draw the Mandelbrot set and the Julia sets for any rational function. More precisely the iteration formula is z → f(z) + c, where f(z) is a rational function, that is, a function of the form f(z) = p(z)/q(z), where p(z) and q(z) are polynomials. As a polynomial is given by a row of numbers (the coefficients, in order of increasing exponents), a rational function is given by two rows of numbers, for instance 1 0 -1 and 0 1 -0.01 0.005.

Put the program RatioUF, the file texfil and the colouring algorithm RatioCol in the folder where you have your Ultra Fractal formula programs. The colouring algorithm consists of three programs: Gradient is the primary, Image is for the use of an imported picture of a cyclic colour scale, and FieldLines is for drawing of field lines, this technique demands two imported colour scales. For the moment you can use the enclosed pictures of colour scales. A colour scale is imported by clicking on the folder in Layer Properties/Outside.

Make a txt. document with the name "function" in the folder with the program, and write the coefficients of the rational function in precisely this way:

There must not be other spaces than the space between the two rows, and you must press Enter after the last row.

We get the usual Mandelbrot set if we write:

When RatioUF is activated, an Ultra Fractal program with the name Ratio is produced (you must alter its name if you want to save it). This consists of a "Mandelbrot" program and of one or two "Julia" programs.

The Mandelbrot set is drawn in two different ways, depending on whether or not the first row contains at least two numbers more than the second. In the first case the iterations are towards infinity, and in this case you can, by setting the formula parameter light to a number different from 0, introduce lighting-effect in the Mandelbrot set:

I the second case, that is, when the first row does not contain at least two numbers more than the second, the iterations are towards cycles of finite points. In this case a parameter bailout, determining the distance from the cycle that stops the iteration, is required. It should be as small as possible (e.g. 0.01). This number and the maximum iteration number must match each other, otherwise there will be flaws in the picture. Here is a section of the Mandelbrot set for the function 1   -1 -1 0 1:

And here is a section of the Mandelbrot set for the function 1/z - z∙(1 + 0.001∙z)/(1 - 0.002∙z + 0.001∙z2) = "1 -0.002 - 0.999 -0.001   0 1 -0.002 0.001":

The colour scale is displaced by a pc displace. The closeness of the colours and the intensity of the lighting-effect are determined by two numbers of density which you must carefully adjust. The light is also dependent on two angles. Before you make a picture in large size, you must set the number width to the width (in pixels) of the picture, in order to adjust the numbers in the calculations of the lighting-effect. You should also make the boundary thinner, when you draw a large picture.

The Mandelbrot set is constructed on the basis of two so-called critical points (= the solutions to the equation f'(z) = 0). All the critical points are calculated automatically by the program, and they are lying symmetrically around the x-axis (because the coefficients of our rational function are real). If the first row contains at least two numbers more than the second, infinity is a critical point, and this is used as the one of the two points, so that we in this case only have to choose one critical point. In the opposite case, we have ordered some pairs of critical points, so that we also here only need to make a single choice. Namely in this way: The first consists of two points having the smallest and the largest x-value (if there is a difference in the x-values). The following are all the pairs lying symmetrically around the x-axis. I both cases you make a choice by setting the parameter critical point to one of the numbers 1, 2, 3, ... (if no Mandelbrot set appears you must go to the next number).

A Julia set (or rather, the domain outside the Julia set) is composed of a number of so-called Fatou domains (each containing a critical point), and the "Julia" program draws them all. You can always introduce lighting-effect in the colouring, but it usually looks best when the iterations are towards a super-attracting cycle. As in the first picture above, where the iterations are towards infinity. In this case the colour of the outer Fatou domain and the inner Fatou domain(s) are adjusted separately, and the two domains can be coloured with different colour scales when the colouring program Image is used:

Another case where the cycle is super-attracting, is when the Julia set is associated to Newton-iteration for solvation of an equation. If we have an equation, for instance h(z) = 4 - z2 + z4 = 0, we can construct the rational function f(z) = z - h(z)/h'(z) = (z∙h'(z) - h(z))/h'(z). And then the iteration z → f(z), that is, the Julia set iteration for c = 0, is the Newton-iteration for the solvation of the equation: for every point outside the Julia set the iteration will lead to a solution. The calculation of f(z) can be performed by the program, so that you for this type of function only need to enter the coefficients of the equation: write a casual letter character ("a", for instance) and just after this the coefficients of the equation (and press Enter), then the program rewrites the "function" document. In our case "a 4 0 -1 0 1" is rewritten to "-4 0 -1 0 3   0 -2 0 4". In the Julia set we can find this motif:

In this case you should (after reopening the "function" document) make alterations in the numbers, alter -2 to 2, for instance:

There are now two Fatou domains, and as neither are super-attracting we have avoided lighting-effect.

Here are Julia sets for 0.01 0 -1   0 1 -0.1 0.03 and 1 0 -1   0 1 -0.01 0.005:

If the first row does not contain at least two numbers more than the second (so that the iterations are towards cycles of finite points), there is a program more for Julia sets. It is called "JuliaField" and it is, combined with the colouring program FieldLines, for drawing of field lines in the Julia set. These are the lines orthogonal to the equipotential lines, and we colour the domains between regularily situated pairs of field lines. The colouring is determined by the distance to the centre line of the field line (density/across) and by the potential function (density/along), and this colouring can be mixed with the colouring of the background. As two colour scales are required, these must be imported. For the functions 1 0 0 2   0 0 3 (Newton-iteration for the equation z3 = 1) and 0 1 0 -0.16667   1 0 -1 0 0.25 the field lines can look like this:

This program draws only one of the Fatou domains, and this is chosen by setting the number Fatou domain to one of the numbers 1, 2, 3, .... The field lines are determined by their number, their (relative) thickness (≤ 1) and a number transition determining the mixing of the colours of the field lines with the background - e.g. 0.1 for a soft transition and therefore indistinct and thinner looking field lines, and 4 for more well defined field lines. If the field lines do not run precisely coherently, the bailout number must be diminished and the maximum iteration number increased. Here is the function 1   1 0 0 1, and the background is made of one colour by setting the density to 0:

The Mandelbrot program switches to "Julia", you can make it to switch to "JuliaField" by moving the semicolon at the end of the program (and save). Here is the function 1 -1 -2   0 1 -0.01 0.005, there are two field lines and they are made a little thicker than allowed:

With the program ColourScale you can produce a picture of a colour scale made with Ultra Fractal. The program draws a cyclic colour scale instead of a fractal, and is to be combined with the colouring algorithm Gradient. Save the picture as a file of width 720 pixels (and reduce hereafter the height to 60 pixels, for instance).

The RatioI and RatioF programs

These programs are versions of the previous program that are pure Ultra Fractal programs (therefore not produced by an external program). Instead of being entered in a txt document (read by the external program) the function is entered in the Class Library document rational.ulb. You write the coefficients in this way and save:

After this you run the program RatioI ("infinite") or RatioF ("finite") depending on whether or not the degree of the numerator c[i] is at least two larger than the degree of the denominator d[i].

The FuncI and FuncF programs

These programs are versions of the previous programs where the function needs not be rational. The function is written in the Class Library document compfunc.ulb in the formula language of Ultra Fractal. For instance:

The programs are for iterations towards infinity and towards cycles of finite points, respectively. On the basis of the expression of the function, you must decide which of the programs is to be applied. If the function is rational, this will be the first or the second, depending on whether or not the degree of the numerator is at least two larger than the degree of the denominator. If the iterations are towards infinity (FuncI), you must enter the degree of the function in the space "Layer Properties"/"Formula"/"degree". For a rational function, this will be the degree of the numerator minus the degree of the denominator, otherwise you must choose a suitable degree and accept errors in the colouring. The bailout radius must also be chosen manually, in the shape of a power of 10. For a rational function the exponent should be about 30 divided by the degree. For a transcendent function such as sin(z) it must not exceed 3. The programs do not compute all the critical points automatically, FuncI needs one critical point and FuncF, two. These are at first calculated by iterating pre-entered points, but most probably these will have to be altered by entering other coordinates in the space "Layer Properties"/"Formula"/"critical point". As a guide you can run the program CriticalPoints (to be combined with Gradient), which shows a picture of all the critical points:

For the Julia sets, only a single Fatou domain is coloured, namely that containing a point whose coordinates are entered in the space "Layer Properties"/"Formula"/"Fatou point" - preferably a critical point used in the construction of the Mandelbrot set. FuncI allows lighting-effect in the Mandelbrot and Julia sets (by setting light larger than 0), and FuncF allows field-lines in the Julia sets (by setting thickness larger than 0).

For a transcendental complex function, such as sin(z), cos(z), exp(z), ..., which must be assigned degree ∞ and which has ∞ as an attracting fixed point, the potential function for the Fatou domain containing ∞ does not exist, and therefore the colouring cannot be made smooth in the usual way. Besides this, it is possible that the status of ∞ as an attracting fixed point is ambiguous.

This is the case for sin(z) and cos(z). Sin(z) can be defined by sin(x + iy) = sin(x)cosh(y) + icos(x)sinh(y), and we see from this formula, that if we go towards ∞ along a vertical line, the value grows (exponentially) to ∞, but if we go towards ∞ along a horizontal line, the value remains bounded. As an iteration of z by sin(z) + c can be small when z has an arbitrarily high y-value (namely if cos(x) is near 0), the inner Fatou domains extend towards ∞ in the vertical direction, and also in the horizontal direction, because of the periodicity. The same applies therefore for the Julia set. The Fatou domain containing ∞ must here be defined as the Fatou domain containing points having arbitrarily large y-values, but this Fatou domain is not an open set: it has no interior points. In the colouring it is therefore inseparable from the Julia set, which consists of infinitely dense lying threads. So, if there are no inner Fatou domains, the Julia set is lying densely in the plane, implying that the whole plane should be coloured as the boundary. Nevertheless, the computer gives us a non-trivial picture:

The reason is that we are forced to use a relatively small radius of the large circle determining the stopping of the iteration, owing to the exponential growth of sin(z) in the y-direction. Therefore the sequences of iteration stop after only few iterations, and we colour on the basis of the number of iterations. As the colour of a point c outside the Mandelbrot set is the colour of the (second) critical point of the Fatou domain for c containing ∞, the domain outside the Mandelbrot set is, like the outer Fatou domain, without interior points: it is interwoven with infinitely lying threads. This wire mesh makes up a continuation of the usual boundary, which is unaffected by the phenomenon, as the distance function is unaffected by the nature of the function. For a rational function, the boundary consists of the points such that the associated Julia set contains the (second) critical point. However, for a transcendental function this set can be larger than the boundary constructed from the distance function, and in our case it lies densely in the domain outside the interior of the Mandelbrot set. Nevertheless we get a colouring, because the iterations stop early. We are here in the Sea Horse Valley of a mini-mandelbrot of the Mandelbrot set for sin(z) + c:

For iteration towards finite cycles (or rather, non-super-attracting cycles), the Julia sets look like those for rational functions. But it can happen that there are small circles in the picture of only one colour, because it is impossible here, at a specific step in the iteration, to calculate the next value of the transcendental function in the formula (such circles are visible on the next picture of a Julia set with field lines). The Mandelbrot set for 1/cos(z) has a look that is typical for the rational functions where the iterations are towards finite cycles:

As cos(z) is periodic with period 2π, the Mandelbrot set and the Julia sets for 1/cos(z) will repeat themselves along the x-axis. The section above is of width 2π. The critical points for 1/cos(z) are the solutions to the equation sin(z) = 0, that is, the points nπ (n = 0, 1, 2, ...). We have used 0 and π for the construction the Mandelbrot set. As cos(z) has power series expansion 1 - z2/2! + z4/4! - z6/6! + z8/8! - ... (where n! = 12...n), we can get rational approximations to the Mandelbrot set and the Julia sets for 1/cos(z) by restricting this series.

The Mandelbrot set for cos(z) - z2/2 is very similar in shape to the usual Mandelbrot set, but it is polluted. For the inverse function 1/(cos(z) - z2/2) we can find this Julia set:

Here is a Julia set for 1/z - 1/sin(z):

Julia set for z/2 + 1/sin(z):

Julia set for tan(z)/cos(z) (one of the Julia sets above made with RatioUF is for a rational approximation to this function):

For more instructions and ideas for formulas - and for the production of cyclic colour scales - see the Ratio and RatioField sites.

The Quaternion program

This Ultra Fractal program draws the Mandelbrot set and the Julia sets for the family of iteration z → z2/2 + p∙z4/4 + c, where p is a real parameter and where z and c represent quaternions, instead of, as usually, complex numbers (p = 0 gives the quaternion version of the usual Mandelbrot set). The picture is in grey scale, and program is to be combined with the colouring algorithm QuatCol. The picture is drawn by approximations "down" to the fractal in smaller and smaller steps.

The fractal is cut through by a plane parallel to the basic plane, and we see the part lying back (or below) this plane. The plane is determined by a level which for the Mandelbrot sets must be larger than 0, and for the Julia sets must be larger than -2. Here is a section of the Mandelbrot set for p = 1:

The height of the Julia set point is initially the same as the level of the plane cutting the Mandelbrot set. Here is a Julia set for p = 0:

If the parameter interior is set to a number different from 0, the interior of the Julia set is also drawn, and you can draw field lines in it:

The precision is determined by a number step, which is the smallest step used in the approximations, and a number additional precision, which is a number the successive estimations are divided by. The first must be sufficiently small and the second sufficiently large, in order to prevent jumping past the boundary or the field lines (they should for instance be 0.01 and 4 for the final picture). The parameter bailout has the same meaning as above. The light is determined by three numbers: intensity, exponent and turn down. The last number must be < 0.9.

For more instructions see the Quaternion site.

The programs

The formula programs

RatioUF: A program that can produce Ultra Fractal formula programs for drawing of the Mandelbrot set and the Julia sets for a rational function. The rows of coefficients of the two polynomials are written in a txt. document called "function".

RatioI and RatioF: Ultra Fractal formula programs for drawing of the Mandelbrot set and the Julia sets for a rational function, whose coefficients are entered in the Class Library document rational.ulb (RatioI for iteration towards infinity and RatioF for finite iteration).

FuncI and FuncF: Ultra Fractal formula programs for drawing of the Mandelbrot set and the Julia sets for an arbitrary function entered in the Class Library document compfunc.ulb (FuncI for iteration towards infinity and FuncF for finite iteration).

Quaternion: Ultra Fractal formula program for drawing of the Mandelbrot set and the Julia sets for z → z2/2 + p∙z4/4 + c, where p is a real parameter and where z and c represent quaternions.

The colouring programs

RatioCol: Colouring program (containing the three procedures 1 Gradient, 2 Image and 3 FieldLines) to be combined with the formula programs except Quaternion.

QuatCol: Colouring program to be combined with Quaternion.

The auxiliary programs

ColourScale: Ultra Fractal formula program (to be combined with RatioCol) that (instead of drawing a fractal) shows the chosen Ultra Fractal colour scale, in order to produce a picture of it (of width 720 pixels) to be used by the colouring procedures 2 Image or 3 FieldLines of RatioCol.

CriticalPoints: Ultra Fractal formula program (to be combined with RatioCol) that (instead of drawing a fractal) shows the situation of the critial points for a function entered in compfunc.ulb (to be drawn with FuncI or FuncF).

Revised: December 2010

This site is a subsection of