Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

graphing ODE's using euler's method

Im trying to plot a graph based on the change in susceptible, exposed and infected people due to guinea worm, included is a plot of the worm population W. This is an attempt to at least replicate some of what is from this mathematical model

(http://mysite.science.uottawa.ca/rsmith43/GuineaWorm.pdf ),

hopefully using the Impulsive differential equations but right now I've been relentlessly trying to graph these equations on a reasonable axis over ten years but for some reason it doesn't. Plus the y axis is completely off from what it should be, does anyone know what is wrong with the code? Thanks for any responses

timedata=[]

Sdata=[]

Edata=[]

Idata=[]

Wdata=[]

t=0

S=2600

E=1

I=1

W=200

bR= 37

k= 8760

m= .0142

r= .9

B= .0255*(1/W)

A= 1

Y=100000

mW=26

dt=.1

timedata.append(t)

Sdata.append(S)

Edata.append(E)

Idata.append(I)

Wdata.append(W)

T=10

Tfinal=(T/dt)

for i in range(0,Tfinal):

t= t+dt

Sprime=bR-B*S*W-m*S+k*I

Eprime=B*S*W-A*E-m*E

Iprime=A*E-k*I-m*I

Wprime=Y*I-mW*W

S= S+(Sprime*dt)

E= E+(Eprime*dt)

I= I+(Iprime*dt)

W= W+(Wprime*dt)

timedata.append(t)

Sdata.append(S)

Edata.append(E)

Idata.append(I)

Wdata.append(W)

Splot=list_plot(zip(timedata,Sdata),color='green',plotjoined=True)

Eplot=list_plot(zip(timedata,Edata),color='orange',plotjoined=True)

Iplot=list_plot(zip(timedata,Idata),color='black',plotjoined=True)

Splot

click to hide/show revision 2
No.2 Revision

graphing ODE's using euler's method

Im trying to plot a graph based on the change in susceptible, exposed and infected people due to guinea worm, included is a plot of the worm population W. This is an attempt to at least replicate some of what is from this mathematical model

(http://mysite.science.uottawa.ca/rsmith43/GuineaWorm.pdf ),

hopefully using the Impulsive differential equations but right now I've been relentlessly trying to graph these equations on a reasonable axis over ten years but for some reason it doesn't. Plus the y axis is completely off from what it should be, does anyone know what is wrong with the code? Thanks for any responses

timedata=[]

Sdata=[]

Edata=[]

Idata=[]

Wdata=[]

t=0

S=2600

E=1

I=1

W=200

timedata=[]
Sdata=[]
Edata=[]
Idata=[]
Wdata=[]

t=0
S=2600
E=1
I=1
W=200
bR= 37

37 k= 8760

m= .0142

r= .9

B= .0255*(1/W)

.0255*(1/W) A= 1

Y=100000

mW=26

dt=.1

timedata.append(t)

Sdata.append(S)

Edata.append(E)

Idata.append(I)

Wdata.append(W)

T=10

Tfinal=(T/dt)

1 Y=100000 mW=26 dt=.1 timedata.append(t) Sdata.append(S) Edata.append(E) Idata.append(I) Wdata.append(W) T=10 Tfinal=(T/dt) for i in range(0,Tfinal):

range(0,Tfinal):
    t= t+dt
  Sprime=bR-B*S*W-m*S+k*I
  Eprime=B*S*W-A*E-m*E
  Iprime=A*E-k*I-m*I
  Wprime=Y*I-mW*W
  S= S+(Sprime*dt)
  E= E+(Eprime*dt)
  I= I+(Iprime*dt)
  W= W+(Wprime*dt)
  timedata.append(t)
  Sdata.append(S)
  Edata.append(E)
  Idata.append(I)
  Wdata.append(W)

Splot=list_plot(zip(timedata,Sdata),color='green',plotjoined=True)
Eplot=list_plot(zip(timedata,Edata),color='orange',plotjoined=True)
Iplot=list_plot(zip(timedata,Idata),color='black',plotjoined=True)

Splot

Splot=list_plot(zip(timedata,Sdata),color='green',plotjoined=True)

Eplot=list_plot(zip(timedata,Edata),color='orange',plotjoined=True)

Iplot=list_plot(zip(timedata,Idata),color='black',plotjoined=True)

Splot

click to hide/show revision 3
retagged

graphing ODE's using euler's method

Im trying to plot a graph based on the change in susceptible, exposed and infected people due to guinea worm, included is a plot of the worm population W. This is an attempt to at least replicate some of what is from this mathematical model

(http://mysite.science.uottawa.ca/rsmith43/GuineaWorm.pdf ),

hopefully using the Impulsive differential equations but right now I've been relentlessly trying to graph these equations on a reasonable axis over ten years but for some reason it doesn't. Plus the y axis is completely off from what it should be, does anyone know what is wrong with the code? Thanks for any responses

timedata=[]
Sdata=[]
Edata=[]
Idata=[]
Wdata=[]

t=0
S=2600
E=1
I=1
W=200
bR= 37
k= 8760 
m= .0142 
r= .9          
B= .0255*(1/W)
A= 1
Y=100000
mW=26
dt=.1


timedata.append(t)
Sdata.append(S)
Edata.append(E)
Idata.append(I)
Wdata.append(W)

T=10
Tfinal=(T/dt)
for i in range(0,Tfinal):
    t= t+dt
    Sprime=bR-B*S*W-m*S+k*I
    Eprime=B*S*W-A*E-m*E
    Iprime=A*E-k*I-m*I
    Wprime=Y*I-mW*W
    S= S+(Sprime*dt)
    E= E+(Eprime*dt)
    I= I+(Iprime*dt)
    W= W+(Wprime*dt)
    timedata.append(t)
    Sdata.append(S)
    Edata.append(E)
    Idata.append(I)
    Wdata.append(W)

Splot=list_plot(zip(timedata,Sdata),color='green',plotjoined=True)
Eplot=list_plot(zip(timedata,Edata),color='orange',plotjoined=True)
Iplot=list_plot(zip(timedata,Idata),color='black',plotjoined=True)

Splot