On 2/25/14 12:25 PM, Jeff Denny wrote:
My students are attempting to use a python function with an if statement in it 
as part of a differential equation they are solving with desolve_odeint.  
Unfortunately, of course, Sage executes the python function as soon as they 
write it and not within the solver.  I need help on getting around this.  Here 
is some same code for a simpler case than what they are doing.


def f(x,y):
     if x<0.2:
         return(0)
     else:
         return(y*(1-y))

ans=desolve_odeint([SR(1),f(x,y)],[0,0.5],srange(0,10,0.01),[x,y])


I'll note that my first reaction, to call desolve_odeint with just f instead of f(x,y), gives an error about f not having a variables method:

http://sagecell.sagemath.org/?q=zmmcru

Jason


--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to