Example of plotting the solutions to a linear system of differential equations.In this case, we will use a couple of different initial conditions and plot them all.Here is the system (See Exercise 2, p. 409)x'= - x - 4 yy'= x - y We'll also compute the eigenvalues and eigenvectors.restart;
with(LinearAlgebra):
with(DEtools):Enter the constants by column:A:=<<-1, 1>|<-4,-1>>;Eigenvectors(A,output=list); Since the real part of the eigenvalues is negative, the origin will be a spiral sink (solutions will spiral towards the origin)Now define the system of equations and draw a direction field, then solve and plot the particular solution:Sys:=diff(x(t),t)=A[1,1]*x(t)+A[1,2]*y(t),
diff(y(t),t)=A[2,1]*x(t)+A[2,2]*y(t);Some random initial conditions as [t,x,y]ICs:=[[x(0)=1,y(0)=1],[x(0)=1,y(0)=-1],[x(0)=-1,y(0)=-1.5]];DEplot({Sys},[x(t),y(t)],t=0..5,x=-2..2,y=-2..2,ICs,linecolor=black);DEplot({Sys},[x(t),y(t)],t=0..5,x=-2..2,y=-2..2,ICs,linecolor=black,scene=[t,x(t)]);DEplot({Sys},[x(t),y(t)],t=0..5,x=-2..2,y=-2..2,ICs,linecolor=black,scene=[t,y(t)]);