Example.mws

> with(linalg);#This calls the linear algebra package#

> A:=<<1, 4, 0, 0,0,0>|<-1, 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(charpoly(A,t));

> factor(minpoly(A, t));

> multiply((A^2+1), (A-3));multiply((A^2+1)^2, (A-3));#We verify here "by hand" that the other divisors of the characteristic polynomial do not vanish on A#

> #It follows from a Theorem we'll prove that A is not diagonalizable because the minimal polynomial is not a product of linear terms. We therefore proceed to another example#

>

> B:=<<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));

> #Note that B has the same characteristic polynomial but a different minimal polynomial. It is not diagonalizable over Q because the characteristic polynomial is not a product of linear terms. However, the characteristic polynomial factors over the complex numbers and we proceed to diagonalize B over the complex numbers. The eigenvalues are 3, i, -i#

> #We need to find the kernel of 3 - B#

> H3:=3 - B;

> K3 := kernel(H3);

> #This is a basis for the eigenspace E_3. We verify that#

> multiply(B, K3[1]);3*K3[1];multiply(B, K3[2]);3*K3[2];

> #or let Maple check equality by#

> equal(multiply(B, K3[1]),3*K3[1]);equal(multiply(B, K3[2]),3*K3[2]);

> Hi:=I - B;

> Ki := kernel(Hi);

> #This is a basis for the eigenspace E_I. We verify that#

> equal(multiply(B, Ki[1]),I*Ki[1]);equal(multiply(B, Ki[2]),I*Ki[2]);

> Hnegi:=-I - B;

> Knegi :=kernel(Hnegi);

> #This is a basis for the eigenspace E_(-I). We verify that#

> equal(multiply(B, Knegi[1]),-I*Knegi[1]);equal(multiply(B, Knegi[2]),-I*Knegi[2]);

> #Let K be the basis#

> K:= K3 union Ki union Knegi;

> #Then B is diagonal in this basis equal to diag(-I,I,-I,I,3,3). The non standard ordering is due to the whims of Maple#

> #We verify that. Let M be St_M_K#

> M:= <<0, 0, 0, 0, I, 1>|<0, 0, 0, 0, 1, I>|<0, 0, 1, I, 0, 0>|<0, 0, I, 1, 0, 0>|<0, 1, 0, 0, 0, 0>|<1, 0, 0, 0, 0, 0>>;

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

>

> #In fact, Maple can do the whole diagonalization process.#

> JordanForm(A);#The Jordan form of a matrix C is a matrix conjugate to C. We shall see that if C is diagonalizable then its Jordan form is diagonal#

> JordanForm(B);

> M:=JordanForm(B, output=Q);#This gives us the change of basis producing the canonical form#

> #We check that#

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

>

>