How is R able to find eigenvectors for the following matrix? Eigenvalues are 2,2 so eigenvectors require solving solve(matrix(c(0,1,0,0),2,2)) which is singular matrix with no solution.
> eigen(matrix(c(2,1,0,2),2,2))
$values
[1] 2 2
$vectors
[,1] [,2]
[1,] 0 4.440892e-16
[2,] 1 -1.000000e+00
> solve(matrix(c(0,1,0,0),2,2))
Error in solve.default(matrix(c(0, 1, 0, 0), 2, 2)) :
Lapack routine dgesv: system is exactly singular
Both the routines essentially do the same thing. They find x such that (A-lambdaI)x = 0 without finding the inverse of A-lambdaI. Clearly (0 1) is a solution but how I can’t understand why solve did not come up with it and how do I manually solve it.
Maybe it’s using one of the algorithms listed here:
http://en.wikipedia.org/wiki/List_of_numerical_analysis_topics#Eigenvalue_algorithms
?
According to http://stat.ethz.ch/R-manual/R-devel/library/base/html/eigen.html,
eigenseems to use the LAPACK routine at http://netlib.org/lapack/double/dgeev.f (if you have a square matrix which is not symmetric).Note: you’re right that
A - lambda * Iis singular if lambda is an eigenvalue but in order to find eigenvectors, one does need invertA - lambda * Ior solve an equationy = (A - lambda * I) * x(withynot being the null vector). It is sufficient to find non-zero vectorsxwhich satisfy(A - lambda * I) * x = 0One strategy is to find a non-singular transformation matrix
Tsuch that(A - lambda * I) * Tis an upper triangular matrix (i.e. all elements below the diagonal are zero). BecauseA-lambda*Iis singular,Tcan be constructed such that the last element on the diagonal (or even more diagonal elements if the multiplicity of the eigenvalue is larger than one) is zero.A vector
zwhich only has it’s last element equal to a non-zero value (i.e.z = (0,....,0,1)) will then give the zero vector when multiplied with(A-lambda *I) * T. So one has:0 = ((A - lambda * I) * T) * zor in other words,
T*zis an eigenvector ofA.