Exp. Math & Fractal Dragons (HELP!) (133 lines)

Skip to first unread message

Robert Skinner

Jun 27, 1985, 1:19:10 PM6/27/85


Someone on the net recently mentioned "experimental mathematics", without
much elaboration. I want to elaborate here a little because (a): it is
of general interest, and (b): it leads into the second subject, fractal

(In the following discussion, I will represent subscripts with periods:
f-sub-2 ==> f.2, and powers with carats: f squared ==> f^2.
Also, most of this involves complex numbers, so i=sqrt(-1).)

The basic technique of experimental mathematics is to a chose a function (f) and
an area of the complex plane (z) where you wish to plot successive iterations
of the function. The function is iterated by repeatedly substituting the
result of the function back into itself: f.2(z)=f(f(z)) and f.3(z)=f(f(f(z))),
etc. The actual value plotted for each z in the complex plane is the number
of iterations it takes for the result to approach "infinity". When the
number of iterations is assigned a color the output is amazing.

I have only experimented with a small number of functions, and most of
these produce self-similar patterns. The best of the functions were
(a): f(z)=c*sin(z), where c=(1.0,a*i) and a<1.0, the best range is .1-.8
and (b): the (in)famous "dragon function", f(z)=c*z*(1-z), where c~=(1.64,.96i)

Warning: the above information may be hazardous to your computer account,
especially if you have to *pay* for it. I wrote my routines in Fortran,
calculated 1024x1024 points, and ran them on a 11/780 *with* hardware
accellerator. (Which I no longer have (free) access to, I'm sorry to say).
Most of the functions required 10-30 minutes of CPU time. One version of
f(z)=c*sin(z) where c was almost (1.0,0i) never finished after 24 hrs. of
real time. Finished, meaning not all of the sample points had gone to
infinity. None of these times include color assignment or output
formatting, those were all post-processing functions.

And now on to fractal dragons: The function mentioned above did indeed generate
something very close to Mandelbrot's fractal dragon. The difference was that
it was chipped away from the outside going in, and eventually every point went
to infinity. But the process did produce the correct shape, so I was content
for awhile.

But alas, I am no longer content with that, so I have attempted to produce the
dragon Mandelbrot's (& V. Alan Norton's) way. My problem is that either I am
missing something obvious, or the text is not clear. Please, if anyone can
help me let me know. I'm getting ahead of myself, so let me describe what
I've attempted so far. First I'll quote page C4 of The Fractal Geometry of

As to the design that stands out from the black background, it is
made of 25 kinds of "stones", each defined by

{z: lim f (z)=z }
n->infinity 25n g

where the 25 complex numbers z.g are roots of the equation
f.25(z)=z (where f(z)=c*z*(1-z), as above), and in addition
satisfy |(d/dz)f.25(z)|<1. (derivative of the 25th iteration < 1 )

Failure Number 1.

The first phrase to stick in my thick skull was "roots of the equation f.25".
So, I proceeded to try and find all the roots to f.25. Brute force
(try lots of points & hope one works) failed miserably (as it should, I
suppose), so I got more clever. Noting that 0, and 1 are roots to f(z),
I wrote the programs to find the roots to f(z)=c*z*(1-z)=1. That gives
the roots to f.2(z), so all I had to do was recursively find the roots to
trace back 25 iterations and I would find the magic "stones". I quickly
found out that not only does the number of roots grow exponentially, but the
slopes ( which I also found by Brute Force: slope=((f(root+del)-f(root))/del))
were *huge* (Holy Floating Point Exception, Batman!).

Here I was, stuck with 2^25 complex roots that didn't mean anything and not
much closer to a dragon. I realized that the derivatives were going to be
"infinite", because f.25 is a 2^26 order polynomial. My roots would go to
zero, and the iterated value of a point near the root will go to infinity.
In a moment of desperation, I plotted these points anyway and they all lie
on the border of the dragon. The dragon is positioned in the same place
in the complex plane as I found with "experimental math" ( (-.11,-.58i) to
(1.11, +.58i) if you must know ), so I know I'm close.

Failure Number 2.

(Well, I haven't completed the program, so it hasn't failed yet. But
here's why I don't think it will work:) I realized that the book says
roots of f.25(z)=z. Finding those roots will be considerably harder. I
am in the process of writing a program to try Newton's approximation to get
*one* root, then check the slope. I've also realized that if I express
the iterations as f(g(z)) I can calculate the exact derivative incrementally.
(I still think the slope will be huge.)

Here's my problem: I'm assuming that once I find the magic 25 numbers, I will
need to continually iterate them within f(z) to obtain the correct dragon.
The results will be the points I plot, or they go to infinity, whatever.
*However*, I know that f.25(z)=z, so after 25 iterations, I'm back at z,
where I started. 25 numbers, period. Even if there are 25 distinct sets
of these 25 number cycles, that only gives me 25*25=625 points max. You
can't plot the dragon with the required detail with only 625 points.

General question:
In chapter 19, Mandelbrot gives two equations for finding appropriate constants
c: c=exp(2(pi)i*(m/n)) or c=2-exp(2(pi)i*(m/n)) where m/n is an irreducible
rational number < 1. The constant Mandelbrot gives looks more like the
second equation, so c=(1.64,.96i)=2-(.36,-.96i). *However*, the magnitude
of the second term is 1.05, instead of 1. as the exp should be. Also, on page
192, Mandelbrot implies that the number n gives the dragon it's characteristic
number of arms. Therefore n should equal 5, but if you calculate (m/n)
you get -.195, not a factor of 1/5. So what's going on here, should c be what
Mandelbrot gives us, or should (m/n)=.2? (Using (m/n)=.2 yields
c=(1.691,-.951) and a mirror image dragon similar to the target dragon.)

Appeal for Help:
Has anyone out there recreated the dragon in question? Are you willing
to give me hints, clues, direct answers, so I can satisfy my intellectual
longing and generate a pretty fractal at the same time? What is the magic
constant, c, anyway? If I can find the 25 magic numbers, what do I do with

I will offer my dragon code to anyone who wants it in return, and eventually
the "experimental mathematics" code, if I ever convert it from VMS.

Please respond by mail and I'll summarize on the net.
Thanks in advance.

It's pretty, but is it Mathematics"

Name: Robert Skinner
Mail: Saber Technology, 2381 Bering Drive, San Jose, California 95131
AT&T: (408) 945-0518, or 945-9600 (mesg. only)
UUCP: ...{decvax,ucbvax}!decwrl!saber!skinner

Camille Goudeseune

Jul 15, 1985, 8:38:53 PM7/15/85
In response to the dragon-hunters out there who may have had more success
than i've had, and those who want to attempt it soon, a plea for more
info, and a few tips and pointers:

1. When writing your code, check it 10^9 times for mechanical errors.
The conversion of the formula f(z)=(lambda)*z*(1-z), trivial as it
may seem, caused me to waste about a week of effort, because the
output STILL looked rather nifty...

2. Use a high-resolution output device if at all possible. If you have
to pay for your account, I sympathize, but it makes seeing patterns
in the dragons you produce possible as opposed to near-impossible.
(I consider 200 by 200 the bare minimum. 2000 by 2000 is much nicer.)

3. This almost goes without saying - make your code as efficient as
possible, but if you're not yet sure if you've cornered the dragon
to some degree, don't spend too much time optimizing what will
have to be rewritten. Trivial hints that I beg of you not to
flame me for:

3.1 Do as much calculation OUTSIDE loops as possible, i.e.
avoid using the computer to do the same thing twice
(or n times, at that!)

3.2 At the same time, if you have two loops doing separate
things that could be combined into one loop, DO SO.
(Even if it throws structured programming out the

I've never actually seen these pointers in print, but I may have
been forced to adopt these methods while I was mucking about on
a ZX81, the ultimate machine for teaching efficient programming.

4. (Plea for help) I have managed to produce a reasonable replica
of the dragon (on page C4 of The Fractal Geometry of Nature),
but the only problem is that, where each 'tentacle' of the
original consists of 'stones' connected by numerous 'wasp
waists' (Mandelbrot's words), my tentacles have no wasp waists,
just uniform, well, tentacles, that have frilly minitentacles
attached at numerous intervals. Something like this:
% % $
.,' % $ % % % & ,,.
.'' ! / \ $ # % $ & !^, ~
$ % % ^ &

but wigglier. If you want, each tentacle has only one stone.
I am using f(z)=lambda * z * (1-z), with lambda=1.64 + 0.96*i,
I've tried approximations of lambda to 0.1 each way, and the
algorithm I'm using amounts to an efficient version of creating
a 2k by 2k array of pixels corresponding to the square centered
on zero on the complex plane with corners +- 1.4 +- 1.4i ,
applying the formula about 95 times for each point in
the array, and if, at any time during these iterations the image
of the point goes outside the circle centered on zero with
'radius' 1.4, discarding that point as not being part of the
dragon. (1.4 is my approximation for infinity.) If, after
all the iterations for a given point, it is still within the
circle, I set that pixel to 1. (otherwise 0.)

Is there something fundamentally wrong with my algorithm, or
what? HELP! It seems simple enough to be bug-free; here is the
Berkely pascal source code, for those who want it. If nothing
else, it does produce pretty patterns at mildly shocking cpu
expense (something to run on your micro at home for a week?).

a few notes: my output device uses as input a binary file, one
row or scan line = 264 bytes = 2112 pixels. The program generates
the dragon 1 scan-line at a time, writing the bits to a file at the
end of each line. Typical input for the program:

1.64 0.960 1.5 1.4 1500 <return>

program main(input, output); { ******** FRACTAL DRAGON ********** }
c0 = 2111;{# of pixels}
c1 = 263; {# of bytes}
e, f, m, width, i, j, a, b, r, u, v: real;
c, ch, k, k1, size, scol: integer;
s: array [0..c0] of char;
t: array [0..8] of integer;
t[0] := 1; {table of powers of 2, used in constructing bytes.}
for k := 1 to 8 do
t[k] := t[k - 1] * 2;
{ Input e, f, radius, square size, & output size }
readln(e, f, r, m, size);
width := m / (size / 2);
a := -m/2; { modified starting points here... }
r:=r*r; { in the sake of efficiency }
while a <= m do
b := -m * 0.75; { and here. }
scol := 0;
while b <= m do
k := 0;
i := a;
j := b; { 90 * iterations for each pixel }
while (k < 90) and (i * i + j * j < r) do
u := j * j + i * (1 - i); { (i,j) := f(i,j) - pardon my }
v := j * (i + i - 1); { use of these letters in a }
i := e * u + f * v; { complex context! }
j := f * u - e * v;
k := k + 1;
if k = 90 then
s[scol] := 'x'; {aha! this pixel is in the dragon! }
scol := scol + 1;
b := b + width
for k:= 0 to c1 do
ch := 0;
for c := 0 to 7 do {construct this byte from 8 bits}
k1 := k * 8 + 7 - c;
if s[k1] = 'x' then ch := ch + t[c];
s[k1] := ' '; {reset this pixel for next scanline }
write(chr(ch)) {write out these 8 bits.}
a := a + width; {next scanline...}

I will be reasonably happy to answer questions about this code and
hereby forfeit my right to earn a fortune on it by decreeing it to
be public-domain, in the better interests of all who search for the
elusive fractal dragon. (Almost as much fun as rogue :-) !)

Camille Goudeseune
(after august 5/85, real mail only at:
2054 waycross cres., Mississauga, Ont., Canada
L5K 1H9.)


just because you're not paranoid doesn't mean that nobody's following you!

Reply all
Reply to author
0 new messages