Ask Your Question

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

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?

## 1 Answer

Sort by » oldest newest most voted

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.

more

## Comments

@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).

## Your Answer

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

Add Answer

## Stats

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

Seen: 330 times

Last updated: May 13 '16