There are 3 chaotic functions to graph as examples.

Graph of function (0) is a curve. Graph of function (1) is a group of lines. (Both are Xn+1 = f(Xn) type functions.)

Graph of function (2) on the other hand is a plane. (It is Xn+1 = f(Xn, Xn-1) type function.)

These mean there is a simple relationship between the previous and next X values in (0) and (1). (Next X value can always be predicted from the previous X value by using the graph of the function w/o knowing the function itself.) But (2) does not have a discernible relationship. (No prediction possible!) So (2) is clearly more chaotic than others. (I think it could be used as a Pseudo-Random Number Generator (PRNG).)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ```
# Chaotic Function Analysis Graph
# GrX = Xn
# GrY = Xn+1
# FB - 201012094
import math
import random
from PIL import Image
imgx = 800
imgy = 600
image = Image.new("RGB", (imgx, imgy))
# drawing region
xa = 0.0
xb = 1.0
ya = 0.0
yb = 1.0
x0 = random.random() # initial x does not matter for this type of graph
x1 = x0 # prev x
x2 = x1 # prev of prev x
maxIt = 100000
for i in range(maxIt):
x2 = x1
x1 = x0
# chaotic function to graph
# x0 = math.fmod(math.fabs(math.sin(3.0 * x1 + 0.3)), 1.0) # (0)
# x0 = math.fmod((x1 + math.pi) ** 2.0, 1.0) # (1)
# x0 = math.fmod((x1 + x2 + math.pi) ** 2.0, 1.0) # (2) PRNG?
x0 = 4.0 * x1 * (1.0 - x1) # (3) logistic equation in chaotic state
# x0 = (x2 + 3.0) * x1 * (1.0 - x1) # (4) ?
xi = int((imgx - 1) * (x1 - xa) / (xb - xa))
yi = int((imgy - 1) * (x0 - ya) / (yb - ya))
if xi >=0 and xi < imgx and yi >= 0 and yi < imgy:
image.putpixel((xi, yi), (255, 255, 255))
image.save("chaotic_function_graph.png", "PNG")
``` |