混沌的计算实验与分析
- 混沌(chaos)是指确定性动力学系统因对初值敏感而表现出的不可预测的、类似随机性的运动。
- 动力学系统的确定性是一个数学概念,指系统在任一时刻的状态被初始状态所决定。虽然根据运动的初始状态数据和运动规律能推算出任一未来时刻的运动状态,但由于初始数据的测定不可能完全精确,预测的结果必然出现误差,甚至不可预测。运动的可预测性是一个物理概念。一个运动即使是确定性的,也仍可为不可预测的,二者并不矛盾。牛顿力学的成功,特别是它在预言海王星上的成功,在一定程度上产生误解,把确定性和可预测性等同起来,以为确定性运动一定是可预测的。20世纪70年代后的研究表明,大量非线性系统中尽管系统是确定性的,却普遍存在着对运动状态初始值极为敏感、貌似随机的不可预测的运动状态——混沌运动。
- 混沌是指现实世界中存在的一种貌似无规律的复杂运动形态。共同特征是原来遵循简单物理规律的有序运动形态,在某种条件下突然偏离预期的规律性而变成了无序的形态。混沌可在相当广泛的一些确定性动力学系统中发生。混沌在统计特性上类似于随机过程,被认为是确定性系统中的一种内禀随机性。
一、混沌介绍
1.1迭代
1.1.1迭代
- 迭代是重复反馈过程的活动,其目的通常是为了逼近所需目标或结果。每一次对过程的重复称为一次“迭代”,而每一次迭代得到的结果会作为下一次迭代的初始值
- fortran实现
module diedai
implicit none
contains
real function complex_x(x) result(ans) !创建迭代符合函数,参数为变量值
real :: x,a=1.0
integer,parameter :: number = 100 !迭代次数
integer :: i
ans=x
do i=1,number,1
ans = 2*(ans)+a
end do
return
end function complex_x
end module diedai
program main
use diedai
implicit none
real :: answer,x
write(*,*) "请输入x的初始值:"
read(*,*) x
answer=complex_x(x)
write(*,*) "第100次迭代后,结果为:",answer
stop
end program main
module diedai
implicit none
contains
real function complex_x(x) result(ans) !创建迭代符合函数,参数为变量值
real :: x
integer,parameter :: number = 100000000 !迭代次数
integer :: i
ans=x
do i=1,number,1
ans = sin(ans)
end do
return
end function complex_x
end module diedai
program main
use diedai
implicit none
real :: answer,x
write(*,*) "请输入x的初始值:"
read(*,*) x
answer=complex_x(x)
write(*,*) "第100000000次迭代后,结果为:",answer
stop
end program main
结果:n趋近于无穷大时,f(x)的值趋近于0,与初值无关。
练习题
module diedai implicit none contains real function complex_x(x) result(ans) !创建迭代符合函数,参数为变量值 real :: x integer,parameter :: number = 10 !迭代次数 integer :: i ans=x do i=1,number,1 ans = ans*ans-1 end do return end function complex_x end module diedai program main use diedai implicit none real :: answer,x write(*,*) "请输入x的初始值:" read(*,*) x answer=complex_x(x) write(*,*) "第10次迭代后,结果为:",answer stop end program main
module diedai implicit none integer,parameter :: fileid=10 contains subroutine complex_sin(x,number) implicit none real :: x,ans integer :: number,i ans=x if(number<0) then write(*,*) "迭代次数有误,stop" stop else open(unit=fileid,file='data_diedai.txt',status='old') write(fileid,"('迭代次数-----------迭代后值-----初值',F6.4)") ans do i=1,number,1 ans=sin(ans)+cos(ans) write(fileid,"(I3,' ',F6.4)") i,ans end do close(fileid) end if return end subroutine complex_sin end module diedai program main use diedai implicit none real :: x integer :: n write(*,*) "请输入迭代初值:" read(*,*) x write(*,*) "请输入迭代次数:" read(*,*) n call complex_sin(x,n) write(*,*) "over!" stop end program main
结果:通过不同的初值,经过迭代后都收敛到1.2597,图片可以看出初值越大,收敛速度越快。
1.1.2二元二次迭代
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(a,b,number)
implicit none
real :: a,b,ans_x,ans_y,ans_xi,ans_yi
integer :: number,i
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary.txt',status='old')
write(fileid,"('迭代次数---X----Y----a,b值',F6.2,F6.2)") a,b
ans_x=0.3
ans_y=0.5
do i=1,number,1
!迭代函数
ans_xi=1-a*ans_x*ans_x+ans_y
ans_yi=b*ans_x
ans_x=ans_xi
ans_y=ans_yi!这里需要用到ans_x,所以需要区分一下ans_yi与ans_y,ans_x与ans_xi
write(fileid,"(I4,' ',F6.2,' ',F6.2)") i,ans_x,ans_y
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b
integer :: n
write(*,*) "请输入迭代a,b的初值:"
read(*,*) a,b
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,n)
write(*,*) "over!"
stop
end program main
- 结果
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y,number)
implicit none
real :: ans_x,ans_y,ans_xi,ans_yi
integer :: number,i
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----X0,Y0值',F6.3,F6.3)") ans_x,ans_y
do i=1,number,1
!迭代函数
ans_xi=0.0164-ans_x+ans_x*ans_x-ans_x*ans_y+ans_y+ans_y*ans_y
ans_yi=0.1-ans_x+ans_x*ans_y
ans_x=ans_xi
ans_y=ans_yi
write(fileid,"(I4,' ',F6.4,' ',F6.4)") i,ans_x,ans_y
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b
integer :: n
write(*,*) "请输入迭代x,y的初值:"
read(*,*) a,b
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,n)
write(*,*) "over!"
stop
end program main
- 常数0.0165
- 常数为0.0164
- x0=0.215,yo=0.215,常数项0.0164
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y,number)
implicit none
real :: ans_x,ans_y,ans_xi,ans_yi
integer :: number,i
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----X0,Y0值',F6.2,F6.2)") ans_x,ans_y
do i=1,number,1
!迭代函数
ans_xi=-0.2-ans_x+ans_x*ans_x-ans_x*ans_y+ans_y+sna_y*ans_y
ans_yi=0.1--ans_x+ans_x*ans_y
ans_x=ans_xi
ans_y=ans_yi
write(fileid,*) i,ans_x,ans_y
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b
integer :: n
write(*,*) "请输入迭代x,y的初值:"
read(*,*) a,b
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,n)
write(*,*) "over!"
stop
end program main
1.1.3线性随机IFS迭代
IFS
是英文iterated function systems
(迭代函数系统)的缩写,下面是一种常用的线性随机迭代算法
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y,number)
implicit none
real :: ans_x,ans_y,ans_xi,ans_yi,random0_1
integer :: number,i,e,f,n=9876
real :: a(4,6)
DATA((a(e,f),e=1,4),f=1,6) /0.00,0.85,0.20,-0.15,0.00,0.04,-0.26,0.28,0.00,-0.04,0.23,0.26,0.16,0.85,0.22,&
0.24,0.00,0.00,0.01,0.00,0.00,1.60,1.60,0.44/
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----X0,Y0值',F6.2,F6.2)") ans_x,ans_y
do i=1,number,1
!迭代函数
n=mod(8121*n+28411,134456)
random0_1=real(n)/134456
write(*,*) random0_1
if(random0_1<=0.01) then
ans_xi=a(1,1)*ans_x+a(1,2)*ans_y+a(1,5)
ans_yi=a(1,3)*ans_x+a(1,4)*ans_y+a(1,6)
ans_x=ans_xi
ans_y=ans_yi
else if(random0_1>0.01.and.random0_1<=0.86) then
ans_xi=a(2,1)*ans_x+a(2,2)*ans_y+a(2,5)
ans_yi=a(2,3)*ans_x+a(2,4)*ans_y+a(2,6)
ans_x=ans_xi
ans_y=ans_yi
else if(random0_1>0.86.and.random0_1<=0.93) then
ans_xi=a(3,1)*ans_x+a(3,2)*ans_y+a(3,5)
ans_yi=a(3,3)*ans_x+a(3,4)*ans_y+a(3,6)
ans_x=ans_xi
ans_y=ans_yi
else
ans_xi=a(4,1)*ans_x+a(4,2)*ans_y+a(4,5)
ans_yi=a(4,3)*ans_x+a(4,4)*ans_y+a(4,6)
ans_x=ans_xi
ans_y=ans_yi
end if
write(fileid,*) i,ans_x,ans_y
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b
integer :: n
write(*,*) "请输入迭代x,y的初值:"
read(*,*) a,b
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,n)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y,number)
implicit none
real :: ans_x,ans_y,ans_xi,ans_yi,random0_1
integer :: number,i,e,f,n=9876
real :: a(8,6)
DATA((a(e,f),e=1,8),f=1,6) /0.08,0.0801,0.75,0.9430,-0.4020,0.2170,0.2620,0.2200,-0.0310,0.0212,0.00,&
0.00,0.00,-0.0520,-0.1050,0.00,0.084,-0.08,0.00,0.00,0.00,0.075,0.1140,0.00,0.0306,0.0212,0.5300,0.4740,&
0.4020,0.1500,0.2410,0.4300,5.17,6.62,-0.3570,-1.98,15.5130,3.000,-0.4730,14.60,7.9700,9.400,1.1060,&
-0.6500,4.5880,5.7400,3.0450,4.2860/
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----X0,Y0值',F6.2,F6.2)") ans_x,ans_y
do i=1,number,1
!迭代函数
n=mod(8121*n+28411,134456)
random0_1=real(n)/134456
if(random0_1<=0.03) then
ans_xi=a(1,1)*ans_x+a(1,2)*ans_y+a(1,5)
ans_yi=a(1,3)*ans_x+a(1,4)*ans_y+a(1,6)
ans_x=ans_xi
ans_y=ans_yi
else if(random0_1>0.03.and.random0_1<=0.055) then
ans_xi=a(2,1)*ans_x+a(2,2)*ans_y+a(2,5)
ans_yi=a(2,3)*ans_x+a(2,4)*ans_y+a(2,6)
ans_x=ans_xi
ans_y=ans_yi
else if(random0_1>0.055.and.random0_1<=0.275) then
ans_xi=a(3,1)*ans_x+a(3,2)*ans_y+a(3,5)
ans_yi=a(3,3)*ans_x+a(3,4)*ans_y+a(3,6)
ans_x=ans_xi
ans_y=ans_yi
else if(random0_1>0.275.and.random0_1<=0.520) then
ans_xi=a(4,1)*ans_x+a(4,2)*ans_y+a(4,5)
ans_yi=a(4,3)*ans_x+a(4,4)*ans_y+a(4,6)
ans_x=ans_xi
ans_y=ans_yi
else if(random0_1>0.520.and.random0_1<=0.730) then
ans_xi=a(5,1)*ans_x+a(5,2)*ans_y+a(5,5)
ans_yi=a(5,3)*ans_x+a(5,4)*ans_y+a(5,6)
ans_x=ans_xi
ans_y=ans_yi
else if(random0_1>0.730.and.random0_1<=0.80) then
ans_xi=a(6,1)*ans_x+a(6,2)*ans_y+a(6,5)
ans_yi=a(6,3)*ans_x+a(6,4)*ans_y+a(6,6)
ans_x=ans_xi
ans_y=ans_yi
else if(random0_1>0.80.and.random0_1<=0.9) then
ans_xi=a(7,1)*ans_x+a(7,2)*ans_y+a(7,5)
ans_yi=a(7,3)*ans_x+a(7,4)*ans_y+a(7,6)
ans_x=ans_xi
ans_y=ans_yi
else
ans_xi=a(8,1)*ans_x+a(8,2)*ans_y+a(8,5)
ans_yi=a(8,3)*ans_x+a(8,4)*ans_y+a(8,6)
ans_x=ans_xi
ans_y=ans_yi
end if
write(fileid,*) i,ans_x,ans_y
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b
integer :: n
write(*,*) "请输入迭代x,y的初值:"
read(*,*) a,b
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,n)
write(*,*) "over!"
stop
end program main
- 线性随机IFS迭代也是迭代的一种,由于其是线性的,所以目前的研究成果相对比较多。一般把上面的似树叶,山的点集叫做(近似的混沌)吸引子
1.1.4三元二次迭代
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y,ans_z,number)
implicit none
real :: ans_x,ans_y,ans_z,ans_xi,ans_yi,ans_zi
integer :: number,i
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x,ans_y,ans_z
do i=1,number,1
!迭代函数
ans_xi=-0.3-ans_x+ans_x*ans_x-ans_x*ans_y+ans_y+ans_y*ans_y
ans_yi=0.2-ans_x+ans_x*ans_y
ans_zi=-ans_x*ans_y-ans_y*ans_z-ans_x*ans_z
ans_x=ans_xi
ans_y=ans_yi
ans_z=ans_zi
write(fileid,*) i,ans_x,ans_y,ans_z
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b,c
integer :: n
write(*,*) "请输入迭代x,y,z的初值:"
read(*,*) a,b,c
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,c,n)
write(*,*) "over!"
stop
end program main
1.1.5三角函数迭代
- 三角函数迭代一般绘制出的吸引子比较复杂,理论分析也比多项式迭代困难。
- Clifford系统
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y,ans_z,number)
implicit none
real :: ans_x,ans_y,ans_z,ans_xi,ans_yi,ans_zi
integer :: number,i
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x,ans_y,ans_z
do i=1,number,1
!迭代函数
ans_xi=sin(2.24*ans_y)-ans_z*cos(0.43*ans_x)
ans_yi=ans_z*sin(-0.65*ans_x)-cos(-2.43*ans_y)
ans_zi=1.0*sin(0.43*ans_x)
ans_x=ans_xi
ans_y=ans_yi
ans_z=ans_zi
if(number>3000) then
write(fileid,*) i,ans_x,ans_y,ans_z
end if
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b,c
integer :: n
write(*,*) "请输入迭代x,y,z的初值:"
read(*,*) a,b,c
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,c,n)
write(*,*) "over!"
stop
end program main
- 练习:把例1.9迭代表达式中的正弦、余弦函数都使用泰勒公式展开,然后代替三角函数进行迭代,观察实验结果
1.1.6小波函数对二元二次函数迭代的控制
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(k,u)
implicit none
real :: ans_x=-5,ans_y=0
real :: k,u
open(unit=fileid,file='data_diedai_wavelet.txt',status='new')
write(fileid,"('迭代次数---X----Y----X0,Y0值',F6.2,F6.2)") ans_x,ans_y
do while(.true.)
!迭代函数
if(ans_x>5) exit
ans_y=k(1-ans_x*ans_x)*exp(-u*(ans_x-0.5)*(ans_x-0.5))
write(fileid,*) ans_x,ans_y
ans_x=ans_x+0.01
end do
close(fileid)
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: k,u
write(*,*) "请输入迭代k,u值:"
read(*,*) k,u
call complex_binary(k,u)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y,number)
implicit none
real :: ans_x,ans_y,ans_xi,ans_yi,k=1,u=1
integer :: number,i
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----X0,Y0值',F6.2,F6.2,F6.2)") ans_x,ans_y
do i=1,number,1
!迭代函数
ans_xi=(2-ans_x+ans_x*ans_x-ans_x*ans_y+ans_y+ans_y*ans_Y)*k*(1-ans_x*ans_x)*&
exp(-u*(ans_x-0.5)*(ans_x-0.5))
ans_yi=(0.2-ans_x+ans_x*ans_y)*k*(1-ans_x*ans_x)*exp(-u*(ans_x-0.5)*(ans_x-0.5))
ans_x=ans_xi
ans_y=ans_yi
write(fileid,*) i,ans_x,ans_y
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b
integer :: n
write(*,*) "请输入迭代x,y的初值:"
read(*,*) a,b
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,n)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y,number)
implicit none
real :: ans_x,ans_y,ans_xi,ans_yi,k=1.73,u=1
integer :: number,i
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----X0,Y0值',F6.2,F6.2,F6.2)") ans_x,ans_y
do i=1,number,1
!迭代函数
ans_xi=(2-ans_x+ans_x*ans_x-ans_x*ans_y+ans_y+ans_y*ans_Y)*k*(1-ans_x*ans_x)*&
exp(-0.5*ans_x*ans_x)
ans_yi=(0.2-ans_x+ans_x*ans_y)*k*(1-ans_x*ans_x)*exp(-0.5*ans_x*ans_x)
ans_x=ans_xi
ans_y=ans_yi
write(fileid,*) i,ans_x,ans_y
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b
integer :: n
write(*,*) "请输入迭代x,y的初值:"
read(*,*) a,b
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,n)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y,ans_z,number)
implicit none
real :: ans_x,ans_y,ans_z,ans_xi,ans_yi,ans_zi
integer :: number,i
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z0----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x,ans_y,ans_z
do i=1,number,1
!迭代函数
ans_xi=(2-ans_x+ans_x*ans_x-ans_x*ans_y+ans_y+ans_y*ans_Y)*k*(1-ans_x*ans_x)*&
exp(-0.5*ans_x*ans_x)
ans_yi=(0.2-ans_x+ans_x*ans_y)*k*(1-ans_x*ans_x)*exp(-0.5*ans_x*ans_x)
ans_zi=2-ans_x+ans_x*ans_x-ans_x*ans_y+ans_y+ans_y*ans_Y
ans_x=ans_xi
ans_y=ans_yi
ans_z=ans_zi
write(fileid,*) i,ans_x,ans_y,ans_z
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b,c
integer :: n
write(*,*) "请输入迭代x,y的初值:"
read(*,*) a,b,c
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,c,n)
write(*,*) "over!"
stop
end program main
1.2混沌与分岔
1.2.1混沌的描述性定义
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x)
implicit none
real :: ans_x,ans_y,u=4.0
real,parameter :: h=0.045
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----,X0值',F6.2)") ans_x
do while(.true.)
!迭代函数
ans_y=u*ans_x*(1-ans_x)
write(fileid,*) ans_x,ans_y
ans_x=ans_x+h
if(ans_x>1) exit
end do
close(fileid)
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: x
write(*,*) "请输入迭代x的初值:"
read(*,*) x
call complex_binary(x)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y,ans_z,number)
implicit none
real :: ans_x,ans_y,ans_z,ans_xi,ans_yi,ans_zi
integer :: number,i
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x,ans_y,ans_z
do i=1,number,1
!迭代函数
ans_xi=-0.3-ans_x+ans_x*ans_x-ans_x*ans_y+ans_y+ans_y*ans_y
ans_yi=0.2-ans_x+ans_x*ans_y
ans_zi=-ans_x*ans_y-ans_y*ans_z-ans_x*ans_z
ans_x=ans_xi
ans_y=ans_yi
ans_z=ans_zi
write(fileid,*) i,ans_x,ans_y,ans_z
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b,c
integer :: n
write(*,*) "请输入迭代x,y,z的初值:"
read(*,*) a,b,c
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,c,n)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y,ans_z,number)
implicit none
real :: x,y,z
real :: ans_x,ans_y,ans_z,ans_xi,ans_yi,ans_zi
real :: ans_x1=0.2001,ans_y1=0.2,ans_z1=0.2,ans_xi1,ans_yi1,ans_zi1
integer :: number,i
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x,ans_y,ans_z
do i=1,number,1
!迭代函数
ans_xi=-0.3-ans_x+ans_x*ans_x-ans_x*ans_y+ans_y+ans_y*ans_y
ans_yi=0.2-ans_x+ans_x*ans_y
ans_zi=-ans_x*ans_y-ans_y*ans_z-ans_x*ans_z
ans_x=ans_xi
ans_y=ans_yi
ans_z=ans_zi
ans_xi1=-0.3-ans_x1+ans_x1*ans_x1-ans_x1*ans_y1+ans_y1+ans_y1*ans_y1
ans_yi1=0.2-ans_x1+ans_x1*ans_y1
ans_zi1=-ans_x1*ans_y1-ans_y1*ans_z1-ans_x1*ans_z1
ans_x1=ans_xi1
ans_y1=ans_yi1
ans_z1=ans_zi1
x=ans_x1-ans_x
y=ans_y1-ans_y
z=ans_z1-ans_z
write(fileid,*) i,x,y,z
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b,c
integer :: n
write(*,*) "请输入迭代x,y,z的初值:"
read(*,*) a,b,c
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,c,n)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,number)
implicit none
real :: ans_x
real :: ans_y
integer :: number,i
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x
do i=1,number,1
!迭代函数
ans_y=4*ans_x*(1-ans_x)
write(fileid,*) i,ans_y
ans_x=ans_x+0.01
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a
integer :: n
write(*,*) "请输入迭代x的初值:"
read(*,*) a
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,n)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y,ans_z,number)
implicit none
real :: ans_x,ans_y,ans_z,ans_xi,ans_yi,ans_zi
integer :: number,i
if(number<0) then
write(*,*) "迭代次数有误,stop"
stop
else
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x,ans_y,ans_z
do i=1,number,1
!迭代函数
ans_xi=-0.3-ans_x+ans_x*ans_x-ans_x*ans_y+ans_y+ans_y*ans_y
ans_yi=0.2-0.99999*ans_x+ans_x*ans_y
ans_zi=-ans_x*ans_y-ans_y*ans_z-ans_x*ans_z
ans_x=ans_xi
ans_y=ans_yi
ans_z=ans_zi
write(fileid,*) i,ans_x,ans_y,ans_z
end do
close(fileid)
end if
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b,c
integer :: n
write(*,*) "请输入迭代x,y,z的初值:"
read(*,*) a,b,c
write(*,*) "请输入迭代次数:"
read(*,*) n
call complex_binary(a,b,c,n)
write(*,*) "over!"
stop
end program main
1.2.2Logistic映射
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x)
implicit none
real :: ans_x
integer :: i
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x
do i=1,100,1
!迭代函数
ans_x=2*ans_x*(1-ans_x)
write(fileid,*) i,ans_x
end do
close(fileid)
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a
integer :: n
write(*,*) "请输入迭代x的初值:"
read(*,*) a
call complex_binary(a)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x)
implicit none
real :: ans_x
integer :: i
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x
do i=1,100,1
!迭代函数
ans_x=4.0*ans_x*(1-ans_x)
write(fileid,*) i,ans_x
end do
close(fileid)
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a
integer :: n
write(*,*) "请输入迭代x的初值:"
read(*,*) a
call complex_binary(a)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x)
implicit none
real :: ans_x
integer :: i
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x
do i=1,1000,1
!迭代函数
ans_x=3.8*ans_x*(1-ans_x)
write(fileid,*) i,ans_x
end do
close(fileid)
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a
integer :: n
write(*,*) "请输入迭代x的初值:"
read(*,*) a
call complex_binary(a)
write(*,*) "over!"
stop
end program main
- 增加0.0001,u=3.8001,x0=0.001
- 继续增加,u=3.801,x0=0.001,出现稳定点
1.2.3不动点与周期点
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x)
implicit none
real :: ans_x
integer :: i
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x
do i=1,1000,1
!迭代函数
ans_x=(1+ans_x)**(1.0/3.0)
write(fileid,*) i,ans_x
end do
close(fileid)
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a
integer :: n
write(*,*) "请输入迭代x的初值:"
read(*,*) a
call complex_binary(a)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x)
implicit none
real :: ans_x
integer :: i
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x
do i=1,1000,1
!迭代函数
ans_x=3.2*ans_x*(1-ans_x)
write(fileid,*) i,ans_x
end do
close(fileid)
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a
integer :: n
write(*,*) "请输入迭代x的初值:"
read(*,*) a
call complex_binary(a)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x)
implicit none
real :: ans_x
integer :: i
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x
do i=1,1000,1
!迭代函数
ans_x=3.5*ans_x*(1-ans_x)
write(fileid,*) i,ans_x
end do
close(fileid)
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a
integer :: n
write(*,*) "请输入迭代x的初值:"
read(*,*) a
call complex_binary(a)
write(*,*) "over!"
stop
end program main
1.2.4分岔图
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x)
implicit none
real :: ans_x,u=3
integer :: i
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x
do while(.true.)
!迭代函数
u=u+0.001
ans_x=0.01
if(u>4) exit
do i=1,100,1
ans_x=u*ans_x*(1-ans_x)
write(fileid,*) u,ans_x
end do
end do
close(fileid)
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a
integer :: n
write(*,*) "请输入迭代x的初值:"
read(*,*) a
call complex_binary(a)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x)
implicit none
real :: ans_x,u=-2
integer :: i
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x
do while(.true.)
!迭代函数
u=u+0.001
ans_x=0.001
if(u>1.5) exit
do i=1,100,1
ans_x=2.0*(1.0-ans_x**2)*exp(-0.5*(ans_x+u)**2)
write(fileid,*) u,ans_x
end do
end do
close(fileid)
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a
integer :: n
write(*,*) "请输入迭代x的初值:"
read(*,*) a
call complex_binary(a)
write(*,*) "over!"
stop
end program main
module diedai
implicit none
integer,parameter :: fileid=10
contains
subroutine complex_binary(ans_x,ans_y)
implicit none
real :: ans_x,ans_y,a=-2,b=1.0
real :: ans_xi,ans_yi
integer :: i
open(unit=fileid,file='data_diedai_binary2.txt',status='old')
write(fileid,"('迭代次数---X----Y----Z----X0,Y0,Z0值',F6.2,F6.2,F6.2)") ans_x,ans_y
do while(.true.)
!迭代函数
a=a+0.01
ans_x=0.01
ans_y=0.01
if(a>2.0) exit
do i=1,5,1
ans_xi=1-a*ans_x**2+ans_y
ans_yi=b*ans_x
ans_x=ans_xi
ans_y=ans_yi
write(fileid,*) a,ans_y
end do
end do
close(fileid)
return
end subroutine complex_binary
end module diedai
program main
use diedai
implicit none
real :: a,b
integer :: n
write(*,*) "请输入迭代x,y的初值:"
read(*,*) a,b
call complex_binary(a,b)
write(*,*) "over!"
stop
end program main
1.3混沌的数学特征
1.3.1关联维数
1.3.2Lyapunov指数
module Lyapunov
integer,parameter :: fileid = 10
integer,parameter :: N = 500
contains
subroutine sub1(x)
implicit none
integer :: i
real x,y,u,yy
real p(N)
open(10,file="data.txt")
do u=3.5,3.9,0.001
do i=1,N,1
y=u*x*(1-x)
p(i) = u-2*u*x
x=y
end do
p=abs(p) !一维函数,取模后即是特征值
p=log(p) !取对数,以10为底
yy=sum(p)/N !对数组p求和
write(10,*) u,yy
end do
return
end subroutine sub1
end module Lyapunov
program main
use Lyapunov
implicit none
real :: x = 0.1
call sub1(x)
stop
end program main
module package
implicit none
integer,parameter :: fileid = 10
integer,parameter :: N = 50
contains
subroutine sub1(x,y)
implicit none
real(kind=8) :: x,y,x1,y1
real(kind=8) :: a(2,2),b(2,2),e(2,2),f(2,2)
real(kind=8) :: xx(N),yy(N),ans,nabuda1=0.4,nabuda2=-1.6
integer(kind=4) :: i,c,d
DATA((a(c,d),c=1,2),d=1,2) /-0.56,0.3,1.0,0/
DATA((b(c,d),c=1,2),d=1,2) /0,0.3,1.0,0/
DATA((e(c,d),c=1,2),d=1,2) /1,0,0,1/
xx(1)=x
yy(1)=y
do i=2,N,1
x1=1.0-1.4*x**2+y
y1=0.3*x
x=x1
y=y1
xx(i)=x
yy(i)=y
b(1,1) = -2.8*xx(i)
a=matmul(a,b) !矩阵相乘
!write(*,*) abs(f(1,1)*f(2,2)-f(1,2)*f(2,1))
!write(*,*) nabuda
end do
!ans=log(abs(a(1,1)*a(2,2)-a(1,2)*a(2,1)))
!write(*,*) ans/50.0
!do nabuda=-2.0,1.0,0.1
!f = nabuda*e-a
!write(*,*) abs(f(1,1)*f(2,2)-f(1,2)*f(2,1))
!if(abs(f(1,1)*f(2,2)-f(1,2)*f(2,1))<0.09) then
!write(*,*) log(nabuda)
!end if
!end do
write(*,*) abs((a(1,1)*nabuda1*a(2,2)*nabuda2-a(1,2)*nabuda1*a(2,1)*nabuda2))
write(*,*) log(0.4)/50.0
return
end subroutine sub1
end module package
program Lyapunov
use package
implicit none
real(kind=8) :: x,y
x=0.2
y=0.3
call sub1(x,y)
stop
end program Lyapunov
module Lyapunov
integer,parameter :: fileid = 10
integer,parameter :: N = 500
contains
subroutine sub1(x)
implicit none
integer :: i
real x,y,u,yy
real p(N)
open(10,file="data.txt")
do u=-1.5,1.5,0.001
do i=1,N,1
y=2.0*(1.0*x**2)*exp(-0.5*(x+u)**2) ! 原函数用来递归
p(i) = -4.0*x*exp(-0.5*(x+u)**2)-2.0*(1.0*x**2)*exp(-0.5*(x+u)**2)*(x+u)
x=y
end do
p=abs(p) !一维函数,取模后即是特征值
p=log(p) !取对数,以10为底
yy=sum(p)/N !对数组p求和
write(10,*) u,yy
end do
return
end subroutine sub1
end module Lyapunov
program main
use Lyapunov
implicit none
real :: x = 0.1
call sub1(x)
stop
end program main
- 练习题1
- 练习题2
module Lyapunov
integer,parameter :: fileid = 10
integer,parameter :: N = 5
integer,parameter :: number = 2
contains
subroutine sub1()
implicit none
integer :: i,c,d
real :: x=1.0,y=2.0,x1,y1,xx(N),yy(N)
real :: a(2,2),b(2,2)
real :: p(N)
open(10,file="data.txt")
x1=x
y1=y
DATA((a(c,d),c=1,2),d=1,2) /-1,1,5,0/
DATA((b(c,d),c=1,2),d=1,2) /0,0,0,0/
do i=2,N,1
x1=0.0165-x1+x1**2-x1*y1+y1+y1**2
y1=0.1-x1+x1*y1
x=x1
y=y1
xx(i)=x
yy(i)=y
b(1,1)=-1+2*xx(i)-yy(i)
b(1,2)=1+2*yy(i)
b(2,1)=-1+yy(i)
a=a*b
write(*,*) a
end do
return
end subroutine sub1
end module Lyapunov
program main
use Lyapunov
implicit none
call sub1()
stop
end program main
1.3.3混沌的数学定义
module Lyapunov
integer,parameter :: fileid = 10
integer,parameter :: N = 100
contains
subroutine sub1()
implicit none
integer :: i,j
real(kind=4) :: x,x1
real(kind=4) :: y(N)
do x=0.737,0.999,0.00001
x1=x
open(10,file="data.txt")
do i=1,N,1
y(i)=3.8*x1*(1.0-x1)
x1=y(i)
end do
do j=1,N,1
if(abs(x-y(j))<0.000001) then
write(10,*) 'j=',j,'x=',x
end if
end do
end do
return
end subroutine sub1
end module Lyapunov
program main
use Lyapunov
implicit none
call sub1()
stop
end program main
1.4Lorenz系统族
1.4.1从微分方程到迭代
module Lyapunov
integer,parameter :: fileid = 10
integer,parameter :: N = 10000
real,parameter :: dt = 0.005
contains
subroutine sub1(x,y,z)
implicit none
integer :: i
real :: x,y,z,x1,y1,z1
real :: a=10.0,b=8.0/3.0,c=28.0
open(10,file="data.txt")
do i=1,N,1
x1=x+a*(y-x)*dt
y1=y+(c*x-x*z-y)*dt
z1=z+(x*y-b*z)*dt
x=x1
y=y1
z=z1
write(10,*) i,x,y,z
end do
return
end subroutine sub1
end module Lyapunov
program main
use Lyapunov
implicit none
real :: x,y,z
write(*,*) "请输入x,y,z的初值:"
read(*,*) x,y,z
call sub1(x,y,z)
write(*,*) "over"
stop
end program main
1.4.2Lorenz系统的简单分析(洛伦兹系统)
module Lyapunov
integer,parameter :: fileid = 10
integer,parameter :: N = 10000
real,parameter :: dt = 0.005
contains
subroutine sub1(x,y,z)
implicit none
integer :: i
real :: x,y,z,x1,y1,z1
real :: a=10.0,b=8.0/3.0,c=28.0
open(10,file="data.txt")
do i=1,N,1
x1=x+a*(y-x)*dt
y1=y+(c*x-x*z-y)*dt
z1=z+(x*y-b*z)*dt
x=x1
y=y1
z=z1
write(10,*) i,x,y,z
end do
return
end subroutine sub1
end module Lyapunov
program main
use Lyapunov
implicit none
real :: x,y,z
write(*,*) "请输入x,y,z的初值:"
read(*,*) x,y,z
call sub1(x,y,z)
write(*,*) "over"
stop
end program main
1.4.3陈系统与吕系统
- 练习题1
module Lorenz
implicit none
integer,parameter :: fileid = 10
integer,parameter :: N = 10000
integer,parameter :: size = 3
contains
subroutine sub1(x,fx,size,a)
implicit none
integer :: i
real :: x(size),fx(size)
real :: a
integer :: size
fx(1)=(25.0*a+10.0)*(x(2)-x(1))
fx(2)=(28.0-35.0*a)*x(1)-x(1)*x(3)+(29.0*a-1.0)*x(2)
fx(3)=x(1)*x(2)-((a+8.0)/3.0)*x(3)
return
end subroutine sub1
subroutine rk(x,h,size,a)
implicit none
real :: x(size),xx(size),h,fx(size)
real :: kx1(size),kx2(size),kx3(size),kx4(size)
real :: a
integer :: size
xx=x
call sub1(xx,fx,size,a)
kx1=h*fx
xx=x+0.5*kx1
call sub1(xx,fx,size,a)
kx2=h*fx
xx=x+0.5*kx2
call sub1(xx,fx,size,a)
kx3=h*fx
xx=x+kx3
call sub1(xx,fx,size,a)
kx4=h*fx
x=x+(kx1+2.0*kx2+2.0*kx3+kx4)/6.0
return
end subroutine rk
end module Lorenz
program main
use Lorenz
implicit none
real :: x(size),h=0.001,a
integer :: i
write(*,*) "请输入x,y,z的初值:"
read(*,*) x(1),x(2),x(3)
write(*,*) "请输入a的值:"
read(*,*) a
open(10,file="data.txt")
do i=1,N,1
call rk(x,h,size,a)
if(i>1000) then
write(10,*) x
end if
end do
write(*,*) "over"
stop
end program main
- 练习题2
module Lorenz
implicit none
integer,parameter :: fileid = 10
integer,parameter :: N = 10000
integer,parameter :: size = 3
contains
subroutine sub1(x,fx,size)
implicit none
integer :: i
real :: x(size),fx(size)
real :: a=10.0,b=3.0,c=28.0
integer :: size
fx(1)=a*(x(2)-x(1))
fx(2)=(c-a)*x(1)-x(1)*x(3)+c*x(2)
fx(3)=x(1)*x(2)-b*x(3)
return
end subroutine sub1
subroutine rk(x,h,size)
implicit none
real :: x(size),xx(size),h,fx(size)
real :: kx1(size),kx2(size),kx3(size),kx4(size)
integer :: size
xx=x
call sub1(xx,fx,size,a)
kx1=h*fx
xx=x+0.5*kx1
call sub1(xx,fx,size,a)
kx2=h*fx
xx=x+0.5*kx2
call sub1(xx,fx,size,a)
kx3=h*fx
xx=x+kx3
call sub1(xx,fx,size,a)
kx4=h*fx
x=x+(kx1+2.0*kx2+2.0*kx3+kx4)/6.0
return
end subroutine rk
end module Lorenz
program main
use Lorenz
implicit none
real :: x(size),h=0.001
integer :: i
write(*,*) "请输入x,y,z的初值:"
read(*,*) x(1),x(2),x(3)
open(10,file="data.txt")
do i=1,N,1
call rk(x,h,size)
if(i>1000) then
write(10,*) x
end if
end do
write(*,*) "over"
stop
end program main
- 练习3
module Lyapunov
integer,parameter :: fileid = 10
integer,parameter :: N = 10000
real,parameter :: dt = 0.005
contains
subroutine sub1(x,y,z)
implicit none
integer :: i
real :: x,y,z,x1,y1,z1
real :: a=10.0,b=8.0/3.0,c=28.0
open(10,file="data.txt")
do i=1,N,1
x1=x+a*(y-x)*dt
y1=y+(-x*z+c*y)*dt
z1=z+(x*y-b*z)*dt
x=x1
y=y1
z=z1
write(10,*) i,x,y,z
end do
return
end subroutine sub1
end module Lyapunov
program main
use Lyapunov
implicit none
real :: x,y,z
write(*,*) "请输入x,y,z的初值:"
read(*,*) x,y,z
call sub1(x,y,z)
write(*,*) "over"
stop
end program main