Henon映射的混沌吸引子
import matplotlib.pyplot as plt
listx=[]
listy=[]
def Henon(x,y,n):
for i in range(n):
x1 = 1 - 1.4 * x ** 2 + y
y1 = 0.3 * x
x = x1
y = y1
listx.append(x)
listy.append(y)
if __name__ == '__main__':
Henon(0.13245678,0.13246789,1000)
plt.plot(listx, listy)
plt.show()
Lorenz吸引子
# -*- coding: utf-8 -*-
"Lorenz's strange attractor"
import matplotlib as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
xs, ys, zs = [], [], []
def mkPoints():
a, b, c = 10.0, 28.0, 8.0 / 3.0
h = 0.01
x0, y0, z0 = 0.1, 0, 0
for i in range(10000):
x1 = x0 + h * a * (y0 - x0)
y1 = y0 + h * (x0 * (b - z0) - y0)
z1 = z0 + h * (x0 * y0 - c * z0)
x0, y0, z0 = x1, y1, z1
xs.append(x0)
ys.append(y0)
zs.append(z0)
if __name__ == "__main__":
# 画3D的
fig = plt.figure()
ax = Axes3D(fig)
mkPoints()
ax.plot(xs, ys, zs, label="Lorenz's strange attractor")
ax.legend()
plt.show()
# 画2D的
# mkPoints()
# plt.plot(zs, ys)
# plt.show()