\[\begin{equation} Prove AA^{T} \neq A^{T}A \end{equation}\]

\[\begin{equation} Let A=\begin{bmatrix} w & y \\ x & z \end{bmatrix} \end{equation}\]

\[\begin{equation} Then, A^{T}=\begin{bmatrix} w & x \\ y & z \end{bmatrix} \end{equation}\]

\[\begin{equation} AA^{T} = \begin{bmatrix} ww + yy & xw + yz \\ xw + yz & xx + xz \end{bmatrix} \end{equation}\]

\[\begin{equation} A^{T}A = \begin{bmatrix} ww + xx & wy + xz \\ wy + xz & yy + zz \end{bmatrix} \end{equation}\]

\[\begin{equation} Therefore, AA^{T} \neq A^{T}A \blacksquare \end{equation}\]

  1. For an
  1. Identity matrix and
  2. Square matrices where \[\begin{equation} A=A^{T} \end{equation}\]

the statement

\[\begin{equation} AA^{T} = A^{T}A \end{equation}\] is true.

Decompose 3x3 matrix in to L and U.

decompose <- function(m) {
  elimination_matrices=list()
  if (nrow(m)==3) {
    # m[2,1], m[3,1], m[3,2]
    if (m[2,1] !=0) {
      multiplier <- m[2,1]/m[1,1]
      m[2,] <- m[2,] - m[1,] * multiplier
      temp_mat <- diag(3)
      temp_mat[2,1] <- -multiplier
      elimination_matrices <- append(list(temp_mat),elimination_matrices)
    }
    if (m[3,1] !=0) {
      row <- if (!is.nan(m[3,1]/m[2,1]) && !is.infinite(m[3,1]/m[2,1])) 2 else 1
      multiplier <- m[3,1]/m[row,1]
      m[3,] <- m[3,] - m[row,] * multiplier
      temp_mat <- diag(3)
      temp_mat[3,1] <- -multiplier
      elimination_matrices <- append(list(temp_mat),elimination_matrices)
    }
    if (m[3,2] != 0) {
      row <- if (!is.nan(m[3,2]/m[2,2]) && !is.infinite(m[3,2]/m[2,2])) 2 else 1
      multiplier <- m[3,2]/m[row,2]
      m[3,] <- m[3,] - m[row,] * multiplier
      temp_mat <- diag(3)
      temp_mat[3,2] <- -multiplier
      elimination_matrices <- append(list(temp_mat),elimination_matrices)
    }
  }
  return (elimination_matrices)
}
em_list <- decompose(matrix(c(1,2,3,1,1,1,2,0,1), nrow=3))
print(em_list)
## [[1]]
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    0    1    0
## [3,]    0   -2    1
## 
## [[2]]
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    0    1    0
## [3,]   -3    0    1
## 
## [[3]]
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]   -2    1    0
## [3,]    0    0    1
getU <- function(x) {
  u <- as.matrix(x[1])
  for (i in 2:length(x)) {
    print(x[i])
    u <- as.matrix(x[i]) %*% u
  }
  return (u)
}