DATA605: Assignment 4

Bonnie Cooper

Inverse of a Matrix / Single Value Decomposition

Problem Set #1

Given a 3 × 2 matrix A: \[A = \begin{bmatrix} 1 & 2 & 3 \\ -1 & 0 & 4 \end{bmatrix}\]

write code in R to compute \(\mathbf{X} = \mathbf{AA^T}\) and \(\mathbf{Y} = \mathbf{A^TA}\). Then, compute the eigenvalues and eigenvectors of \(\mathbf{X}\) and \(\mathbf{Y}\) using the built-in commands in R.

##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]   -1    0    4
##      [,1] [,2]
## [1,]   14   11
## [2,]   11   17
##      [,1] [,2] [,3]
## [1,]    2    2   -1
## [2,]    2    4    6
## [3,]   -1    6   25



Compute the eigenvalues and eigenvectors of X and Y using the built-in commans in R.

## [1] "eigenvalues of X:"
## $values
## [1] 26.601802  4.398198
## [1] "eigenvalues of Y:"
## $values
## [1] 2.660180e+01 4.398198e+00 1.058982e-16
## [1] "eigenvectors of X:"
## $vectors
##           [,1]       [,2]
## [1,] 0.6576043 -0.7533635
## [2,] 0.7533635  0.6576043
## [1] "eigenvectors of Y:"
## $vectors
##             [,1]       [,2]       [,3]
## [1,] -0.01856629 -0.6727903  0.7396003
## [2,]  0.25499937 -0.7184510 -0.6471502
## [3,]  0.96676296  0.1765824  0.1849001


Compute the left-singular, singular values, and right-singular vectors of A using the svd command:

## [1] "singular values of A"
## $d
## [1] 5.157693 2.097188
## [1] "left singular vectors of A"
## $u
##            [,1]       [,2]
## [1,] -0.6576043 -0.7533635
## [2,] -0.7533635  0.6576043
## [1] "right singular vectors of A"
## $v
##             [,1]       [,2]
## [1,]  0.01856629 -0.6727903
## [2,] -0.25499937 -0.7184510
## [3,] -0.96676296  0.1765824


Examine the two sets of singular vectors and show that they are indeed eigenvectors of X and Y. In addition, the two non-zero eigenvalues (the 3rd value will be very close to zero, if not zero) of both X and Y are the same and are squares of the non-zero singular values of A:

## [1] "Num differences between the eigenvectors of X and the left singular vectors of A:  0"
## [1] "Num differences between the eigenvectors of Y and the right singular vectors of A:  0"


## [1] "The 2 nonzero eigenvalues of X & Y are equal"
## [1] "The 2 eigenvalues of X are equal to the square of the singular values of A (it follows that this holds for the non zero eigenvalues of Y as well)"