Examples
A third order equation, plots the solution "y(x)" against x. Looking under Function above you can see the format used.
This is written so it is "clear". It is irritating that initial conditions are indicated in a totally different manner than for dsolve.
Initial conditions are given as a list of lists - one set for each solution to be plotted. The stepsize parameter is optional, see Description. If you get a bad picture, as we do here with the default stepsize set a smaller stepsize.
>
with(DEtools):
eqs:=cos(x)*diff(y(x),x$3)-diff(y(x),x$2)+Pi*diff(y(x),x)=y(x)-x;
vars:={y(x)};
ivrange:=x=-2.5 .. 1.4:
dvrange:=y=-4..5:
inits:=[[y(0)=1,D(y)(0)=2,(D@@2)(y)(0)=1]];
DEplot(eqs,vars,ivrange,inits,dvrange,title=`Default Stepsize`,linecolor=red);
DEplot(eqs,vars,ivrange,inits,dvrange,stepsize=.05,title=`Stepsize =.05`,linecolor=red);
A system of three equations: plots two of the components [z(t),x(t)] as t runs - giving a parameterized curve - via the "scene" specification. The method specification is one of the things that one can set, but we don't and won't learn enough to understand this here. The linecolour specification changes the colour as a function of the independent variable and could do other things.
>
eqs:={D(x)(t)=y(t)-z(t),D(y)(t)=z(t)-x(t),D(z)(t)=x(t)-y(t)*2};
vars:=[x(t),y(t),z(t)];
ivrange:=t=-2..2;
inits:=[[x(0)=1,y(0)=0,z(0)=2]];
Scene:=scene=[z(t),x(t)];
DEplot(eqs,vars,ivrange,inits,stepsize=.05,Scene,\
linecolour=sin(t*Pi/2),method=classical[foreuler]);
Same game as above, but now we use DEplot3d in order to get three d info: We leave the equations, etc., alone, up to the scene (this won't work as intended unless eqs, etc., are from above):
>
Scene:=scene=[x(t),y(t),z(t)];
DEplot3d(eqs,vars,ivrange,inits,stepsize=.05,Scene,\
linecolour=sin(t*Pi/2),method=classical[foreuler]);
Scene:=scene=[x(t),y(t),t];
DEplot3d(eqs,vars,ivrange,inits,stepsize=.05,Scene,\
linecolour=sin(t*Pi/2),method=classical[foreuler]);
A Lotka-Volterra system: if no inits given, DEplot just plots the direction field via arrows.
>
eqs:={diff(x(t),t)=x(t)*(1-y(t)),diff(y(t),t)=.3*y(t)*(x(t)-1)};
vars:=[x(t),y(t)];
ivrange:=t=-2..2:
dvrange:=x=-1..2,y=-1..2;
DEplot(eqs,vars,ivrange,dvrange,arrows=thin,title=`Lotka-Volterra model`);
Same thing with inits:- colour affects the arrows here, while linecolor affects the plotted curves.
>
eqs:={diff(x(t),t)=x(t)*(1-y(t)),diff(y(t),t)=.3*y(t)*(x(t)-1)};
vars:=[x(t),y(t)];
ivrange:=t=-7..7;\ # default range other vars is -10 to 10
inits:=[[x(0)=1.2,y(0)=1.2],[x(0)=1,y(0)=.7]];
# default for scene is [x(t),y(t)] - the dependent vars - this is only for 2x2's.
DEplot(eqs,vars,ivrange,inits,stepsize=.2,title=`Lotka-Volterra model`,color=[.3*y(t)*(x(t)-1),x(t)*(1-y(t)),.1],linecolor=t/2,arrows= MEDIUM,method=rkf45);
Same thing, but plotting x(t) against t - there is then no direction field to plot.
>
eqs:={diff(x(t),t)=x(t)*(1-y(t)),diff(y(t),t)=.3*y(t)*(x(t)-1)};
vars:=[x(t),y(t)];
ivrange:=t=-2..2:
inits:=[[x(0)=1.2,y(0)=1.2]];
dvrange:=x=-1..2,y=-1..2;
Scene:=scene=[t,x(t)]:
DEplot(eqs,vars,ivrange,inits,dvrange,title=`Lotka-Volterra model`,Scene,linecolor=t);
What is this about?
>
DEplot(diff(y(x),x)=1/2*(-x-(x^2+4*y(x))^(1/2)),y(x),x=-3..3,y=-3..2,\
title=`Restricted domain`,color=1/2*(-x-(x^2+4*y)));