MATLAB: Eig command returning wrong eigenvectors

calculationeigeigenvalueeigenvectorwrong value

Hi!
I am very new to using Matlab, so this question might seem silly.
I have a matrix:
K =
-7 -18 -18 9 27
0 3 0 0 0
-8 -12 -5 7 17
-10 -16 -20 10 25
-6 -10 -6 6 17
My goal is to calculate the eigenvectors and eigenvalues, which I attempt by using the command
[M,N] = eig(A)
This command gives my two new matrices, one with the values and the other with the vectors. I get the right results for the values: 2, 3 and 5 (3 and 5 twice) but the vectors aren't correct:
M =
273/1520 * 647/2153 -509/586 *
0 0 0 0 310/409
-273/1520 888/2737 2811/5162 266/1651 283/1695
273/304 -2220/2737 -847/1906 -452/1003 -293/7624
-273/760 1332/2737 813/1261 -446/3473 873/1387
The vectors should instead be something along the lines of (-1/2,0,1/2,-5/2,1).
What am I doing wrong? (I am assuming it's me and not the program)
Thanks in advance!

Best Answer

Doing wrong? First, it looks like you have format set to rat.
[V,D] = eig(K);
V
V =
0.179605302026751 -5.06266247219048e-14 0.300510985421823 -0.868600674748355 1.49364371455249e-15
0 0 0 0 0.757946284651594
-0.179605302026794 0.324442842261484 0.544556381601175 0.161114353924498 0.166961764835024
0.898026510133868 -0.811107105653849 -0.444386053127199 -0.45064791217395 -0.0384312697617635
-0.359210604053568 0.486664263392254 0.644726710075106 -0.128419204324953 0.629415789578334
diag(D)
ans =
2.00000000000014
2.99999999999972
5.00000000000016
5
3
So eigenvalues of 2,3,5, the latter are of essentially multiplicity 2 each, if we ignore the trash in those least significant bits.
How about the eigenvectors?
You need to recognize that an eigenvector is unique only to within a scale factor. An eigenvector (V) basically has the property
K*V = lambda*V
for corresponding eigenvalue lambda.
But if that holds, then surely
K*(s*V) = lambda*(s*V)
for any scalar value s. So what happens if you scale those eigenvectors?
V(:,1)/V(1,1)
ans =
1
0
-1.00000000000024
5.00000000000064
-2.00000000000037
How interesting.
So eig is NOT returning the wrong eigenvectors. It merely normalizes the eigenvectors so they have unit norm. Your expectations were wrong.
norm(V(:,1))
ans =
1
But that is just scaling the vectors by a constant. And we just discussed that that constant is completely arbitrary. At the same time, having unit normalized eigenvectors is very useful in mathematics.