import matplotlib
.pyplot
as plt
import numpy
as np
x0
= 0.2
b
= 0.0001
R
= 4
size
= 30
t
= np
.arange
(size
)
x1
= np
.zeros
(size
)
x1
[0] = x0
x2
= np
.zeros
(size
)
x2
[0] = x0
+b
for i
in range(1,size
):
x1
[i
] = R
*x1
[i
-1]*(1-x1
[i
-1])
x2
[i
] = R
*x2
[i
-1]*(1-x2
[i
-1])
plt
.plot
(t
,x1
)
plt
.plot
(t
,x2
)
plt
.savefig
('1.png',dpi
=500)
plt
.show
()
R=4时表现出的混沌现象:
分叉图
import matplotlib
.pyplot
as plt
import numpy
as np
iterations
= 1000
last
= 100
n
= 20000
r
= np
.linspace
(2.5, 4.0, n
)
x
= 0.2 * np
.ones
(n
)
fig
, ax1
= plt
.subplots
(figsize
=(16, 14), dpi
=200)
for i
in range(iterations
):
x
= r
* x
* (1 - x
)
if i
>= (iterations
- last
):
ax1
.plot
(r
, x
, ',k', alpha
=0.5)
ax1
.set_title
("Bifurcation diagram")
plt
.grid
(True)
plt
.savefig
('Bifurcation_diagram.png')
plt
.show
()
转载请注明原文地址: https://mac.8miu.com/read-511057.html