Finding the Jordan Canonical Form of a Matrix

Let's begin with a matrix A.

In[8]:=

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

Out[8]=

  1    1    -1
  
  0    0    2
  
  0    -1   3

We will put A in Jordan form. Do do this we need to find a nonsingular matrix S such that Inv(S)AS=J, where J is the Jordan form. This matrix S will be made up of eigenvectors and "generalized eigenvectors" as we shall see.

First, we must find the eigenvalues of A.

In[9]:=

  Eigenvalues[A]

Out[9]=

  {1, 1, 2}

You notice that A has a repeated eigenvalue. This does not necessarily mean that A does not have a full complement of eigenvectors. Let's see.

In[10]:=

  
  Eigenvectors[A]

Out[10]=

  {{1, 0, 0}, {0, 0, 0}, {0, 1, 1}}

Notice that by listing an eigenvector of {0,0,0}, Mathematica is
telling you that A does not have a full complement of eigenvectors. We must search for "generalized eigenvectors".

An eigenvector v solves the matrix equation Av=lambda v
[or (A-lambda I)v=0, where I is the identity matrix]. A generalized eigenvector v(i) will solve the matrix equation

Av(i)=lambda(i) v(i) + v(i-1)

[note that v(i) represents a subscript].
Here v(i) is the generalized eigenvector corresponding to the eigenvector v(i-1)
This equation can be written (A-lambda(i) I)v(i)=v(i-1).

v(1)=the first eigenvector, v(2)=generalized eigenvector to go with v(1), and v(3) is the second eigenvector. A generalized eigenvector will go in each slot that Mathematica gives the zero vector as an eigenvector.

In[11]:=

  LinearSolve[A-1 IdentityMatrix[3],{1,0,0}]

Out[11]=

  {0, 2, 1}

We have just found v(2), the generalized eigenvector to go with v(1)={1,0,0}. We now have three vectors to form the nonsingular matrix S. Inv(S)AS should give us the Jordan form of A.

In[12]:=

  S=Transpose[{{1,0,0},{0,2,1},{0,1,1}}];
  MatrixForm[S]

Out[12]=

  1   0   0
  
  0   2   1
  
  0   1   1

In[13]:=

  JA=Inverse[S].A.S;
  MatrixForm[JA]

Out[13]=

  1   1   0
  
  0   1   0
  
  0   0   2

Let's try another one.

In[14]:=

  Clear[B,S]

In[15]:=

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

Out[15]=

  2    -1   2    0
  
  0    3    -1   0
  
  0    1    1    0
  
  0    1    -3   5

In[16]:=

  Eigenvalues[B]

Out[16]=

  {2, 2, 2, 5}

You notice that B has a repeated eigenvalue. This does not necessarily mean that B does not have a full complement of eigenvectors. Let's see.

In[17]:=

  Eigenvectors[B]

Out[17]=

  {{1, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 1}}

Notice that by listing an eigenvector of {0,0,0,0} twice, Mathematica is
telling you that B does not have a full complement of eigenvectors. We must search for 2 "generalized eigenvectors".

In[18]:=

  LinearSolve[B-2 IdentityMatrix[4],{1,0,0,0}]

Out[18]=

            2
  {0, 1, 1, -}
            3

Let's keep going....

In[19]:=

  LinearSolve[B-2 IdentityMatrix[4],{0,1,1,2/3}]

Out[19]=

            5
  {0, 2, 1, -}
            9

We now have our four vectors for the matrix S.

In[20]:=

  S=Transpose[{{1,0,0,0},{0,1,1,2/3},{0,2,1,5/9},{0,0,0,1}}];
  MatrixForm[S]

Out[20]=

  
  
  1   0   0   0
  
  
  
  0   1   2   0
  
  
  
  0   1   1   0
  
      2   5
      -   -
  0   3   9   1

In[21]:=

  JB=Inverse[S].B.S;
  MatrixForm[JB]

Out[21]=

  2   1   0   0
  
  0   2   1   0
  
  0   0   2   0
  
  0   0   0   5

Up to Jordan Canonical Form