MAT 232 Chapter 5

1613 days ago by kcrisman

Chapter 5 - Eigenstuff

Section 5.1

We can calculate these things, and Sage has the usual approximation techniques of any such software.

M = matrix([[1,2,3],[1,2,3],[1,2,3]]); M 
       
[1 2 3]
[1 2 3]
[1 2 3]
[1 2 3]
[1 2 3]
[1 2 3]
M.eigenvalues() 
       
[6, 0, 0]
[6, 0, 0]
M.eigenspaces_right() 
       
[
(6, Vector space of degree 3 and dimension 1 over Rational Field
User basis matrix:
[1 1 1]),
(0, Vector space of degree 3 and dimension 2 over Rational Field
User basis matrix:
[   1    0 -1/3]
[   0    1 -2/3])
]
[
(6, Vector space of degree 3 and dimension 1 over Rational Field
User basis matrix:
[1 1 1]),
(0, Vector space of degree 3 and dimension 2 over Rational Field
User basis matrix:
[   1    0 -1/3]
[   0    1 -2/3])
]

Note that eigenvectors come with their full information in Sage.

M.eigenvectors_right() 
       
[(6, [
(1, 1, 1)
], 1), (0, [
(1, 0, -1/3),
(0, 1, -2/3)
], 2)]
[(6, [
(1, 1, 1)
], 1), (0, [
(1, 0, -1/3),
(0, 1, -2/3)
], 2)]
for EV in M.eigenvectors_right(): print EV[0] print EV[1] print EV[2] 
       
6
[
(1, 1, 1)
]
1
0
[
(1, 0, -1/3),
(0, 1, -2/3)
]
2
6
[
(1, 1, 1)
]
1
0
[
(1, 0, -1/3),
(0, 1, -2/3)
]
2

The "RDF" is more or less like what Matlab would do.

M = random_matrix(RDF,10); html(M) 
       
[  0.985144560397  0.0385057567241   0.183363679128  -0.922013098027   0.650047214395  -0.977055936778  -0.709926661381   0.446707664765   0.184998756647 -0.0218336418339]
[  0.654733123549   0.201172431502  -0.819729438089   0.735537571773   0.291799053466  -0.099637553131  -0.196792361033  -0.220259005958  -0.399922897238  -0.900609310198]
[  0.503720690018  -0.415995871865  -0.808668688464  -0.885926196204   0.155588552522   0.823786663845   0.736290280717   0.124126330692  -0.459000363746  -0.987739173145]
[ -0.175908438108   0.800746900172   -0.67045214045   0.335243012759 -0.0700703628598   0.952814483876   0.877882007945  -0.754667562946  -0.807797778388  -0.842303818369]
[ -0.541797656484  -0.803213298536   0.187816993509   0.930353763015   0.493777666749   0.495338447406   0.590418920309  -0.562387100905   0.907670159327  -0.652761799633]
[  0.370585286131  -0.693112755348  -0.249036871276   0.316945202831 -0.0545218285829   0.122216000756  -0.618146652185 -0.0586424970691   0.013882788525 -0.0449979844575]
[ -0.132149122703   0.658832238905  -0.795206011884  -0.938959963263   0.727902386315   0.502353313696   0.113863160114   -0.93954854808   0.111554195433   0.512398427247]
[ -0.196585304802  -0.254872052268   0.820545827413   0.544243702946  -0.806226971797   0.622998405736   0.580582247294   0.155532099073   0.438813111639   0.634668048389]
[  0.393387175094  -0.758276792882  -0.935454782071   0.988066943019   0.961273651909  -0.168656246577  -0.522965933234   0.873860877884  0.0665697872688  -0.897205456006]
[  0.925082369204  -0.113503411058   -0.88575699136   0.753731535531   0.332572271891  -0.905590186526  -0.694321512842  -0.733430724522   0.595323249835   0.496007375444]
[  0.985144560397  0.0385057567241   0.183363679128  -0.922013098027   0.650047214395  -0.977055936778  -0.709926661381   0.446707664765   0.184998756647 -0.0218336418339]
[  0.654733123549   0.201172431502  -0.819729438089   0.735537571773   0.291799053466  -0.099637553131  -0.196792361033  -0.220259005958  -0.399922897238  -0.900609310198]
[  0.503720690018  -0.415995871865  -0.808668688464  -0.885926196204   0.155588552522   0.823786663845   0.736290280717   0.124126330692  -0.459000363746  -0.987739173145]
[ -0.175908438108   0.800746900172   -0.67045214045   0.335243012759 -0.0700703628598   0.952814483876   0.877882007945  -0.754667562946  -0.807797778388  -0.842303818369]
[ -0.541797656484  -0.803213298536   0.187816993509   0.930353763015   0.493777666749   0.495338447406   0.590418920309  -0.562387100905   0.907670159327  -0.652761799633]
[  0.370585286131  -0.693112755348  -0.249036871276   0.316945202831 -0.0545218285829   0.122216000756  -0.618146652185 -0.0586424970691   0.013882788525 -0.0449979844575]
[ -0.132149122703   0.658832238905  -0.795206011884  -0.938959963263   0.727902386315   0.502353313696   0.113863160114   -0.93954854808   0.111554195433   0.512398427247]
[ -0.196585304802  -0.254872052268   0.820545827413   0.544243702946  -0.806226971797   0.622998405736   0.580582247294   0.155532099073   0.438813111639   0.634668048389]
[  0.393387175094  -0.758276792882  -0.935454782071   0.988066943019   0.961273651909  -0.168656246577  -0.522965933234   0.873860877884  0.0665697872688  -0.897205456006]
[  0.925082369204  -0.113503411058   -0.88575699136   0.753731535531   0.332572271891  -0.905590186526  -0.694321512842  -0.733430724522   0.595323249835   0.496007375444]
M.eigenvalues() 
       
[-1.35668644967 + 0.158924091228*I, -1.35668644967 - 0.158924091228*I,
0.0533646296425 + 1.63369153324*I, 0.0533646296425 - 1.63369153324*I,
1.22277348018 + 0.599548307145*I, 1.22277348018 - 0.599548307145*I,
0.807762737038 + 0.845851075287*I, 0.807762737038 - 0.845851075287*I,
0.353214305604 + 0.172017153727*I, 0.353214305604 - 0.172017153727*I]
[-1.35668644967 + 0.158924091228*I, -1.35668644967 - 0.158924091228*I, 0.0533646296425 + 1.63369153324*I, 0.0533646296425 - 1.63369153324*I, 1.22277348018 + 0.599548307145*I, 1.22277348018 - 0.599548307145*I, 0.807762737038 + 0.845851075287*I, 0.807762737038 - 0.845851075287*I, 0.353214305604 + 0.172017153727*I, 0.353214305604 - 0.172017153727*I]

Here is #16.

A = matrix([[5,0,-1,0],[1,3,0,0],[2,-1,3,0],[4,-2,-2,4]]); A 
       
[ 5  0 -1  0]
[ 1  3  0  0]
[ 2 -1  3  0]
[ 4 -2 -2  4]
[ 5  0 -1  0]
[ 1  3  0  0]
[ 2 -1  3  0]
[ 4 -2 -2  4]
for ES in A.eigenspaces_right(): if ES[0]==4: ES 
       
(4, Vector space of degree 4 and dimension 2 over Rational Field
User basis matrix:
[1 1 1 0]
[0 0 0 1])
(4, Vector space of degree 4 and dimension 2 over Rational Field
User basis matrix:
[1 1 1 0]
[0 0 0 1])
A.eigenspaces_right() 
       
[
(4, Vector space of degree 4 and dimension 2 over Rational Field
User basis matrix:
[1 1 1 0]
[0 0 0 1]),
(3.500000000000000? - 0.866025403784439?*I, Vector space of degree 4 and
dimension 1 over Algebraic Field
User basis matrix:
[                                        1 0.500000000000000? +
0.866025403784439?*I 1.500000000000000? + 0.866025403784439?*I
3.000000000000000? + 1.732050807568878?*I]),
(3.500000000000000? + 0.866025403784439?*I, Vector space of degree 4 and
dimension 1 over Algebraic Field
User basis matrix:
[                                        1 0.500000000000000? -
0.866025403784439?*I 1.500000000000000? - 0.866025403784439?*I
3.000000000000000? - 1.732050807568878?*I])
]
[
(4, Vector space of degree 4 and dimension 2 over Rational Field
User basis matrix:
[1 1 1 0]
[0 0 0 1]),
(3.500000000000000? - 0.866025403784439?*I, Vector space of degree 4 and dimension 1 over Algebraic Field
User basis matrix:
[                                        1 0.500000000000000? + 0.866025403784439?*I 1.500000000000000? + 0.866025403784439?*I 3.000000000000000? + 1.732050807568878?*I]),
(3.500000000000000? + 0.866025403784439?*I, Vector space of degree 4 and dimension 1 over Algebraic Field
User basis matrix:
[                                        1 0.500000000000000? - 0.866025403784439?*I 1.500000000000000? - 0.866025403784439?*I 3.000000000000000? - 1.732050807568878?*I])
]

Section 5.2

Sage can calculate characteristic polynomials, too.

A.characteristic_polynomial() 
       
x^4 - 15*x^3 + 85*x^2 - 216*x + 208
x^4 - 15*x^3 + 85*x^2 - 216*x + 208
A.characteristic_polynomial().subs(x=A) 
       
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
A^4-15*A^3+85*A^2-216*A+208*identity_matrix(4) 
       
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]

Let's think of Smiley Guy in terms of eigenstuff.

t = var('t') @interact() def _(A=matrix(RDF,[[1,0],[0,1]]),auto_update=False): ID = matrix(RDF,[[1,0],[0,1]]) def makeface(M): pll=M*vector((-0.5,0.5)) plr=M*vector((-0.3,0.5)) prl=M*vector((0.3,0.5)) prr=M*vector((0.5,0.5)) left_eye=line([pll,plr])+point(pll,size=5)+point(plr,size=5) right_eye=line([prl,prr],color='green')+point(prl,size=5,color='green')+point(prr,size=5,color='green') mouth=parametric_plot(M*vector([t, -0.15*sin(2*pi*t)-0.5]), (t, -0.5, 0),color='red')+parametric_plot(M*vector([t, -0.15*sin(2*pi*t)-0.5]), (t,0,0.5),color='orange') face=parametric_plot(M*vector([cos(t),sin(t)]), (t,0,pi/2),color='black')+parametric_plot(M*vector([cos(t),sin(t)]), (t,pi/2,pi),color='lavender')+parametric_plot(M*vector([cos(t),sin(t)]), (t,pi,3*pi/2),color='cyan')+parametric_plot(M*vector([cos(t),sin(t)]),(t,3*pi/2,2*pi),color='sienna') return right_eye+left_eye+face+mouth html('smiley guy, transformed by $A$') G = graphics_array([[makeface(ID),makeface(A)]]) for ev in A.eigenvalues(): try: RR(ev) html("We have an eigenvalue $%s$ - can you see the eigenspace?"%ev) break except: pass G.show(aspect_ratio=1) 
       

Click to the left again to hide and once more to show the dynamic interactive window

Eigenvalues can be hard to come by symbolically.

var('lam') show(((-1-lam)*(1-lam)*(2-lam)+6).solve(lam)[2]) 
       

We can talk about the characteristic polynomial too!

A = matrix([[5,0,-1,0],[1,3,0,0],[2,-1,3,0],[4,-2,-2,4]]); A 
       
[ 5  0 -1  0]
[ 1  3  0  0]
[ 2 -1  3  0]
[ 4 -2 -2  4]
[ 5  0 -1  0]
[ 1  3  0  0]
[ 2 -1  3  0]
[ 4 -2 -2  4]
A.characteristic_polynomial() 
       
x^4 - 15*x^3 + 85*x^2 - 216*x + 208
x^4 - 15*x^3 + 85*x^2 - 216*x + 208

And here's the Cayley-Hamilton Theorem.

A.characteristic_polynomial().subs(x=A) 
       
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
A^4-15*A^3+85*A^2-216*A+208*identity_matrix(4) 
       
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]

Sections 5.3 and 5.4

Here we come to the crux of it, and where I differ from the text in how it should be motivated.  What do eigenvalues give us, under the best circumstances?

t = var('t') @interact() def _(A=matrix([[1,0],[0,1]]),auto_update=False): ID = matrix(RDF,[[1,0],[0,1]]) def makeface(M): pll=M*vector((-0.5,0.5)) plr=M*vector((-0.3,0.5)) prl=M*vector((0.3,0.5)) prr=M*vector((0.5,0.5)) left_eye=line([pll,plr])+point(pll,size=5)+point(plr,size=5) right_eye=line([prl,prr],color='green')+point(prl,size=5,color='green')+point(prr,size=5,color='green') mouth=parametric_plot(M*vector([t, -0.15*sin(2*pi*t)-0.5]), (t, -0.5, 0),color='red')+parametric_plot(M*vector([t, -0.15*sin(2*pi*t)-0.5]), (t,0,0.5),color='orange') face=parametric_plot(M*vector([cos(t),sin(t)]), (t,0,pi/2),color='black')+parametric_plot(M*vector([cos(t),sin(t)]), (t,pi/2,pi),color='lavender')+parametric_plot(M*vector([cos(t),sin(t)]), (t,pi,3*pi/2),color='cyan')+parametric_plot(M*vector([cos(t),sin(t)]),(t,3*pi/2,2*pi),color='sienna') return right_eye+left_eye+face+mouth html('smiley guy, transformed by $A$') IDface = makeface(ID) Aface = makeface(A) for ev in A.eigenvectors_right(): val = ev[0] ev = ev[1] for vect in ev: try: vect.change_ring(RR) html("There is an eigenvector with eigenvalue $%s$"%val) IDface += plot(vect) Aface += plot(A*vect) except ValueError: pass G = graphics_array([[IDface,Aface]]) G.show(aspect_ratio=1) 
       

Click to the left again to hide and once more to show the dynamic interactive window

Notice that now we can see Smiley Guy's eigenvectors and how they are moved.  

  • With some matrices, of course, there is only one eigenvector or none, but the premise remains. (Try a shear or rotation.)
  • Also note that if we change things to Matlab-style RDF, we can get extraneous eigenvectors!  (Try RDF of a shear matrix.)

But if we have two linearly independent eigenvectors (a basis), we can see exactly how things change.  You stretch each basis vector by its eigenvalue, and everything else follows suit!

  • A nice example of this is $$\left[\begin{array}{cc}0 & 1\\-3 & 4\end{array}\right]$$ (this is #13 in section 5.4)
  • Another one $$\left[\begin{array}{cc}2 & 3\\3 & 2\end{array}\right]$$ (this is #14 in section 5.4)
  • By the way, I wonder why the basis in the second example is at right angles, but not the first... that couldn't possibly be important...

Now, try out a matrix like $$\left[\begin{array}{cc}5 & 0\\0 & -1\end{array}\right]$$  That seems to basically act the same way, right?  Only... it stretches a different basis.

If only there were a way to make our transformation look that simple.  If only...

 
       
 
       

Now let's try to look at a typical example.

t = var('t') A=matrix([[7,2],[-4,1]]) ID = matrix(RDF,[[1,0],[0,1]]) def makeface(M): pll=M*vector((-0.5,0.5)) plr=M*vector((-0.3,0.5)) prl=M*vector((0.3,0.5)) prr=M*vector((0.5,0.5)) left_eye=line([pll,plr])+point(pll,size=5)+point(plr,size=5) right_eye=line([prl,prr],color='green')+point(prl,size=5,color='green')+point(prr,size=5,color='green') mouth=parametric_plot(M*vector([t, -0.15*sin(2*pi*t)-0.5]), (t, -0.5, 0),color='red')+parametric_plot(M*vector([t, -0.15*sin(2*pi*t)-0.5]), (t,0,0.5),color='orange') face=parametric_plot(M*vector([cos(t),sin(t)]), (t,0,pi/2),color='black')+parametric_plot(M*vector([cos(t),sin(t)]), (t,pi/2,pi),color='lavender')+parametric_plot(M*vector([cos(t),sin(t)]), (t,pi,3*pi/2),color='cyan')+parametric_plot(M*vector([cos(t),sin(t)]),(t,3*pi/2,2*pi),color='sienna') return right_eye+left_eye+face+mouth html('smiley guy, transformed by $A$') IDface = makeface(ID) Aface = makeface(A) for ev in A.eigenvectors_right(): val = ev[0] ev = ev[1] for vect in ev: try: vect.change_ring(RR) html("There is an eigenvector with eigenvalue $%s$"%val) IDface += plot(vect) Aface += plot(A*vect) except ValueError: pass G = graphics_array([[IDface,Aface]]) G.show(aspect_ratio=1) 
       
smiley guy, transformed by 
There is an eigenvector with eigenvalue 
There is an eigenvector with eigenvalue 
smiley guy, transformed by 
There is an eigenvector with eigenvalue 
There is an eigenvector with eigenvalue 

Notice how the images of the vectors are about the same length.  But that is sheer coincidence; the important point is that the eigenvectors are expanded by the eigenvalue.  Here is a different basis.

t = var('t') A=matrix([[7,2],[-4,1]]) ID = matrix(RDF,[[1,0],[0,1]]) def makeface(M): pll=M*vector((-0.5,0.5)) plr=M*vector((-0.3,0.5)) prl=M*vector((0.3,0.5)) prr=M*vector((0.5,0.5)) left_eye=line([pll,plr])+point(pll,size=5)+point(plr,size=5) right_eye=line([prl,prr],color='green')+point(prl,size=5,color='green')+point(prr,size=5,color='green') mouth=parametric_plot(M*vector([t, -0.15*sin(2*pi*t)-0.5]), (t, -0.5, 0),color='red')+parametric_plot(M*vector([t, -0.15*sin(2*pi*t)-0.5]), (t,0,0.5),color='orange') face=parametric_plot(M*vector([cos(t),sin(t)]), (t,0,pi/2),color='black')+parametric_plot(M*vector([cos(t),sin(t)]), (t,pi/2,pi),color='lavender')+parametric_plot(M*vector([cos(t),sin(t)]), (t,pi,3*pi/2),color='cyan')+parametric_plot(M*vector([cos(t),sin(t)]),(t,3*pi/2,2*pi),color='sienna') return right_eye+left_eye+face+mouth html('smiley guy, transformed by $A$') IDface = makeface(ID) Aface = makeface(A) R = -1 for ev in A.eigenvectors_right(): val = ev[0] ev = ev[1] for vect in ev: try: vect.change_ring(RR) vect = R*vect R = R+2 html("There is an eigenvector with eigenvalue $%s$"%val) IDface += plot(vect) Aface += plot(A*vect) except ValueError: pass G = graphics_array([[IDface,Aface]]) G.show(aspect_ratio=1) 
       
smiley guy, transformed by 
There is an eigenvector with eigenvalue 
There is an eigenvector with eigenvalue 
smiley guy, transformed by 
There is an eigenvector with eigenvalue 
There is an eigenvector with eigenvalue 

The point is that, in any eigenbasis, the matrix really should just be $$\left[\begin{array}{cc}5 & 0\\0 & 3\end{array}\right]$$  That is what diagonalization will do for us.  So all we have to do is figure out how to interpret this correctly - and that is by finding the matrix of a linear transformation with respect to a given basis, just like we found the representation of a vector with respect to different bases.

M = matrix([[1,1,1],[0,1,1],[0,0,1]]) 
       
M^-1 
       
[ 1 -1  0]
[ 0  1 -1]
[ 0  0  1]
[ 1 -1  0]
[ 0  1 -1]
[ 0  0  1]
M*matrix([[0,1,1],[0,0,2],[0,0,0]])*M^-1 
       
[0 1 2]
[0 0 2]
[0 0 0]
[0 1 2]
[0 0 2]
[0 0 0]
M^-1*matrix([[0,1,0],[0,0,2],[0,0,0]])*M 
       
[ 0  1 -1]
[ 0  0  2]
[ 0  0  0]
[ 0  1 -1]
[ 0  0  2]
[ 0  0  0]