Inicio del mensaje reenviado:
> De: Arnau Mir <arnau....@uib.es> > Fecha: 14 de noviembre de 2011 13:24:31 GMT+01:00 > Para: Martin Maechler <maech...@stat.math.ethz.ch> > Asunto: Re: [R] How to compute eigenvectors and eigenvalues? > > Sorry, but I can't explain very well. > > > The matrix 4*mp is: > > 4*mp > [,1] [,2] [,3] > [1,] 0 1 1 > [2,] 3 0 1 > [3,] 1 3 2 > > > > The eigenvalues are: > lam > [1] 4 -1 -1 > > There is only one eigenvector linearly independent with eigenvalue -1. This > eigenvector is c(0,1,-1) but R computes two eigenvectors: > > > V > [,1] [,2] [,3] > [1,] 0.3207501 1.068531e-08 -1.068531e-08 > [2,] 0.4490502 -7.071068e-01 -7.071068e-01 > [3,] 0.8339504 7.071068e-01 7.071068e-01 > > > One is > V[,2] > [1] 1.068531e-08 -7.071068e-01 7.071068e-01 > > and the other one: > > > V[,3] > [1] -1.068531e-08 -7.071068e-01 7.071068e-01 > > The first component of these two vectors must be zero but due to numerical > errors, R computes 1.068531e-08 and -1.068531e-08 respectively. > > So, the matrix V is singular but R isn't aware of. > > You are right when you say: > > V %*% diag(lam) %*% solve(V) > [,1] [,2] [,3] > [1,] 8.788496e-09 1.000000e+00 1 > [2,] 3.000000e+00 -9.313226e-10 1 > [3,] 1.000000e+00 3.000000e+00 2 > > > but this expression doesn't make any sense because solve(V) doesn't exist. > > What I want is that R responses that mp or 4*mp is not diagonalizable and > solve(V) doesn't exist. > > Arnau. > El 14/11/2011, a las 13:06, Martin Maechler escribió: > >> >>> Consider the following matrix: >> >>>> mp <- matrix(c(0,1/4,1/4,3/4,0,1/4,1/4,3/4,1/2),3,3,byrow=T) >> >>>> mp >>> [,1] [,2] [,3] >>> [1,] 0.00 0.25 0.25 >>> [2,] 0.75 0.00 0.25 >>> [3,] 0.25 0.75 0.50 >> >>> The eigenvectors of the previous matrix are 1, 0.25 and 0.25 and it is not >>> a diagonalizable matrix. >> >>> When you try to find the eigenvalues and eigenvectors with R, R responses: >> >>>> eigen(mp) >> >>> $values >>> [1] 1.00 -0.25 -0.25 >> >>> $vectors >>> [,1] [,2] [,3] >>> [1,] 0.3207501 1.068531e-08 -1.068531e-08 >>> [2,] 0.4490502 -7.071068e-01 -7.071068e-01 >>> [3,] 0.8339504 7.071068e-01 7.071068e-01 >> >>> The eigenvalues are correct but the eigenvectors aren't. >> >> Well, let's look at 4*mp which is an integer matrix: >> >>> (M <- matrix(c(rep(c(0, 3, 1, 1), 2),2), 3,3)); em <- eigen(M); V <- >>> em$vectors; lam <- em$values >> [,1] [,2] [,3] >> [1,] 0 1 1 >> [2,] 3 0 1 >> [3,] 1 3 2 >>> all.equal(M, V %*% diag(lam) %*% solve(V)) >> [1] TRUE >>> zapsmall(V %*% diag(lam) %*% solve(V)) >> [,1] [,2] [,3] >> [1,] 0 1 1 >> [2,] 3 0 1 >> [3,] 1 3 2 >>> >> >> So, as you see V is not singular, >> and the basic property of the eigenvalue decomposition is >> fulfilled: >> >> M = V Lambda V^{-1} >> or >> M V = V Lambda >> >> i.e. each column of V *is* eigenvector to the corresponding >> eigenvalue. >> >> >>> Moreover, if you try to compute the inverse of the matrix of eigenvectors, >>> R is not aware that this matrix is singular: >> >>>> solve(eigen(mp)$vectors) >>> [,1] [,2] [,3] >>> [1,] 6.235383e-01 6.235383e-01 6.235383e-01 >>> [2,] 3.743456e+07 -9.358641e+06 -9.358640e+06 >>> [3,] -3.743456e+07 9.358640e+06 9.358641e+06 >> >> it isn't... >> >> >> >>> My question is: how can I fix it? >> >> No need to fix anything, as nothing is broken ;-) >> >> Martin Maechler, ETH Zurich >> > > ------------------------------------------------------------ > Arnau Mir Torres > Edifici A. Turmeda > Campus UIB > Ctra. Valldemossa, km. 7,5 > 07122 Palma de Mca. > tel: (+34) 971172987 > fax: (+34) 971173003 > email: arnau....@uib.es > URL: http://dmi.uib.es/~arnau > ------------------------------------------------------------ > ------------------------------------------------------------ Arnau Mir Torres Edifici A. Turmeda Campus UIB Ctra. Valldemossa, km. 7,5 07122 Palma de Mca. tel: (+34) 971172987 fax: (+34) 971173003 email: arnau....@uib.es URL: http://dmi.uib.es/~arnau ------------------------------------------------------------ [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.