Different eigenvectors calculated from Matlab and Python
조회 수: 21 (최근 30일)
이전 댓글 표시
I was studying an eigenvector problem and found Matlab and Python produce different eigenvectors for the same matrix. (The matrix does not have unique eigenvectors) R has the same result with Python. I was wondering the reason of this issue. Thank you!
An example of the matrix is 

댓글 수: 1
Star Strider
2021년 12월 25일
Calculating them manually will also produce different eigenvectors. Eigenvectors are not unique.
답변 (2개)
John D'Errico
2021년 12월 25일
편집: John D'Errico
2021년 12월 25일
Look at it this way. THERE IS NO ISSUE. While you say that R and Python produce the same result, does it matter? (It possibly means that R and Python may both use the same external tool to compute the eigenvalues and eigenvectors.)
You say yourself that the eigenvalues are not unique, because of the eigenvalue of multiplicity 2. But that means MATLAB, or ANY code, could arbitrarily have made a different choice.
A = [1 .4 .4; .4 1 -.4; .4 -.4 1]
[V,D] = eig(A)
The second and third columns are the eigenvectors that correspond to the replicated eigenvalues. Are there different eigenvectors possible? Of course. Rotate them any way you wish.
V23 = V(:,2:3)
lambda = D(2,2)
format long g
A*V23/1.4
As you can see, we get back V23 by this operation. But suppose I rotate the vectors? For example...
rot = @(theta) [cos(theta) sin(theta);-sin(theta) cos(theta)];
V23hat = V23*rot(pi/4)
So what you see are a completely different eigenvector pair. But they are still validly eigenvectors.
A*V23hat/lambda
As you can see, they still work nicely as eigenvectors for that eigenvalue.
Again. There is no issue. The only issue lies in your appreciation of what it means to be non-unique.
Matt J
2021년 12월 25일
편집: Matt J
2021년 12월 25일
Eigenvectors are not unique.
Especially in a symmetric matrix with eigenvalues having multiplicity >1, as is the case here,
eig([1.0000 0.4000 0.4000
0.4000 1.0000 -0.4000
0.4000 -0.4000 1.0000])
Because this matrix is symmetric, the eigenvalue λ=1.4 is guaranteed to have at least two linearly independent eigenvectors. Moreover, every linear combination of those eigenvectors is also an eigenvector for λ=1.4.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!