- Getting Maple to plot direction fields for
a system of two differential equations
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:
(YES, with two brackets - hey, I didn't make the rules), and afterwards:
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:
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:
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":
notice the :
at the end, instead of ;
- this is so that maple defines the solution internally, but does not display
OK, now we can finally plot like this:
(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