Table of Contents
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-1E-7,3,5}, {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("The left and right hand vectors are now only marginally different\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 { -3.7873476689872 , 0.64886022722351 , 8.1384874417637 } The left eigenfunctions are { { -0.3763 , -0.5129 , 0.7715 } , { -0.853 , 0.5169 , -0.0725 } , { -0.3616 , -0.6854 , -0.632 } } The right eigenfunctions are { { -0.3763 , -0.5129 , 0.7715 } , { -0.853 , 0.5169 , -0.0725 } , { -0.3616 , -0.6854 , -0.632 } } The matrix transformed to a diagonal matrix by its eigenfunctions is { { -3.7873 , 0 , 0 } , { 0 , 0.6489 , 0 } , { 0 , 0 , 8.1385 } } The left and right hand vectors are now only marginally different { { -3.7873 , -5.4e-8 , 2.3e-9 } , { 9.2e-9 , 0.6489 , -6.7e-9 } , { -4.9e-9 , -8.4e-8 , 8.1385 } }