Purpose
To work out Exer 2 from Numerical Algebra

> Q <- diag(5)
> A <- diag(x = 1, nrow = 5, ncol = 5)
> for (i in 1:4) {
+     A[i, (i + 1)] <- 2
+ }

Eigen Values

> eig.val <- eigen(A)$values
> print(eig.val)
[1] 1 1 1 1 1

R matrix of QR decomposition

> R <- qr.R(qr(A))
> print(R)
     [,1] [,2] [,3] [,4] [,5]
[1,]   -1   -2    0    0    0
[2,]    0   -1   -2    0    0
[3,]    0    0   -1   -2    0
[4,]    0    0    0   -1   -2
[5,]    0    0    0    0    1

Singular values

> print(svd(A)$d)
[1] 2.8852717 2.5523972 2.0371820 1.4170931 0.0470367

There is no connection between singular values eigen vectors and R matrix…