[U,V]=eig(A) , AU won't equal UV

조회 수: 3 (최근 30일)
steam086
steam086 2019년 11월 19일
편집: Bhaskar R 2019년 11월 19일
My understanding with [U,V]=eig(A) is that AU=UV, however, in some cases with matlab, these this is not true.
It works with A=diag([3, 3, 3, 2, 2, 1]), but not with A=magic(4) or A=ones(4)
matlab help.png
Is AU=UV supposed to hold true or will they not equal each other in certain cases?

채택된 답변

Bhaskar R
Bhaskar R 2019년 11월 19일
편집: Bhaskar R 2019년 11월 19일
In general terms A*U and U*V are equal but in MATLAB it computes with difference in decimal points almost at 15th decimal value as you see
A=magic(4);
[U,V]=eig(A);
format long
>> A*U
-17.000000000000000 -7.366563145999501 -3.366563145999497 -0.000000000000001
-17.000000000000000 3.788854381999832 -0.211145618000169 0.000000000000007
-17.000000000000000 0.211145618000165 -3.788854381999833 0.000000000000004
-17.000000000000000 3.366563145999499 7.366563145999495 0.000000000000006
>> U*V
-17.000000000000000 -7.366563145999498 -3.366563145999494 0.000000000000000
-16.999999999999993 3.788854381999834 -0.211145618000169 0.000000000000001
-17.000000000000004 0.211145618000170 -3.788854381999831 -0.000000000000001
-16.999999999999996 3.366563145999493 7.366563145999494 -0.000000000000000
as you can see that there is a difference at 15th decimal point thats why your if condition is failing each time
And one more thing you can't use A*U == U*V in if condition cause it produces matrix instead of a logical condition, use as isequal(A*U, U*V).

추가 답변 (1개)

Erivelton Gualter
Erivelton Gualter 2019년 11월 19일
It is not a bug.
It depends of the floating point numbers. If you type the following, you will observe that the floating point is equivalent to 2.2204e-16:
eps
Now, try the following:
A*U - U*V
It is almost zero. Maybe aroung 10^-15 for your case.
There is a better explanation about this matter. But for sure, I know you do not need to worry about the eig function contains a bug or not.

카테고리

Help CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by