Matlab Eigenvalue/Vector wrong?!
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Meysam Ahmadi
am 26 Jun. 2019
Bearbeitet: John D'Errico
am 26 Jun. 2019
I am trying to find eigenvalues and vectors of following matrix.
Lsr=[0.0397796877172068 0.0138619531470359 0.0138619531468867 ;
0.0138619531470345 0.0397796877174583 0.0138619531469220;
0.0138619531468881 0.0138619531469388 0.0397796877171021]
[t,el]=eig(Lsr)
But when I reconstruct the matrix with:
X=t*el*t'
I get
X=[0.0403022792872612 0.0124347611687027 0.0147665535551808
0.0124347611687027 0.0406842881257273 0.0143845447169696
0.0147665535551808 0.0143845447169696 0.0383524957387787]
Which is totally off!
Any idea?
2 Kommentare
Walter Roberson
am 26 Jun. 2019
>> Lsr - t*el/t
ans =
0 -5.20417042793042e-18 -3.46944695195361e-18
5.20417042793042e-18 -1.38777878078145e-17 -8.67361737988404e-18
6.93889390390723e-18 3.46944695195361e-18 -6.93889390390723e-18
t' is not expected to be inv(t)
Akzeptierte Antwort
John D'Errico
am 26 Jun. 2019
Bearbeitet: John D'Errico
am 26 Jun. 2019
Um, perhaps you misunderstand what eig does, when the matrix is not the usual, Hermitian symmetric matrix.
Lsr=[0.0397796877172068 0.0138619531470359 0.0138619531468867 ;
0.0138619531470345 0.0397796877174583 0.0138619531469220;
0.0138619531468881 0.0138619531469388 0.0397796877171021];
[V,D] = eig(Lsr);
V =
-0.577350269189232 0.808123905425629 -0.183748102870356
-0.577350269193195 -0.303057917597884 0.780842465815243
-0.577350269186450 -0.505065987828188 -0.597094362953727
D =
0.067503594011158 0 0
0 0.025917734570257 0
0 0 0.025917734570353
Now, do these vectors behave as eigenvalues/eigenvectors? It looks like they do.
>> Lsr*V(:,1) - V(:,1)*D(1,1)
ans =
1.0e-17 *
0
0.693889390390723
0
>> Lsr*V(:,2) - V(:,2)*D(2,2)
ans =
1.0e-16 *
0.069388939039072
0.121430643318376
0.069388939039072
>> Lsr*V(:,3) - V(:,3)*D(3,3)
ans =
1.0e-17 *
-0.346944695195361
-0.693889390390723
-0.346944695195361
So if we multiply the matrix Lsr by an eigenvector, we get the same result, as if we just multiplied that vector by the corresponding eigenvalue. It seems like eig worked. Or did it?
Can you recover Lsr from the form V*D*V'? Well, no. In fact, the matrix Lsr is a defective matrix. This is a common mistake made by people. They assume that all matrices have an eigenvalue decomposition where they can recover the original matrix. But the vectors returned in V are not an orthogonal set.
V'*V
ans =
1.000000000000000 0.000000000000051 0.000000000000348
0.000000000000051 1.000000000000000 -0.083559671916240
0.000000000000348 -0.083559671916240 1.000000000000000
As it turns out, Lsr is not actually a symmetric matrix.
Lsr - Lsr'
ans =
1.0e-13 *
0 0.013999218451133 -0.013999218451133
-0.013999218451133 0 -0.167990621413594
0.013999218451133 0.167990621413594 0
It is close, but not so. We can symmetrize it.
Lsrhat = (Lsr + Lsr')/2;
[Vhat,Dhat] = eig(Lsrhat)
Vhat =
-0.802537691434951 -0.150332699348411 0.577350269189232
0.271076909065118 0.770184377947321 0.577350269193321
0.531460782370591 -0.619851678607487 0.577350269186324
Dhat =
0.025917734570256 0 0
0 0.025917734570353 0
0 0 0.067503594011158
>> Vhat'*Vhat
ans =
1.000000000000000 0.000000000000000 -0.000000000000000
0.000000000000000 1.000000000000000 0.000000000000000
-0.000000000000000 0.000000000000000 1.000000000000000
>> Vhat*Dhat*Vhat' - Lsrhat
ans =
1.0e-16 *
0 0.034694469519536 -0.034694469519536
0.069388939039072 0.346944695195361 -0.017347234759768
-0.034694469519536 -0.052041704279304 0
And now eig is happy. Lsrhat is no longer defective. What is important to see is the tiny change from Lsr to Lsrhat was enough to make a serious change in the eigenvalues and the eigenvectors.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Algebra finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!