JCFexample1withCheck.nb

This notebook is on the class web site, on the homework page.
Find the general solution to x dot = A x, where

A = {{3,1,1,0},
{-1,1,0,-1},
{-1,-1,0,1},
{-2,-1,-1,1}};
MatrixForm[A]

If we were to do this whole problem by hand, the hardest part is to find the eigenvalues.  We would have to take the determinant of A-lambda I, and factor the resulting characteristic polynomial.  We’ll use the computer to find the eigenvalues instead.

Eigenvalues[A]

there is a one dimensional eigenspace for 2

MatrixForm[RowReduce[A - 2 IdentityMatrix[4]]]

There is a 3 - dimensional generalized eigenspace for 1, and we need to compute the deficiency indices to find the JCF.

A1 = A -  IdentityMatrix[4];
MatrixForm[A1]

MatrixForm[RowReduce[A1]]

So delta_1 is 2 and there are two blocks with eigenvalue 1.  The partition of the 3 dimensional eigenspace is 3 = 2+1.  We conclude that the JCF of A is B = diag(J_1(2), J_2(1), J_1(1)).  
Note that
(B-2I)e1 = 0
(B-I)e2 = 0
(B-I)e3=e2
(B-I)e4= 0
Then we get equations for the 4 columns of P = [v1 v2 v3 v4] by getting the analogous equations replacing B with A and ei with vi:
(A-2I)v1 = 0
(A-I)v2 = 0
(A-I)v3=v2
(B-I)v4= 0
Finding v1 is easy, For the others, start with any rank 2 generalized eigenvector (v3), which is in the null space of (A-I)^2:

MatrixForm[RowReduce[A1.A1]]

Try the simplest choice, v3 = {0,0,0,1}, then compute (A-I)v3.  Since (A-I)v3 is nonzero, that is v2 = {0,-1,1,0}.  (If  (A-I)v3 had been zero we would need to try another choice for v3. )  Finally,  choose another eigenvector v4 that is LI from v2:  The simplest choice for v4 has the first free variable = 0 and the second free variable = 1.

v1 = {-1,0,1,1};  (* An eigenvector with eigenvalue 2 *)
v2 = {0, -1, 1, 0};
v3 = {0, 0, 0, 1};
v4 = {-1,2,0, 1};

Now, take the solution of y dot = B y, and replace the ei with vi to get the solution in the x-variables:

xSoln = v1 Exp[2t]c1 + Exp[t](v2(c2+c3 t) + v3 c3 + v4 c4);
MatrixForm[xSoln]

Now, that form of the general solution is not very pretty, but look how we can check if the solution is correct:

Simplify[A.xSoln - (∂_t) xSoln]  (* the (∂_t) is the derivative with respect to t *)

We are now confident that we have solved the problem correctly.  To be sure we have the general solution, we can check that P is nonsingular:

P = Transpose[{v1,v2,v3,v4}];
MatrixForm[P]
Det[P]

For fun, let us confirm that the Matrix P puts A into Jordan canonical form.  One would never want to do this by hand since it involves finding the inverse of the matrix.
The Jordan canonical form of A is

MatrixForm[Inverse[P].A.P]