I have to: Using spectral decomposition, compute the square of the original matrix A^2.
Given:
q3_A <- matrix(c(4, 1, 1, 1, 2, 0, 1, 0, 3), nrow = 3, byrow = TRUE)
I computed:
dim(q3_A)
(ev<-eigen(q3_A))
#extract componets
(L <- ev$values)
# [1] 4.879385 2.652704 1.467911
(V <- ev$vectors)
# [,1] [,2] [,3]
# [1,] 0.8440296 -0.2931284 0.4490988
# [2,] 0.2931284 -0.4490988 -0.8440296
# [3,] 0.4490988 0.8440296 -0.2931284
q3_spectral_A <- V %*% diag(L) %*% t(V)
all.equal(q3_spectral_A, q3_A, check.attributes = FALSE)
#True
q3_square_A <- V %*% diag(L) %*% diag(L) %*% t(V)
q3_square_A
# [,1] [,2] [,3]
# [1,] 18 6 7
# [2,] 6 5 1
# [3,] 7 1 10
But as we can see that is not A^2 (I think).
So my question is:
q3_A * q3_A
# [,1] [,2] [,3]
#[1,] 16 1 1
#[2,] 1 4 0
#[3,] 1 0 9
q3_A %*% q3_A #note: same as spectral above
# [,1] [,2] [,3]
#[1,] 18 6 7
#[2,] 6 5 1
#[3,] 7 1 10
the first of these is dot product, the other is matrix multiplication – right? The dot product yields what I thought would be the correct A^2 while the Spectral Decomp and the Matrix Multiplication does not. Why is this?
I already reviewed: How to Inverse and square root of matrix using spectral decomposition in r?
1