MATLAB eig function giving different eigenvectors on different computers?
조회 수: 15 (최근 30일)
이전 댓글 표시
I had my students use [V,D] = eig(A) to compute eigenvectors of the matrix A = [5 -10 -5; 2 14 2; -4 -8 6] as part of an assignment. I noticed they were getting differing results for their V matrices. I investigated this:
On two different machines I own, both having Apple Silicon processors, and using both R2024a and R2024b, the command [V,D] = eig(A) yields the results
V =
0.7454 -0.8234 -0.5750
-0.2981 0.1362 0.5773
0.5963 0.5509 -0.5797
D =
5.0000 0 0
0 10.0000 0
0 0 10.0000
However, when I try the operation using MATLAB online (R2024b) , [V,D] = eig(A) yields the same D matrix but a different V matrix:
V =
-0.7454 -0.0000 -0.6650
0.2981 0.4472 0.5724
-0.5963 -0.8944 -0.4797
Examining my students' answers, most of them match the second result, although a few have the first result.
In both cases the computation A*V - V*D yields a matrix with entries on the order of 1e-14, so all is well numerically in both cases. Anyone know what is causing the difference in results?
댓글 수: 2
Bruno Luong
2024년 10월 11일
This post mainly deal with EIGS not EIG. EIGS is an iterative method with random starting vector that has even more instability issue from run-o-run on the same computer.
채택된 답변
Bruno Luong
2024년 10월 10일
편집: Bruno Luong
2024년 10월 10일
"In both cases the computation A*V - V*D yields a matrix with entries on the order of 1e-14, so all is well numerically in both cases. Anyone know what is causing the difference in results?"
Most likely because the double eigen value 10. The eigen space is then 2-D vector space, the eigen vectors are then arbitrary picked by different library. Nothing to worry since A*V == V*D numerically.
Even for an isolated eigen vector, the correspondign has arbitrary sign in case of real and arbitray complex phase in case of complex. One should not expect the eigen vector returned match on different computers, especially if computer has differnt CPU.
댓글 수: 0
추가 답변 (1개)
Walter Roberson
2024년 10월 10일
MATLAB Online is running using Linux on X64 CPUs, not Apple Silicon.
Apple Silicon uses a different library for the calculations - one optimized by Apple.
It is also likely that different releases of MATLAB for different operating systems and different CPUs use different libraries.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!