Diagonalization and the Jordan form
> with(linalg):
The command "jordan" produces the Jordan form of a matrix. If the matrix can be diagonalized
it Jordan form is its diagonalization. If the matrix cannot be diagonalized its Jordan form tells us the eigenvalues and is a complete similarity invariant.
Example 1:
> A:=matrix([[1,3,2],[0,2,2],[0,0,3]]);
> J:=jordan(A,'P');
> evalm(P);
The jordan command produces the Jordan form directly, and stores the transition matrix in P.
The column vectors of P are eigenvectors of A. We check that P^(-1)*A*P=J.
> evalm(inverse(P) &* A &* P);
Compare to the eigenvector command.
> eigenvectors(A);
Check that each of these are multiples of columns of P.
Example 2: (Nondiagonalizable)
> B:=matrix([[2,3,0],[0,2,0],[1,0,-5]]);
> jordan(B,'P2');
The eigenvalues are 2,2,-5. But we do not get a diagonal matrix. In this case the repeated eigenvalue 2 does not have two lineary independent eigenvectors. (The transition matrix is more complex is the case).
> eigenvectors(B);
The geometric multiplicity of 2 is 1, while its algebraic multiplicity is 2. When this happens the matrix while not be diagonalizable.
Example 3:
> C:=matrix([[-5,0,4],[0,2,5],[0,0,2]]);
> jordan(C);
Thus C is similar to B. One has to be a little careful. If the Jordan form results do not match, but can be made to match by rearranging the diagonial blocks, then the matrices are still similar.