Phase Portrait for the nonlinear equationrestart:
with(plots):with(DEtools):What you will want to change for a different problem, is (i) the definition of the differential equation, given in the line defining NonLinDE, (ii) the initial conditions, given in the linedefining IC, and (iii) the range of the varariables x and y, and the range of time t in the line for the plot of the phase portrait (x=-2..2, y=-2..2, t=-7..6). Sometimes you may want to adjust the step size in the plot of the phase protrait to a number between 0.1 and 0.01.The following line defines the differential equation. NonLinDE := [diff(x(t),t) = -x(t)+y(t),
diff(y(t),t) = x(t)*y(t)-1];Plot the phaseportrait using Runge-Kutta method; the initial conditions are given in the first line and can be changed.IC:=[[x(0)=1.01,y(0)=1.022],[x(0)=1.1,y(0)=2],[x(0)=1.6,y(0)=2],
[x(0)=-2,y(0)=1],[x(0)=0.99,y(0)=1-0.022],[x(0)=2,y(0)=0.61], [x(0)=1,y(0)=-1],[x(0)=0,y(0)=0],[x(0)=-2,y(0)=-1]];DEplot(NonLinDE, [x(t),y(t)], t=-7..6,
IC,linecolour=BLUE, x=-2..2, y=-2..2, stepsize=0.1,
arrows=NONE, method=classical[rk4]);Plot one coordinate versus time. IC2:=[[x(0)=0.99,y(0)=1-0.022]];DEplot(NonLinDE, [x(t),y(t)], t=0..5,
IC2,linecolour=BLUE, x=0.25..2, y=0..2, stepsize=0.02,
arrows=NONE, method=classical[rk4],scene=[t,x]);