Calculating eigenvectors/values of a 2x2 tensor
I'm implementing the system described within this paper, and I'm getting a little stuck. I only recently encountered tensors/eigenvalues etc so excuse me if this is a lit开发者_如何学运维tle simple!
Given a 2x2 tensor, how can I calculate the major and minor eigenvectors of it?
Bonus points for implementations which are easy to translate into C# ;)
(I'm using MATLAB matrix notation; semicolons mean "new row".)
[u;v] is an eigenvector of [a b; c d] with eigenvalue t if [a b; c d] [u;v] = t[u;v]. That means that au+bv=tu and cu+bv=tv; that is, (a-t)u+bv=0 and cu+(d-t)v=0. If this has any nontrivial solutions, it's because those two equations are the same apart from a constant factor; then your eigenvector is [u;v] = [b;t-a]. (Unique only up to a constant factor, of course.)
The eigenvalues are the values of t for which this is possible; that is, for which those two equations are the same apart from a constant factor. That happens iff the matrix [a-t b; c d-t] is singular, which means its determinant is zero, which means (a-t)(d-t)-bc=0, which means t^2 - (a+d)t + (ad-bc) = 0.
So: Solve that equation for the eigenvalues, and then get the eigenvectors the way I described above.
The eigenvalues may be complex (e.g., for a rotation). In that case you'll get complex eigenvectors too, which is correct because you can't have Av=kv with A,v real but k not real.
Two warnings.
Some matrices have two equal eigenvalues. They may or may not have two independent eigenvectors. If the matrix is a constant multiple of the identity matrix -- of the form [k 0; 0 k] -- then it does have two independent eigenvectors, and in fact any two independent vectors will do, because everything is an eigenvector. Otherwise, there is only one eigenvector and any theorems or algorithms that rely on having two are liable to fail. This will happen, e.g., with "shear" matrices of the form [1 k; 0 1].
In dimensions higher than 2, you don't want to do things this way. There are much better (but more complicated) ways of computing eigenvectors and eigenvalues, and the ways in which you can fail to have the "right" number of independent eigenvectors are more extensive.
精彩评论