필터 지우기
필터 지우기

Matlab gives different eigenvalue for same matrix

조회 수: 4 (최근 30일)
Suma
Suma 2014년 4월 26일
댓글: Suma 2014년 4월 27일
Hello,
why does matlab give me two different eigenvalues for the same matrix? Working for days and found that the source of error is that I get different eigenvalues for same matrix when evaluated in different way and is such that one has even a negative zero(??). I cannot understand the source of error, can anybody help me? below is the code from my work
>> [0.6029;0.0778-0.794*i]
ans =
0.6029
0.0778 - 0.7940i
>> ans*ans'
ans =
0.3635 0.0469 + 0.4787i
0.0469 - 0.4787i 0.6365
>> eig(ans)
ans =
0.0000
1.0000
>> A(:,:,2) =
0.3635 0.0469 + 0.4787i
0.0469 - 0.4787i 0.6365
>> eig(A(:,:,2))
ans =
-0.0000
1.0000
thanks
  댓글 수: 3
Geoff Hayes
Geoff Hayes 2014년 4월 26일
What are you initializing A(:,:,2) with? Are you setting it as
A(:,:,2) = ans*ans';
or
A(:,:,2) = [0.3635 0.0469 + 0.4787i
0.0469 - 0.4787i 0.6365 ];
Because the above two assignments are not strictly the same due to the precision of the doubles written to the console.
For example,
>> ans*ans'
ans =
0.3635 0.0469 + 0.4787i
0.0469 - 0.4787i 0.6365
But if I print out more precision to the doubles then we see that:
>> format long g
>> ans*ans'
ans =
0.36348841 + 0i 0.04690562 + 0.4787026i
0.04690562 - 0.4787026i 0.63648884 + 0i
So I think that is reasonable that you are observing two sets of slighty different eigenvalues (note that your 0.0000 and -0.0000 are both small and nearly identical; the use of format long g would probably show more information) since you are inputs are slightly different (one set more precise than the other).
Suma
Suma 2014년 4월 26일
Hi,
No I am not setting A(:,:,2) = ans*ans';
actually A(:,:,k) for k=1:N are matrices that I get in my program, they in turn are dependent on multiplication of column vectors formed by random variables rand.
after searching for the reason why i get complex number I came to know that A(:,:,k) =A(:,:,2) gives me eigenvalues -0.0000 and 1.0000. I tracked its matrix value and found that it was 0.3635 0.0469 + 0.4787i 0.0469 - 0.4787i 0.6365
So I again recomputed the column vector source that gave me the A(:,:,2) matrix which was 0.6029 0.0778 - 0.7940i
doing multiplication of this matrix as [ 0.6029;0.0778 - 0.7940i]*[ 0.6029;0.0778 - 0.7940i]' or ans*ans' gave me the same matrix(of course), 0.3635 0.0469 + 0.4787i 0.0469 - 0.4787i 0.6365
but now its eigen value are simply 0.0000 1.0000
Having explained this, if the matrix that the program generated (hence matlab) is alright because of precision then I get negative eigenvalue. But this is in contradiction to expected real eigenvalue of the matrix.
On the other hand if the precision is be limited (IDK how), so that I get real eigenvalues(non-negative) then it would make my work easier. But then I would be doing assumption rather than working with real precised mathematical values that matlab is providing.
Of course I want exact results and results are sensitive but don't know how to resolve the above stated problem.
Thanks

댓글을 달려면 로그인하십시오.

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 26일
  댓글 수: 1
Suma
Suma 2014년 4월 27일
Hi,
I looked at the wiki but didn't find what I am looking for. For one thing, I did try solving the problem by converting to single precision format but it didn't work.
I want to convert the negative eiqen values to positive.
Thanks

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Eigenvalues & Eigenvectors에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by