Lay Chapter 5,
Eigenvalues and Eigenvectors

Eigenvalues and Eigenvectors

Mathematica has several commands for working with eigenvalues and eigenvectors.

In[1]:=

Clear[a] 

a = ( {{1, 2, 3}, {1, 2, 3}, {1, 2, 3}} ) ;

In[3]:=

eigenvals = Eigenvalues[a]

Out[3]=

{6, 0, 0}

Since the Eigenvectors command returns a list eigenvectors, those eigenvectors will appear as rows of a matrix.
It is frequently convenient to reassemble them as columns of a matrix.

In[4]:=

eigenvecsRows = Eigenvectors[a] ;

%//MatrixForm

eigenvecs = Transpose[eigenvecsRows] ;

%//MatrixForm

Out[5]//MatrixForm=

( {{1, 1, 1}, {-3, 0, 1}, {-2, 1, 0}} )

Out[7]//MatrixForm=

( {{1, -3, -2}, {1, 0, 1}, {1, 1, 0}} )

The Eigensystem command returns both eigenvalues and eigenvectors.

In[8]:=

Eigensystem[a] ;

Map[MatrixForm, %]

Out[9]=

{( {{6}, {0}, {0}} ), ( {{1, 1, 1}, {-3, 0, 1}, {-2, 1, 0}} )}

Diagonalization of a matrix,   A == P^(-1).Λ.P

An important result from linear algebra takes the form

In[10]:=

(* P . A . P^(-1)  Λ and A  P^(-1) . Λ . P *)

when the matrix A is diagonalizable. Let's work towards that result.

In[11]:=

diagλ = DiagonalMatrix[eigenvals] ;

%//MatrixForm

Out[12]//MatrixForm=

( {{6, 0, 0}, {0, 0, 0}, {0, 0, 0}} )

Now, observe.

In[13]:=

a . eigenvecs ;

%//MatrixForm

Out[14]//MatrixForm=

( {{6, 0, 0}, {6, 0, 0}, {6, 0, 0}} )

In[15]:=

eigenvecs . diagλ ;

%//MatrixForm

Out[16]//MatrixForm=

( {{6, 0, 0}, {6, 0, 0}, {6, 0, 0}} )

Therefore,

In[17]:=

Inverse[eigenvecs] . a . eigenvecs ;

%//MatrixForm

diagλ  Inverse[eigenvecs] . a . eigenvecs

Out[18]//MatrixForm=

( {{6, 0, 0}, {0, 0, 0}, {0, 0, 0}} )

Out[19]=

True

and

In[20]:=

eigenvecs . diagλ . Inverse[eigenvecs] ;

%//MatrixForm

a  eigenvecs . diagλ . Inverse[eigenvecs]

Out[21]//MatrixForm=

( {{1, 2, 3}, {1, 2, 3}, {1, 2, 3}} )

Out[22]=

True

Another Matrix Diagonalization,   A == P^(-1).Λ.P

In[23]:=

Clear[a] 

a = ( {{-6, 4, 0, 9}, {-3, 0, 1, 6}, {-1, -2, 1, 0}, {-4, 4, 0, 7}} ) ;

In[25]:=

eigenvals = Eigenvalues[a]

Out[25]=

{5, -2, -2, 1}

In[26]:=

eigenvecsRows = Eigenvectors[a] ;

%//MatrixForm

eigenvecs = Transpose[eigenvecsRows] ;

%//MatrixForm

Out[27]//MatrixForm=

( {{2, 1, -1, 2}, {6, -3, 0, 4}, {1, 1, 1, 0}, {2, -1, -7, 2}} )

Out[29]//MatrixForm=

( {{2, 6, 1, 2}, {1, -3, 1, -1}, {-1, 0, 1, -7}, {2, 4, 0, 2}} )

In[30]:=

Eigensystem[a] ;

Map[MatrixForm, %]

Out[31]=

{( {{5}, {-2}, {-2}, {1}} ), ( {{2, 1, -1, 2}, {6, -3, 0, 4}, {1, 1, 1, 0}, {2, -1, -7, 2}} )}

In[32]:=

diagλ = DiagonalMatrix[eigenvals] ;

%//MatrixForm

Out[33]//MatrixForm=

( {{5, 0, 0, 0}, {0, -2, 0, 0}, {0, 0, -2, 0}, {0, 0, 0, 1}} )

Now, observe.

In[34]:=

a . eigenvecs ;

%//MatrixForm

Out[35]//MatrixForm=

( {{10, -12, -2, 2}, {5, 6, -2, -1}, {-5, 0, -2, -7}, {10, -8, 0, 2}} )

In[36]:=

eigenvecs . diagλ ;

%//MatrixForm

Out[37]//MatrixForm=

( {{10, -12, -2, 2}, {5, 6, -2, -1}, {-5, 0, -2, -7}, {10, -8, 0, 2}} )

Therefore,

In[38]:=

Inverse[eigenvecs] . a . eigenvecs ;

%//MatrixForm

diagλ  Inverse[eigenvecs] . a . eigenvecs

Out[39]//MatrixForm=

( {{5, 0, 0, 0}, {0, -2, 0, 0}, {0, 0, -2, 0}, {0, 0, 0, 1}} )

Out[40]=

True

and

In[41]:=

eigenvecs . diagλ . Inverse[eigenvecs] ;

%//MatrixForm

a  eigenvecs . diagλ . Inverse[eigenvecs]

Out[42]//MatrixForm=

( {{-6, 4, 0, 9}, {-3, 0, 1, 6}, {-1, -2, 1, 0}, {-4, 4, 0, 7}} )

Out[43]=

True

Characteristic Polynomial

Calculate the characteristic polynomial of a certain square matrix.

In[44]:=

Clear[a, λ, id] 

a = ( {{1, 2}, {3, 4}} ) ;

id = IdentityMatrix[2] ; 

ch[λ_] = Det[a - λ id]

Out[47]=

-2 - 5 λ + λ^2

Roots of ch[λ] are eigenvalues of a.

In[48]:=

Solve[ch[λ] 0, λ]//Flatten

Out[48]=

{λ1/2 (5 - 33^(1/2)), λ1/2 (5 + 33^(1/2))}

Complex Eigenvalues

In[49]:=

Clear[a] 

a = ( {{1, -2}, {1, 3}} ) ;

In[51]:=

eigenvals = Eigenvalues[a]

Out[51]=

{2 + , 2 - }

In[52]:=

eigenvecsRows = Eigenvectors[a] ;

%//MatrixForm

eigenvecs = Transpose[eigenvecsRows] ;

%//MatrixForm

Out[53]//MatrixForm=

( {{-1 + , 1}, {-1 - , 1}} )

Out[55]//MatrixForm=

( {{-1 + , -1 - }, {1, 1}} )

In[56]:=

Eigensystem[a] ;

Map[MatrixForm, %]

Out[57]=

{( {{2 + }, {2 - }} ), ( {{-1 + , 1}, {-1 - , 1}} )}

In[58]:=

diagλ = DiagonalMatrix[eigenvals] ;

%//MatrixForm

Out[59]//MatrixForm=

( {{2 + , 0}, {0, 2 - }} )

Now, observe.

In[60]:=

a . eigenvecs ;

%//MatrixForm

Out[61]//MatrixForm=

( {{-3 + , -3 - }, {2 + , 2 - }} )

In[62]:=

eigenvecs . diagλ ;

%//MatrixForm

Out[63]//MatrixForm=

( {{-3 + , -3 - }, {2 + , 2 - }} )

Therefore,

In[64]:=

Inverse[eigenvecs] . a . eigenvecs ;

%//MatrixForm

diagλ  Inverse[eigenvecs] . a . eigenvecs

Out[65]//MatrixForm=

( {{2 + , 0}, {0, 2 - }} )

Out[66]=

True

and

In[67]:=

eigenvecs . diagλ . Inverse[eigenvecs] ;

%//MatrixForm

a  eigenvecs . diagλ . Inverse[eigenvecs]

Out[68]//MatrixForm=

( {{1, -2}, {1, 3}} )

Out[69]=

True

Polar Form of a Matrix

In[70]:=

Clear[m, a, b, φ, rot, r] 

a = 3^(1/2) ;

b = 1 ; 

m = ( {{a, -b}, {b, a}} ) ;

%//MatrixForm

Out[74]//MatrixForm=

( {{3^(1/2), -1}, {1, 3^(1/2)}} )

Find the angle of the rotation.

In[75]:=

φ = ArcTan[b/a]

Out[75]=

π/6

... and compute the rotation matrix.

In[76]:=

rot[φ_] := ({{Cos[φ], -Sin[φ]}, {Sin[φ], Cos[φ]}}) ; 

rot[φ] ;

%//MatrixForm

Out[78]//MatrixForm=

( {{3^(1/2)/2, -1/2}, {1/2, 3^(1/2)/2}} )

Find the scaling factor.

In[79]:=

r =    (a^2 + b^2)^(1/2)

Out[79]=

2

Check the decomposition.

In[80]:=

m  r rot[φ]

Out[80]=

True

The Rotation Due to a Complex Eigenvalue

If a real 2x2 matrix has a complex eigenvalue, a particular decomposition will display the rotation "hidden within."
See Lay 5.5, pp. 338--341.

In[81]:=

Clear[m, a, b, c, p] ; 

m = ( {{1, -2}, {1, 3}} ) ;

%//MatrixForm

Out[83]//MatrixForm=

( {{1, -2}, {1, 3}} )

In[84]:=

evals = Eigenvalues[m]

Out[84]=

{2 + , 2 - }

Construct the matrix c.

In[85]:=

a = Re[evals[[1]]] ;

b = -Im[evals[[1]]] ; 

c = ( {{a, -b}, {b, a}} ) ;

%//MatrixForm

Out[88]//MatrixForm=

( {{2, 1}, {-1, 2}} )

Construct the matrix p.

In[89]:=

evecs = Eigenvectors[m]

Out[89]=

{{-1 + , 1}, {-1 - , 1}}

In[90]:=

p1 = Re[evecs[[1]]] ;

p2 = Im[evecs[[1]]] ; 

p = Transpose[{p1, p2}] ;

%//MatrixForm

Out[93]//MatrixForm=

( {{-1, 1}, {1, 0}} )

Check these results.
We should find that m = p.c.Inverse[p] where c is a polar matrix (rotation with scaling).

In[94]:=

p . c . Inverse[p] ;

%//MatrixForm

m  p . c . Inverse[p]

Out[95]//MatrixForm=

( {{1, -2}, {1, 3}} )

Out[96]=

True


Created by Mathematica  (February 22, 2005) Valid XHTML 1.1!