ExampleA.mws

 > with(linalg);

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

 > 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]]);

 > charpoly(A, t);

 > factor(%);

 > factor(minpoly(A, t));

 > #A is not diagonalizable because its minimal polynomial has repeated roots.

 > B:=matrix([[3, 0, 0, 0, 0, 0], [0, 3, 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(charpoly(B,t));

 > factor(minpoly(B, t));

 > #B is diagonalizable over the complex numbers. Lets verify that this is indeed the minimal polynomial.

 > multiply(B-3, B^2 + 1);

 > #Lets diagonalize B. We calculate the eigenspaces

 > ESP(3) := kernel(B-3);

 > #Check:

 > multiply(B, ESP(3)[1]);

 > ESP(I):=kernel(B-I);

 > #Check:

 > multiply(B, ESP(I)[1]);

 > evalm(I*ESP(I)[1]);

 > ESP(minusI):=kernel(B+I);

 > #Check:

 > multiply(B, ESP(minusI)[1]);

 > evalm(-I*ESP(minusI)[1]);

 > #By putting the eigenvectors together we get a matrix M that diagonalizes B

 > M:=transpose(matrix([ESP(3)[1], ESP(3)[2], ESP(I)[1], ESP(I)[2], ESP(minusI)[1], ESP(minusI)[2]]));

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

 > #Later we'll learn about the Jordan form. If a matrix is diagonalizable then its Jordan form is diagonal. Else, it's not.

 > jordan(A);

 > jordan(B);

 > #In fact, Maple can givs us the transition matrix too.

 > jordan(B, 'N');

 > print(N);

 > multiply(inverse(N), B, N);

 >