Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168731
Image: ubuntu2004
x,y = var('x y') maxima.eval('load("plotdf");') eq='(x+y)/(x-y)' x0,x1,y0,y1=-3,3,-3,3 eq=sage_eval(eq,locals={'x':x,'y':y}) #p=plot_slope_field(eq, (x,x0,x1), (y, y0, y1)) p=implicit_plot(eq==0, (x, x0, x1), (y, y0, y1), color="red") p=p+implicit_plot(1/(eq)==0,(x, x0, x1),(y, y0, y1),color="yellow") show(p) @interact def df(eq='-x/y',usemaxima=False,window=matrix(2,2,[-3,3,-3,3]),IVP=False,xinit=0,yinit=1): x0=window[0,0] x1=window[0,1] y0=window[1,0] y1=window[1,1] eq=sage_eval(eq,locals={'x':x,'y':y}) html(r'This is the vector field corresponding to $\frac{dy}{dx}='+latex(eq)+'$') if not usemaxima: p=implicit_plot(eq==0, (x, x0, x1), (y, y0, y1), color="red") p=p+plot_slope_field(eq, (x,x0,x1), (y, y0, y1)) p=p+implicit_plot(1/eq==0,(x, x0, x1),(y, y0, y1),color="yellow") if IVP: p+=list_plot(desolve_rk4(eq,y,ics=[xinit,yinit],ivar=x,end_points=[x0,x1]) ,ymin=y0,ymax=y1) p.show(aspect_ratio=1) else: if IVP: maxima.plotdf(eq,str([y,y0,y1]),str([x,x0,x1]), '[trajectory_at, %s, %s]'%(str(xinit), str(yinit) )) else: maxima.plotdf(str(eq),str([y,y0,y1]),str([x,x0,x1]))
x,y=var('x y') @interact def iso(eq=-x/y,isofrom =-2,isoto=2,isostep=.5,xmin=-3,xmax=3,ymin=-3,ymax=3): print html('This interact plots the slope field for $\\frac{dy}{dx}='+str(eq)+'$') print html('It also shows the isoclines given by the from, to and step numbers') print html('as well as the isocline corresponding to the vertical slopes') p=plot_slope_field(eq, (x,xmin,xmax), (y,ymin,ymax)) for k in srange(isofrom,isoto,isostep): p+=implicit_plot(eq==k, (x, xmin, xmax), (y, ymin, ymax), cmap='autumn') p+implicit_plot(1/eq==0,(x, xmin, xmax), (y, ymin, ymax), cmap='autumn') show(p,aspect_ratio=1)
#Is this a bug? x,y=var('x y') q=implicit_plot((x-y)/(x+y)==0,(x,-2,2),(y,-2,2),color='red') p=implicit_plot((x+y)/(x-y)==0,(x,-2,2),(y,-2,2),color='yellow') show(q) show(p) show(p+q)