Pixel
Sometimes, what we want to do in an image isn't really cut out for an iterative formula. Or maybe we need to have more information for the coloring formula than we can pass through the z variable. In these cases, we can use a Pixel formula. These formulas essentially just move the action from the calculation formula to the coloring formula. They are simple enough that we won't concentrate on writing them. If you need a Pixel formula, here are a few to try:
Non-Escaping Formulas
Many iterative formulas neither escape to infinity or to a final answer. An example is the Popcorn algorithm, in which two complex variables (a and b) are related:
(If you know calculus, this is similar to a discrete integration of a nonlinear differential equation. If you don’t know calculus, this is similar to “blah, blah, blah.”)
Because of the construction of the equations, a and b very rarely get large. Instead, they wander around the complex plane chaotically. Typically, this kind of formula is used to make an image by counting how many times one of the variables lands on a particular pixel or according to some characteristic of one of the variables.
Regardless of the coloring, this formula has some similarities with more traditional fractal formulas, in that variables are initialized and iterated. Two major differences are the z variable and the bailout condition. There’s no one best choice for z. Some possibilities are:
Since neither a nor b get very large, there’s no bailout per se. Of course, you are free to write any bailout condition you wish, but how do you force the formula to run until the maximum iterations for every pixel? Since the Bailout section evaluates the truth of a logical statement, all we need to do is come up with a logical statement that is always true. That way, the iterating will never stop early. A couple of ways to do this are:
Other problems are relatively easily modeled using Ultra Fractal, for example, the gravitational field between multiple stars (Gravity 2, -3, and -4 in lkm.ufm) or the chaotic bouncing of a ball on an oscillating piston head (Piston in lkm.ufm). Quite often, these formulas allow for great flexibility in implementation (read: not easy to write), and generally require many iterations.
Embossing and Lighting
Other types of formulas may be escape-time or of another kind, written to be used with specific coloring formulas. A prime example of this is an embossing formula. Embossing formulas are named for the effect that you might see with embossed paper (like from the seal of a Notary Public); the color doesn’t change, but the shadows and highlights indicate depth. Some sample embossed images are shown in Figure 11.
![]() Mandelbrot ![]() Fouth-Order Newton |
The embossed effect can be approximated through a judicious use of layering, but is best done through an embossing formula in conjunction with the Embossed coloring (in lkm.ucl or standard.ucl). The basic structure of an embossed escape-time formula is:
Another series of such formulas is the Slope (Mandelbrot, Julia, or Newton) formulas by Damien Jones in dmj.ufm and standard.ufm. Here, three points are iterated for each pixel and then are used to create a three-dimensional surface. A vector perpendicular to that surface is used as the z variable and is passed to the coloring routine. When a Slope formula is used with the Lighting coloring, the result resembles a fractal surface being illuminated from above and to the side. Examples of Slope-Lighting images are shown in Figure 12.
![]() Mandelbrot ![]() Fouth-Order Newton |
Naturally, when you create a formula like one of these that iterates multiple points per pixel, the calculation time increases accordingly.
Homework
Non-Linear Oscillator
In the standard linear harmonic oscillator, a weight hangs on the end of a spring. The weight either has an initial position away from the equilibrium point, or an initial velocity, or both. The force in the spring is proportional to how much the spring is stretched or compressed from the equilibrium point and is directed opposite of the position (so if the weight is pushed up, the spring pushes down). Without friction, the weight would bob up and down indefinitely. Typically, a dampening (friction) force is added, whose magnitude is proportional to the speed of the weight, and whose direction opposes the velocity, so that it always acts to slow the motion. In this problem, we’re going the make the spring force vary with the stretch or compression to some power, and the dampening force vary with a power of the velocity. To deal with the velocity and acceleration of the weight, we’re going to use the position at different points in time. Each iteration of the formula corresponds to one step forward in time.
The equations to be implemented are:
Initialization: