ExampleB1.mws

>    with(linalg):

Warning, the protected names norm and trace have been redefined and unprotected

>    #We consider again the matrix

>    A:=matrix([[1, -1, 0, 0, 0, 0], [4, 5, 0, 0, 0, 0], [0, 0, 0, -1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, -1, 0]]);

A := matrix([[1, -1, 0, 0, 0, 0], [4, 5, 0, 0, 0, 0], [0, 0, 0, -1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, -1, 0]])  

>    factor(minpoly(A, t));

(t^2+1)*(t-3)^2  

>    #We now consider the Primary Decomposition Theorem over the rational numbers. Previously we have factored (t^2+1) = (t+I)(t-I) and dealt with linear factors. Over Q, (t^2+1) is irreducible. The corresponding subspace is

>    W1:=kernel(A^2+1);

W1 := {vector([0, 0, 1, 0, 0, 0]), vector([0, 0, 0, 1, 0, 0]), vector([0, 0, 0, 0, 1, 0]), vector([0, 0, 0, 0, 0, 1])}  

>    #In addition we have

>    W2:=kernel((A-3)^2);

W2 := {vector([1, 0, 0, 0, 0, 0]), vector([0, 1, 0, 0, 0, 0])}  

>    #The change of basis matrix is

>    M:=transpose(matrix([W1[1], W1[2], W1[3], W1[4], W2[1], W2[2]]));

M := matrix([[0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0]])  

>    #We change basis and get

>    multiply(inverse(M), A, M);

matrix([[0, -1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, -1, 0, 0, 0], [0, 0, 0, 0, 1, -1], [0, 0, 0, 0, 4, 5]])  

>    #Notice the matrix is indeed composed of two blocks (4x4 and 2x2).