Chaos Theory: Difference Equation Applet


[Português] [PDF]

One of my chaos-related programs is this Java applet which I wrote to exercise two difference equations x = cx(1 − x) and x = x² + c. It demonstrates how merely changing the value of the constant c changes the entire behaviour of the equation. The applet illustrates a mathematical process which is thought to be the key to the next phase of man's quest to understand nature. This same process is also understood to be the driving force of national economies - and indeed the global economy as a whole. Consequently it is of critical significance to those who seek to set economic and social policies for the future.

You should find this applet easy to operate and adequate for its purpose. However, if you are keen to explore further the behaviour of these and other equations, you can modify and recompile the source code provided, but having done so you are politely requested to acknowledge my work in writing this original version of the applet. If with Microsoft Windows a Security box pops up saying that the application has been blocked because it's untrusted please click here. If you get warning messages with Linux, please click here.

The Iteration Process

This comprises calculating the value of y from a non-linear equation y = f(x), plotting it, then feeding y back into the equation in place of x and repeating the process endlessly. It is what is known as a positive feed-back process. Practical examples are: the life process, and the supply and demand processes in a free market.

The Bounce & Time Graphs

The applet makes visible this iteration process through the bounce graph shown in the bottom right quarter of its display area. The applet draws the curve of y = f(x) and the diagonal straight line y = x. The iteration process starts from the point on the diagonal corresponding to the initial value of x. It then draws a line from this point vertically to hit the curve y = f(x). This yields the corresponding value of y. From this point it then projects a line horizontally until it hits the diagonal. This in effect feeds this value of y back into the equation as x for the next iteration. Neat! It draws the current iteration's bounce lines in dark green and then re-draws the previous iteration's bounce lines in bright green. If you slow the iteration rate down to plot every 2 seconds you will clearly see this process working. The applet plots a Time graph of x versus time concurrently with its plotting of the bounce graph.

Strange Attractors

As iterations mount up on the bounce graph, the bright green lines build up into an attractor in the two-dimensional phase space formed by plotting xn versus xn-1. For values of c producing linear and periodic behaviour, the attractor is simply a point or square. If the variables x and t were continuous instead of discrete, the squares would be circles or ellipses as produced by my Lissajous Figures applet. When the behaviour becomes chaotic the attractor becomes 'strange' - a succession of changing rectangles. Although within the precision of the pixel raster of the screen, some rectangles seem to repeat and overlay each other, in the closer reality of the IEEE double floating point arithmetic used in the program, they in fact never quite overlay exactly. Again, if the variables x and t were continuous instead of discrete, the trace would resemble something akin to the owl mask or butterfly trace which has become know as Lorenz's strange attractor.

Type of Function

Surprisingly, whatever type of function f may be does not seem to affect the fundamental behaviour of the iteration process. It doesn't have to be either of the two functions embodied by the equations chosen for the applet. Other functions exhibit the same kind of behaviour so long as they are non-linear (ie they produce curves not lines). All that changing the function seems to do is reposition, rescale and ever so slightly reshape the path traced out by successive values of x with respect to the origin of the co-ordinate system on which they are plotted.

Types of Behaviour

Whatever particular function is used for the difference equation, it exhibits one of three types of behaviour according to the current value of the constant c, namely:

transient
x gravitates towards and settles on a stable final-value,
oscillatory
x gravitates towards and settles on a steady oscillation between a small number of fixed values,
chaotic
x gravitates towards and settles within a max/min envelope within which it jumps about unpredictably forever.

Iterating x = cx(1 − x)

For c < 2·1 iterating this equation produces the familiar sigmoid curve used to represent the growth of plants and trees, populations, market demand and a myriad other things. For 2·1 < c < 2·9 the curve climbs to a maximum then follows a dying oscillation which eventually settles to a constant value. For 2·9 < c < 3·4 the curve climbs as usual but settles down to a regular oscillation. For 3·4 < c < 3·6 the oscillation becomes increasingly complex, at one point adopting a kind of waltz rhythm. From 3·7 < c < 4 regular oscillations give way to chaotic behaviour. For c > 4 this becomes so extreme that the 'population' soon makes a chaotic dive to zero from which it cannot recover - like a population becoming extinct.

Iterating x = x² + c

This is mathematically equivalent to the other equation above, so its behaviour will be the same, and it can equally well represent the natural processes represented by the other one.

Equation's behaviours for different values of c:
for c = 0·5 and beyond, x skates off to infinity
for c = 0·15, x climbs to a steady value
for c = 0, x stays at zero
for c = −0·5, x climbs to a steady negative value
for c = −1, x oscillates with period 2
for c = −1·3, x oscillates with period 4
for c = −1·4, x oscillates with period 8
for c = −1·5, bounded chaotic oscillation
for c = −1·7, a good demonstration of bounded chaos
for c = −1·75, periodic oasis within chaos - period 3
for c < −2, x rapidly goes wild into infinite chaos

This equation may be thought of as a real-axis only version of the complex difference equation z = z² + c which generates the Mandelbrot Set.

Mathematical Equivalence

Both equations are parabolic functions. When plotted, they produce parabolas. The differences between the equations is not to do with the nature of what they describe. It is merely to do with the position from which what they describe is observed. Changing the position and angle from which you observe a thing does not change the thing itself.

The essence of a parabola is described completely by the equation y = x². All other terms in the mathematician's general form of the equation of a parabola are simply to do with where the observer chooses to observe it from. That is, where he chooses to place his centre of the frame of reference, and the scalings he will use to measure what he observes. The observer, by definition, always resides at the origin (point 0, 0) of his co-ordinate system.

The general form of the equation for a parabola is a + bx + c where:

The effects of these 3 variables are superimposed on each other. For instance, when c is not zero, changing b moves the point y = c (not the co-ordinate origin y = 0) around the curve of the parabola. The essential point of all this is that a parabola is a parabola, namely y = x². All the other paraphernalia in the generalised form of the equation is simply to do with where the observer is. And where the observer is cannot affect the intrinsic nature and behaviour of what is observed. So in studying the behaviour of the equation it does not matter what particular equation you use so long as it is a parabola.

All the forms of the equation can all be mapped onto each other simply by changing the observer's position. To change from seeing a parabola as y = cx(1 − x) to seeing it as y = x² + c, you do the following:

  1. Move half a unit to your right. The equation is now y = c(½ + x)(½ − x) which simplifies to y = c(¼ − x²)

  2. Go round the back and turn yourself upside down. The equation is now y = c(x² − ¼)

  3. Put on a pair of astigmatic spectacles which reduce the y-scale by a factor of c. The equation is now y = x² − ¼c. Then let the constant c in the new equation be what ¼c was in the old one. Thus the equation becomes y = x² + c.

The equation - the way you are seeing what it represents - has changed. Nevertheless, what you are looking at is itself unchanged. The reason for changing your position of observation is that the second equation is simpler and therefore easier to build into a computer program and faster to compute. In iterative programs, time is of the essence.

Scientists often bend, fold, scale and twist graphical representations of phenomena in order to make them more viewable. Hénon's strange attractor is a prime example. The difficulty is that they may no longer be able to correlate easily the new form of their equations to the real-world phenomenon they are trying to simulate and from which they concocted their original equations. It is all a matter of compromise - and a most interesting aspect of relativity.

Chaos in Nature

The applet's first equation x = cx(1 − x) is known as the Standard Logistics Difference Equation. It models, among other things, the way in which populations of reproductive life-forms wax and wane. In this context, the constant c represents the fecundity of the life-form concerned - that is, the ferocity with which it reproduces. This is moderated by a factor representing the degree of ease or difficulty with which the species is able to acquire its needs of life from its environment. The population is thus held in balance by a mechanism analogous to an amplifier with negative feed-back, or an engine with a torque-sensitive speed regulator, or a market economy regulated by interest rates.

Human and animal populations follow a smooth sigmoid curve like that produced by the applet for c < 2·1 in the equation x = cx(1 − x). Try c = 1·85 for a good example of a population sigmoid. Currently, human world population is thought to be at about 0·4 on the Time Graph's vertical scale. This corresponds to about 6,000 million. But this doesn't mean that the Earth cannot support more than 6750 million (0·45 on the graph, the point at which it levels off). It simply means that it cannot do so under the present level of technology and under the currently dominant socio-economic régime.

In complex dynamical systems especially, there is a delay between cause and effect. For human population this delay is very short compared with the reproduction cycle. That is why the curve it follows is a smooth sigmoid. But with insects, due to their high fecundity, the delay is significant. Effects of changes thus trail well behind their causes. This makes some insect populations wax and wane chaotically, corresponding to the behaviour of the equation for c = 3·6 or thereabouts. This has a future significance for humanity in a way which is more immediate and less obvious than one may suppose.

Chaos in Economies

The applet's first equation x = cx(1 − x) is known as the Standard Logistics Difference Equation. It models, among other things, the way in which the population of a product grows within its potential market. In this context, the constant c is an amalgam of two factors. The first represents productivity - the number of product units which can be realised by one unit of human effort. This is amplified by production technology. The second represents the number of product units which can be sold into the market by one unit of human effort. This is amplified by communications technology. However, it is diminished by competition. The population of a product within a market is thus held in balance by a mechanism similar to that which holds life-form populations in balance with their environments.

Nature yields bounteously the needs of life in return for human labour. In the absence of war, oppression and exploitation all could therefore live in comfort and well-being. The value of c provided by nature (let us suppose it's around 1·3 or 1·4) is more than adequate for the needs of mankind. It creates an economy with a smooth productivity curve. But the human life-form then started to develop technology. First tools then the wheel, then machines, then automation, computers, communications and mass-media.

The smooth sigmoid reached to ever-greater heights. Once c passed 2·34 the curve started to 'ring' as it reached the top. That is, production over-shot and then fell back to its stable rate. The ringing became more pronounced until at c = 2·9 it gave birth to an almost steady (albeit shallow) rhythm of boom/bust which Western economies have gradually seen emerge from the end of World War II. Nevertheless, as the applet's Time Graph shows, the ratio between boom and bust gradually fades away (proving every time of course that government economic policy is working!?). But technology keeps on advancing, driving productivity and marketing reach ever higher and further.

The result is that the ratio between boom and bust gets larger but now ceases to fade away. As c increases further, so does the boom-bust ratio until eventually its rhythm becomes more complex. We will probably leave the 20th century with many national economies booming and busting to this mesmerising 'waltz rhythm'. But of the future? What does the new millennium hold in store for national economies? In a word: chaos. Technical progress will not stop. On the contrary, its rate of progress will accelerate. The boom-bust cycle will probably soon be following the profile of c = 3·68 which is what was being traced out by the applet when you first saw it.

Chaotic economic cycles are unlikely to hurt national economies or those who control them. However, they will ruin and destroy the economic lives of ordinary people. That is, unless the rules of engagement between the individual and the body-corporate are substantially re-engineered.

Footnote:
The applet depicts the growth in population of a single product sold by a single supplier in a simple market. Although in reality a national economy is far more complicated, its behaviour boils down to what bears an uncanny resemblance to what the applet displays. Chaos is scalable. I goes into this subject in far greater depth in my book The Lost Inheritance.

Operating Instructions

The applet's control panel is the collection of buttons etc. in the bottom left quarter of the applet's display area.

Speed Control
This is the column of 5 radio buttons entitled "Plot every:" at the extreme left of the control panel. It allows you to set or change the speed at which the applet iterates the equation and plots the resulting new value of x. The buttons are labelled in terms of the inter-plot period in milliseconds rather than the frequency of plotting. You can change the speed of plotting by clicking on one of these radio buttons. You may change the plot speed when the graph is stopped or while it is running. The change is effected immediately one of the radio buttons is clicked. The default speed is the fastest (a new value of x is plotted every 100 milliseconds) to give a sense of the process's rhythm. By slowing the process right down to a plot every 2 seconds you are better able to see the correlation between what is happening on the bounce graph and what is taking place on the time line graph.

Equation Selector
This is the column of 2 radio buttons entitled "Equation:" at the top centre of the control panel area. It allows you to select or change the equation you would like to exercise. You select the equation you want by clicking the appropriate radio button. Selecting the other (or even the same) equation causes the iteration process to reset itself. This causes each graph to be cleared of any existing trace and the constant c and variable x to be reset respectively to their default and starting values for the selected equation. After a reset the iteration process must be re-started by clicking the Start button.

Scan Mode Selector
This is the column of 2 radio buttons entitled "Scan Mode:" at the bottom right of the control panel area. It allows you to set or change the scan mode. In single-scan mode the process carries on iterating the selected equation until it gets to the end of the time line graph's time axis. The process then stops. This allows you to study the start-up and first 70 or so iterations of the equation. In continuous mode the iteration process carries on indefinitely. In this mode, when the time line graph has reached the end of the time axis, it flies back to the beginning again and continues plotting. In doing so it wipes the old trace a little distance ahead of each new plot. You can use the Stop button to temporarily halt the iteration process any time. The Start button then re-starts the iteration process from exactly where it was halted. You may if you wish change the scan mode while the equation is iterating.

Plot Mode Selector
This is the column of 2 radio buttons entitled "Plot Mode:" at the top right of the control panel area. In line graph mode, the Time Graph is plotted by joining consecutive plots with straight lines. This is the way you see the Time Graph being plotted when you first see the applet. In spot value mode, the spot value of x after each iteration of the equation is displayed as a short horizontal line. Its length is that of the iteration period on the time axis. When you select spot value mode, the Scan Mode is automatically set to continuous so that plotting continues even after the plots have reached the end of the time axis. However, the trace does not then fly back to the beginning of the time axis as it does in line graph mode when continuous scanning is selected. Instead, it carries on plotting the values of 'x' at the same horizontal position at the end of the time axis. These plots gradually build up into a 'bar' which shows the envelope within which the values of 'x' vary once it has settled down after its initial 70 or so iterations from its starting value. This envelope is unique for each value of 'c' within the currently selected equation.

The 'Constant c' Entry Field
This is a text entry field in which you can enter your own value for the constant 'c' in the currently selected equation. It thus allows you to explore the effects of very small and precise changes in the value of 'c'. This is particularly interesting for the values around which the behaviour of the iterating equation changes dramatically from smooth to oscillatory or from oscillatory to chaotic. If you enter a collection of characters which cannot be parsed into a number within the valid ranges for 'c', the applet will reinstate the previous valid value. To enter a new value of 'c', click into the text field beneath the title "Adjust c", delete what is there already, type in the value you want and hit the 'return' key (on your computer's keyboard). The new value is then in effect. Entering a new value of 'c' causes each graph to be cleared of any existing trace and 'x' to be reset to its appropriate starting value. The iteration process must then be started by clicking the Start button.

The + − Buttons
These allow you to inch the value of 'c' up and down by 0·01 per click. However, they will not allow you to raise or lower 'c' outside its valid range of values for the currently selected equation. When you click either of these buttons the parabola on the bounce graph to the right expands or contracts accordingly to accommodate the new value of 'c'.

The Stop/Start Button
The Stop button simply halts the iteration process at the point it has reached at the time. It does not reset x or c. Nor does it clear the graphs. Once the Stop button has been pressed, it turns into a Start button. As a Start button it simply re-starts the iteration process from the point at which it was stopped. This button thus allows you to stop the process and study the behaviour of the currently selected equation over any short snap-shot of time no matter how long the iteration process has been running. You may then restart the iteration process again if you so wish.

The 'Clear' Button
This causes the iteration process (if running) to be stopped and the graphs to be cleared. The value of 'x' is reset to its starting value. If x = cx(1 − x) is the currently selected equation, the starting value for 'x' is reset to a small arbitrarily value of 0·01 (otherwise x would never get off the ground). If x = x² + c is the currently selected equation, 'x' is reset to zero. The 'Clear' button does not alter the value of 'c'.

Source Code for the Difference Equation Iterator

The Difference Equation Iteration Demonstrator applet is made up of the following classes:

Long before it was enhanced and re-written in Java, this difference equation iter­ation demonstrator began life as three separate programs written in MS Quick­BASIC 2.0 (which shows how long ago that was!). To the software archaeologists among you these three original programs: stdLog.bas, stdLog1.bas and stdLog2.bas should prove to be most interesting artefacts. They do however provide a somewhat different presentation from the applet.


© November 1997 Robert John Morton | PREV | NEXT