solegs.mw

Solving Two Dimensional Systems of Linear Differential Equations.

 > restart; with(LinearAlgebra):

A utiity procedure.

 > buildsys := proc(mat) {diff(x(t),t)=mat[1,1]*x(t)+mat[1,2]*y(t), diff(y(t),t)=mat[2,1]*x(t)+mat[2,2]*y(t)}; end;   >

 >

 >

 >

Diagonializable, real eigenvalues.

 > A := Matrix([[-4, 6], [-3, 5]]); >

 > sys := buildsys(A); Initial Condition

 > xno := ; Maple's Solution

 > sol := dsolve(sys union {x(0)=a, y(0)=b}, [x(t),y(t)]); Now, we'll solve it.

 >

 > evv := Eigenvectors(A); > P:=evv; > P^(-1).A.P; > zmat := DiagonalMatrix([exp(2*t), exp(-t)]); > xsol := P.zmat.P^(-1).xno; Rearrange to compare with Maple.

 >

 > map(collect, %, [exp(2*t), exp(-t)]); >

 >

Diagonalizable, nonreal eigenvalues.

 >

 > A := Matrix([[11, -6], [15, -7]]); >

 >

 > sys := buildsys(A); > dsol:=dsolve(sys union {x(0)=a, y(0)=b}, [x(t), y(t)]);  >

 >

 > evv := Eigenvectors(A); > P := evv; > p1 := Column(P,1); > u := map(Re,p1); > v := -map(Im, p1); > u - I*v; > Q := ; > B:=Q^(-1).A.Q; > zmat := << exp(2*t)*cos(3*t)|-exp(2*t)*sin(3*t)>, >; > xsol := Q.zmat.Q^(-1).xno; To check that this is the same as Maple's solution, create differences

 > {x(t)-xsol, y(t)-xsol};  Now substitute Maple's solutions for and > subs(dsol, %);   > map(simplify, %); >

Nondiagonalizable.

 >

 > A := Matrix([[-8/3, 4/3], [-1/3, -4/3]]); > sys := buildsys(A); > dsol := dsolve(sys union {y(0)=b, x(0)=a}, [x(t), y(t)]); >

 >

 > evv := Eigenvectors(A); > u:= <2, 1>; Pick some vector independent of > v := < -1,3>; > A.v; > A.v - (-2)*v; This is Adjust > v := v/(7/3); > A.v - (-2)*v; This is Tis normalization gives us the 1 in the matrix B below.

 > P := ; > B := P^(-1).A.P; > zmat := << exp(-2*t) | t*exp(-2*t)>, <0| exp(-2*t)>>; > xsol := P.zmat.P^(-1).xno; > {x(t)-xsol, y(t)-xsol}; > subs(dsol, %);  > map(simplify, %); >