fractals

David B. Lewis david at ics.com
Wed Nov 15 05:49:46 AEST 1989


In SunSpots v8 n181, Jon Dunn <jwd at phil.indiana.edu> asks:

> Are there any Sunview programs which plot Mandelbrot sets or other
> fractals?

Hm... go to my archives.  I have a program to do just that (untested).
Not large; I can probably send it.

Here's the README:

This is a program for interactive Mandelbrot exploration for Sun
workstations using SunView.

What's new and exciting with this program (IMHO :-) ) is that it
implements a new algorithm. This is good for fast calculation of a (rough)
outline of the Mandelbrot set and thus suitable for interactive
manipulations. This makes it possible to iterate e.g. only every 10:th row
and column of the image, thus reducing the time by a factor of 100
compared to the standard Mandelbrot algorithm. It's also fun to watch,
since it's recursive...

It has been tested on the following configurations:

Sun-2/120 under SunOS 3.5, Sun-3/50, 3/75, 3/110 with FPA, 3/280, 4/110
and 4/280, all using SunOS 4.0(.1). Hopefully it should work on others
too.

So how does it work? Well, using some intricate mathematics you can arrive
at an equation that estimates the distance from a point outside the
Mandelbrot set to the nearest point IN the set. Using this knowledge, it's
possible to exclude all points lying inside a disk with the radius equal
to this distance. You know they can't be part of the set and mark them as
uninteresting. Then you repeat the calculation with a couple of points
picked from the edge of this disk. In this fashion, you will get an
outline of the set in a very short time.

Time for the bad news: if you want an image with the same resolution as
one generated with the standard algorithm, this algorithm will be just as
slow. This is because this algorithm quickly excludes points that are not
part of the Mandelbrot set. Unfortunately, the calculations for these
points will usually be fast since they rapidly diverges to infinity. So
the points left that need to be iterated are all very time-consuming.
Furthermore, this algorithm cannot provide those good-looking color images
you have all seen. It only provides information whether a point is in the
set or not.  Of course, on a B/W screen this will usually suffice. Using
this program, you can quickly find interesting areas and then run off to
your cray and feed the coordinates to a standard Mandelbrot algorithm.

I certainly didn't invent this myself. I urge you to get the book "The
Science of Fractal Images" edited by Peitgen and Saupe. Springer Verlag,
ISBN 0-387-96608-0. It's filled with good stuff like this.

A possible enhancement would be for the program to draw disks INSIDE the
Mandelbrot set too. Unfortunately, this problem is quite non-deterministic
and does not have a simple solution. Besides, the set, at larger
magnifications, has a very intricate structure and it would probably not
be possible to draw any large disks inside it.

I refer you to the man-page for more instructions about running the stuff.
To get going, just hit the DRAW button as soon as it starts.

You will probably see a lot of inefficient coding, e.g. using array
subscripting instead of pointers etc. Let me just say that profiling shows
that without the Sun-specific stuff, it can spend as much as 98% of the
time in the MSetDist routine (most of which are floating-point
calculations)... That is why I have kept the inefficient, but more
readable, code. Using GCC, you cannot achieve much better speed hand-coding
MSetDist in assembler, but you are welcome to try...

Finally, don't flame me for the coding. I just wanted to try this
algorithm, and whipped together a demonstration program using parts from
other programs in a very short time. Specifically: don't run it through
lint!  (I haven't :-). I don't have the time to work on this anymore but I
thought this was interesting enough to warrant posting.

One thing I would really love is an X version of this (hint, hint!).  Poor
me only knows the workings of SunView... :-(

Dept. of Electrical Engineering	         ====>>>    pell at isy.liu.se
University of Linkoping, Sweden	     ...!uunet!enea!isy.liu.se!pell



More information about the Comp.sys.sun mailing list