# Making sense of the output of svd() in R

I created a matrix of dimensions 6X5 and applied the svd() function on it.

>matrix_A
V W X Y Z
A 4 1 5 0 0
B 0 1 3 0 1
C 0 1 0 5 4
D 0 1 0 4 0
E 0 1 2 0 4
F 5 0 4 1 0

>svd_A <- svd(matrix_A)


When I see the 'U' matrix, it has dimensions 6X5.

>svd_A$u [,1] [,2] [,3] [,4] [,5] [1,] -0.6337425 0.27376062 -0.01574796 -0.2086500 -0.5249861 [2,] -0.2648734 -0.01058103 0.33757481 -0.6686728 0.6057323 [3,] -0.2315021 -0.80402040 -0.06816000 0.2435956 0.1600463 [4,] -0.1117109 -0.40493588 -0.51738041 -0.4942192 -0.2799135 [5,] -0.2618584 -0.26685759 0.71943981 0.1595892 -0.3116502 [6,] -0.6273517 0.20810652 -0.30963419 0.4245959 0.3954564  Now, I have read that the 'U' matrix must by a square matrix of dimension 6X6 (here). Further, the singular value matrix ('D') must be of 6X5 and the 'V' matrix must be of 5X5 dimension. Now, what is the R's svd() doing? Why is my U matrix of dimension 6X5? Is there another way of factorizing the matrix other than the method I know? (there most probably is) Update: The manual says the dimension of U would be c(n,nu) where nu is the number of left single value vectors to be computed between 0 and n and the default nu is *nrow(matrix_A)*. So, by default, in my above example, n = nu = 6. Hence it should have been a 6X6 matrix. I got this doubt because I saw an example Here and the V dimensions weren't matching with the output of svd(). R's output for a:  [,1] [,2] [,3] [1,] 3 1 1 [2,] -1 3 1  was: svd(a)$d
[1] 3.464102 3.162278

$u [,1] [,2] [1,] -0.7071068 -0.7071068 [2,] -0.7071068 0.7071068$v
[,1]          [,2]
[1,] -0.4082483 -8.944272e-01
[2,] -0.8164966  4.472136e-01
[3,] -0.4082483  5.231953e-16


Here V has dimension 3X2 while in the example in the link, V has dimensions 3X3.

• What happens (in the last example) when you follow the instructions on the help page and compute svd(a, nv=3)?
– whuber
Commented Jul 25, 2013 at 13:40
• Okay. I'm feeling stupid now. That works. I always thought the default was ncol(a) and not min(nrow(a), ncol(a)). My bad. Commented Jul 26, 2013 at 7:45