[sage-support] 'unable to simplify to float approximation' error in Logistic equation

2011-11-16 Thread Jose Guzman
I am having some troubles to get the logistic equation from its 
differential form. For example:


sage: tau = var('tau') # proportionality constant
sage: k = var('k') # max population size
sage: t = var('t') # independent variable
sage: p = function('p', t) # dependent variable

sage: myode = tau*diff(p,t) == p*(1-p/k)
sage: sol(t) = desolve(de=myode, ivar=t, dvar=p)

sage returns:
 -tau*log(-k + p(t)) + tau*log(p(t)) == c + t

Now, when I try to show the solution to the equation:

sage: plot(sol.subs(tau=20, k=10, c=1), 0, 100)

i've got the following error:

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


I would appreciate some help here.

Thanks in advance

Jose

--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] 'unable to simplify to float approximation' error in Logistic equation

2011-11-16 Thread D. S. McNeil
The problem is that the solution that desolve returns:

 sage: myode = tau*diff(p,t) == p*(1-p/k)
 sage: sol(t) = desolve(de=myode, ivar=t, dvar=p)

 sage returns:
  -tau*log(-k + p(t)) + tau*log(p(t)) == c + t

isn't in an easy enough form for plot to display.  You're setting
sol(t) not to an expression but to an equation, and a non-trivial one.
 (You might be able to make implicit_plot work with some tweaking but
I'm lazy. :^)

We can fix that, though.  Try something like



tau = var('tau') # proportionality constant
k = var('k') # max population size
t = var('t') # independent variable
p = function('p', t) # dependent variable

myode = tau*diff(p,t) == p*(1-p/k)
sol = desolve(de=myode, ivar=t, dvar=p)
sol = sol.simplify_full() # simplify_log would suffice
sol_p(t) = solve(sol,p,solution_dict=True)[0][p] # make a function
from the solution
plot(sol_p.subs(tau=20, k=10, c=1), 0, 100)




Doug

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org