> with(linalg):
> #We want to do the whole process of diagonalization on Maple.
> A:=matrix([[1, 2, 0],[1, 0, 0], [0, 0, 2]]);
> #Characteristic polynomial, minimum polynomial and their factorization
> Delta:=charpoly(A,t);factor(Delta);m := minpoly(A, t);factor(m);
>
> #We may find the eigenvalues directly by
> eigenvalues(A);
> #And we find the eigenvectors by
> eigenvectors(A);
> #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]]);
> #The matrix M^(-1) A M is diagonal. We verify that
> multiply(M^(-1), A, M);
> # 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');
> #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);
> #And we check
> evalm(M^(-1)&*A&*M);
> #This is another way to do
> multiply(M^(-1), A, M);
>