Click on the image to see its parameters.

Tutorial: Alternating Functions Fractal Formula

Text and Images © 2013 Kerry Mitchell


This formula allows you to create fractals using several different functions. The functions are alternated, one being used each iteration. The ways in which they are alternated can be changed, as well as the value that is sent to the coloring formulas.


Each iteration, one formula is chosen from a group of up to six. Those functions are chosen from a palette of 12 possibilities: two Mandelbrots, two Julias, four Newtons, and four Popcorn fractal formulas.

The Mandelbrots are of the standard variety, iterating the function z = zn + c, where z is initialized to a constant value (typically, 0) and c takes on the value of the pixel. Each Mandelbrot can have its own power, n.

Likewise, the Julias are of the standard variety. They iterate the function z = zn + c, where z is initialized to the pixel value and c takes on a specific parameter value. Each Julia can have its own power, n, and parameter, c.

To see why there are four Newton functions, consider how the Newton function is typically used. A standard Newton fractal could be created by using Newton's method to find the fourth roots of 1, that is, find z such that z4 = 1. This is a Julia form of Newton fractal; the initial value of z is taken from the pixel and the value c is a constant for all pixels (1, in this example). In this formula, this function is denoted "Newton J." There is also a Mandelbrot form of the Newton fractal, denoted here as "Newton M." With a Newton M, the initial value of z is an input parameter and c is taken from the pixel value. See the below figure for examples of each. The Alternating Functions fractal formula allows for two different Newton M functions and two different Newton J functions. Click on the images to see their parameters.

Newton M
z4 = pixel
initial z = 1
Newton J
z4 = 1
initial z = pixel

There are also four Popcorn functions, two each of two different types. The basic Popcorn algorithm splits z into its real and imaginary parts, x and y, respectively. Then, each component is iterated independently and the new components are combined into the new z:

  1. xold = the real part of zold and
    yold = the imaginary part of zold.
  2. xnew = xold - step × fouter(yold + finner(frequency × yold)) and
    ynew = yold - step × fouter(xold + finner(frequency × xold)).
  3. znew = xnew + (0, 1) × ynew.
While this was intended to be implemented with real values of x, y, step, and frequency, there's no reason why they can't be complex. The real-valued function is Popcorn R and the complex function is Popcorn C. You can use two of each.

Up to six of the 12 functions can be used in the alternating pool. You choose the number of functions in the pool and then define the functions. For example, you could have three functions, #1 being a Mandelbrot, #2 being a Newton M, and #3 being a Popcorn R. Then, you can specify how the functions are alternated. The "ramp" oscillator just repeatedly runs up through the numbers: 1, 2, 3, 1, 2, 3, 1, 2, 3, etc. The "sine" and "cosine" methods tend to put more emphasis are some of the functions. With three functions, the sine method would use them in this order for the first 12 iterations: 2, 3, 3, 2, 1, 1, 1, 3, 3, 3, 1, and 1. The cosine method yields: 3, 3, 1, 1, 1, 3, 3, 3, 2, 1, 1, and 2. The last two methods, "random msb" and "random lsb" are two different ways to randomly choose functions, based on Ultra Fractal's random() function.

Once the function is chosen and iterated, you can determine what value is sent to the coloring formula. The idea for this was taken from Newton fractals. With the Newton formula, z usually settles down to one of a few values. However, the difference between the old and new values of z can be interesting. So, this formula allows you to send the new z (iterate), the difference between the old and new values, their ratio, or some other combination.


The parameters are in three groups: general, those for the functions being alternated, and those for the oscillator (determining the alternating order).

General Parameters

Alternating function Parameters Oscillator Parameters


Back to Tutorials page
Up to my home page