Using R, I'm trying to verify SVD with simple 3-by-2 matrix M by calculating eigenvalues and vectors of transposed matrix, say N1 and N2 shown below.
column1 <- c(1,2,3)
column2 <- c(4,5,6)
M <- cbind(column1,column2)
N1 <- M %*% t(M)
N2 <- t(M) %*% M
> N1
[,1] [,2] [,3]
[1,] 17 22 27
[2,] 22 29 36
[3,] 27 36 45
> N2
column1 column2
column1 14 32
column2 32 77
Then, I made R calculate the eigenvalues of N1 and N2, which must be same each other, but it has shown me unexpected results like below.
> eigen(N1)$values
[1] 9.040267e+01 5.973275e-01 1.329470e-15
> eigen(N2)$values
[1] 90.4026725 0.5973275
The last eigenvalue of N1 is probably caused by float calculation issue. Is there any way to avoid that? Otherwise, I have to eliminate this last one and also the last column of eigenvector of N1 to reproduce SVD.