Direction Fields and Systems

file: fields.mws

>    restart;

Load differential equations tools

>    with(DEtools):

Define the system of ODEs

>    odes := diff(x(t),t)=3*x(t)-2*y(t), diff(y(t),t)=2*x(t)-2*y(t);

odes := diff(x(t),t) = 3*x(t)-2*y(t), diff(y(t),t) = 2*x(t)-2*y(t)

Plot the directions field and the solution with 3 different initial conditions

>    DEplot([odes],[x(t),y(t)],t=0..2,[[x(0)=1,y(0)=2],[x(0)=1,y(0)=1.75],[x(0)=1,y(0)=.5]],x=-3..3,y=-3..3,arrows=SLIM,title="Boyce-DiPrima HW", linecolor=blue);

[Maple Plot]

Try a full 3dim plot

>    DEplot3d([odes],[x(t),y(t)],t=0..4,[[x(0)=1,y(0)=1.75]],x=-3..3,y=-3..3,arrows=SLIM,title="Boyce-DiPrima HW", linecolor=black,scene=[t,x(t),y(t)]);

[Maple Plot]

Plot x(t) vs. t for three different ics

>    DEplot([odes],[x(t),y(t)],t=0..2,[[x(0)=1,y(0)=2],[x(0)=1,y(0)=1.75],[x(0)=1,y(0)=.5]],x=-3..3,y=-3..3,arrows=SLIM,title="Boyce-DiPrima HW", linecolor=blue,scene=[t,x(t)]);

[Maple Plot]

Construct the exact solution - does this agree with your exact solution.

>    soln0 := dsolve({odes},[x(t),y(t)]);

soln0 := {x(t) = 2*_C1*exp(2*t)+1/2*_C2*exp(-t), y(t) = _C1*exp(2*t)+_C2*exp(-t)}

Solve IVP - see class example

>    ics := x(0)=1,y(0)=1.75;

ics := x(0) = 1, y(0) = 1.75

>    soln := dsolve({odes,ics},[x(t),y(t)]);

soln := {y(t) = 1/12*exp(2*t)+5/3*exp(-t), x(t) = 1/6*exp(2*t)+5/6*exp(-t)}

Define a parametric solution [x(t),y(t),t=a..b] then plot it

>    soln3 := subs(soln,[x(t),y(t),t=0..2]);

soln3 := [1/6*exp(2*t)+5/6*exp(-t), 1/12*exp(2*t)+5/3*exp(-t), t = 0 .. 2]

>    plot(soln3);

[Maple Plot]

>