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

3 次查看(过去 30 天)
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