Example.mws

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

[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp,...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp,...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp,...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp,...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp,...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp,...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp,...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp,...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp,...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp,...

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

A := _rtable[17212508]

> factor(charpoly(A,t));

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

> factor(minpoly(A, t));

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

> 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#

matrix([[-20, -10, 0, 0, 0, 0], [40, 20, 0, 0, 0, 0...

matrix([[-200, -100, 0, 0, 0, 0], [400, 200, 0, 0, ...

> #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>>;

B := _rtable[18357972]

> factor(charpoly(B,t));

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

> factor(minpoly(B,t));

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

> #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;

H3 := _rtable[2728944]

> K3 := kernel(H3);

K3 := {vector([1, 0, 0, 0, 0, 0]), vector([0, 1, 0,...

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

vector([3, 0, 0, 0, 0, 0])

3*vector([1, 0, 0, 0, 0, 0])

vector([0, 3, 0, 0, 0, 0])

3*vector([0, 1, 0, 0, 0, 0])

> #or let Maple check equality by#

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

true

true

> Hi:=I - B;

Hi := _rtable[18008200]

> Ki := kernel(Hi);

Ki := {vector([0, 0, 0, 0, -I, 1]), vector([0, 0, 1...

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

true

true

> Hnegi:=-I - B;

Hnegi := _rtable[3181340]

> Knegi :=kernel(Hnegi);

Knegi := {vector([0, 0, 0, 0, I, 1]), vector([0, 0,...

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

true

true

> #Let K be the basis#

> K:= K3 union Ki union Knegi;

K := {vector([1, 0, 0, 0, 0, 0]), vector([0, 1, 0, ...

> #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>>;

M := _rtable[3166544]

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

>

matrix([[-I, 0, 0, 0, 0, 0], [0, I, 0, 0, 0, 0], [0...

> #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#

_rtable[18718384]

> JordanForm(B);

_rtable[20857376]

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

M := _rtable[18635580]

> #We check that#

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

matrix([[3, 0, 0, 0, 0, 0], [0, I, 0, 0, 0, 0], [0,...

>

>