#problem 2.31.e)
A <- matrix(c(2,0,-2,
0,2,-2,
-2,-2,4),3,3,byrow=TRUE)
eigen(A)
## eigen() decomposition
## $values
## [1] 6.000000e+00 2.000000e+00 5.329071e-15
##
## $vectors
## [,1] [,2] [,3]
## [1,] -0.4082483 -7.071068e-01 0.5773503
## [2,] -0.4082483 7.071068e-01 0.5773503
## [3,] 0.8164966 8.881784e-16 0.5773503
#eigenvalues and eigenvectors of matrix A
A <- matrix(c(2,0,-2,
0,2,-2,
-2,-2,4),3,3,byrow=TRUE)
eigen(A)
## eigen() decomposition
## $values
## [1] 6.000000e+00 2.000000e+00 5.329071e-15
##
## $vectors
## [,1] [,2] [,3]
## [1,] -0.4082483 -7.071068e-01 0.5773503
## [2,] -0.4082483 7.071068e-01 0.5773503
## [3,] 0.8164966 8.881784e-16 0.5773503
# Eigenvalues
# 6, 2, 5.329071e-15
# The third value (5.329071e-15) is numerically equal to 0
# Therefore the eigenvalues are:
# 6, 2, 0
#Corresponding normalized eigenvectors are the columns of the matrix:
# v1 = (-0.4082483, -0.4082483, 0.8164966)'
# v2 = (-0.7071068, 0.7071068, 0)'
# v3 = ( 0.5773503, 0.5773503, 0.5773503)'
# These correspond to the normalized vectors
#(1/sqrt(6))* (-1, -1, 2)'
# (1/sqrt(2)) * (-1, 1, 0)'
# (1/sqrt(3))* ( 1, 1, 1)'
#which match the eigenvectors obtained analytically in the previous part,
#up to multiplication by -1 (which does not change eigenvectors)
#2.44.b)
A <- matrix(c(1,1),2,1)
svd(A)
## $d
## [1] 1.414214
##
## $u
## [,1]
## [1,] 0.7071068
## [2,] 0.7071068
##
## $v
## [,1]
## [1,] 1
#The singular value returned by R is 1.414214, which equals sqrt(2).
#This matches the theoretical singular value obtained from
#sqrt(eigenvalue of A'A).
#The left singular vector (column of U) is
#(0.7071068, 0.7071068)' = (1/sqrt(2)) * (1,1)'.
#The right singular vector (V) is simply (1), since A'A = [2]
#and its eigenvector is 1.
#Therefore the SVD is:
# A = U D V'
# where
# U = (1/sqrt(2)) * (1,1)'
# D = sqrt(2)
# V = (1)
#R returns the reduced SVD because A has rank 1.
# The results agree with the SVD obtained analytically in part (a).