You probably also want to do something like P=plot_slope_field(-g,(x,0,3),(y,0,20))
since the slope of the solution is -g, not g. -Marshall On Nov 30, 4:37 pm, Jason Grout <jason-s...@creativetrax.com> wrote: > kcrisman wrote: > > Dear support, > > > I'm giving a talk Wednesday and would like to do the following > > interact as an example of how easy interacts are: > > > y = var('y') > > @interact > > def _(g=input_box(default = 1-y)): > > P=plot_slope_field(g,(x,0,3),(y,0,20)) > > y = function('y',x) > > f = desolve(diff(y,x) + g, y, ics=[2,2]) > > Q=plot(f,0,3) > > show(P+Q) > > > Only it isn't easy. The declaring of y = function('y',x), which is > > necessary to use desolve, causes the following error: > > > UnboundLocalError: local variable 'y' referenced before assignment > > > And the 'g' in the desolve also causes problems shortly thereafter. I > > tried a lot of things to fix this, but nothing seemed to work quite > > right. Note that this works nicely without interact. > > > Any help one can give in a relatively timely basis would be much > > appreciated! Thanks in advance, > > It looks like you are confusing y-as-a-variable and y-as-a-function an > awful lot. How about: > > y = var('y') > @interact > def _(g=input_box(default = 1-y)): > P=plot_slope_field(g,(x,0,3),(y,0,20)) > yfun = function('yfun',x) > f = desolve(diff(yfun,x) + g(y=yfun), yfun, ics=[2,2]) > Q=plot(f,0,3) > show(P+Q) > > Does that give what you want? > > Jason -- 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