> with(linalg):

> #We want to do the whole process of diagonalization on Maple.

> A:=matrix([[1, 2, 0],[1, 0, 0], [0, 0, 2]]);

[Maple Math]

> #Characteristic polynomial, minimum polynomial and their factorization

> Delta:=charpoly(A,t);factor(Delta);m := minpoly(A, t);factor(m);

>

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> #We may find the eigenvalues directly by

> eigenvalues(A);

[Maple Math]

> #And we find the eigenvectors by

> eigenvectors(A);

[Maple Math]

> #Notice that the first entry is the eigenvalue, the second is the multiplicity and in the curly brackets we have a basis.

> #We get a basis B from putting the bases for the eigenspaces together and a change of basis matrix M by

> M:= matrix([[-1, 2, 0], [1, 1, 0], [0, 0, 1]]);

[Maple Math]

> #The matrix M^(-1) A M is diagonal. We verify that

> multiply(M^(-1), A, M);

[Maple Math]

> # Now, there is a much more efficient way of doing this. In which, the information is more hidden from us. Use

> J := jordan(A, 'M');

[Maple Math]

> #What you got is the Jordan form of A, which would always be diagonal if A is diagonalizable. The matrix M is a matrix such that M^(-1) A M = J. Therefore, when A is diagonalizable, the columns of M are eigenvectors and give a basis of eigenvectors with respect to which A is represented by J. To obtain M use

> print(M);

[Maple Math]

> #And we check

> evalm(M^(-1)&*A&*M);

[Maple Math]

> #This is another way to do

> multiply(M^(-1), A, M);

[Maple Math]

>