ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 20 Feb 2014 11:26:00 -0600desolve_rk4 cannot handle a piecewise functionhttp://ask.sagemath.org/question/11062/desolve_rk4-cannot-handle-a-piecewise-function/I am trying to get a numeric solution to a differential equation involving a function that is piecewise (actually defined using an if/else statement). I successfully generated a slopefield using the lambda function, but desolve_rk4 seemingly cannot cope with this syntax. It seems to me that a numeric solver should be able to handle a function defined this way, but perhaps I am just doing something wrong?
Code:
var('t')
def f(t):
if t<5:
return 3
else:
return 0
V=function('V',t)
desolve_rk4(lambda t,V: ((f)-V)/(2.3*1.2),V, ics=(0,0),ivar=t)Groenendael72Thu, 20 Feb 2014 11:26:00 -0600http://ask.sagemath.org/question/11062/Defining a function and forcing max or min valuehttp://ask.sagemath.org/question/8896/defining-a-function-and-forcing-max-or-min-value/Hi,
Is it possible to define a funtion, say f, and have it be the maximum (or minimum) of another function and a constant?
Example (pseudo-script): if g(x)=log(abs(x)), let f(x)=g(x) if g(x)>0, and f(x)=0 for all g(x)<0
Thanks
N.C.sagembTue, 17 Apr 2012 02:08:11 -0500http://ask.sagemath.org/question/8896/