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!