Linear Algebra Powertool
Diagonalization
Online 6.2
Worksheet by Russell Blyth
Goals of this worksheet:
1) Construct a diagonalizable matrix which has specified eigenvalues and eigenvectors.
2) Compute powers of diagonalizable matrices with ease!
>
restart:with(plots):with(linalg):
randomize():
Warning, the name changecoords has been redefined
Warning, the protected names norm and trace have been redefined and unprotected
Constructing diagonalizable matrices
How might a professor find a diagonalizable matrix A to use as an example or on a test question? We see here how to use the equation
for this purpose, where D is diagonal with entries that are eigenvalues and Q is the matrix whose columns are eigenvectors of A. We first randomly choose the eigenvalues, and then the eigenvectors corresponding to each of these eigenvectors. (Note we cannot use the variable D, which is a Maple system variable)
> DD := matrix(3,3,[[rand(-3..3)(),0,0],[0,rand(-3..3)(),0],[0,0,rand(-3..3)()]]);
>
Q1 := randvector(3,entries=rand(-3..3));
Q2 := randvector(3,entries=rand(-3..3));
Q3 := randvector(3,entries=rand(-3..3));
Construct the matrix Q by assembling Q1, Q2, Q3 as its columns
> Q := augment(Q1,Q2,Q3);
Check that {Q1,Q2,Q3} is independent.
> rank(Q);
If the rank of Q is not three, then the set {Q1, Q2, Q3} is not independent - go back and compute a new set.
Now compute the matrix A
> A := evalm(Q &* DD &* inverse(Q));
Check that the matrix A has the expected eigenvalues and eigenvectors
> eigenvectors(A);
Let's also check the characteristic polynomial of A.
> chp := charpoly(A,x);
> factor(chp);
Exercises:
1) Find a 3 x 3 matrix B which has the eigenvectors and eigenvalues of your choice. Make all your eigenvalues nonzero, and all entries of your eigenvectors nonzero. (Don't reuse the variables DD or Q)
>
2) The matrices A and B probably have fractional entries. How could the professor make sure that a matrix computed this way has only integer entries?
>
Computing Powers of matrices using the diagonalization
Compute a high power of A using the diagonal matrix DD. First we choose an appropriate power:
> power := rand(8..20)();
Raise the matrix DD to this power.
> powerDD := evalm(DD^power);
A to the given power is now computed using Q
> powerA := evalm(Q &* powerDD &* inverse(Q));
Check by direct calculation:
> evalm(A^power);
Exercise:
3) Compute some power of B between 8 and 20 using the same technique.
>
>