my problem is the following: using scipy.linalg.eig to get eigenvectors and eigenvalues i see that all my eigenvalues have multiplicity 1 yet when i run the code below it doesn\
As many others quoted, distinct eigenvalues do not guarantee eigenvectors are orthogonal.
But we have 2 special types of matrices Symmetric matrices and Hermitian matrices.
Here the eigenvalues are guaranteed to be real and there exists a set of orthogonal eigenvectors (even if eigenvalues are not distinct).
In numpy
,
numpy.linalg.eig(any_matrix)
returns eigenvalues and eigenvectors for any matrix (eigen vectors may not be orthogonal)
And we have built-in functionality to find orthogonal eigenvectors for Symmetric and Hermitian matrix.
eigen_values, eigen_vectors = numpy.linalg.eigh(symmetric_matrix)
Note:
numpy.linalg.eigh
will consider only the upper triangular part or lower triangular part of the matrix to calculate eigenvalues (one part is like the mirror image of the other for these special matrices).
So if you pass a matrix which is neither symmetric nor Hermitian to get orthogonal eigenvectors, it will construct a symmetric matrix (not actually constructed, just for our understanding) with lower triangular part of the matrix and return eigenvalues and eigenvectors (they are orthogonal!) of this new matrix. So the answer will be wrong!
For more details, please refer
Eigen values of symmetric matrices
numpy.linalg.eigh
Why should they be orthogonal? Your matrix
a=matM(60000)
is far from being symmetric,
abs(a-a.T).max() -> 2.16
with
abs(a).max() -> 1.08
so I wouldn't necessarily expect orthogonal eigenvectors. Is it possibile that the function matM
or the data matA
or matB
is wrong?