Plotting the phase portrait to a solution of a differential equation

sm311o_2.mws,wdj,1-20-98

> with(plots):
with(DEtools):

The first method is to explicitly solve the DE and then plot the function. Obviously, this will not work if MAPLE cannot solve the DE explicitly.

> de:=diff(y(t),t$2)+2*diff(y(t),t)+2*y(t)=0;
The differential equation

[Maple Math]

> ic:=D(y)(0)=0,y(0)=1;
The initial conditions

[Maple Math]

> soln:=dsolve({de,ic},y(t),method=laplace);
The DE and IC need to be surrounded by curly brackets. The option method=laplace insures that the solution function will probably be expressed in the same form as if you solved it yourself by hand.

[Maple Math]

> y0:=a->subs(t=a,rhs(soln)):
y0(t);
You have to (unfortunately) create a function - called y0 to distinguish it from the dependent variable y - in MAPLE from the solution soln using the arrow notation -> and the substitution command subs . This is because MAPLE does not recognize the right hand side of the solution rhs(soln) as a function but sees it as a sequence of symbols.

[Maple Math]

> v0:=t->diff(y0(t),t);

[Maple Math]

> plot([y0(t),v0(t)],t=0..1);
Plotting the solution and its derivative separately gives:

[Maple Plot]

> plot([y0(t),v0(t),t=0..10],labels=[y0,v0]);
Plotting the solution vs its derivative to give the phase portrait .

[Maple Plot]

Another, easier method, is to use MAPLE's phaseportrait command in the DEtools package. However, to do this it must entered as a system. We can convert the second order ODE above into a system of 2 first order ODEs by creating 2 new variables y1 and y2, where y1=y and y2=y'. The resulting system is:

y1' = y2, y2' = -2*y1-2*y2

> sys:=diff(y1(t),t)=y2(t),diff(y2(t),t)=-2*y1(t)-2*y2(t);
ic:=y1(0)=1,y2(0)=0;

[Maple Math]

[Maple Math]

> phaseportrait([sys],[y1(t),y2(t)],t=0..10,[[ic]],scene=[y1(t),y2(t)],stepsize=.05);

[Maple Plot]

>

Another example, this time of y''+y=0:

> sys:=diff(y1(t),t)=y2(t),diff(y2(t),t)=-y1(t);
ic:=y1(0)=1,y2(0)=0;

[Maple Math]

[Maple Math]

> phaseportrait([sys],[y1(t),y2(t)],t=0..(.5),[[ic]],scene=[y1(t),y2(t)],stepsize=.05,y1=-1..1,y2=-1..1);

[Maple Plot]

>