Matlab gives different eigenvalue for same matrix

7 views (last 30 days)
Suma
Suma on 26 Apr 2014
Commented: Suma on 27 Apr 2014
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 Comments
Geoff Hayes
Geoff Hayes on 26 Apr 2014
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 on 26 Apr 2014
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

Sign in to comment.

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 26 Apr 2014
  1 Comment
Suma
Suma on 27 Apr 2014
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

Sign in to comment.

Categories

Find more on Eigenvalues & Eigenvectors in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!