Show that \({ A }^{ T }\cdot A\quad \neq \quad A\cdot { A }^{ T }\) :
If A is not a square matrix with dimention mxn, then \({ A }^{ T }\) will have dimension nxm. Hence if, \({ m\quad \neq \quad n }\), the matrix represented by \({ A }^{ T }\cdot A\) will have dimension nxn and \(A\cdot { A }^{ T }\) will have dimension mxm. So we can conclude that
\({ A }^{ T }\cdot A\quad \neq \quad A\cdot { A }^{ T }\).
Let us consider the case where A is a square matrix and m=n. For illustration, we will consider an arbitrary 4x4 matrix A.
\(A \quad =\quad \begin{bmatrix} {a}_{ 11 } & { a }_{ 12 } & { a }_{ 13 } & { a }_{ 14 } \\ { a }_{ 21 } & { a }_{ 22 } & { a }_{ 23 } & { a }_{24}\\{ a }_{31} & { a }_{32} & { a }_{33} & { a }_{34} \\ { a }_{41} & { a }_{42} & { a }_{43} & { a }_{44} \end{bmatrix}\)
The transpose of A can be written as:
\({ A }^{ T }\quad =\quad \begin{bmatrix} { a }_{ 11 }^{ ' } & { a }_{ 12 }^{ ' } & { a }_{ 13 }^{ ' } & { a }_{ 14 }^{ ' } \\ { a }_{ 21 }^{ ' } & { a }_{ 22 }^{ ' } & { a }_{ 23 }^{ ' } & { a }_{ 24 }^{ ' } \\ { a }_{ 31 }^{ ' } & { a }_{ 32 }^{ ' } & { a }_{ 33 }^{ ' } & { a }_{ 34 }^{ ' } \\ { a }_{ 41 }^{ ' } & { a }_{ 42 }^{ ' } & { a }_{ 43 }^{ ' } & { a }_{ 44 }^{ ' } \end{bmatrix}\)
Also, \({ A }^{ T }\quad =\quad \begin{bmatrix} { a }_{ 11 } & { a }_{ 21 } & { a }_{ 31 } & { a }_{ 41 } \\ { a }_{ 12 } & { a }_{ 22 } & { a }_{ 32 } & { a }_{42}\\{ a }_{13} & { a }_{23} & { a }_{33} & { a }_{43} \\ { a }_{14} & { a }_{24} & { a }_{43} & { a }_{44} \end{bmatrix}\)
Let us now consider matrix C, \(C\quad =\quad A\cdot { A }^{ T }\)
\(C\quad =\quad \begin{bmatrix} { c }_{ 11 } & { c }_{ 12 } & { c }_{ 13 } & { c }_{ 14 } \\ { c }_{ 21 } & { c }_{ 22 } & { c }_{ 23 } & { c }_{24}\\{ c }_{31} & { c }_{32} & { c }_{33} & { c }_{34} \\ { c }_{41} & { c }_{42} & { c }_{43} & { c }_{44} \end{bmatrix}\)
a given element of C, \({ c }_{ 23 }\), can be written as follows:
\({ c }_{ 23 }\quad =\quad { a }_{ 21 }\cdot { a }_{ 13 }^{ ' }\quad +\quad { a }_{ 22 }\cdot { a }_{ 23 }^{ ' }\quad +\quad { a }_{ 23 }\cdot { a }_{ 33 }^{ ' }\quad +\quad { a }_{ 24 }\cdot { a }_{ 43 }^{ ' }\)
The same element, \({ c }_{ 23 }\), can also be written as follows:
\({ c }_{ 23 }\quad =\quad { a }_{ 21 }\cdot { a }_{ 31 }\quad +\quad { a }_{ 22 }\cdot { a }_{ 32 }\quad +\quad { a }_{ 23 }\cdot { a }_{ 33 }\quad +\quad { a }_{ 24 }\cdot { a }_{ 34 }\)
Let us now consider maxtrix D such as; \(D\quad =\quad { A }^{ T }\cdot A\)
Also, \(D\quad =\quad \begin{bmatrix} { d }_{ 11 } & { d }_{ 12 } & { d }_{ 13 } & { d }_{ 14 } \\ { d }_{ 21 } & { d }_{ 22 } & { d }_{ 23 } & { d }_{24}\\{ d }_{31} & { d }_{32} & { d }_{33} & { d }_{34} \\ { d }_{41} & { d }_{42} & { d }_{43} & { d }_{44} \end{bmatrix}\)
An arbitrary element of D, \({ d }_{ 23 }\) can be obtain as follows:
\({ d }_{ 23 }\quad =\quad { a }_{ 21 }^{ ' }\cdot { a }_{ 13 }\quad +\quad { a }_{ 22 }^{ ' }\cdot { a }_{ 23 }\quad +\quad { a }_{ 23 }^{ ' }\cdot { a }_{ 33 }\quad +\quad { a }_{ 24 }^{ ' }\cdot { a }_{ 43 }\quad\)
\({ d }_{ 23 }\quad =\quad { a }_{ 12 }\cdot { a }_{ 13 }\quad +\quad { a }_{ 22 }\cdot { a }_{ 23 }\quad +\quad { a }_{ 32 }\cdot { a }_{ 33 }\quad +\quad { a }_{ 42 }\cdot { a }_{ 43 }\quad\)
In most cases, \({ c }_{ 23 }\) would not be equal to \({ d }_{ 23 }\).
For \({ A }^{ T }\cdot A\quad =\quad A\cdot { A }^{ T }\), we would have to have \({ c }_{ ij } \quad =\quad { d }_{ ij }\) (see above). This will imply that in the case we have above,
\({ a }_{ 21 }\cdot { a }_{ 31 }\quad +\quad { a }_{ 22 }\cdot { a }_{ 32 }\quad +\quad { a }_{ 23 }\cdot { a }_{ 33 }\quad +\quad { a }_{ 24 }\cdot { a }_{ 34 } \quad =\quad { a }_{ 12 }\cdot { a }_{ 13 }\quad +\quad { a }_{ 22 }\cdot { a }_{ 23 }\quad +\quad { a }_{ 32 }\cdot { a }_{ 33 }\quad +\quad { a }_{ 42 }\cdot { a }_{ 43 }\quad\)
For this to hold true in all cases, we would have to have \({ a }_{ ij } \quad =\quad { a }_{ ji }\). This would indicate that the matrix A would be symetrical.
Factorization_Matrices <- function (A){
# Validate input parameters, A, b, and whether row(A)==length(b)
if(missing(A)){
stop("Need to specify matrix A in equation Ax = b.")
}
if(nrow(A) != ncol(A)){
stop("Needs A to be square matrix.")
}
# store nrow and ncol for matrix A for reference
n <- nrow(A)
# Build Upper-Triangular Matrix & Lower Triangular Matrices
U <- A
L <-diag(n)
# Initialize colum cursor
c <- 1
while (c <= n){
# Initialize row cursor
r <- c
# Assuming that pivot is first position and non-zero
p <- U[r,c]
# Proceed with elimination for each rows
i <- r + 1
while (i <= n){
# Determine multiplier
m = U[i,c]/p
U[i, ] <- U[i, ] - m*U[r, ]
L[i,c] <- m
i <- i + 1
} # end of for while for rows
c <- c + 1
} # end of while loop for columns
#------------#
result <- list(U,L)
return(result)
}
##########################################################
# Testing Function
A <- matrix(c(1,2,3,1,1,1,2,0,1),nrow=3)
A
## [,1] [,2] [,3]
## [1,] 1 1 2
## [2,] 2 1 0
## [3,] 3 1 1
m_result <- Factorization_Matrices(A)
U_result <- m_result[[1]]
L_result <- m_result[[2]]
test <- (L_result %*% U_result)
test == A
## [,1] [,2] [,3]
## [1,] TRUE TRUE TRUE
## [2,] TRUE TRUE TRUE
## [3,] TRUE TRUE TRUE
Thank you