slope

481 days ago by voloch

#plot of slope field dy/dx=x+y and special solutions with initial conditions, y(0)=2,-1,-2 #see http://doc.sagemath.org/html/en/reference/plotting/sage/plot/plot_field.html x,y = var('x y') a = plot_slope_field(x+y, (x,-4,4), (y,-5,6)) b = plot(-x -1 + 3*e^x,(x,-4,1)) c = plot(-x -1,(x,-4,4),color='red') d = plot(-x -1 -e^x,(x,-4,1),color='green') show(a+b+c+d) #symbolic DE solver see http://doc.sagemath.org/html/en/constructions/calculus.html #same equation as above plot y=function('y')(x) z=desolve(diff(y,x) == x+y, dvar = y) print z w=desolve(diff(y,x) == x+y, dvar = y,ics=[0,2]) print w print desolve(diff(y,x) == x+y, dvar = y,ics=[0,-1])
 -((x + 1)*e^(-x) - _C)*e^x -x + 3*e^x - 1 -x - 1 -((x + 1)*e^(-x) - _C)*e^x -x + 3*e^x - 1 -x - 1
#plot of slope field dy/dx=(2*x-y)/(2*x+2*y) and special solutions x,y = var('x y') a = plot_slope_field((2*x-y)/(2*x+2*y), (x,-10,10), (y,-10,10)) b = plot(-2*x,(x,-5,5)) c = plot(x/2,(x,-10,10),color='red') show(a+b+c) 