I am using numpy to calculate the eigenvalue and eigenvector of a circular matrix. Here is my code(Hji for j=1,2...6 is predefined):
>>> import numpy as np
>>> H = np.array([H1i, H2i, H3i, H4i, H5i, H6i])
>>> H
array([[ 0., 1., 0., 0., 0., 1.],
[ 1., 0., 1., 0., 0., 0.],
[ 0., 1., 0., 1., 0., 0.],
[ 0., 0., 1., 0., 1., 0.],
[ 0., 0., 0., 1., 0., 1.],
[ 1., 0., 0., 0., 1., 0.]])
>>> from numpy import linalg as LA
>>> w, v = LA.eig(H)
>>> w
array([-2., 2., 1., -1., -1., 1.])
>>> v
array([[ 0.40824829, -0.40824829, -0.57735027, 0.57732307, 0.06604706,
0.09791921],
[-0.40824829, -0.40824829, -0.28867513, -0.29351503, -0.5297411 ,
-0.4437968 ],
[ 0.40824829, -0.40824829, 0.28867513, -0.28380804, 0.46369403,
-0.54171601],
[-0.40824829, -0.40824829, 0.57735027, 0.57732307, 0.06604706,
-0.09791921],
[ 0.40824829, -0.40824829, 0.28867513, -0.29351503, -0.5297411 ,
0.4437968 ],
[-0.40824829, -0.40824829, -0.28867513, -0.28380804, 0.46369403,
0.54171601]])
The eigenvalues are correct. However, for the eigenvector, I found out they are not linearly independent
>>> V = np.zeros((6,6))
>>> for i in range(6):
... for j in range(6):
... V[i,j] = np.dot(v[:,i], v[:,j])
...
>>> V
array([[ 1.00000000e+00, -2.77555756e-17, -2.49800181e-16,
-3.19189120e-16, -1.11022302e-16, 2.77555756e-17],
[ -2.77555756e-17, 1.00000000e+00, -1.24900090e-16,
-1.11022302e-16, -8.32667268e-17, 0.00000000e+00],
[ -2.49800181e-16, -1.24900090e-16, 1.00000000e+00,
-1.52655666e-16, 8.32667268e-17, -1.69601044e-01],
[ -3.19189120e-16, -1.11022302e-16, -1.52655666e-16,
1.00000000e+00, 1.24034735e-01, -8.32667268e-17],
[ -1.11022302e-16, -8.32667268e-17, 8.32667268e-17,
1.24034735e-01, 1.00000000e+00, -1.66533454e-16],
[ 2.77555756e-17, 0.00000000e+00, -1.69601044e-01,
-8.32667268e-17, -1.66533454e-16, 1.00000000e+00]])
>>>
You can see there are off-diagonal terms(check V[2,5] = -1.69601044e-01) which means they are not linear independent vectors. Since this is a Hermitian matrix, how can its eigenvectors become dependent?
By the way, I also use matlab to calculate it and it returns the right value
V =
0.4082 -0.2887 -0.5000 0.5000 0.2887 -0.4082
-0.4082 -0.2887 0.5000 0.5000 -0.2887 -0.4082
0.4082 0.5774 0 0 -0.5774 -0.4082
-0.4082 -0.2887 -0.5000 -0.5000 -0.2887 -0.4082
0.4082 -0.2887 0.5000 -0.5000 0.2887 -0.4082
-0.4082 0.5774 0 0 0.5774 -0.4082
D =
-2.0000 0 0 0 0 0
0 -1.0000 0 0 0 0
0 0 -1.0000 0 0 0
0 0 0 1.0000 0 0
0 0 0 0 1.0000 0
0 0 0 0 0 2.0000
The result returned by eig is perfectly fine. This can be seen by
np.allclose(v.dot(np.diag(w)).dot(LA.inv(v)),H)
True
Note that the output of eig corresponds to a factorization of the input matrix of the form v * diag(w) * inv(v), which holds for generic diagonalizable matrices. Since eig treats H as having no special structure the returned eigenvectors are not expected to have a special structure, e.g., orthogonal. (Do not confuse orthogonality with linear independence - the columns of v are indeed linearly independent as can be simply verified by the non-zero LA.det(v).)
Function eigh knows that the input matrix is hermitian and returns a more convenient, i.e., orthogonal, set of eigenvectors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With