All this fiddling around with the Lorenz attractor has made me try to think of other simple, easy graphics hacks that I could make. I recalled that A.K. Dewdney had some simple graphics hacks in one of his *Computer Recreations* column back in the 1980s. It turns out that *Wallpaper for the mind* was published back the September 1986 issue of Scientific American, and was reprinted in Dewdney’s compendium *The Armchair Universe*. I had a quick look, and wrote the following implementation of the HOPALONG program first… discovered? written? by Barry Martin. The program initializes X and Y to zero, and then repeatedly applies a pair of functions to the existing X, Y to generate new values. The program here just prints the values.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define LIMIT 21000000
double sgn(double x)
{
if (x == 0.) return x ;
if (x < 0.0) return -1. ;
return 1.0 ;
}
main(int argc, char *argv[])
{
double x, y ;
// double a = -200, b = .1, c = -80 ;
// double a = 0.4, b = 1, c = 0 ;
// double a = -3.14, b = 0.3, c = 0.3 ;
double a = -1000., b = 0.1, c = -10 ;
double nx, ny ;
int i ;
x = y = 0.0 ;
for (i=0; i<LIMIT; i++) {
printf("%lf %lf\n", x, y) ;
nx = y - sgn(x) * sqrt(fabs(b*x-c)) ;
ny = a - x ;
x = nx ;
y = ny ;
}
}

Depending on the value of a, b, and c, a different set of points is produced. I’ve left several “interesting” values as comments in the code. The set that remains uncommented is actually among the more interesting. It generates all sorts of interesting details. To visualize these points, I found it convenient to use gnuplot. Zooming into a fairly small region, you can see this wonderfully vascular like pattern evolve:

I remember implementing this on my old Atari 400 back then. But I probably didn’t really appreciate how it worked. Now, I recognize that this iteration is some kind of iterated function system, and that you might reasonably expect it to develop these kind of fractal patterns. It seems likely for convergence that the variable b should have absolute value less than 1, but a and c can (I think) be more or less chosen at any scale you desire. The sqrt implements some nonlinearity, which accounts for the many curved features that are visible.

This program has all sorts of fun tweaks. It always begins by initializing x and y to zero, but if you try different starting points, you get different orbits. You could try coloring the dots by slowly changing the way they are colored, or by coloring all points on the same orbit the same color. I removed the sqrt, and still got some interesting patterns. I’ve also thought of producing some animations by slowly varing some of the parameters to see how the resulting pattern evolves. All sorts of good stuff.