Problem Set 1.

Eigenvectors for x are 0.658, 0.753, -0.753, 0.658.
Values for u of the decomposition are -0.658, -0.753, -0.753, 0.658.
The first vector is the negative of the computed eigenvector and the second is identical, which means they are the same.
Eigenvectors for y are -0.019, 0.255, 0.967, -0.673, -0.718, 0.177, 0.74, -0.647, 0.185.
Values for v of the decomposition are 0.019, -0.255, -0.967, -0.673, -0.718, 0.177.
The first vector of v is the negative of the first computed eigenvector for y, and the second is the same as the second. (The third does not appear in the SVD).
The singular values of A are 5.158, 2.097.
When they are squared, they are 26.6, 4.4.
The Eigenvalues for both X and Y are 26.6, 4.4, 0 and 26.6, 4.4.
These also match.

eigen.for.x
## $values
## [1] 26.602  4.398
## 
## $vectors
##       [,1]   [,2]
## [1,] 0.658 -0.753
## [2,] 0.753  0.658
eigen.for.y
## $values
## [1] 26.602  4.398  0.000
## 
## $vectors
##        [,1]   [,2]   [,3]
## [1,] -0.019 -0.673  0.740
## [2,]  0.255 -0.718 -0.647
## [3,]  0.967  0.177  0.185
s.v.decomposition
## $d
## [1] 5.158 2.097
## 
## $u
##        [,1]   [,2]
## [1,] -0.658 -0.753
## [2,] -0.753  0.658
## 
## $v
##        [,1]   [,2]
## [1,]  0.019 -0.673
## [2,] -0.255 -0.718
## [3,] -0.967  0.177

Problem Set 2.

We show our matrix, followed by its inverse.
Then we show A*A-1 and A-1*A to show that our inverse is valid.
Finally, we show our code to create an inverse matrix.

##      [,1] [,2] [,3]
## [1,]    2    2    4
## [2,]   -4    6    6
## [3,]   16   -1   -8
##            [,1]        [,2]        [,3]
## [1,]  0.1296296 -0.03703704  0.03703704
## [2,] -0.1975309  0.24691358  0.08641975
## [3,]  0.2839506 -0.10493827 -0.06172840
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    0    1    0
## [3,]    0    0    1
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    0    1    0
## [3,]    0    0    1
new.matrix<-matrix(c(2,-4,16,2,6,-1,4,6,-8),nrow=3)
inverse.maker<-function(a){
cofactor.matrix<-matrix(nrow=3,ncol=3)
inverse.matrix<-matrix(nrow=3,ncol=3)
k = 1
determinant.temporary<-matrix(nrow=2,ncol=2)
#find minors of the matrix, place in position swapped along diagonal
for(m in 1:3){
  for(n in 1:3){
    for (i in 1:3){
      for (j in 1:3){
    if(i==m | j==n){}else{
           determinant.temporary[k]<-a[j,i]
           det(a) 
           k<-k+1
           if(k==5){
             cofactor.matrix[m,n]<-det(determinant.temporary)
             k=1}
                         }}}}}
#switch "checkerboard" to negative
cofactor.matrix[1,2]<--cofactor.matrix[1,2]
cofactor.matrix[2,1]<--cofactor.matrix[2,1]
cofactor.matrix[2,3]<--cofactor.matrix[2,3]
cofactor.matrix[3,2]<--cofactor.matrix[3,2]
cofactor.matrix
#divide by determinant
determinant.of.matrix=0
for(i in 1:3){determinant.of.matrix<-(determinant.of.matrix+(cofactor.matrix[i,1]*a[1,i])) }
for(i in 1:3){
  for(j in 1:3){
    inverse.matrix[i,j]<-(cofactor.matrix[i,j]/determinant.of.matrix)
  }}  
a<-inverse.matrix
return(a)
}
inverse.matrix<-inverse.maker(new.matrix)
new.matrix
inverse.matrix
round(new.matrix%*%inverse.matrix,digits=1)
round(inverse.matrix%*%new.matrix,digits=1)