I have a matrix A
as below:
A
Out[34]:
array([[1, 1, 1, 1, 0, 0, 0, 0],
[1, 1, 1, 1, 0, 0, 0, 0],
[1, 1, 1, 1, 0, 0, 0, 0],
[1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1],
[0, 0, 0, 0, 1, 1, 1, 1],
[0, 0, 0, 0, 1, 1, 1, 1],
[0, 0, 0, 0, 1, 1, 1, 1]])
I want to find the eigenvalues and eigenvectors.
Consider a vector x
as below:
x
Out[35]: array([4, 4, 4, 4, 0, 0, 0, 0])
This is an eigenvector as can be seen below:
np.matmul(A, x) == 4 * x
Out[36]: array([ True, True, True, True, True, True, True, True])
(np.matmul(A, x) == 4 * x).all()
Out[37]: True
But, when I compute the eigenvectors using np.linalg.eig
, it does not include x (or a scaled vector of x).
l, v = np.linalg.eig(A)
l
Out[40]: array([0., 4., 0., 0., 0., 4., 0., 0.])
v
Out[41]:
array([[-8.66025404e-01, 5.00000000e-01, -2.77555756e-17,
-2.77555756e-17, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00],
[ 2.88675135e-01, 5.00000000e-01, -5.77350269e-01,
-5.77350269e-01, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00],
[ 2.88675135e-01, 5.00000000e-01, 7.88675135e-01,
-2.11324865e-01, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00],
[ 2.88675135e-01, 5.00000000e-01, -2.11324865e-01,
7.88675135e-01, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00],
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, -8.66025404e-01, 5.00000000e-01,
-2.77555756e-17, -2.77555756e-17],
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 2.88675135e-01, 5.00000000e-01,
-5.77350269e-01, -5.77350269e-01],
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 2.88675135e-01, 5.00000000e-01,
7.88675135e-01, -2.11324865e-01],
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 2.88675135e-01, 5.00000000e-01,
-2.11324865e-01, 7.88675135e-01]])
Though the eigenvalue 4 is included, the eigenvector is missing. Am I missing something ?
question from:
https://stackoverflow.com/questions/65950798/numpy-linalg-eig-does-not-find-obvious-eigen-vector