|
|||||||||||||
|
Chaos and Java:
Interactive Learning By Brian Davies Australian National University |
|||||||||||||
|
ABSTRACT
This paper reports on a project in which I have developed special purpose software to allow students to learn about complex dynamical behaviour by making their own numerical experiments. I shall show examples of how theory and experiment may be synthesised by students, taken from a course currently being taught at the ANU. I shall also relate some of my experiences in using JAVA for computationally intensive tasks, and demonstrate the remarkable efficiency of the latest JIT technology. Perspective Non-linear dynamics and chaos is a comparatively new science, emanating from the remarkable fact that determinism does not imply either regular behaviour or predictability in even the most simple non-linear systems. Poincaré appreciated these matters over 100 years ago, as did a few other pioneers during the years 1900 - 1960. Poincaré wrote about the stability of the solar system2, an academic question which does not have high priority in everyday life. Nevertheless, chaos is an important area of study for today's undergraduates, since chaotic behaviour is ubiquitous in everyday systems. It is often the case that an increase in some controlling factor can cause a system to break into complex - apparently random - behaviour, despite the fact that the smaller value did not produce such undesirable effects. In other cases the reverse may happen. Either way, there are symptoms which prefigure such events, and factors which should be understood in order to avoid such a circumstance. In this regard it is important to note that Lorenz went looking for it rather than trying to dismiss it as entirely bizarre and uninteresting. Increasingly, some understanding of chaos is required in many disciplines; hopefully future graduates will learn to distinguish between its scientific meaning and its many misleading everyday uses, just as one knows that the temperature in parliament is not measured in degrees Celsius. The first incarnation was a few simple MATLAB programs, integrated with some student exercises. The next was a Macintosh program which had expanded features and ease of use, but the same basic philosophy. Following the World Wide Developers Conference in May 1997, where one of the themes was the emerging importance of JAVA, the project was redefined to be a new text, closely integrated with a JAVA package. It will be titled Exploring Chaos: Theory and Experiment, and will be published early in 1999. In this talk I shall concentrate mainly on the software, and on the suitability of JAVA for the purpose at hand. In writing a book, I have the same intention as numerous other authors: to provide the clearest possible exposition of the subject matter at the chosen level - in this case undergraduates6. From the beginning of my forays into the teaching of chaos, I was convinced that students need software which enables them to make sophisticated numerical experiments as part of the learning process. The software should provide visualisation of non-linear dynamical behaviour, together with tools for making precise numerical measurements on representative systems. The solution of non-linear equations is numerically intensive; nevertheless the graphical user interface, for which we owe much to the Apple Macintosh, is a convenient way to present the results to students.
Lorenz equation - visualising infinite complexity The Lorenz equations are one of the standard paradigms for chaotic dynamics. Before enunciating them, I want to plead with non-technical readers that there will be no sophisticated mathematics here. Lorenz equations are:
dx/dt = Fx = s (y-x),
2.1 Simple problem, complex solutions
This means that static pictures have very little to say about an infinitely complex situation. It also implies that we cannot teach students using the same techniques as are used in elementary calculus, with dozens of routine problems on which to practice.
2.2 Strange attractors and butterflies The first thing is to visualise how solutions of the Lorenz equations unfold in time. Following Lorenz choice for the parameters9, we see orbits which have become one of the icons of chaos. Notice how, on rotating the figure to get an impression of its three-dimensional form, it is somewhat reminiscent of 'Butterfly wings'. In a moment I shall explain how apposite this coincidence is. Using another of the software features, we may watch how the solution point generates the orbit in time. You will see that it makes one or more circuits around one of the wings before switching to the other; this process of making circuits and switching sporadically continues indefinitely. For example, two orbits which differ initially only in the fourth significant place, are not even on the same 'wing' after a dozen circuits or so. Nevertheless, one obvious qualitative feature is that they are both organised by the same strange attractor. This effect, sensitive dependence of the evolution of a system to the most insignificant changes of initial state is known as the butterfly effect, after the title of a talk by Lorenz, Predictability: Does the flap of a Butterfly's Wings in Brazil set off a Tornado in Texas?11
2.3 Tracking the return One of the tools used by Lorenz in his original paper was based on the simple observation that, as the system evolves, it repeatedly attains a maximum value of z (reverse temperature gradient). This suggests that there might be useful information in correlating successive maxima in z; this was done by Lorenz, and I repeat here his experiment using another feature of the software. Looking at the figure it indeed appears that there is a very good correlation lying on a tent shaped graph, although close examination allows us to see that it is not quite a one-dimensional curve.
3. Iteration of maps: what is chaos?
xn+1 = f(xn) = r xn (1 - xn)
where r is an adjustable parameter (number) between the values 0 and 4, and x is a real number between 0 and 1; n denotes the n'th iteration. Notice the extreme simplicity of this formula, evident also in the graph13 of the function f(x); it involves no more than taking the square of a number. But therein lies the non-linearity, and the source of infinite complexity14.
3.1 Examining the dependence on r
The point of my demonstration, in relation to the title of the talk, is the ease with which a student may make these discoveries.
3.2 Looking for chaos
The answer is that both of the properties can be observed experimentally, by actually iterating the system and computing some global data from it. To investigate the question of whether the motion repeats itself, one can examine the frequency content. If the only observable components are at low frequency, this is strong evidence of periodic behaviour. If there seems to be a continuous distribution of frequencies, that is evidence of non-periodicity. Similarly, one can compute the tendency to converge or diverge at each step, and from it an average (logarithmic) factor called a L'Lyapunov exponent'. If it is positive in the long term limit, then the observed motion is unstable. This may seem rather ad-hoc, justifying the taunt that it is 'experimental mathematics'. But then mathematics is employed in the present context as servant, not master17. Here I demonstrate in the case of the logistic map with the maximum parameter value, r = 4. First let's look at some iterations as a simple plot18; irregularity is apparent but nothing is proved thereby. One useful way to observe the data is to take rather a long sample - here I choose 100,000 iterations - and plot a histogram which shows the relative frequency with which they land in various parts of the allowed range between 0 and 1. Now, with the click of a button, the Lyapunov exponent is calculated for this orbit. The result is approximately +0.69, an indication of very strong dependence on the initial state19. Now let's look at the frequency components of this orbit, using yet another facility which evaluates Fourier transforms. It is quite clear from the figure that there are no dominant frequencies. Thus one can settle, at least in an experimental way, the fact that this is almost certainly a chaotic orbit.
4. The price of control - fractal boundaries Suppose I introduce some linear feedback into the logistic map, aimed at keeping the iterations from jumping about20. This gives a system whose specification requires two variables, the present and immediate past value of x. I spare the technicalities, and ask that it be taken on faith that things can be arranged in a way which effects the possibility of control. But it also introduces the possibility of disaster! Recall that I said that x was confined between the values of 0 and 1. This is perpetuated by the fact that, for a given input state x in this range, the logistic function delivers a new state in the same range - look at the graph to see this. But adding together this output to the control, it is entirely possible that their sum will be out of range. After that, the system may go right off the planet.
We can observe this using yet another feature of the software. For reasons I don't want to explain, the value of a = 1.6 which I use here corresponds to an r value of nearly 4, for which the logistic map is chaotic. The (desired) stable state of the system is shown as a large dark blue point sitting in the middle of a light blue region; starting the system from anywhere in the light region results in control, that is it steadily approaches the stable state. Starting the system from anywhere in the dark grey region results in disaster: the values of x increase without limit. Instantly one sees something new, indeed fractal; the light blue and dark grey regions are mixed up in an infinitely complex manner.
4.1 Efficiency considerations The demonstrations just shown are computationally intensive. What the program must do is to compute, for each pixel position, the evolution of the system if it starts from the point represented by that pixel. That is, several thousand calculations for tens of thousands of pixels! I believe that you have seen for yourself that things are comfortably fast, since the picture is displayed as it is computed, on the fly. More generally, because of the way this project has developed, I have C++ code for many of the computations, with which I can compare the JAVA performance, since much of the code is identical line by line. A number of trials have convinced me that a good JAVA JIT compiler performs very well compared with a good C++ compiler, although I would temper this claim by the observation that graphic performance in Java is still far from optimal. However, having seen a 10-fold increase in computational performance in the past year, I have every confidence that reservations about the graphical performance will soon fade, leaving one to exploit the many advantages of JAVA in teaching.
I would like to acknowledge the assistance I have received from the Apple University Consortium and Apple University Development Fund, by way of an AUDF grant and support to attend World Wide Developer's Conferences in the USA in 1997 and 1998. I would particularly like to thank my local contact with these bodies, Berrick Krahnen. 1 That is, systems whose law of evolution is not governed by simple proportionality to their present state. 2 In fact, he was awarded a major prize for his ground-breaking work. 3 References to scientific literature will not be given here; they may be found in many textbooks on Chaos. 4 It is interesting to note that Lorenz graphics consisted of printing asterisks on a 132 character printer and joining them with a coloured crayon! 5 The chief exception to this is that their is a lot of software available for constructing fractals', such as the well known Mandelbrot and Julia sets, for both Macintosh and Windows platforms. 6 Almost all the existing books are at a higher level, or mainly descriptive. 7 The terms xz and xy are products of two of the state variables, the vital feature. Thus the relative influence of either variable in this term is proportional to the instantaneous value of the other. 8 The software may be visited at http://wwwmaths.anu.edu.au/~briand using a Java-enabled browser. 9 Lorenz selected the values b=10, s=8/3 and r=28 from consideration of the underlying physical processes. 10 A fortuitous result of the expense, both in dollars and time, of printing out all six digits actually computed! 11 Lorenz pointed out that one might equally well ask if the Butterfly can prevent a tornado in Texas. 12 The only interesting behaviour of the tent map is chaos; the Logistic map exhibits richer modes of behaviour. 13 Here I chose r = 3.2, so the maximum is 0.8 rather than 1. 14 The most famous fractals of all, the Mandelbrot set with its associated Julia sets, are obtained from the iteration of the same quadratic. In that case the formula is usually written in a different (but equivalent) manner, and the state variable x assumes values in the complex number plane, rather than just real numbers as here. 15 Often called a bifurcation diagram; however there is good reason to use the present terminology when observing actual states rather than theoretically possible orbits. 16 Only the second figure appears in the written version of this paper; black and white printing makes it somewhat harder to interpret since the colours are rendered as shades of grey. 17 Of course there is much important current research aimed at elucidating carefully formulated theoretical propositions about chaos. Such investigations are at a high level of theoretical difficulty, more suitable for graduate level courses than the present purpose. Moreover, for the example I shall consider in the final section, (the Hénon map) there is at present no theoretical resolution of many questions for which a relatively certain answer may be given using just the software of this paper. 18 There is no printed figure corresponding to this demonstration. 19 In fact, because it is the natural logarithm of 2, it indicates a divergence by an average factor of 2 per step over the whole orbit. This is one of the few occasions where such a result can be proved theoretically. 20 This produces a system more commonly know as the Hénon map, hence the different parameter conventions. 21 This appears as lighter grey in the printed version.
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||