问题
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't confirm that the eigenvectors are orthogonal as they should be in this case. any reason why this would be? or how to fix it?
import scipy as SP
import numpy as NP
from scipy import linalg
from numpy import linspace,asscalar,argsort
import cmath
import time
matA=SP.array([[-0.0001, 0., 0., 0.00001, 0., 0., 0.00002, 0.],[0., -0.0002, 0.,
0., 0., 0., 0., 0.],[0., 0., -0.00015, 0., 0., -9.*10**-6,
0., -0.00005],[0.00001, 0., 0., -0.0001, 0., 0.00001, 1.*10**-6,
0.],[0., 0., 0., -5.*10**-6, -0.0001, 0., 0., 0.],[0., -9.*10**-6,
0., 0.00001, 0., -0.0002, 0., 0.00005],[0., 0., 0., 0.00002, 0.,
0., -0.0001, 0.],[0., 0.00004, 0., 0., 0., 0.00005, 0., -0.00015]])
matB=SP.array([[0., 0., 0., 0., 0., 0., 0., 0.],[0., 0., 1.5*10**-10, 0., 0., 0.,
0., 0.],[0., -1.5*10**-10, 0., 0., 0., 0., 0., 0.],[0., 0., 0., 0.,
0., 0., 0., 0.],[0., 0., 0., 0., 0., 3.*10**-10, 0., 0.],[0., 0.,
0., 0., -3.*10**-10, 0., 2.*10**-10, 0.],[0., 0., 0., 0.,
0., -2.*10**-10, 0., 0.],[0., 0., 0., 0., 0., 0., 0., 0.]])
matdim=len(matB[0])
#coefficient matrix for original ODE
def matM(x):
return matA+(x**2)*matB
#define sorted eigensystem function
def eigsys(x):
evs,EVS=linalg.eig(matM(x),check_finite=False)
absevs=abs(evs)
idx=argsort(absevs)[::-1]
evs=evs[idx]
EVS=EVS[:,idx]
return (evs,EVS)
#check for orthogonality
eigvecs=SP.transpose(eigsys(60000)[1])
for j in range(8):
for i in range(8):
print SP.vdot(eigvecs[i],eigvecs[j])
#show eigenvalues all have multiplicity 1
print eigsys(60000)[0]
回答1:
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?
来源:https://stackoverflow.com/questions/25430583/eigenvectors-from-numpy-eig-not-orthogonal