DE.07 Eigenvectors and Eigenvalues for Linear Systems
 LITERACY

Needs["Graphics`Colors`"];
Needs["Graphics`FilledPlot`"];

If[MemberQ[{"Global`","Graphics`Common`GraphicsCommon`","Vector3D`"}, 
    Context[ScaleFactor]],Remove["*`ScaleFactor"]];
<<"Graphics`Legend`";
<<"Graphics`Common`GraphicsCommon`";
Remove["*`ScaleFactor"];
Graphics`Colors`GosiaGreen=RGBColor[0, 0.392187, 0];
Off[General::spell];
Off[General::spell1];
Off[ParametricPlot3D::ppcom];
Off[ParametricPlot::ppcom];
Off[Plot::plnr];
Needs["Calculus`Master`"];
Off[Unique::"usym"];
SetOptions[Limit,Analytic->True];

CMView = {2.7, 1.6, 1.2};

Off[Graphics::gpt]

New Vector Drawers

(* :Title:  NewVectorDraw  *)
(* :Author: Bruce Carpenter *)
(* :Summary:  Construct 2 and 3 dimensional vectors,
     arrows, and arrowheads as graphics 
     objects.
*)
(* :Date:  Copyright 1997, Math Everywhere, Inc. 
*)
(*  :Drawbacks:  Since the vectors are drawn out of 
     context, the shapes of the arrowheads are only 
     correct with AspectRatio set to Automatic.
*)
BeginPackage["Vector3D`","Graphics`Colors`"];

Axes3D::usage = "Axes3D[a, b] creates a Graphics3D object of cartesian axes with x, y, and z running from -a/3 to a, and with axes labels b units beyond the tips of the axes.  Axes3D[a] is Axes3D[a, a/8].";

Perpend::usage = "Perpend[a] returns a unit vector which is perpendicular to the vector a.";

Arrow::usage = "Arrow[a] produces a 2 or 3 dimensional vector from the origin to a. Arrow[a, Tail -> tail] gives a vector from tail to a.";
	
Vector::usage = "Vector[a, b] gives a 2D or 3D vector from a to b.";

ArrowHead::usage = "ArrowHead[a, vec] produces an arrowhead with its tip placed at the point a, pointing in the direction of the vector vec.";

Tail::usage = "Tail -> point puts the tail of the vector at point.";

Norm::usage = "Norm[vec] returns the Euclidean length of vec.";

Normalize::usage = "Normalize[vec] returns a unit vector in the direction of vec, provided vec is nonzero.";

Aperture::usage = "Aperture is the ratio of the radius of the base to the length of the head of a vector.";

TipSize::usage = "TipSize specifies an absolute size for the inner tip length of the head of a vector.";

TipRatio::usage = "TipRatio is the ratio of the inner length of the arrowhead to the length of the shaft of a vector.";

HeadRatio::usage = "HeadRatio is the ratio of the outer length of the arrowhead to the length of the shaft of a vector.";

HeadSize::usage = "HeadSize specifies an absolute size for the head of a vector.";

ScaleFactor::usage = "ScaleFactor specifies the amount to scale a vector in length and may be either a number or a pure function.";

ZeroVectorPointSize::usage = "ZeroVectorPointSize is the size of the point used to represent a zero vector.";

Options[Vector] = Options[Arrow] = Options[ArrowHead] =
{HeadRatio -> 0.18, TipRatio -> 0.14, Aperture -> 0.3, ScaleFactor -> 1, HeadType -> Polygon, ShaftQ -> True, EdgesQ -> True, VectorColor -> RGBColor[0,0,1], ShaftWidth -> 0.005, ZeroVectorPointSize -> 0.01};
		
Begin["`Private`"];

SetOptions[ParametricPlot,AspectRatio -> Automatic];
SetOptions[Plot,AspectRatio -> Automatic];
SetOptions[Graphics,AspectRatio -> Automatic];

Axes3D[u_,v_] := 
      Graphics3D[{
            {Blue,Line[{{-u/3,0,0},{u,0,0}}]},
                    Text["x",{u + v,0,0}],
            {Blue,Line[{{0,-u/3,0},{0,u,0}}]},
                    Text["y",{0, u + v,0}],
            {Blue,Line[{{0,0,-u/3},{0,0,u}}]},
                    Text["z",{0,0,u + v}]}]; 
Axes3D[u_] := Axes3D[u,u/8];
				
Norm[a_?VectorQ] := N[Sqrt[a.a]];

Normalize[a_?VectorQ] := If[a.a == 0, a, a/Norm[a]];

Perpend[a_?VectorQ] := Normalize[{a[[2]],-a[[1]]}]/;Length[a]==2
Perpend[a_?VectorQ] := Normalize[If[a[[1]]==0,{1,0,0},{0,a[[3]],-a[[2]]}]]/;Length[a]==3

Base3D = Table[{Cos[2 k Pi/8.], Sin[2 k Pi/8.]},{k,0,8}]; 

Vector[from_?VectorQ, to_?VectorQ, opts___] := Module[
   {sq, sw, ht, hs, hr, tr, ap, sf, vc, zvps, diff = to - from, tip},
   {sq, sw, ht, hs, hr, ts, tr, ap, sf, vc, zvps} = {ShaftQ, ShaftWidth, HeadType, HeadSize, HeadRatio, TipSize, TipRatio, Aperture, ScaleFactor, VectorColor, ZeroVectorPointSize} /. {opts} /. Options[Vector];
   If[from==to, Return[Graphics[{PointSize[zvps],vc,Point[from]}]]];
   diff = If[NumberQ[N[sf]], sf diff, sf[diff]];
   tip = from + diff;
   If[NumberQ[hs], hr = hs/Norm[diff]; tr = 0.75 hr];
   If[NumberQ[ts], tr = ts/Norm[diff]];
   Graphics[{If[sq,{vc,Thickness[sw],Line[{from,tip - tr diff}]},{}],
      With[{trans = ap hr Norm[diff] Perpend[diff]},
      {vc, Thickness[sw], ht[{tip,
                   (tip - hr diff + trans),
                   (tip - tr diff),
                   (tip - hr diff - trans),tip}]}]}]
] /; Length[from]==Length[to]==2

Vector[from_?VectorQ, to_?VectorQ, opts___] := Module[
   {sq, eq, sw, hs, hr, tr,ap, sf, vc, zvps, diff = to - from, tip},
   {sq, eq, sw, hs, hr, ap, sf, vc, zvps} = {ShaftQ, EdgesQ, ShaftWidth, HeadSize, HeadRatio, Aperture, ScaleFactor, VectorColor, ZeroVectorPointSize} /. {opts} /. Options[Vector];
   If[from==to, Return[Graphics3D[{PointSize[zvps],vc,Point[from]}]]];
   diff = If[NumberQ[N[sf]], sf diff, sf[diff]];
   tip = from + diff;
   If[NumberQ[hs], hr = hs/Norm[diff]];
   tr = hr/2;
   Graphics3D[{If[sq,{vc,Thickness[sw],Line[{from,tip-tr diff}]},{}], If[eq, {}, EdgeForm[]], {SurfaceColor[vc],
      With[{temp = Perpend[diff]},
      Polygon[Append[#,tip]]& /@ Partition[(tip - hr diff + #)&/@((ap hr Norm[diff] Base3D) . {temp,Normalize[Cross[temp,diff]]}),2,1]]}}]
] /; Length[from]==Length[to]==3


Arrow[a_, Tail->b_, opts___] := Vector[b,a+b,opts]

Arrow[a_, opts___] := Vector[Table[0,{Length[a]}],a,opts]

ArrowHead[a_, b_, opts___] := Vector[a-b,a,ShaftQ->False,opts];

End[];

EndPackage[];
Null

VectorField and Phase Lines

(*  :Title: VectorAndPhase.m  *)

(*  :Author:  Bill Davis  *)

(*  :Dates:  about March, 1996 *)

(*  :Drawbacks:  I wish someone serious would come and turn these into
                 Really carefully done packages.  *)

BeginPackage["PhaseStuff`","Vector3D`",
		"Utilities`FilterOptions`"];

PhaseLine::usage = "PhaseLine[fcn,{var,a,b},tint,pos]
	makes a vertical phase line for the function, fcn, of the variable, var,
	for the variable going from a to b, with 
	a color given by tint,  at the x-coordinate pos.";
	
PhaseLine3D::usage = "PhaseLIne3D[fcn,{var,a,b},tint,loc]
	makes a vertical phase line for the function, fcn, of the variable, var,
	for the variable going from a to b, with 
	a color given by tint, and base point at loc = {x,y}";
	
VectorField::usage = "VectorField[{function,{var1,a,b,space1},{var2,c,d,space2}]
	will make a vector field of normalized vectors, colored by
	magnitude, for the function of the variables on the
	range {r1,r2} with spacing between points given by 
	{space1, space2}.  If a single function of a single variable is given,
	the vector field {1,f} will be plotted.";
	
StikPikXZ::usage = "StikPikXZ[picture,a:_0] takes a 2 dimensional
	Mathematica picture and embeds it on the XZ plane at y = a.  
	Some optional characteristics of the graphs are lost in the 
	process.  StikPikYZ and StikPikXZ are similar.";
	
StikPikYZ::usage = "StikPikYZ[picture,a:_0] takes a 2 dimensional
	Mathematica picture and embeds it on the XZ plane at y = a.  
	Some optional characteristics of the graphs are lost in the 
	process.  StikPikYZ and StikPikXZ are similar.";
	
StikPikXY::usage = "StikPikXY[picture,a:_0] takes a 2 dimensional
	Mathematica picture and embeds it on the XZ plane at y = a.  
	Some optional characteristics of the graphs are lost in the 
	process.  StikPikYZ and StikPikXZ are similar.";
	
Begin["`Private`"];	

PhaseLine[fcn_,{var_,a_,b_},tint_,pos_:0] := 
	Module[{len,len1,k,zset,zero,zero1,signs,stick,dots,pointers},
	zset = Solve[fcn==0,var];
	zero = If[Length[zset]==0,{},var/.zset];
	zero = Sort[zero];
	zero = Select[zero,((# >= a)&&(# <= b))&];
	zero1 = Sort[Union[zero,{a,b}]];
	len = Length[zero];
	len1 = Length[zero1];
	signs = Table[Sign[fcn/.var->((zero1[[k+1]] + zero1[[k]])/2)],
		{k,1,len1-1}];
	stick = {Thickness[0.007],Line[{{pos,a},{pos,b}}]};
	dots = Point[{pos,#}]&/@zero;
	dots = Join[{PointSize[0.05],tint},dots];
	heads = Table[MakeHead[zero1[[k]],zero1[[k+1]],pos,
		signs[[k]],b-a,tint],{k,1,len1-1}];
	Return[{Graphics[Join[{tint},stick,dots]],heads}]
		]
		
MakeHead[a_,b_,c_,s_,slen_,tint_] := Module[{u,v,w},
	u = Min[2(b-a),3/4 slen];
	Return[ArrowHead[{c,a(.5-s/5)+b(.5+s/5)},
		{0,s u},VectorColor->tint]]]
		
PhaseLine3D[fcn_,{var_,a_,b_},tint_,pos_:{0,0}] := 
	Module[{len,len1,k,zset,zero,zero1,signs,stick,dots,pointers},
	zset = Solve[fcn==0,var];
	zero = If[Length[zset]==0,{},var/.zset];
	zero = Sort[zero];
	zero = Select[zero,((# >= a)&&(# <= b))&];
	zero1 = Sort[Union[zero,{a,b}]];
	len = Length[zero];
	len1 = Length[zero1];
	signs = Table[Sign[fcn/.var->((zero1[[k+1]] + zero1[[k]])/2)],
		{k,1,len1-1}];
	stick = {Thickness[0.007],Line[{{pos[[1]],pos[[2]],a},
		{pos[[1]],pos[[2]],b}}]};
	dots = Point[{pos[[1]],pos[[2]],#}]&/@zero;
	dots = Join[{PointSize[0.03],tint},dots];
	heads = Table[MakeHead3D[zero1[[k]],zero1[[k+1]],pos,
		signs[[k]],b-a,tint],{k,1,len1-1}];
	Return[{Graphics3D[Join[{tint},stick,dots]],heads}]
		]
		
MakeHead3D[a_,b_,c_,s_,slen_,tint_] := Module[{u,v,w},
	u = Min[2(b-a),1/2 slen];
	Return[ArrowHead[{c[[1]],c[[2]],a(.5-s/5)+b(.5+s/5)},
		{0,0,s u},VectorColor->tint]]]
		
		
VectorField[function_List,{var1_,a_,b_,sp1_:1},{var2_,c_,d_,sp2_:1}] := 
	Module[{i,j,U,V,UU,VV,ulow,uhigh,vlow,vhigh,maxval,minval,
		lengths,directions,locations,mlen},
	mlen = Min[sp1,sp2];
	normf[uu_,vv_] = Sqrt[function[[1]]^2+function[[2]]^2]/.
		{var1->uu,var2->vv};
	lengths = Table[N[normf[U,V]],{U,a,b,sp1},{V,c,d,sp2}];
	maxval = Max[lengths]; minval = Min[lengths];
	If[minval == maxval,maxval += 1];
	locations = Table[{uu,vv},{uu,a,b,sp1},
		{vv,c,d,sp2}];
	directions = Table[If[N[normf[U,V]]==0,{0,0},
		mlen (function/.{var1->U,var2->V})/(1.3 N[normf[U,V]])],
			{U,a,b,sp1},{V,c,d,sp2}];
	{UU,VV} = Dimensions[directions][[{1,2}]];
	Return[Table[Arrow[directions[[i,j]],
			Tail->locations[[i,j]],Aperture->1,
			HeadRatio->.4,ShaftWidth->0.008, VectorColor->
			RGBColor[(lengths[[i,j]] - minval)/(maxval-minval),0,
				(maxval -lengths[[i,j]])/(maxval-minval)]],{i,UU},{j,VV}]]
		]
		
VectorField[function_,{var1_,a_,b_,sp1_:1},{var2_,c_,d_,sp2_:1}] :=
	VectorField[{1,function},{var1,a,b,sp1},{var2,c,d,sp2}]
	
	
Needs["Utilities`FilterOptions`"]

FixOptions[a_] := Module[{picture = a, opt3},
If[Options[picture] != {}, 
	opt3 = FilterOptions[Graphics3D,#]&/@Options[picture];
	(* Fix things that might carry 2D characteristics. *)
	opt3 = opt3//. {(AxesLabel -> _) ->(AxesLabel -> None),
			(PlotRange->_) -> (PlotRange->Automatic),
			(PlotRegion -> _) -> (PlotRegion -> Automatic),
			(Ticks -> _) -> (Ticks -> Automatic)};
	picture = Apply[List,picture];
	picture[[-1]] = opt3;
	picture = Apply[Graphics3D,picture]];
	Return[picture]
	]

StikPikXZ[picture_,a_:0] := Module[{PIK3 = picture},
	PIK3 = PIK3//.{Graphics->Graphics3D,
		{u_?NumberQ,v_?NumberQ}:>{u,a,v}};
	PIK3 = FixOptions[PIK3];
	Return[PIK3]
		]


StikPikYZ[picture_,a_:0] := Module[{PIK3 = picture},
	PIK3 = PIK3//.{Graphics->Graphics3D,
		{u_?NumberQ,v_?NumberQ}:>{a,u,v}};
	PIK3 = FixOptions[PIK3];
	Return[PIK3]
		]


StikPikXY[picture_,a_:0] := Module[{PIK3 = picture},
	PIK3 = PIK3//.{Graphics->Graphics3D,
		{u_?NumberQ,v_?NumberQ}:>{u,v,a}};
	PIK3 = FixOptions[PIK3];
	Return[PIK3]
		]
		
End[];

EndPackage[];
Null

ThreeAxes[u,v]

ThreeAxes[u_,v_] := 
      Graphics3D[{
            {Blue,Line[{{-u,0,0},{u,0,0}}]},
                    Text["x",{u + v,0,0}],
            {Blue,Line[{{0,-u,0},{0,u,0}}]},
                    Text["y",{0, u + v,0}],
            {Blue,Line[{{0,0,0},{0,0,u}}]},
                    Text["z",{0,0,u + v}]}]; 
ThreeAxes[u_] := ThreeAxes[u,u/8];
ThreeAxes::usage = "ThreeAxes[a,b] makes a standard cartesian axis graphics object
	with x, y, and z running from -a to a, and with axis
	labels b units beyond the tips of the axes.  ThreeAxes[a]
	is ThreeAxes[a,a/8].";

Crisscross

Clear[x];
crisscross = Plot[{Cos[x],Sin[x]},{x,Pi/8,3 Pi/8},
    PlotStyle->{{RGBColor[1,0,0],Thickness[0.02]}},
    Axes->None,AspectRatio->1/3,
    DisplayFunction->Identity];

L.1)

a) Write down the matrix A that allows you to express the linear system
        x'[t]=  3.1 x[t] - 6.0 y[t]
        y'[t]=-2.2 x[t] + 1.7 y[t]
in the form
       {x'[t],y'[t]}=A . {x[t], y[t]}.
       
b) Write down the matrix A that allows you to express the linear system
        x'[t]=-2.9 y[t]
        y'[t]=  1.6 x[t] + 4.5 y[t]
in the form
       {x'[t],y'[t]}=A . {x[t], y[t]}.
       
c) Given 
        A=(({{1.4, -2.5}, {4.1, 0}})), 
what do you get when you multiply out A . {x[t], y[t]}?

L.2)

Here are six plots of trajectories for six different linear systems 
        x'[t]=a x[t] + b y[t]
        y'[t]=c x[t] + d y[t]
all with {x[0], y[0]} = {5, 1}:

\(Clear[m, n, x, y, t]; 
m[x_, y_] = \(-2\)\ y + 0.2\ x; 

    \(n[x_, y_] = x - 0.2\ y; \)\)starterpoint = {5, 1}; {a, b} = starterpoint; equationx=x'[t]==m[x[t], y[t]];equationy=y'[t]==n[x[t], y[t]];starterx = x[0] == a; startery = y[0] == b; endtime = 24.0; approxsolutions1 = 
      NDSolve[{equationx, equationy, starterx, startery}, {x[t], y[t]}, {t, 
          0, endtime}]; \(Clear[trajectory]; 

    trajectory[t_] = {
        x[t] /. approxsolutions1[[1]], 
        y[t] /. approxsolutions1[[1]]}; 
    
\(trajectoryplot1 = 
      ParametricPlot[trajectory[t], {t, 0, endtime}, 
        PlotStyle -> {{Red, Thickness[0.015]}}, 
        PlotLabel -> "Plot 1", DisplayFunction -> Identity]; 
    \)\)starterplot = 
      Graphics[{Red, PointSize[0.08], Point[starterpoint]}]; firstyplot = 
      Plot[y[t] /. 
          approxsolutions1[[1]], {t, 0, 
          endtime}, PlotStyle -> {{Red, Thickness[0.01]}}, 
        AxesLabel -> {"t", "y[t]"}, AspectRatio -> (1/5), 
        DisplayFunction -> Identity]; firstphaseportrait = 
      Show[starterplot, trajectoryplot1, PlotRange -> All, 
        Axes -> True, AxesLabel -> {"x", "y"}, 
        PlotLabel -> "Plot 1", DisplayFunction -> Identity]; 
    c = 0.3; \(Clear[m, n, x, y, t]; 
m[x_, y_] = \(-y\) - c\ x; 
\(n[x_, y_] = x; 
    \)\)Clear[x, y, t];
equationx=x'[t]==m[x[t], y[t]];
equationy=y'[t]==n[x[t], y[t]];starterx = x[0] == a; startery = y[0] == b; endtime = 24.0; approxsolutions2 = 
      NDSolve[{equationx, equationy, starterx, startery}, {x[t], y[t]}, {t, 
          0, endtime}]; \(Clear[trajectory]; 

    trajectory[t_] = {
        x[t] /. approxsolutions2[[1]], 
        y[t] /. approxsolutions2[[1]]}; 
    
\(trajectoryplot2 = 
      ParametricPlot[trajectory[t], {t, 0, endtime}, 
        PlotStyle -> {{Red, Thickness[0.015]}}, 
        PlotLabel -> "Plot 2", DisplayFunction -> Identity]; 
    \)\)secondyplot = 
      Plot[y[t] /. 
          approxsolutions2[[1]], {t, 0, 
          endtime}, PlotStyle -> {{Red, Thickness[0.01]}}, 
        AxesLabel -> {"t", "y[t]"}, PlotRange -> All, 
        AspectRatio -> (1/2), DisplayFunction -> Identity]; secondphaseportrait = 
      Show[starterplot, trajectoryplot2, PlotRange -> All, 
        Axes -> True, AxesLabel -> {"x", "y"}, 
        PlotLabel -> "Plot 2", DisplayFunction -> Identity]; 
    c = -0.1; \(Clear[m, n, x, y, t]; 
m[x_, y_] = \(-y\) - c\ x; 
\(n[x_, y_] = x; 
    \)\)equationx=x'[t]==m[x[t], y[t]];equationy=y'[t]==n[x[t], y[t]];starterx = x[0] == a; startery = y[0] == b; endtime = 24.0; approxsolutions3 = 
      NDSolve[{equationx, equationy, starterx, startery}, {x[t], y[t]}, {t, 
          0, endtime}]; \(Clear[trajectory]; 

    trajectory[t_] = {
        x[t] /. approxsolutions3[[1]], 
        y[t] /. approxsolutions3[[1]]}; 
    
\(trajectoryplot3 = 
      ParametricPlot[trajectory[t], {t, 0, endtime}, 
        PlotStyle -> {{Red, Thickness[0.015]}}, 
        PlotLabel -> "Plot 3", DisplayFunction -> Identity]; 
    \)\)thirdyplot = 
      Plot[y[t] /. 
          approxsolutions3[[1]], {t, 0, 
          endtime}, PlotStyle -> {{Red, Thickness[0.01]}}, 
        AxesLabel -> {"t", "y[t]"}, PlotRange -> All, 
        AspectRatio -> (1/2), DisplayFunction -> Identity]; thirdphaseportrait = 
      Show[starterplot, trajectoryplot3, PlotRange -> All, 
        Axes -> True, AxesLabel -> {"x", "y"}, 
        PlotLabel -> "Plot 3", DisplayFunction -> Identity]; 
    \(Clear[m, n, x, y, t]; 
m[x_, y_] = 0.2\ x; 
\(n[x_, y_] = 0.5\ y; 
    \)\)equationx=x'[t]==m[x[t], y[t]];equationy=y'[t]==n[x[t], y[t]];starterx = x[0] == a; startery = y[0] == b; endtime = 3.0; approxsolutions4 = 
      NDSolve[{equationx, equationy, starterx, startery}, {x[t], y[t]}, {t, 
          0, endtime}]; \(Clear[trajectory]; 

    trajectory[t_] = {
        x[t] /. approxsolutions4[[1]], 
        y[t] /. approxsolutions4[[1]]}; 
    
\(trajectoryplot4 = 
      ParametricPlot[trajectory[t], {t, 0, endtime}, 
        PlotStyle -> {{Red, Thickness[0.015]}}, 
        PlotLabel -> "Plot 4", DisplayFunction -> Identity]; 
    \)\)fourthyplot = 
      Plot[y[t] /. 
          approxsolutions4[[1]], {t, 0, 
          endtime}, PlotStyle -> {{Red, Thickness[0.01]}}, 
        AxesLabel -> {"t", "y[t]"}, PlotRange -> All, 
        AspectRatio -> (1/2), DisplayFunction -> Identity]; fourthphaseportrait = 
      Show[starterplot, trajectoryplot4, PlotRange -> All, 
        Axes -> True, AxesLabel -> {"x", "y"}, 
        PlotLabel -> "Plot 4", DisplayFunction -> Identity]; 
    \(Clear[m, n, x, y, t]; 
m[x_, y_] = \(-2\)\ y + 0.3\ x; 

    \(n[x_, y_] = x - 0.2\ y; \)\)endtime = 30; equationx=x'[t]==m[x[t], y[t]];equationy=y'[t]==n[x[t], y[t]];starterx = x[0] == a; startery = y[0] == b; approxsolutions5 = 
      NDSolve[{equationx, equationy, starterx, startery}, {x[t], y[t]}, {t, 
          0, endtime}]; \(Clear[trajectory]; 

    trajectory[t_] = {
        x[t] /. approxsolutions5[[1]], 
        y[t] /. approxsolutions5[[1]]}; 
    
\(trajectoryplot5 = 
      ParametricPlot[trajectory[t], {t, 0, endtime}, 
        PlotStyle -> {{Red, Thickness[0.015]}}, 
        PlotLabel -> "Plot 5", DisplayFunction -> Identity]; 
    \)\)fifthyplot = 
      Plot[y[t] /. 
          approxsolutions5[[1]], {t, 0, 
          endtime}, PlotStyle -> {{Red, Thickness[0.01]}}, 
        AxesLabel -> {"t", "y[t]"}, PlotRange -> All, 
        AspectRatio -> (1/2), DisplayFunction -> Identity]; fifthphaseportrait = 
      Show[starterplot, trajectoryplot5, PlotRange -> All, 
        Axes -> True, AxesLabel -> {"x", "y"}, 
        PlotLabel -> "Plot 5", DisplayFunction -> Identity]; 
    \(Clear[m, n, x, y, t]; 
m[x_, y_] = \(-0.3\)\ x; 

    \(n[x_, y_] = 0.2\ x - 0.8\ y; \)\)endtime = 20; equationx=x'[t]==m[x[t], y[t]];equationy=y'[t]==n[x[t], y[t]];starterx = x[0] == a; startery = y[0] == b; approxsolutions6 = 
      NDSolve[{equationx, equationy, starterx, startery}, {x[t], y[t]}, {t, 
          0, endtime}]; \(Clear[trajectory]; 

    trajectory[t_] = {
        x[t] /. approxsolutions6[[1]], 
        y[t] /. approxsolutions6[[1]]}; 
    
\(trajectoryplot6 = 
      ParametricPlot[trajectory[t], {t, 0, endtime}, 
        PlotStyle -> {{Red, Thickness[0.015]}}, 
        DisplayFunction -> Identity]; \)\)sixthyplot = 
      Plot[y[t] /. 
          approxsolutions6[[1]], {t, 0, 
          endtime}, PlotStyle -> {{Red, Thickness[0.01]}}, 
        AxesLabel -> {"t", "y[t]"}, PlotRange -> All, 
        AspectRatio -> (1/2), DisplayFunction -> Identity]; starterplot = Graphics[{Red, PointSize[0.1], Point[starterpoint]}]; sixthphaseportrait = 
      Show[starterplot, trajectoryplot6, PlotRange -> All, 
        Axes -> True, AxesLabel -> {"x", "y"}, 
        PlotLabel -> "Plot 6", DisplayFunction -> Identity]; 
    Show[
      GraphicsArray[{{firstphaseportrait, secondphaseportrait, 
            thirdphaseportrait}, {fourthphaseportrait, fifthphaseportrait, 
            sixthphaseportrait}}]];

a)  Use the visual evidence presented and make the calls:
     Which plot depicts a trajectory of a linear system whose coefficient matrix has eigenvalues:
i)      p + i q and p - i q with p > 0 and q = 0 ?
ii)     p + i q and p - i q with p < 0 and q ≠ 0 ?
iii)    p + i q and p - i q with p = 0 and q ≠ 0 ?  
iv)    p and q with both p and q real and both p and q < 0? 
v)     p and q with both p and q real at least one of p or q is positive?

b) Here are the plots of solutions, y[t], of the same six systems
    all with the same starter data {x[0], y[0]} = {5, 1}:

Show[
      GraphicsArray[{{fourthyplot, secondyplot, sixthyplot}, {firstyplot, 
            thirdyplot, fifthyplot}}]];

Your job is to pair the solution plots with the corresponding trajectory plots.

L.2)

How do you tell that none of the following systems is a linear system?
a)  {x'[t],y'[t]}={Sin[x[t]] + 4.9 y[t], -2.3 x[t] + 0.4 y[t]},
b)  {x'[t],y'[t]}={-(y[t]^2 - 1) x[t] - y[t], x[t]},
c)  {x'[t],y'[t]}={x[t] y[t], -x[t]}.

L.3)

Here is the flow of solutions of a certain linear system
       x'[t]=-1.75 x[t] - 2.17 y[t]
       y'[t]=-1.8 x[t] + 0.75 y[t]:

A = {{-1.75, -2.17}, {-1.8, 0.75}}; \(Clear[Field]; 
Field[x_, y_] = A . {x, y}; 
\(scalefactor = 0.15; 
    \)\)\(flowplot = 
      Table[Arrow[scalefactor\ Field[x, y], Tail -> {x, y}, 
          VectorColor -> Blue], {x, \(-3\), 3, 6\/12}, {y, \(-3\), 3, 
          6\/12}]; 

    \(Show[flowplot, Axes -> True, 
      AxesLabel -> {"x", "y"}]; \)\)

Pencil in the eigenvectors of the coefficient matrix 
          A=(({{-1.75, -2.17}, {-1.8, 0.75}})).
Explain how you see at a glance that one eigenvalue of the matrix 
          A=(({{-1.75, -2.17}, {-1.8, 0.75}}))
is positive and the other is negative.
Where are the straight line trajectories?
How are all other trajectories related to the straight line trajectories?

L.4)

Here's the flow of solutions of the linear system
       x'[t]=  1.75 x[t] + 2.17 y[t]
       y'[t]=  -1.7 x[t] - 0.75 y[t]:

A = {{1.75, 2.17}, {-1.7, -0.75}}; \(Clear[Field]; 
Field[x_, y_] = A . {x, y}; 
\(scalefactor = 0.15; 
    \)\)\(flowplot = 
      Table[Arrow[scalefactor\ Field[x, y], Tail -> {x, y}, 
          VectorColor -> Blue], {x, \(-3\), 3, 6\/12}, {y, \(-3\), 3, 
          6\/12}]; 

    \(Show[flowplot, Axes -> True, 
      AxesLabel -> {"x", "y"}]; \)\)

Explain how you see at a glance that if p + i q  (with p and q both real) is an eigenvalue of the coefficient matrix 
         A=(({{1.75, 2.17}, {-1.7, -0.75}})), 
then q ≠ 0. 
If you look a bit harder, you can determine the sign of p. Do it.

L.5)

a) Here are the eigenvalues and eigenvectors of matrix A=(({{0, 1}, {1, 0}}))

A = {{0, 1.0}, {1.0, 0}};

Eigenvalues[A]

Eigenvectors[A]

Use this information to help pencil in on the axes below what you expect to be some sample trajectories of the system
          {x'[t],y'[t]}=A . {x[t], y[t]}.

a = 2; Show[Graphics[Line[{{-a, 0}, {a, 0}}]], 
      Graphics[Line[{{0, -a}, {0, a}}]], Axes -> True, 
      Ticks -> None, AxesLabel -> {"x", "y"}];

b) You are given a system of differential equations:
       x'[t]=a x[t] + b y[t]
       y'[t]=c x[t] + d y[t].
with specified numerical constants a, b, c, and d.
You ask Mathematica for the eigenvalues of the associated coefficient matrix and learn that
       0.1 + 4 I and  0.1 - 4 I
are eigenvalues. 
Pencil in on the axes below what you expect to be some sample trajectories.
Don't worry about clockwise vs. counterclockwise

a = 2; Show[Graphics[Line[{{-a, 0}, {a, 0}}]], 
      Graphics[Line[{{0, -a}, {0, a}}]], Axes -> True, 
      Ticks -> None, AxesLabel -> {"x", "y"}];

c)  You are given a system of differential equations:
       x'[t]=a x[t] + b y[t]
       y'[t]=c x[t] + d y[t].
with specified numerical constants a, b, c, and d.
You ask Mathematica for the eigenvalues of the associated coefficient matrix and learn that
       -0.2 + 3 I and -0.2 - 3 I
are eigenvalues. 
Pencil in on the axes below what you expect to be some sample trajectories.
Don't worry about clockwise vs. counterclockwise

a = 2; Show[Graphics[Line[{{-a, 0}, {a, 0}}]], 
      Graphics[Line[{{0, -a}, {0, a}}]], Axes -> True, 
      Ticks -> None, AxesLabel -> {"x", "y"}];

d) You are given a linear system of differential equations:
        System 1:  x'[t]=a x[t] + b y[t]
                         y'[t]=c x[t] + d y[t]
with specified numerical constants a, b, c, and d.
You ask Mathematica for the eigenvalues of the associated matrix and learn that
       -0.2 + 3 I and -0.2 - 3 I
are eigenvalues.

You are given another linear system:
       System  2:   x'[t]=aa x[t] + bb y[t]
                           y'[t]=cc x[t] + dd y[t]
with specified numerical constants aa, bb, cc, and dd.
You ask Mathematica for the eigenvalues of the associated matrix and learn that
      -0.2 + 5 I and -0.2 - 5 I
are eigenvalues.

Say whether the solutions of System 1 oscillate more rapidly or more slowly than solutions of System 2.  Include a word or two about how you arrived at your answer.

L.6)

Here's a linear system of differential equations: 
        x'[t]=-1.4 x[t] + 1.2 y[t]
        y'[t]=-2.4 x[t] + 2.2 y[t].

You can write down the ultimate ratio
       (lim_(t  ->  ∞))((y'[t])/(x'[t]))
for solutions {x[t], y[t]} of this linear system
simply by looking at the output from:

A = {{-1.4, 1.2}, {-2.4, 2.2}}; Clear[eigenvalue];

{eigenvalue[1], eigenvalue[2]} = Eigenvalues[A]

\(Clear[eigenvector]; 
    
{eigenvector[1], eigenvector[2]} = Eigenvectors[A]\)

a) Do it. 
    Does this ultimate ratio depend on starter data? If so, how?

b) Imagine that you are given a new linear system
         {x'[t],y'[t]}=A . {x[t], y[t]}
with one propeller and one sucker (no swirl). Explain how you could go about using eigenvalue and eigenvector information to calculate the ultimate ratio  
       (lim_(t  ->  ∞))((y'[t])/(x'[t]))

L.7)

You are going with a cleared matrix A:

\(Clear[a, b, c, d]; 
A = {{a, b}, {c, d}}; 
MatrixForm[A]\)

And the corresponding linear system:

\(Clear[x, y, t]; 
{\(x'\)[t_], \(y'\)[t_]}\  = \ A . {x[t], y[t]}; \)

{x'[t], y'[t]}

You search for straight line trajectories running parallel to a vector {u, v}:

\(Clear[r, u, v]; 
{x[t_], y[t_]} = {u, v}\ E\^\(r\ t\)\)

To be sure this is a genuine trajectory, you substitute them into the linear system and get:

{x'[t],y'[t]}==A . {x[t], y[t]}

a) Explain why this is the same as:

r {u, v} == A . {u, v}

b) Explain why this tells you that straight line trajectories (real or imaginary) of the linear system must go in the directions of eigenvectors of the coefficient matrix A.

L.8)

Folks with lots of experience with linear systems
       {x'[t],y'[t]}=A . {x[t], y[t]}
say that if you know the eigenvalues and eigenvectors of A, then you have formulas for the straight line trajectories and once you have these you can get the formula for the trajectory starting at any point you like.
What do these folks mean?

L.9)

Here's a linear system of differential equations
        x'[t]=-1.6 x[t] + 0.4 y[t]
        y'[t]=  0.6 x[t] - 1.4 y[t].

You read off the matrix A:

A = {{-1.6, 0.4}, {0.6, -1.4}}; MatrixForm[A]

You ask for the eigenvectors of A:

Clear[eigenvector]; {eigenvector[1], eigenvector[2]} = Eigenvectors[A]

And the eigenvalues of A:

Clear[eigenvalue]; {eigenvalue[1], eigenvalue[2]} = Eigenvalues[A]

Here are formulas for solutions corresponding to the straight line trajectories:

\(Clear[x1, y1, x2, y2]; 
    
{x1[t_], y1[t_]} = eigenvector[1]\ E\^\(\(-2\)\ t\)\){x2[t_], y2[t_]} = eigenvector[2] (E^(-t))

Stay with the same matrix A and write down formulas for the solutions {x[t], y[t]} of the linear system
              {x'[t],y'[t]}=A . {x[t], y[t]}
with
              {x[0], y[0]} = eigenvector[1] + 2 eigenvector[2]
This problem is not as hard as it looks.

L.10)

Here is a linear system:

Clear[b, c];
A = {{4, 6}, {(1/2), 2}};
Clear[x, y, t];
linearsystem={x'[t],y'[t]}==A . {x[t], y[t]}

You check the eigenvalues of A:

Eigenvalues[A]

And the eigenvectors of A:

Eigenvectors[A]

At this point, you have enough information to come up with a hand calculation of the formulas for the solutions x[t] and y[t] with given starter data x[0] = 2 and y[0] = 3.
Do it.

L.11)

Explain where the following Mathematica output comes from:

\(Clear[p, q, t]; 
ComplexExpand[E\^\(\((p + I\ q)\)\ t\)]\)

\(Clear[p, q, t]; 
ComplexExpand[E\^\(\((p - I\ q)\)\ t\)]\)

ComplexExpand[(1/2) ((E^(I q t)) + (E^(-I q t)))]

ComplexExpand[(1/2) I ((E^(-I q t)) - (E^(I q t)))]

ComplexExpand[
      (1/2) ((E^((p + I q) t)) + (E^((p - I q) t)))]

ComplexExpand[
      (1/2) I ((E^((p - I q) t)) - (E^((p + I q) t)))]

L.12)

a) (Multiple Choice)
You are going with a linear system:
       x'[t]=a x[t] + b y[t]
       y'[t]=c x[t] + d y[t]
with specified numerical constants a, b, c and d.
You calculate the eigenvalues of the coefficient matrix and 
get p + I q and p - I q where p and q are ordinary real numbers with q ≠ 0. This in turn tells you to expect formulas for x[t] and y[t] in terms of combinations of
        (i)    (E^(q t)) Cos[p t] and  (E^(q t)) Sin[p t]
        (ii)   (E^(p t)) Cos[q t] and  (E^(p t)) Sin[q t]
        (iii)  (E^(p t)) Cos[q t] and  (E^(p t)) Sin[p t]
        (iv)  None of the above.

b) You are going with a linear system:
       x'[t]=a x[t] + b y[t]
       y'[t]=c x[t] + d y[t]
with specified numerical constants a, b, c and d.
You calculate the eigenvalues of the coefficient matrix and 
get p + I q and p - I q where p and q are ordinary real numbers with q ≠ 0. 
How does your answer to part a) reinforce the idea that if p < 0, then
        Limit[x[t], t -> ∞] = 
        Limit[y[t], t -> ∞] = 0
no matter what the starting data are?

c) You are going with a linear system:
       x'[t]=a x[t] + b y[t]
       y'[t]=c x[t] + d y[t]
with specified numerical constants a, b, c and d.
You calculate the eigenvalues of the coefficient matrix and 
get p + I q and p - I q where p and q are ordinary real numbers. How does your answer to part a) reinforce the idea that if p = 0, then all solutions x[t] and y[t] are periodic with the same frequency
independent of what the starting data are?

L.13)

Here is Mathematica's calculation of the eigenvalues of a cleared matrix 
           A=(({{a, b}, {c, d}})):

\(Clear[a, b, c, d]; 
A = {{a, b}, {c, d}}; 
Eigenvalues[A]\)

Put 
        trace[A] = a + d
and look at the determinant of A:

Det[A]

This tells you that
the eigenvalues of A are given by
        (1/2) (trace[A] + (Sqrt[trace[A]^( 2) - 4 Det[A]]))
and 
        (1/2) (trace[A] - (Sqrt[trace[A]^( 2) - 4 Det[A]])).

a) Use these formulas and a cheap calculator to come up with eigenvalues of the indicated matrices A, B and C:
i)       A=(({{-1.0, 2.0}, {-1.0, 1.0}})), 

ii)      B=(({{-1.0, 2.0}, {-1.0, 1.1}})),

iii)     C=(({{-1.0, 2.0}, {-1.0, 0.9}})).

b) Stay with the same matrices A, B and C and explain the following statement:
Even though the linear systems
        {x'[t],y'[t]}=A . {x[t], y[t]}
        {x'[t],y'[t]}=B . {x[t], y[t]}
and
        {x'[t],y'[t]}=C . {x[t], y[t]}
appear to be almost the same, the long-term behavior of the solutions of these three systems is radically different.

L.14)

Here is Mathematica's calculation of the eigenvalues of a cleared matrix 
          A=(({{a, b}, {c, d}})):

\(Clear[a, b, c, d]; 
A = {{a, b}, {c, d}}; 
Eigenvalues[A]\)

Put 
         trace[A] = a + d
and look at the determinant of A:

Det[A]

This tells you that the eigenvalues of A are given by
       (1/2) (trace[A] + (Sqrt[trace[A]^( 2) - 4 Det[A]]))
and 
       (1/2) (trace[A] - (Sqrt[trace[A]^( 2) - 4 Det[A]])).

Use these formulas to help to explain:
a)  If trace[A] = 0 and trace[A]^2 - 4 Det[A] < 0, 
then all the solutions {x[t], y[t]} of the linear system 
         {x'[t],y'[t]}=A . {x[t], y[t]}
oscillate with the same frequency no matter what starter data are given.

b)  If trace[A] < 0 and trace[A]^2 - 4 Det[A] < 0, 
then all the solutions {x[t], y[t]} of the linear system 
         {x'[t],y'[t]}=A . {x[t], y[t]} 
satisfy   
         Limit[x[t], t -> ∞] = 
        Limit[y[t], t -> ∞] = 0

L.15)

a) Go with an ordinary linear oscillator
          y''[t]+b y'[t]+c y[t]=0
and use the substitution x[t]=y'[t] to convert this to a system
         {x'[t],y'[t]}=A . {x[t], y[t]}.
to get
          x'[t]=-b x[t] - c y[t]
          y'[t]=x[t].
This gives you
      {x'[t],y'[t]}=A . {x[t], y[t]}
where 
       A=(({{-b, -c}, {1, 0}}))

The Mathematica calculation in an earlier problem revealed that the eigenvalues of a matrix A are given by
        (1/2) (trace[A] + (Sqrt[trace[A]^( 2) - 4 Det[A]]))
and 
        (1/2) (trace[A] - (Sqrt[trace[A]^( 2) - 4 Det[A]])).

Use these formulas to confirm that the eigenvalues of A are given by 
        (1/2) (-b + (Sqrt[(b^2) - 4 c])) and  (1/2) (-b - (Sqrt[(b^2) - 4 c])).

b) How do the eigenvalues above compare to what you get when you solve 
            (z^2)  +  b z  +  c = 0
for z?