Strange Attractor

Programs: RMstrange.z80, RMstrange2.z80

Chaos theory was all the rage in the 1980s and this program is an attempt illustrate it!

The first program above prompts the user for a  number, A, to be used in the expression A*x*(1-x) then generates a random number, x, between 0 and 1. That number, along with the user's input for A, is plugged into the above equation, which generates the next iteration of x. The process is repeated until x settles on a single value (if A is less than about 3), or 2 values (when A is ~3 to ~3.5), then 4 values, after which the behaviour becomes chaotic from around 3.6. Well, that is what is supposed to happen, but the program seems to be  sometimes erroneously reporting two values when it should be one, so it needs some investigation.

Values for A should be entered in the range ~-2 to 4, although there are no restrictions on input. Outside this range, x diverges to + or - infinity.

The second program, RMstrange2.z80, is a version of the first that I meant to write, but didn't get around to until now. It plots a graph of these stable values of x (but on the y axis!) vs. A (on the x axis), to produce what is known as the logistic map. To do this, I reused some of the code from the Mandelbrot set program, as well. There's one difference between the two programs in determining the stable values of x: in the first, as noted above, a random number is generated for the first value of x. This could be useful to demonstrate that the starting value doesn't affect the stable point(s).  However, in the second program, x is always seeded with the value 0.5.

One interesting point I've noticed is that it seems to take significantly longer to determine the stable points as A increases from 2 to 3. Another program is called for to investigate this!

In the screen-shot below, centred on (3, 0.5), the x-axis is shown from around 2 to +4 and and the y-axis from 0 to 1. The horizontal line at the bottom is a progress bar.

There are 3 settings in the  program that can be varied (by editing the appropriate lines) to show different areas of interest:

Another screenshot is shown here. The magnification is 1 and the graph is centred on (-1, 0.5).

Here's another: magnification 5, centred on (3.5, 0.4)