Answer: From textbook example MMNC (\(\xi MM\), page 151), we see that matrix multiplication is not communtative. In other words, for two matrices \(A\) and \(B\):
\(AB \neq BA\)
So, if \(B = A^{T}\) we get the similar result:
\(AA^{T} \neq A^{T}A\)
To show one case where they are not equal, we start with a matrix A:
\(A = \begin{bmatrix}8 & 4\\3 & 2\end{bmatrix}\) with \(A^{T} = \begin{bmatrix}8 & 3\\4 & 2\end{bmatrix}\)
\(AA^{T} = \left[\begin{array}{@{}c|c@{}} A\begin{bmatrix}8\\4\end{bmatrix} & A\begin{bmatrix}3\\2\end{bmatrix} \end{array}\right] = \left[\begin{array}{@{}c|c@{}} 8\begin{bmatrix}8\\4\end{bmatrix} + 4\begin{bmatrix}4\\2\end{bmatrix} & 3\begin{bmatrix}8\\4\end{bmatrix} + 2\begin{bmatrix}4\\2\end{bmatrix} \end{array}\right]\)
\(AA^{T} = \left[\begin{array}{@{}c|c@{}} \begin{bmatrix}64\\32\end{bmatrix} \begin{bmatrix}16\\8\end{bmatrix} & \begin{bmatrix}24\\12\end{bmatrix} \begin{bmatrix}8\\4\end{bmatrix} \end{array}\right] = \left[\begin{array}{@{}c|c@{}} \begin{bmatrix}82\\40\end{bmatrix} & \begin{bmatrix}32\\16\end{bmatrix} \end{array}\right] = \begin{bmatrix}82 & 32\\40 & 16\end{bmatrix}\)
Following similar steps, we generate \(A^{T}A = \begin{bmatrix}76 & 40\\30 & 16\end{bmatrix}\). So we can see that at least for one case, \(AA^{T} \ne A^{T}A\).
Answer:
The above statement is true under two conditions:
Condition 1) \(A_{mn}\) is a square matrix (\(m = n\))
Condition 2) \(A_{ij} = A_{ji}\) for values of \(1 \ge i \ge m\) and \(1 \ge j \ge m\)
find_lu_matrix <- function(m) {
L <- diag(nrow(m))
# for every row
for (start_row in 1:(nrow(m)-1)) {
# start on columns from 'start_row'
for (i in start_row:(nrow(m)-1)) {
# Calculate the value to zero out a row
x <- -(m[i+1,start_row] / m[start_row,start_row])
# Save this value to the L matrix
L[i+1,start_row] <- -x
# Combine rows
m[i+1, ] <- x * m[start_row,] + m[i+1,]
}
}
# return a list of two matrices
return_list <- list("U" = m, "L" = L)
return (return_list);
}
B <- matrix(c(1, -2, 3, 4, 8, 4, -3, 5, 7), nrow = 3)
# show the initial matrix
B
## [,1] [,2] [,3]
## [1,] 1 4 -3
## [2,] -2 8 5
## [3,] 3 4 7
my_matrices <- find_lu_matrix(B)
# display the lower and upper matrices
my_matrices$L
## [,1] [,2] [,3]
## [1,] 1 0.0 0
## [2,] -2 1.0 0
## [3,] 3 -0.5 1
my_matrices$U
## [,1] [,2] [,3]
## [1,] 1 4 -3.0
## [2,] 0 16 -1.0
## [3,] 0 0 15.5