Ask Your Question
1

Plotting solution to O.D.E.

asked 2016-05-10 18:51:02 +0200

jofk gravatar image

updated 2016-05-10 19:11:25 +0200

tmonteil gravatar image

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  
[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.

edit retag flag offensive close merge delete

Comments

note that to put a block of code, instead of a quote (with ">"), you should add four spaces for each line. It can be done by clicking on the 0101010 button.

tmonteil gravatar imagetmonteil ( 2016-05-10 19:12:17 +0200 )edit
1

The problem is that your solution seems to not have been solved (perhaps can't be) for c(t) by Sage's solver. You could conceivably try an implicit plot?

kcrisman gravatar imagekcrisman ( 2016-05-10 19:55:34 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-05-11 05:27:24 +0200

updated 2016-05-13 23:53:25 +0200

As @kcrisman said, try an implicit plot. For example:

var('c t')
implicit_plot(log(c)== 4001/40*t + 1/164040*log(4201) + log(2) - 1/164040*log(100*c + 4001) + 164041/164040*log(c - 1),(t,0,.1),(c,0,10),aspect_ratio=.01)

Here's an updated link to see the result.

edit flag offensive delete link more

Comments

That example helps a lot! Thank you.

jofk gravatar imagejofk ( 2016-05-11 14:19:50 +0200 )edit

@jofk if this answers your question, let me invite you to accept it (by clicking on the check mark on the top left of the answer).

tmonteil gravatar imagetmonteil ( 2016-05-11 17:29:12 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-05-10 18:51:02 +0200

Seen: 524 times

Last updated: May 13 '16