//
Uncategorized

# Visualizing Chaos via Orbit Diagrams of Logistic Map and the Henon Map

Here is a simple C++ program that illustrates chaos through simple rule for updating floating point values. The simple rule for updating is known as Logistic Map.

```#include<iostream>
using namespace std;
int main(){
cout << " Example of Floating Point Chaos" << endl;
float b = 3.90;
float fish = 0.5;
for ( int exp=0 ; exp < 100 ; exp++){
cout << exp << ":  "<< fish <<endl;
fish = fish * (1.0 - fish) * b;
}
}
```

In one class college freshman were introduced “interesting” ideas from the field of Computer Science. I tried to create some labs that would engage the students without being too technical or too dumbed-down. One successful lab had the students take a well-known chaotic function known as the logistic equation x(n+1) = r*x(n)*(1-x(n)) and asked them to try to form a visualization. Here are some of the results of the students.

Here are project results from CS0 students: Daniel Hagerstrand, Cody Mays, and Scott Resnick

Here is basic python code that generates the graphic for the orbit diagram of the logistic equation:

```from Tkinter import *
import random
root = Tk()
canvas = Canvas(width=1000, height=750, bg='white')
canvas.pack(expand=YES, fill=BOTH)
text = canvas.create_text(50,10, text=&amp;quot;Chaos Test&amp;quot;)

# Feigenbaum bifurcation values.
# b1 = 3, b2 = 3.449490…,
# b3 = 3.544090…, b4 = 3.556441…, b5 = 3.568759…, and b6 = 3.569692

r=2.4
while r < 4:
for pix in range(50):
x = random.random()
for i in range(100):
x = r*x*(1-x)
drawcircle(canvas,x*1000,(r-2.4)*(750/1.6),1,'blue')
r+=0.005
root.mainloop()

``` Here is basic python code that generates the graphic for the orbit diagram of the Henon Map:

```from Tkinter import *
import random
root = Tk()

canvas = Canvas(width=1400, height=800, bg='white')
canvas.pack(expand=YES, fill=BOTH)
text = canvas.create_text(100,10, text="    Orbit Diagram of the Henon Map"

def HenonMap(a,b,x,y):
return y + 1.0 - a *x*x, b * x

# Map dependent parameters
a = 1.4
b = 0.3
iterates = 100000
xtemp = 0.1
ytemp = 0.2

for pix in xrange(0,iterates):
xtemp, ytemp = HenonMap(a,b,xtemp,ytemp)
drawcircle(canvas,400*xtemp+750,1000*ytemp+400,1,'blue')

root.mainloop()

```

Henon map image 