Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Plotting solution to O.D.E.

Hello,

I just started using sage yesterday, and I'm trying to plot a solution to an ODE. Here is my code:

t = var('t') c = function('c',t) s = 0.025 n = 10^8 r = 10^(-6) ode = diff(c,t)==r*c*(1-c)*n+s/(1+s*c)*c*(1-c) sol1 = desolve(de=ode, ivar=t, dvar=c,ics=[0,2]) sol1 = sol1.simplify_full() solc = solve(sol1,c) plot(solc,0,100)

sage returns a solution for solc:

... solc = solve(sol1,c); solc #plot(solc,0,100) [log(c(t)) == 4001/40*t + 1/164040*log(4201) + log(2) - 1/164040*log(100*c(t) + 4001) + 164041/164040*log(c(t) - 1)]

The error message I get is:
verbose 0 (3517: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 200 points.
verbose 0 (3517: plot.py, generate_plot_points) Last error message: 'unable to simplify to float approximation'

Is there any way to plot this?

Thanks in advance.

Plotting solution to O.D.E.

Hello,

I just started using sage yesterday, and I'm trying to plot a solution to an ODE. Here is my code:

t = var('t')
c = function('c',t)
s = 0.025
n = 10^8
r = 10^(-6)
ode = diff(c,t)==r*c*(1-c)*n+s/(1+s*c)*c*(1-c) diff(c,t)==rc(1-c)n+s/(1+sc)c(1-c)
sol1 = desolve(de=ode, ivar=t, dvar=c,ics=[0,2])
sol1 = sol1.simplify_full()
solc = solve(sol1,c) plot(solc,0,100)


plot(solc,0,100)

sage returns a solution for solc:

...
solc = solve(sol1,c); solc #plot(solc,0,100)
[log(c(t)) == 4001/40*t + 1/164040*log(4201) 4001/40t + 1/164040log(4201) + log(2) - 1/164040*log(100*c(t) 1/164040log(100c(t) + 4001) + 164041/164040*log(c(t) - 1)]

1)]

The error message I get is:
verbose 0 (3517: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 200 points.
verbose 0 (3517: plot.py, generate_plot_points) Last error message: 'unable to simplify to float approximation'

Is there any way to plot this?

Thanks in advance.

Plotting solution to O.D.E.

Hello,

I just started using sage yesterday, and I'm trying to plot a solution to an ODE. Here is my code:

t = var('t') 
c = function('c',t)
s = 0.025
n = 10^8
r = 10^(-6)
ode = diff(c,t)==rc(1-c)n+s/(1+sc)c(1-c)
diff(c,t)==r*c*(1-c)*n+s/(1+s*c)*c*(1-c) sol1 = desolve(de=ode, ivar=t, dvar=c,ics=[0,2])
sol1 = sol1.simplify_full()
solc = solve(sol1,c)
plot(solc,0,100)

plot(solc,0,100)

sage returns a solution for solc:

...    

...
solc = solve(sol1,c); solc
[log(c(t)) == 4001/40t 4001/40*t + 1/164040log(4201) 1/164040*log(4201) + log(2) - 1/164040log(100c(t) 1/164040*log(100*c(t) + 4001) + 164041/164040*log(c(t) - 1)]

1)]

The error message I get is:

verbose 0 (3517: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 200 points. 
verbose 0 (3517: plot.py, generate_plot_points) Last error message: 'unable to simplify to float approximation'

approximation'

Is there any way to plot this?

Thanks in advance.