Getting Maple to plot direction fields for a system of two differential equations
This is exacly what you do in order to (1) obtain direction fields and numerical solutions for the system:

       x' =  x (1-y)
       y' =  .3 y (x-1)

displaying x and y in a window between -1 and 2, and (2) plotting x(t) and y(t) against t, on the time interval t from 0 to 50.  (I am assuming that you are logged into eden or another unix system; but similar command work on pc's and macs).

First type:   xmaple &

(yeah, hit return or enter afterwards) -- a window will open with the maple program; put the cursor after the prompt ">".

Next, type:  with(DEtools):with(plots):

(note the colons, and also the fact that "DE" is capitalized).  (Yes, hit return!)

Next, type:  eqn:= [diff(x(t),t)=x(t)*(1-y(t)),diff(y(t),t)=.3*y(t)*(x(t)-1)];

(what we did here is define the equation, so we don't need to retype it later)

Next, type:  dfieldplot(eqn,[x(t),y(t)],t=0..50,x=-1..2,y=-1..2);

if all that you want is the direction field  (bonus points if you can answer: why is the command called dfieldplot?).
On the other hand, if you want to plot not just the dircetion field but also the solution curve with initial conditions x(0)=1,y(0)=1.5, then write this first:

     init:=[[x(0)=1,y(0)=1.5]];

(YES, with two brackets - hey, I didn't make the rules), and afterwards:

    DEplot(eqn,[x(t),y(t)],t=0..50,init,x=-1..2,y=-1..2,stepsize=0.01);

a variation is if you want to see in the same graph also the solution with initial condition x(0)=0.5,y(0)=1;  in that case, you write instead:

     init:=[[x(0)=1,y(0)=1.5],[x(0)=0.5,y(0)=1]];

and then repeat the same DEplot command.

What about plotting x(t) and y(t) as functions of t?  (I knew you were about to ask...)
OK, seems like the best thing to do is this: first you define the equation as:

    eqn:=diff(x(t),t)=x(t)*(1-y(t)),diff(y(t),t)=.3*y(t)*(x(t)-1);

Observe that this time we did not put brackets!  (Do you know why? yes?  Then please send email to the instructor explaining why!)
Next, we solve, or rather pretend that we solve, the equation, and put the solution in "sol":

    sol:=dsolve({eqn,x(0)=1,y(0)=1.5},{x(t),y(t)},type=numeric):

notice the : at the end, instead of - this is so that maple defines the solution internally, but does not display it.
OK, now we can finally plot like this:

    odeplot(sol,[[t,x(t)],[t,y(t)]],0..50,numpoints=500); 
 
(the dots are for saying from time 0 to 50 and the numpoints says how many intermediate points to plot; I find in my computer that using about 10 times as many as the size of the interval tends to give a good resolution, but you may need to play wit this a bit).

voila!  wasn't that a nice plot?  (you did see it, right?)
... oh yes,: go to File and click exit when you are done.

Note: to get darker lines, insert:  ,color=black,thickness=2  before the last parenthesis.
Another comment: I like to do Options -> Display -> Window  so that the plots appear in a separate window.
 

go to the one-dimensional direction fields help page


For comments regarding this page, please send email to sontag@math.
This page was last updated on August 01, 2017 at 11:08 am and is maintained by webmaster@math.rutgers.edu.
For questions regarding courses and/or special permission, please contact ugoffice@math.rutgers.edu.
For questions or comments about this site, please contact help@math.rutgers.edu.
© 2018 Rutgers, The State University of New Jersey. All rights reserved.