Skip to content
Prev 206500 / 398503 Next

La.svd of a symmetric matrix

On Jan 16, 2010, at 8:10 AM, Stefano Sofia wrote:

            
Well, it would have been u and t(vt) that you might have been thinking  
should be equal. And they are equal up to an orthonormal transformation.

 > samp <-sample(1:100, 9)
 > M <- matrix(samp,3)+matrix(samp,3,byrow=T)
 >  all.equal( La.svd(M)$vt *c(1,-1,1) , t(La.svd(M)$u) )
[1] "Mean relative difference: 0.6169069"
 > M
      [,1] [,2] [,3]
[1,]   66  101   95
[2,]  101   76  104
[3,]   95  104   26
 > La.svd(M)$vt
            [,1]       [,2]        [,3]
[1,] -0.5853410 -0.6225788 -0.51939540
[2,]  0.2966601  0.4317295 -0.85182300
[3,]  0.7545652 -0.6526908 -0.06801466
 >  t(La.svd(M)$u)
            [,1]       [,2]        [,3]
[1,] -0.5853410 -0.6225788 -0.51939540
[2,] -0.2966601 -0.4317295  0.85182300
[3,] -0.7545652  0.6526908  0.06801466
 >  all.equal( La.svd(M)$vt *c(1,-1,-1) , t(La.svd(M)$u) )
[1] TRUE

And, of course, numerical accuracy gets in the way of exact equality:
 >   La.svd(M)$vt *c(1,-1,-1) == t(La.svd(M)$u)
       [,1]  [,2]  [,3]
[1,] FALSE FALSE FALSE
[2,] FALSE FALSE FALSE
[3,]  TRUE FALSE  TRUE