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); |
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); |
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)]); |
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)]); |
Construct the exact solution - does this agree with your exact solution.
| > | soln0 := dsolve({odes},[x(t),y(t)]); |
Solve IVP - see class example
| > | ics := x(0)=1,y(0)=1.75; |
| > | soln := dsolve({odes,ics},[x(t),y(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]); |
| > | plot(soln3); |
| > |