home *** CD-ROM | disk | FTP | other *** search
-
- !JuliaAnim (Quadratic Julia Set Real Time Animator).
-
- By Ivar Wind Skovgaard.
-
- This is version 1.52, which has been finished Thursday, 24 Sep 1992.
-
-
- Introduction:
-
- This program, I hope, can be used by everybody to see some beautiful
- animated sequences of Julia sets. That is what the primary purpose of it is.
- However it can also be used to gain some insight into the fascinating
- objects that Julia sets are.
-
- !JuliaAnim displays quadratic Julia sets and uses the inverse iteration
- method to allow you to explore the effects of different complex constants in
- the formula in 'real time'.
-
- By moving the mouse or using the cursor keys you can change the complex
- constant in the expression for the Julia sets and (because of the speed of
- the inverse iteration method as well as ARM machine code) immediately see
- the shape of the set change on the screen (which is what I call 'real
- time').
-
- In addition to showing Julia sets the program can also display 'Mandelbrot
- orbits' - the forward orbit of the current value of c as it would be when
- generating the Mandelbrot set - these orbits are of course also animated.
-
-
- Using the program:
-
- Double-clicking on the !JuliaAnim icon will start !JuliaAnim, which takes
- over all the processing time of the machine (except for interrupts).
-
- The program is controlled from the keyboard or the mouse. Initially the
- mouse is selected for control and by moving it you change the complex
- constant c shown at the bottom of the screen. This constant determines the
- shape of the Julia set and it is only constant in the sense that it is
- constant for a given image. The whole point of this program is to see what
- happens when you change this constant (confused? - well you probably still
- will be after reading the rest of this text if you ever get that far).
-
- The following keys can be used with both mouse and keyboard control:
-
- A : Toggles automatic animation on and off
- (during automatic animation the constant c follows the edge of
- the cardioid and the greatest circle of the Mandelbrot set).
-
- H : Display a help screen.
-
- I : Toggles the background image of the Mandelbrot set on and off.
-
- J : Toggles Julia sets on and off
- (if Julias are switched off then orbits are switched on).
-
- M : Toggles between mouse and keyboard control.
-
- O : Toggles Mandelbrot orbits on and off
- (if orbits are switched off then Julias are switched on).
-
- P : Toggles mouse pointer on and off
- (when on the pointer is also shown during keyboard control
- and will then follow the current value of the constant c).
-
- R : Toggles random automatic animation on and off
- (during random automatic animation the constant c
- moves in a direction which changes randomly).
-
- T : Toggles text on and off
- (with text off and some automatic animation on
- you can let the program run indefinitely
- without worrying about burn-in on the monitor).
-
- V : Toggles mirroring of orbit points on and off
- (mirroring (around 0+0i) of orbit points can be used, if the
- Julia set is connected to display extra points belonging to
- the Julia set, and if the Julia set is unconnected to
- display extra points not belonging to the Julia set).
-
- # : (On the keypad) Changes the framerate of animations by
- cycling through 25, 16.7, 12.5 and 10 frames per second
- (with Shift held down the cycling is the other way round).
- On an ARM2 machine the program can't quite manage 25 frames
- per second (due to the limited temporal resolution of the
- centisecond timer - I think). As I have not tried the
- program on an ARM3, I don't know if the extra speed
- solves the problem, nor can I say how it will work
- on the ARM250 based machines.
-
- F1-F12 : Choose one of twelve preset complex constants
- (these are the ones from page XII of 'The Beauty of Fractals').
-
- Home : Return to the initial complex constant c=-0.08+0.66i.
-
- Copy : Redraw the image with the current complex constant c.
-
- Esc : Quit the program.
-
-
- In addition the following keys can be used only during keyboard control:
-
- Cursor keys : Changes the complex constant c in steps of 0.01
- (when Shift is held down the steps are 0.05 but when Ctrl is
- held down (without Shift) the steps are only 0.001 and the
- number of frames per second is lower - incidentally Ctrl
- also decreases the frame rate during mouse control).
-
-
- This program is not very accurate and it would not be well suited for
- zooming into the images. Because of that the display is fixed to a part of
- the complex plane with real values ranging from -2 to 2 and imaginary values
- ranging from -1.6 to 1.6. This is not as bad as it may sound because Julia
- sets do not increase in complexity when you magnify them and unlike the
- Mandelbrot set will usually display all their unique features on the
- macroscopic level.
-
- For complex constants with a large magnitude (distance from 0+0i) the code
- will give an address exception error (due to overflow). To avoid this the
- program will not allow the absolute values of the real and imaginary parts
- of c to exceed 3.5. This is of no great significance, as very few Julia sets
- with values of c outside this range would be contained by the screen. The
- mouse pointer can move off the screen to allow the exploration of complex
- constants to the limits.
-
- The orbits are quite easy to calculate but are even more sensitive to errors
- in the calculations due to the nature of normal forward iteration (inverse
- iteration is attracted to the correct set and thus small errors will
- eventually be 'forgotten' while forward iteration as used for the orbits
- moves away from whatever set you want to find and thereby enlarges any
- errors that occur) and are therefore not quite reliable (at least I don't
- think so) but they are pretty anyway.
-
-
- What can quadratic Julia sets be used for:
-
- Quadratic Julia sets are based on the quadratic formula:
-
- z(n+1)=z(n)^2+c, where c is a constant for a specific Julia set.
-
- Both c and z(n) are complex numbers, which implies that they consist of a
- real part and an imaginary part (which is a real number multiplied by the
- imaginary unit i, which is the square root of -1). Complex numbers were
- invented a long time ago in order to solve some mathematical problems, or
- something like that, and they have since then been applied to many parts of
- science (they are useful in treating electric circuitry and necessary in
- quantum mechanics).
-
- The Julia set then consists of all the points z(0) for which the series z(n)
- stays confined within a finite area for all values of n. It is hard to see
- any immediate connection between this and the real world, but in mathematics
- it can be very useful to explore a fairly simple formula to gain knowledge
- about it and then use this knowledge on more complicated problems.
- Furthermore it is common practice (e.g. in physics) to reduce a complicated
- problem to something simpler to be able to solve it, and a quadratic formula
- is a very common example of a simple but good approximation to a more
- complicated description. In my view none of this really matters as the
- beauty of the sets should be sufficient justification for making them.
-
-
- What to look for - and what not to look for:
-
- Primarily you should look for a lot of pretty images and sequences of
- images. However there are a few things that are worth noticing as they
- actually have something to do with the mathematics behind the sets.
-
- Playing around with the program (I hope you have done so by now) you may
- have noticed, that some Julia sets seem to be a single connected set while
- others seem to consist of a few large pieces, and some seem to consist of
- many small pieces. It turns out, when investigating the sets theoretically,
- that the quadratic Julia sets can be divided into just two categories: Those
- that are connected and those that are disconnected. What is meant by this is
- that a set is either in one piece, in which case any two points in the set
- can be connected by a line (not a straight line) consisting entirely of
- points from the set, or the set consists of a 'cloud' of infinitely many
- points, all of which are separated by areas not belonging to the Julia set
- (no two points from the set can be connected by a line consisting entirely
- of points from the set). A disconnected set is also called a Cantor set. If
- the set on screen seems to be in one piece it will usually be safe to assume
- that it really is connected, and if the set seems to consist of some points
- far apart it is probably disconnected (you can not of course see infinitely
- many distinct points on a screen with finite resolution). The problems occur
- with the sets that seem to consist of a few large pieces. Are they in fact a
- lot of disconnected points lying very close together or are they one big
- piece where the connections have not been calculated by the program?
-
- Fortunately there is a simple way of telling wether a set is connected or
- not. In 1919 both Julia and Fatou proved that a Julia set is connected if a
- sequence of numbers which I call a Mandelbrot orbit stays confined within a
- certain region, and the Julia set is disconnected if the Mandelbrot orbit
- does not stay within this region (in which case it 'escapes to infinity',
- but as infinity is a bit hard to handle we just see wether it gets beyond a
- distance of two or more from the center 0+0i). By switching on Mandelbrot
- orbits in the program you should get a chance to see if the orbit is
- confined to some small area or is unconfined. If only a few points of the
- orbit appears spread all over the screen, then the orbit is probably
- unconfined and the Julia set is disconnected, but if the orbit consists of
- many points in a small area of the screen, then the Julia set is probably
- connected. Once again there are some orbits for which it can be hard to tell
- wether it is confined or not, but there are not many of these.
-
- An additional set has been defined as the set of all those values of c for
- which the Julia set is connected (and the Mandelbrot orbit confined). This
- is the Mandelbrot set, and the outline of this can be seen in the background
- (as a great ugly spider, according to one of my friends), if it is toggled
- on. So if the pointer and thus the value of c is within this set the Julia
- set should be connected. On the borders of the Mandelbrot set some ambiguity
- may arise due to the finite resolution of the screen (I wish someone would
- make a display with infinite resolution), but this is a very small effect.
- It is interesting to note that the Mandelbrot set was in fact discovered in
- the attempt to find some system according to which Julia sets are connected
- or not.
-
- There is an intimate relationship between the appearance of the Mandelbrot
- set around a given value of c and the corresponding Julia set in the same
- region. The parts of the two sets near to the value of c will look very much
- like each other, and the nearer you go to c the greater the likeness will
- become. In this way the Mandelbrot set can be seen as a 'dictionary' to the
- Julia sets, because a small part of a Julia set will look very much like the
- rest of the Julia set. This of course is only relevant for values of c near
- to the border of the Mandelbrot set, though the similarity of the two sets
- is true for all values of c, but far from the border there is not much to be
- seen near to c. The similarity between the two sets can be seen with this
- program particularly around the outer edges of the Mandelbrot set.
-
- The Mandelbrot set can be used to observe even more fenomena. If you switch
- off the display of Julia sets and make the imaginary part of c equal to zero
- (this is most easily done with keyboard control), and then start with a
- value of c to the right of the Mandelbrot set and move to the left, you will
- initially see that the Mamdelbrot orbit goes off the screen to the right.
- But when c passes into the cardioid (the largest part of the Mandelbrot
- set), the Mandelbrot orbit seems to concentrate around a single point (which
- point depends on where in the cardioid c is located). This point is called
- an attractor (of period one) for the orbit (outside the Mandelbrot set the
- attractor is said to be infinity). As c is moved further left into the
- biggest circle to the left of the cardioid, the orbit concentrates around
- two points instead of one, so we now have an attractor (of period two)
- consisting of two points. Moving to the left again, into the small circle
- attached to the big circle, the attractor splits up once more into four
- points (and thus becomes an attractor of period four). To the left of this
- little circle there is an even smaller circle, where the attractor consists
- of eight points (period eight), and to the left of this is a very small
- circle, so small it can't be seen on the picture, where the attractor
- consists of sixteen points (period sixteen). It goes on like this with
- smaller and smaller circles with attractors consisting of more and more
- points (period 32, 64, 128, and so on), until you reach a point where c
- approximately equals -1.401, where there will have been infinitely many
- circles, and thus the number of points in the attractor will be infinite. At
- this point the attractor is said to become chaotic, and it remains so for
- the rest of the points on the left tip of the Mandelbrot set, except for a
- few small regions where the attractor again consists of a few points (e.g. 6
- at -1.475, 5 at -1.625, and 3 at -1.755). The changes in the number of
- points in the attractor as c is changed are called bifurcations (for a more
- precise definition you could read the book 'Chaotic Dynamics' by G.L.Baker
- and J.P.Gollub, where a lot more is said about bifurcations) and this way of
- achieving chaos by an infinite series of bifurcations is in fact quite
- common. The usual way of displaying it is in a bifurcation diagram, also
- called a Feigenbaum diagram, with c (now only real) along one axis and the
- points of the attractor (also real) along the other axis. This could be done
- for the quadratic formula used in this program, but is more normally done
- with another quadratic formula which is related to the evolution of rabbit
- populations. The features are however the same except for the scale and the
- direction of change of c.
-
- I have written a lot about what you can see (with a bit of imagination),
- however I want to emphasize, that there are many features of Julia sets that
- can not be seen with this program. The fine structure of some Julia sets is
- impossible to appreciate in the crude images obtained with the very limited
- accuracy of the code. Also the algorithm used to calculate the sets tends to
- plot many more points on the outer edges of the sets than on the innermost
- edges. In some cases this is so extreme that it might take as long as
- 10^3000 years or more before all pixels with points belonging to the Julia
- set had been plotted (by then the universe will probably have contracted to
- a singularity again or have expanded so much that the temperature will be
- approximately 10^-2989 K, which is very cold, and all the matter will have
- turned into black dwarf stars, neutron stars and black holes, most of which
- will have turned into radiation, unless the proton is unstable, in which
- case all the matter will have turned into radiation). So many of the
- features of Julia sets that change abruptly when changing the value of c
- just a little bit will be impossible to see with this program, though you
- can often get an idea that something has happened by watching the Mandelbrot
- orbits, as their behaviour will usually change at the same points as the
- Julia sets.
-
- If you want to investigate Julia sets (and other fractals) more closely, I
- suggest you get some more programs. There are several in the Public Domain
- that will produce images of Julia sets in different ways. Some of the best
- programs are, in my opinion, !Mandy by Roger Attrill (an easy to use desktop
- program that makes Mandelbrot and Julia sets), !FracTrace by Carl Declerck
- (a multitasking program that produces 3-dimensional Mandelbrot and Julia
- sets), and particularly !Fractal primarily coded by Mike Curnow (it produces
- Mandelbrot and Julia sets for the quadratic and other formulas as well as
- Feigenbaum diagrams and many other fractals, with several different ways of
- plotting the images). At least some of these programs should be available
- from PD libraries - two of the programs are on the AFG 1991 disc which I
- know is available from some PD libraries.
-
-
- The inverse iteration method:
-
- The program is based on the quadratic formula z(n+1)=z(n)^2+c, where z and c
- are complex numbers, however it uses the inverse iteration method to find
- points on the edge of the Julia sets. This method is described in 'The
- Beauty of Fractals' by H.-O. Peitgen and P.H. Richter, and also in many
- other books.
-
- The inverse iteration method actually does the iteration the other way
- round:
-
- z(n+1)=SQR(z(n)-c).
-
- After a few initial iterations of this formula all the z's calculated can be
- plotted as they will be very close to the Julia set (the Julia set is an
- attractor for the mathematical mapping defined by the inverse iteration, or
- something like that).
-
- However this iteration is not as easy as it looks because x and c are
- complex numbers and the calculation of the square root of a complex number
- is quite complicated (pun fully intended). In the following the complex
- number z is represented by two real numbers x and y, so that z=x+yi:
-
- SQR(x+yi)=SQR(r)*COS(a/2)+i*SQR(r)*SIN(a/2),
-
- where r=SQR(x*x+y*y)
-
- and a=ASN(y/r) for x>=0 and a=PI-ASN(y/r) for x<0.
-
- However a square root has two solutions and only one has been found by the
- above formula. The other one is simply the negative of the above (as for
- real numbers) and to avoid any bias in the calculations it is normal to
- select which root to use at random.
-
- So the iteration is done by first calculating x(T)=x(n)-cR and y(T)=y(n)-cI,
- where x(T) and y(T) are temporary values used to calculate the square root
- and cR and cI are the real and imaginary parts of the constant c, then
- calculating r(T)=SQR(x(T)*x(T)+y(T)*y(T)), and SIN(a)=y(T)/r(T) and then
- making a table lookup which converts SIN(a) into the values of COS(a/2) and
- SIN(a/2) (if x(T)<0 then the sines and cosines are swapped). Finally the new
- value of r is calculated as r(n+1)=SQR(r(T)) and this is multiplied by the
- sines and cosines: x(n+1)=r(n+1)*COS(a/2) and y(n+1)=r(n+1)*SIN(a/2). If
- r(T)=0 - which rarely is the case - then the division and the table lookup
- is not performed. After all this, a random bit is produced which determines
- wether the other of the two roots should be used in which case there will be
- an additional two subtractions.
-
- So apart from the table lookup there is one division, two square roots, four
- multiplications, and two or four subtractions (depending on which root is
- selected). I have omitted the addition from this list, because it can be
- integrated with one of the multiplications in ARM assembler. All these
- calculations are done with 32 bit fixed point arithmetic using 13 bits for
- the fractional part.
-
- The points are plotted (by direct screen access) both in the position of the
- actual z value but also mirrored around 0+0i at -z (the other root) because
- Julia sets are symmetric around 0+0i.
-
- Due to the speed of the ARM the program can plot approximately 10000 points
- per second, though during animation this is decreased a bit - particularly
- at the high framerates. If the machine code is allowed to plot a very large
- number of points before returning to basic it can actually plot in excess of
- 11500 points per second, but that is not possible with the current control
- program.
-
-
- Improvement history:
-
- The first PD version was:
-
- 1.00: It featured:
- Julia sets (naturally) calculated in 'real time'.
- Control via mouse or cursor keys, with three different step sizes.
- Automatic animation (tracing the edge of the cardioid and the greatest
- circle of the Mandelbrot set).
- Random animation.
- Some preset values of c.
-
- However no one ever got to see it because I immediately made an alteration
- changing it into:
-
- 1.10: The only difference from version 1.00 was that I changed from mode 13
- to mode 4 giving a significant increase in speed and higher resolution.
-
- After that followed:
-
- 1.50: This version has the same general appearance as version 1.10, but some
- errors have been removed, a few simple features that should have been in the
- first version have been added as well as some more interesting new features:
- Mandelbrot orbits.
- Background image of the Mandelbrot set (making a change from mode 4 to
- mode 8 necessary giving a slight decrease in speed).
- Hide option for the text (sort of screen saving as well as giving a
- prettier picture).
- Different framerates during animation.
- Help screen.
- Mouse pointer is seen at all times following c (if it is toggled on).
- Bug in calculations removed (this caused strange points to appear with
- certain values of c, such as c=i).
- Code further optimized.
- Arcus tangent changed to arcus sine giving greater accuracy and a
- smaller table.
- The two previous changes has resulted in a speed increase (of the
- Julia set calculation) of 6.4%!
- Automatic timing to adjust the program to the speed of the machine
- (with the unfortunate result, that an ARM2 machine probably won't
- plot quite as many points per second as with the first version,
- however with an ARM3 I think it should be an advantage - I have
- not had a chance to see this).
-
- This was very fine but based on my experiences from version 1.10 (which I
- thought was horribly out-dated a few weeks after I had sent it around) I
- decided to postpone the release for about a week by which time I had made:
-
- 1.51: This only contains small refinements from version 1.50.
-
- A few people got this and I then made:
-
- 1.52: This is virtually the same as 1.51 - only I would know the difference.
-
-
- Possible future improvements:
-
- There are of course many possible future improvements, though many of these
- are not of great interest from a fractal viewpoint:
-
- I would like to make a multi-tasking front-end for the program with some
- nice menus for selecting the different options (the keystrokes needed to
- control this version reminds me a bit too much of FRACTINT for IBM PC's, and
- if I add too many extra features, it will not only become almost impossible
- to remember the keys, but the help screen will have to be extended to more
- than one screen). However before doing so I will probably try to learn C and
- convert this program to that language, with the added advantage, that the
- control part of the program will take up less processing time.
-
- Some of the features of this version of the program need some improvement.
- For instance the automatic timing is not very accurate, and could definitely
- benefit from some improving. This will primarily result in more points being
- plotted on each image at the high frame rates. It would also be nice if the
- Mandelbrot orbits were in some other colour than the Julia sets.
-
- Different ways of defining your own automatic animations is also part of my
- ideas for the future. I have already tried some ways, but they don't work
- right, so I will have to sort out some problems before you get to see them
- (the animations - not the problems).
-
- Of greater interest from a fractal viewpoint, is some way of producing high
- quality still images of the Julia sets made by a modified version of the
- inverse iteration method. This is not very hard to do, however the
- requirements for memory (a big array and a very large stack) are very great
- and slightly unpredictable, which means that it needs some sort of flexible
- memory management and effective error trapping if it is to be an integral
- part of this program - C and a Programmers Reference Manual will probably
- help, once I get it.
-
- The program as it is only makes quadratic Julia sets. But there are other
- Julia sets than these, some of which might be interesting to animate.
- However the problem is that each kind of Julia set would require its own
- piece of machine code including tables and other stuff written specially for
- that type in order to get as great a speed as possible, so, even if I ever
- add any extra types to the program, there will, I think, never be many of
- them.
-
- To round off I have some more crazy ideas such as Animated Julia sets as a
- desktop background (giving some deep insight in the relation between the
- quadratic formula and the movement of the mouse in a working session), or as
- a screen saver for the desktop. I might even write a PC version.
-
- However most of this lies far in the future as I make lots of other things
- besides Julia sets!
-
-
- Acknowledgments:
-
- Without the help and suggestions of various people this program would never
- have been, or at least would not have had the features it's got. I would
- therefore like to thank Christian Larsen for making a machine code sine and
- cosine table lookup routine, which gave me the idea for this program and
- formed part of the machine code of the first version.
-
- I am most grateful to Rasmus Roland for giving me the idea of the automatic
- animation around the edge of the cardioid and reminding me of putting an
- image of the Mandelbrot set in the background.
-
- Some credit is due to the authors of FRACTINT (for the IBM PC) - at least
- they who made the orbit option - for giving me the idea of Mandelbrot orbits
- (and for making a good program).
-
- I also want to express my thanks to Mike Curnow for writing some great
- programs - particularly !Fractal - and for administrating the Archimedes
- Fractal Group.
-
- Finally I would like to thank all those people who have had (to pretend) to
- listen to me when I kept on babbling about this program and phoning them at
- 2am to explain that I had just increased the speed by half a percent.
-
-
- Distribution:
-
- This program is Public Domain! You may copy it freely (and please do) as
- long as you do not sell it for a profit or include it with a product that is
- sold for a profit (without my permission) and as long as you do not change
- or delete any of the original files which are:
-
- !JuliaAnim (not really a file),
- !JuliaAnim.!Boot,
- !JuliaAnim.!Help (this file),
- !JuliaAnim.!Run,
- !JuliaAnim.!RunImage,
- !JuliaAnim.!Sprites,
- !JuliaAnim.mc.
-
- To obtain future versions of this program (do NOT expect any before the
- summer of 1993) you could try some Public Domain Library, I will at least be
- sending new versions to some of the ones listed below (all of which are
- allowed to distribute this program - if any other libraries wish to be
- included on this list, they only have to ask, though I can't guarantee that
- they will get new versions sent automatically - it's terribly expensive):
-
- APDL, 96 Lanehouse Road, Thornaby, Cleveland, TS17 8EA,
- Arcaynia PD, PO Box 1927, Sutton Coldfield, B74 3PE,
- Diamond PD, 86 Meadowbank, Moor Lane, Holyway, Holywell, Clywd CH8 7EF,
- DataStream, 32 Hollinwell Avenue, Nottingham, NG8 1JZ,
- Skyfall, PO Box 2220, Birmingham, B43 5RZ.
-
- Also I will probably send new versions to some of these magazines:
-
- Acorn User,
- Archimedes World,
- The Micro User (or Acorn Computing if you like).
-
- They are all welcome to publish it on subscription disks (or, preferably
- with my permission, cover disks), or just mention it in an article (I'm only
- doing all this to become famous) as long as it remains perfectly clear that
- it is Public Domain (otherwise they would have to pay me lots of money -
- which of course everyone is welcome to do anyway)!
-
- As a last resort it is possible to get the newest version from me, however
- sending SAE's with discs to foreign countries isn't the easiest thing to do
- (the cost of the international reply coupons alone, I believe, would be
- about £2 - alternatively a formatted disc and addressed envelope with a
- large cheque (£10 or so - it costs £4 just to cash it) might help). Remember
- to state which version you have and I won't send anything before a major
- development has occurred. This is risky as you can't be sure that there will
- ever be another major development (read: I'll put the postage money in my
- pocket, store pictures on the disc and burn your address).
-
-
- For fractal programmers:
-
- If you are making fractal programs yourself, or are planning to make some, I
- suggest that you contact:
- Mike Curnow, the administrator of:
- Archimedes Fractal Group, 30 Bowen Drive, West Dulwich, London SE21 8PN.
- He might be able to help you or put you in contact with other fractal
- programmers. Remember to include an SAE with correspondance to AFG.
-
-
- Finally:
-
- If you have any suggestions for improvements to this program or have written
- some interesting fractal program yourself which you want to tell me about or
- just want to tell me what a great program you think !JuliaAnim is then you
- can contact me by writing to:
-
- Ivar Wind Skovgaard,
- Havsgårdsvej 27,
- 2900 Hellerup,
- Denmark.
-