Direction Fields

Often it is impossible to find an explicit formula for the solution to a differential equation.  Nevertheless, graphical and numerical approaches may be used to approximate solutions.  In this lesson we will investigate direction fields and the graphical solution.

New Maple Learning
I
n this lesson we introduce two commands in the package of routines DEtools:
dfieldplot(<eqn>,y(x),x=a..b,y=c..d)  plot the slope field of the differential equation <eqn> in x and y (assuming y is a function of x) for points whose x-coordinates are between a and b and whose y-coordinates are between c and d  NOTE:  We must specify y by y(x) and y' by diff(y(x),x).
dsolve({<eqn>,y(a)=b},y(x))  solves the differential equation <eqn> in x and y (assuming y is a function of x) using the initial condition y(a) = b and y = y(x)

Lesson
F
ind the direction field associated to the differential y' = x + y and the three solutions corresponding to the initial conditions y(0) = 0, y(0) = 1, and y(0) = -1.

> restart: with(plots): with(DEtools):

> y0:=y(x);y1:=diff(y(x),x);

> plot0:=dfieldplot(y1=x+y0,y0,x=-2..2,y=-2..2):

> display(plot0);

> dsolve({y1=x+y0,y(0)=0},y(x));

> plot1:=plot(rhs(%),x=-2..2,y=-2..2,color=blue):

> display({plot0,plot1});

> dsolve({y1=x+y0,y(0)=1},y(x));

> plot2:=plot(rhs(%),x=-2..2,y=-2..2,color=red):

> display({plot0,plot1,plot2});

> dsolve({y1=x+y0,y(0)=-1},y(x));

> plot3:=plot(rhs(%),x=-2..2,y=-2..2,color=green):

> display({plot0,plot1,plot2,plot3});