ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 05 Dec 2012 21:59:18 +0100graphing ODE's using euler's methodhttps://ask.sagemath.org/question/9602/graphing-odes-using-eulers-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)
SplotrmmrWed, 05 Dec 2012 21:59:18 +0100https://ask.sagemath.org/question/9602/How do I fix Warning: Output Truncated?https://ask.sagemath.org/question/8359/how-do-i-fix-warning-output-truncated/Below is my code step by step for using Euler's Method to approximate a solution of a system. It will work when n = 10, but not when n = 100 or 1000. How can I fix it so that the output isn't truncated. Thanks!
# Define RR to be the real numbers, rounding to the nearest number, with 25 bits of precision
RR = RealField(25,rnd='RNDN')
# Define t,x,y to be numbers in RR
t,x,y = PolynomialRing(RR,3,"txy").gens()
# Define the system of equations
firsteq = y
secondeq = -x - x^3/6 + x^5/120 - x^7/5040 + x^9/362880
# Define parameters
t0 = 0
x0 = 0
y0 = 2
h = 1/4
n = 10
t1 = t0 + n*h
# Plot the x(t) and y(t) graphs
eulers_method_2x2_plot(firsteq , secondeq, t0, x0, y0, h, t1)ambellinaWed, 05 Oct 2011 20:20:25 +0200https://ask.sagemath.org/question/8359/