문제

I am trying to write a function in C which returns the eigenvalues and eigenvectors of a 2x2 matrix (looking for the eigen-values/vectors programatically). I've no problem with the eigenvalues which is fairly straightforward. But struggle with the eigenvectors, which is essentially solved by a system of simultaneous equations.

If I try a method such as: Solving a simultaneous equation through code this gives me a trivial solutions ([0,0]), as u=0 and v=0, in the case of eigenvectors.

eg. if my matrix is MAT = [[3,2],[2,1]], ie. a=3, b=2, c=2 and d=1, and u=0 and v=0, the equations suggested in the above link y = (v - uc/a) / (d - bc/a) and x = (uc/a - bc/a * y) / c, will equate to the solution [0,0], ie. the trivial solution.

Also, this seemingly provides an answer but I can't generate an example which agrees with the equations on: http://www.math.harvard.edu/archive/21b_fall_04/exhibits/2dmatrices/index.html

it also doesn't seem to cover all cases, what about the case when b and c are not equal to zero?

도움이 되었습니까?

해결책

For the case of a 2x2 matrix, there is a simple analytical solution.

Your function should implement the solution presented at this link, with the three subcases. You may want to normalize the eigenvectors to unitary modulus as an additional step at the end.

다른 팁

Once you have the eigenvalues, the eigenvectors are easy to get.

I'd recommend an iterative method like Jacobi if your matrix is symmetric.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top