dS/dt=-bS+gI, dI/dt=bS-gI (uso b para beta y g para gamma)


```python
from sympy import *
from sympy.abc import S,I,t,b,g
```


```python
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import odeint
import pylab as pl
```


```python
#puntos criticos
P=-b*S+g*I
Q=b*S-g*I
#establecer P(S,I)=0 y Q(S,I)=0
Peqn=Eq(P,0)
Qeqn=Eq(Q,0)
print(solve((Peqn,Qeqn),S,I))
#Eigenvalores y eigenvectores
M=Matrix([[-b,g],[b,-g]])
print(M.eigenvals())
pprint(M.eigenvects())
```

    {S: I*g/b}
    {-b - g: 1, 0: 1}
    ⎡⎛      ⎡⎡g⎤⎤⎞                     ⎤
    ⎢⎜      ⎢⎢─⎥⎥⎟  ⎛           ⎡⎡-1⎤⎤⎞⎥
    ⎢⎜0, 1, ⎢⎢b⎥⎥⎟, ⎜-b - g, 1, ⎢⎢  ⎥⎥⎟⎥
    ⎢⎜      ⎢⎢ ⎥⎥⎟  ⎝           ⎣⎣1 ⎦⎦⎠⎥
    ⎣⎝      ⎣⎣1⎦⎦⎠                     ⎦



```python
b=1
g=1
def dx_dt(x,t):
    return [ -b*x[0]+g*x[1] , b*x[0]-g*x[1] ]
#trayectorias en tiempo hacia adelante
ts=np.linspace(0,10,500)
ic=np.linspace(20000,100000,3)
for r in ic:
    for s in ic:
        x0=[r,s]
        xs=odeint(dx_dt,x0,ts)
        plt.plot(xs[:,0],xs[:,1],"-", color="orangered", lw=1.5)
#trayectorias en tiempo hacia atras
ts=np.linspace(0,-10,500)
ic=np.linspace(20000,100000,3)
for r in ic:
    for s in ic:
        x0=[r,s]
        xs=odeint(dx_dt,x0,ts)
        plt.plot(xs[:,0],xs[:,1],"-", color="orangered", lw=1.5)
#etiquetas de ejes y estilo de letra
plt.xlabel('S',fontsize=20)
plt.ylabel('I',fontsize=20)
plt.tick_params(labelsize=12)
plt.ticklabel_format(style="sci", scilimits=(0,0))
plt.xlim(0,100000)
plt.ylim(0,100000)
#campo vectorial
X,Y=np.mgrid[0:100000:15j,0:100000:15j]
u=-b*X+g*Y
v=b*X-g*Y
pl.quiver(X,Y,u,v,color='dimgray')
plt.savefig("SIS.pdf",bbox_inches='tight')
plt.show()
```


```python
b=1
g=3
def dx_dt(x,t):
    return [ -b*x[0]+g*x[1] , b*x[0]-g*x[1] ]
#trayectorias en tiempo hacia adelante
ts=np.linspace(0,10,500)
ic=np.linspace(20000,100000,3)
for r in ic:
    for s in ic:
        x0=[r,s]
        xs=odeint(dx_dt,x0,ts)
        plt.plot(xs[:,0],xs[:,1],"-", color="orangered", lw=1.5)
#trayectorias en tiempo hacia atras
ts=np.linspace(0,-10,500)
ic=np.linspace(20000,100000,3)
for r in ic:
    for s in ic:
        x0=[r,s]
        xs=odeint(dx_dt,x0,ts)
        plt.plot(xs[:,0],xs[:,1],"-", color="orangered", lw=1.5)
#etiquetas de ejes y estilo de letra
plt.xlabel('S',fontsize=20)
plt.ylabel('I',fontsize=20)
plt.tick_params(labelsize=12)
plt.ticklabel_format(style="sci", scilimits=(0,0))
plt.xlim(0,100000)
plt.ylim(0,100000)
#campo vectorial
X,Y=np.mgrid[0:100000:15j,0:100000:15j]
u=-b*X+g*Y
v=b*X-g*Y
pl.quiver(X,Y,u,v,color='dimgray')
plt.show()
```


```python
b=3
g=1
def dx_dt(x,t):
    return [ -b*x[0]+g*x[1] , b*x[0]-g*x[1] ]
#trayectorias en tiempo hacia adelante
ts=np.linspace(0,10,500)
ic=np.linspace(20000,100000,3)
for r in ic:
    for s in ic:
        x0=[r,s]
        xs=odeint(dx_dt,x0,ts)
        plt.plot(xs[:,0],xs[:,1],"-", color="orangered", lw=1.5)
#trayectorias en tiempo hacia atras
ts=np.linspace(0,-10,500)
ic=np.linspace(20000,100000,3)
for r in ic:
    for s in ic:
        x0=[r,s]
        xs=odeint(dx_dt,x0,ts)
        plt.plot(xs[:,0],xs[:,1],"-", color="orangered", lw=1.5)
#etiquetas de ejes y estilo de letra
plt.xlabel('S',fontsize=20)
plt.ylabel('I',fontsize=20)
plt.tick_params(labelsize=12)
plt.ticklabel_format(style="sci", scilimits=(0,0))
plt.xlim(0,100000)
plt.ylim(0,100000)
#campo vectorial
X,Y=np.mgrid[0:100000:15j,0:100000:15j]
u=-b*X+g*Y
v=b*X-g*Y
pl.quiver(X,Y,u,v,color='dimgray')
plt.show()
```


```python

```

1e838fa8b52019a28d2d97c80755118130f9ba0a
ipynb
Jupyter Notebook
ModeloSIS(no infeccioso).ipynb
deleonja/dynamical-sys
024acc61a4e36d46b1502ce0391707e4afbc58e2
MIT
ModeloSIS(no infeccioso).ipynb
deleonja/dynamical-sys
024acc61a4e36d46b1502ce0391707e4afbc58e2
MIT
ModeloSIS(no infeccioso).ipynb
deleonja/dynamical-sys
024acc61a4e36d46b1502ce0391707e4afbc58e2
MIT
Qwen/Qwen-72B
1. YES
2. YES