Monday, May 24, 2010

Eigenvectors calculation (from Numerical Recipes in C book)?

Hi,


I implemented the algorithms tred2() (page 474) and tqli() (page 480) for calculating eigenvectors and eigenvalues of real matrices, and comparing the results to the ones obtained with MatLab, some of the eigenvectors have the opposite sign. Every single value is ok, but the vector seems to be multiplied by -1.





Does anyone know why is this, and if this is actually an error?





Thanks in advance.





PS: the book can be found online at





http://www.nr.com/nronline_switcher.php

Eigenvectors calculation (from Numerical Recipes in C book)?
Eigenvectors are not unique. If your matrix has an eigenvector of





[ 1, -2]'





for example, then any multiple of that eigenvector is also an eigenvector for that hypothetical matrix, so





[2, -4]'


[50, -100]'


[-1, 2]'


[-1000, 2000]'





are all eigenvectors for this hypothetical matrix. That is because for any square matrix A with eigenvector x corresponding to eigenvalue λ and for any constant c





A(c*x) = c*Ax


= c*λx


= λ(c*x)





Which means that c*x is an eigenvector for A.





So, there is no error. Some are just multiplied by -1. You're good.





edit: No, the eigenvalues do not change. Note in my "proof" above that the same eigenvalue λ was used for the vectors x and c*x. Like I said, eigenvectors aren't unique; not even for a particular eigenvalue.





Here's an example.





A =


[ 4 -2 ]


[ 1 1]





x =


[ 2 ]


[ 1 ]





Ax =


[ 6 ]


[ 3 ]


= 3x





So x is an eigenvector of A with an eigenvalue of 3. Now let's look at y = -x = [-2 -1]'.





Ay =


[ -6 ]


[ -3 ]


= 3y





So y = -x is also an eigenvector of A with an eigenvalue of 3.





I can't message you, so send me a message if you have any questions.


No comments:

Post a Comment