SharedTA Sandbox / Hao's Sandbox / Lab10_slides / Lab10_slides.ipynbOpen in CoCalc
Author: HAO LEE
Views : 12

## Chaos

#### We have learned Two Stable System Behaviors

1. Converge to Equilibrium
2. Stable Limit Cycle

#### Is there any other type?

Chaos System$\begin{cases} \text{Bounded Output}\\ \text{Not Periodic} \end{cases}$

## Romeo Juliet System (Continuous Time Example)

$R' = R + 0.1J$

$J' = -J-T$

$T' = 0.1-cT+RT$

Let $c = 14,R(0)=5, J(0)=5, T(0)=1$

In [1]:
_=var('J,R,T')
c = 14
jprime = R+0.1*J
rprime = -J-T
tprime = 0.1-c*T+R*T


In [2]:
time = srange(0,100,0.1)
sol = desolve_odeint([jprime,rprime,tprime],dvars = [J,R,T],times = time,ics = [5,5,1])

In [85]:
list_plot(zip(time,sol[:,0]),plotjoined=True,axes_labels=['time','J'])

In [86]:
list_plot(zip(time,sol[:,1]),plotjoined=True,axes_labels=['time','R'])

In [87]:
list_plot(zip(time,sol[:,2]),plotjoined=True,axes_labels=['time','T'])


### However, it is still bounded!

In [62]:
list_plot(sol,plotjoined=True)


## Initial Values Matters a Lot

$R' = R + 0.1J$

$J' = -J-T$

$T' = 0.1-cT+RT$

In [69]:
time = srange(0,500,0.1)
sol1 = desolve_odeint([jprime,rprime,tprime],dvars = [J,R,T],times = time,ics = [5,5,1])
sol2 = desolve_odeint([jprime,rprime,tprime],dvars = [J,R,T],times = time,ics = [5.1,5.1,1.1])

In [76]:
fig1 = list_plot(zip(time[0:1000],sol1[0:1000,0]),plotjoined=True)+list_plot(zip(time[0:1000],sol2[0:1000,0]),plotjoined=True,color='red')
fig2 = list_plot(zip(time[4000:-1],sol1[4000:-1,0]),plotjoined=True)+list_plot(zip(time[4000:-1],sol2[4000:-1,0]),plotjoined=True,color='red')

show(fig1)
show(fig2)

In [78]:
list_plot(sol1,plotjoined=True,color='blue')+list_plot(sol2,plotjoined=True,color='red')

In [115]:
time = srange(0,100,0.1)
sol = desolve_odeint([jprime,rprime,tprime],dvars = [J,R,T],times = time,ics = [5,8,2])
fig1 = list_plot(sol,plotjoined=True)
sol = desolve_odeint([jprime,rprime,tprime],dvars = [J,R,T],times = time,ics = [1,4,3])
fig2 = list_plot(sol,plotjoined=True,color='red')

sol = desolve_odeint([jprime,rprime,tprime],dvars = [J,R,T],times = time,ics = [1.3,-1.6,50])
fig3 = list_plot(sol,plotjoined=True,color='green')
show(fig1+fig2+fig3)