This is an old revision of the document!


Eigensystem

Matrix.Eigensystem(M) calculates the eigenvalues and eigenvectors of the square matrix M. If M is Hermitian it returns the eigenvalues and a single eigenvector, if M is non-hermitian it returns both the left and right eigenvectors

Example

For an Hermitian matrix

Input

Example.Quanty
A = Matrix.New({{1,2,3},
                {2,3,5},
                {3,5,1}})
val, fun = Eigensystem(A)
print("The eigenvalues are\n",val)
print("The eigenfunctions are\n",fun)
print("The matrix transformed to a diagonal matrix by its eigenfunctions is\n",Chop( Matrix.Conjugate(fun) * A * Matrix.Transpose(fun)) )

Result

The eigenvalues are
{ -3.4339294734789 , -0.23514404390394 , 8.6690735173829 }
The eigenfunctions are
{ {  0.3019 ,  0.5247 , -0.796  } ,
  {  0.8587 , -0.5123 , -0.012  } ,
  {  0.4141 ,  0.6799 ,  0.6052 } }
 
The matrix transformed to a diagonal matrix by its eigenfunctions is
{ { -3.4339 ,  0      ,  0      } ,
  {  0      , -0.2351 ,  0      } ,
  {  0      ,  0      ,  8.6691 } }

Example

For a non-Hermitian matrix

Input

Example.Quanty
A = Matrix.New({{1,1,3},
                {5,3,7},
                {3,5,1}})
val, funL, funR = Eigensystem(A)
print("The eigenvalues are\n",val)
print("The left  eigenfunctions are\n",funL)
print("The right eigenfunctions are\n",funR)
print("The matrix transformed to a diagonal matrix by its eigenfunctions is\n",Chop( Matrix.Conjugate(funL) * A * Matrix.Transpose(funR)) )

Result

WARNING: non hermitian matrix found
Using left and right handed eigensystem
With potential complex eigenvalues
The eigenvalues are
{ -3.8133538424944 , -0.86687641096757 , 9.680230253462 }
The left  eigenfunctions are
{ {  0.139          , -0.6419         ,  0.847          } ,
  { -0.974          ,  0.4605         , -0.1613         } ,
  { -0.5567         , -0.5736         , -0.655          } }
 
The right eigenfunctions are
{ { -0.3991         , -0.5551         ,  0.8254         } ,
  { -0.9178         ,  0.3854         ,  0.4427         } ,
  { -0.2901         , -0.8128         , -0.5684         } }
 
The matrix transformed to a diagonal matrix by its eigenfunctions is
{ { -3.8134 ,  0      ,  0      } ,
  {  0      , -0.8669 ,  0      } ,
  {  0      ,  0      ,  9.6802 } }

Example

For an Hermitian matrix with small non-Hermitian part

Input

Example.Quanty
A = Matrix.New({{1,1,3},
                {1-2E-10,3,7},
                {3,5,1}})
val, funL, funR = Eigensystem(A)
print("The eigenvalues are\n",val)
print("The left  eigenfunctions are\n",funL)
print("The right eigenfunctions are\n",funR)
print("The matrix transformed to a diagonal matrix by its eigenfunctions is\n",Chop( Matrix.Conjugate(funL) * A * Matrix.Transpose(funR)) )
 
print("Be carefull, using only the left handed eigenvectors is not sufficient to diagonalize the matrix\n",Chop( Matrix.Conjugate(funL) * A * Matrix.Transpose(funL)) )

Result

WARNING: non hermitian matrix found
Using left and right handed eigensystem
With potential complex eigenvalues
The eigenvalues are
{ -4.5383431004156 , 0.59104712937687 , 8.9472959710387 }
The left  eigenfunctions are
{ { -0.3497         , -0.4901         ,  0.8089         } ,
  { -0.924          ,  0.3964         , -0.0062         } ,
  { -0.3429         , -0.6415         , -0.6945         } }
 
The right eigenfunctions are
{ { -0.2791         , -0.6392         ,  0.7283         } ,
  { -0.8588         ,  0.5199         , -0.0562         } ,
  { -0.3174         , -0.7492         , -0.5912         } }
 
The matrix transformed to a diagonal matrix by its eigenfunctions is
{ { -4.5383 ,  0      ,  0      } ,
  {  0      ,  0.591  ,  0      } ,
  {  0      ,  0      ,  8.9473 } }
 
Be carefull, using only the left handed eigenvectors is not sufficient to diagonalize the matrix
{ { -4.6149 , -0.562  ,  0.5784 } ,
  {  0.0732 ,  0.5976 ,  0.0395 } ,
  { -1.1403 ,  0.598  ,  9.0498 } }

Table of contents

Print/export