I suspect the world would be better if that percentage were even greater.
HOPALONG, from Dewdney’s Armchair Universe
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.
[sourcecode lang=”C”]
#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 ;
}
}
[/sourcecode]
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.
Comments
Pingback from » Hopalong | ??????????? Blog » Blog Archive
Time 1/11/2012 at 5:44 am
[…] HOPALONG, from Dewdney’s Armchair Universe […]
Comment from Dr Barry Martin
Time 4/1/2011 at 4:01 am
Dear Mark,
It delights me to see people like yourself digging up my old orbital fractal, which A K Dewdney nicknamed HOPALONG, a name which seems to have caught on. You speculated on whether I discovered or wrote the program. The truth is I’m not sure myself. I was researching the Henon attractor and trying different funtions to replace the Y squared term when I hit upon some which produced remarkable patterns, one of which was Hopalong.
I retired as a mathematics lecturer at Aston University in 1998 but still can’t stop doing math – mostly fluid mechanics these days – for fun.
If you have time have a look at my Flickr site. Address http://www.flickr.com/photos/cleats/ called TORINHOP. In it I have included a little discussion about Hopalong. Also I show that only two constants suffice. C can be set equal to unity with no loss of possibilities. I’m rether plaeased with the simulated jewelry.
Very best wishes Barry Martin