Checking whether two complex matrices are equal
10 ビュー (過去 30 日間)
古いコメントを表示
For matrix A=[3 -3 4;2 3 4;0 -1 1]; I have to prove that eigenvalues of A^2 is equal to square of eigenvalues of A. After obtaining eigenvales I used == to compare results. Both matrix were same but using == gives me result [0 1 1;1 0 1; 1 1 0]. Why?
0 件のコメント
採用された回答
James Tursa
2020 年 8 月 25 日
編集済み: James Tursa
2020 年 8 月 25 日
You can't rely on floating point calculations to give exact results. See this link:
You need to use tolerances for these types of floating point comparisons. E.g.,
>> A = [3 -3 4;2 3 4;0 -1 1];
>> A2 = A*A;
>> eig(A).^2
ans =
-0.999999999999988 +18.973665961010287i
-0.999999999999988 -18.973665961010287i
1.000000000000000 + 0.000000000000000i
>> eig(A2)
ans =
-1.000000000000000 +18.973665961010266i
-1.000000000000000 -18.973665961010266i
1.000000000000001 + 0.000000000000000i
>> eig(A).^2 == eig(A2)
ans =
3×1 logical array
0
0
0
>> abs(eig(A).^2 - eig(A2)) < 1e-10
ans =
3×1 logical array
1
1
1
But, this isn't really a "proof" of course ... just a demonstration within numerical tolerances.
A proof for this case would be to use the Symbolic Toolbox. E.g., start with this:
As = sym(A);
And then work everything with As instead of A. Then see how the results compare ... (hint: you may need to use the simplify( ) function and you may need to reorder the eigenvalues before the comparison)
A general proof for an arbitraty matrix A would be starting with A*x = lambda*x on paper, multiplying both sides by A, and then seeing what you get as a result using hand calculations and simplifying.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Assumptions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!