OnLine6-1-Eigen.mws

Linear Algebra Powertool

Eigenvectors and Eigenvalues

Online 6.1

Worksheet by Russell Blyth

Goals of this worksheet:

1) Compute eigenvalues and eigenvectors for several 3 x 3 matrices.

2) Use eigenvectors and eigenvalues to simplify a matrix computation.

> restart:with(plots):with(linalg):

Warning, the name changecoords has been redefined

Warning, the protected names norm and trace have been redefined and unprotected

Computing Eigenvalues and Eigenvectors

First define a matrix and the identity of the same size.

> A := matrix(3,3,[[-1,0,5],[0,4,0],[5,0,-1]]);
I3 := evalm(array(identity,1..3,1..3));

A := matrix([[-1, 0, 5], [0, 4, 0], [5, 0, -1]])

I3 := matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]])

Compute the characteristic polynomial, which is det(A - x*I3)

> chpol := det(A - x*I3);

chpol := -96+32*x+2*x^2-x^3

Set equal to zero and solve.

> AEvals := solve(chpol = 0,x);

AEvals := -6, 4, 4

Compute the first eigenspace.

> AEspace1 := linsolve(A-AEvals[1]*I3,[0,0,0]);

AEspace1 := vector([_t[1], 0, -_t[1]])

Extract the basis vector(s)

> AEbasis1 := [subs(_t[1]=1, op(AEspace1))];

AEbasis1 := [vector([1, 0, -1])]

Repeat for the second eigenvalue

> AEspace2 := linsolve(A-AEvals[2]*I3,[0,0,0]);

AEspace2 := vector([_t[2], _t[1], _t[2]])

We have two parameters this time.

> AEbasis2 := [subs(_t[1]=1,_t[2]=0, op(AEspace2)),
subs(_t[1]=0,_t[2]=1, op(AEspace2))];

AEbasis2 := [vector([0, 1, 0]), vector([1, 0, 1])]

Check that these eigenspace basis vectors are in fact eigenvectors of A

> evalm(A &* AEbasis1[1]);
evalm(A &* AEbasis2[1]);
evalm(A &* AEbasis2[2]);

vector([-6, 0, 6])

vector([0, 4, 0])

vector([4, 0, 4])

Note that these vectors are the correct multiples of the eigenvectors.

Exercises:

1) Follow the recipe above to find the eigenvalues and eigenvectors of the matrix B.

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

B := matrix([[0, 1, 1], [0, 2, 0], [-2, 1, 3]])

2) Repeat for the matrix C.

> C := matrix(3,3,[[4,-3,1],[4,-1,0],[1,7,-4]]);

C := matrix([[4, -3, 1], [4, -1, 0], [1, 7, -4]])

When you are done: what can you say about the matrix C?

Maple has a command for carrying out all of the above operations at once.

> eigenvectors(A);

[-6, 1, {vector([-1, 0, 1])}], [4, 2, {vector([0, 1...

We get a set of triples, where the first entry of each triple is an eigenvalue, the second entry is its multiplicity as a root of the characteristic polynomial, and the third entry is a basis for the eigenspace corresponding to that eigenvector. We can extract this data if we first place these two triples into a sequence.

> evA := [eigenvectors(A)];

evA := [[4, 2, {vector([0, 1, 0]), vector([1, 0, 1]...

The eigenvalues:

> evA[1][1]; evA[2][1];

4

-6

The eigenvectors:

> evA[1][3][1]; evA[2][3][1]; evA[1][3][2];

vector([1, 0, 1])

vector([1, 0, -1])

vector([0, 1, 0])

If you ge an error here, it's because Maple decided to list the eigenvalues in a different order than it did when I wrote the worksheet - fix the problem by editing the command line.

>

Using eigenvalues and eigenvectors to ease computation

We'll easily compute A^25 * X where X = [2, 3, -1]^t

First note that the three eigenvectors which we computed earlier form a basis for R^3

> AEMat := augment(AEbasis1[1],AEbasis2[1],AEbasis2[2]);
rank(AEMat);

AEMat := matrix([[1, 0, 1], [0, 1, 0], [-1, 0, 1]])...

3

Now find the coefficients of X with respect to the basis above.

> X := vector(3,[2,3,-1]);
Xcvec := linsolve(AEMat,X);

X := vector([2, 3, -1])

Xcvec := vector([3/2, 3, 1/2])

Now A^25 * X is computed as follows:

> evalm(Xcvec[1]*AEvals[1]^25*AEbasis1[1]
+ Xcvec[2]*AEvals[2]^25*AEbasis2[1]
+ Xcvec[3]*AEvals[2]^25*AEbasis2[2]);

vector([-42644869094941130752, 3377699720527872, 42...

Note that this calculation involved no matrix multiplications. What advantage might this have?

Maple will actually compute directly, so let's check.

> evalm(A^25 &* X);

vector([-42644869094941130752, 3377699720527872, 42...

Exercise:

3) Compute B^13 * X (X as above) using eigenvalues and eigenvectors. Check by direct computation. (Note we cannot use this technique for powers of C, since we can't find a basis of eigenvectors of C.)

>

>