Problem Set 1)
1)Prove the following: \[ { A }^{ T }A\neq A{ A }^{ T } \]
Lets first recall the properties of transpose for some matrix A. Suppose we also have some matrix B, not equal to A, and some real constant k: \[ ({ A }^{ T })^{ T }=A\\ (A+B)^{T}=A^{T}+B^{T}\\(kA)^{T}=kA^{T}\\(AB)^{T}=B^{T}A^{T} \]
Since we are attempting to prove that the given identity is not true, we can perhaps look for a counter example under the assumption that the identity is true.
Assume the following is true: \[ { A }^{ T }A= A{ A }^{ T } \]
Let A and it’s transpose be defined as follows: \[ A=\begin{bmatrix} a & b \\ c & d \end{bmatrix}\\ { A }^{ T }=\begin{bmatrix} a & c \\ b & d \end{bmatrix} \]
To find the transpose, we keep the diagonal entries (1,1) and (2,2) the same. We then switch the value in entry (1,2) with that of entry (2,1).
This is a very easy to follow tutorial on multiplying square matricies together https://www.mathsisfun.com/algebra/matrix-multiplying.html https://ncalculators.com/matrix/2x2-matrix-multiplication-calculator.htm
\[ { A }^{ T }A= A{ A }^{ T }\\\begin{bmatrix} a & c \\ b & d \end{bmatrix}\begin{bmatrix} a & b \\ c & d \end{bmatrix}=\begin{bmatrix} a & b \\ c & d \end{bmatrix}\begin{bmatrix} a & c \\ b & d \end{bmatrix}\\\begin{bmatrix} { a }^{ 2 }+{ c }^{ 2 } & ab+cd \\ ab+cd & { b }^{ 2 }+{ d }^{ 2 } \end{bmatrix}=\begin{bmatrix} { a }^{ 2 }+{ b }^{ 2 } & ac+bd \\ ac+bd & { c }^{ 2 }+{ d }^{ 2 } \end{bmatrix} \]
Our assumption is not true, thus we have shown that the identity does not hold by contradicting our assumption. \[ \begin{bmatrix} { a }^{ 2 }+{ b }^{ 2 } & ab+cd \\ ab+cd & { b }^{ 2 }+{ d }^{ 2 } \end{bmatrix}\neq \begin{bmatrix} { a }^{ 2 }+{ b }^{ 2 } & ac+bd \\ ac+bd & { c }^{ 2 }+{ d }^{ 2 } \end{bmatrix}\\{ A }^{ T }A\neq A{ A }^{ T } \]
The matrix for which this condition is true is called a symmetric matrix. A detailed description on symmetric matrix can be found here http://www.mathcentre.ac.uk/resources/uploaded/sigma-matrices2-2009-1.pdf
By definition A symmetric matrix is a square matrix which is symmetric about its leading diagonal (top left to bottom right)
Suppose A is now symmetric \[ A=\begin{bmatrix} a & b \\ b & d \end{bmatrix}\\ { A }^{ T }=\begin{bmatrix} a & b \\ b & d \end{bmatrix} \]
We can see that the following holds true for symmetrix matrix \[ A={ A }^{ T } \]
We will show that the identiy holds for symmetrix matricies similar to the previous problem by using the fact that for symmetric matrix A, it’s transpose is the same. We also use matrix multiplication of square matricies. \[ { A }^{ T }A= A{ A }^{ T }\\{A}{A}=AA\\\begin{bmatrix} a & b \\ b & d \end{bmatrix}\begin{bmatrix} a & b \\ b & d \end{bmatrix}=\begin{bmatrix} a & b \\ b & d \end{bmatrix}\begin{bmatrix} a & b \\ b & d \end{bmatrix}\\\begin{bmatrix} { a }^{ 2 }+{ b }^{ 2 } & ab+bd \\ bd+db & { b }^{ 2 }+{ a }^{ 2 } \end{bmatrix}=\begin{bmatrix} { a }^{ 2 }+{ b }^{ 2 } & ab+bd \\ bd+db & { b }^{ 2 }+{ a }^{ 2 } \end{bmatrix} \]
Problem Set 2)
Matrix factorization is a very important problem. There are supercomputers built just to do matrix factorizations. Every second you are on an airplane, matrices are being factorized. Radars that track flights use a technique called Kalman filtering.
At the heart of Kalman Filtering is a Matrix Factorization operation. Kalman Filters are solving linear systems of equations when they track your flight using radars.
Write an R function to factorize a square matrix A into LU or LDU, whichever you prefer. Please submit your response in an R Markdown document using our class naming convention, E.g. LFulton_Assignment2_PS2.png
You don’t have to worry about permuting rows of A and you can assume that A is less than 5x5, if you need to hard-code any variables in your code. If you doing the entire assignment in R, then please submit only one markdown document for both the problems.
Lets write a mechanic to perform LU
factor_machine <- function(UpperMatrix)
{
LowerMatrix <- diag(nrow =dim(UpperMatrix)[1])
for(i in (1:dim(UpperMatrix)[1]))
{
for(j in (1:dim(UpperMatrix)[1]))
{
if(j<i)
{
Eliminate <- diag(nrow =dim(UpperMatrix)[1])
lower <- diag(nrow =dim(UpperMatrix)[1])
if(UpperMatrix[i,j]>0)
{
Eliminate[i,j] <- -1*UpperMatrix[i,j]
}
else
{
Eliminate[i,j] <- UpperMatrix[i,j]
}
UpperMatrix <- Eliminate %*% UpperMatrix
LowerMatrix <- LowerMatrix %*% solve(Eliminate)
}
}
}
print("Lower Matrix (L)")
print(LowerMatrix)
print("Upper Matrix (U)")
print(UpperMatrix)
print("Multiply (LowerMatrix*UpperMatrix)")
print(LowerMatrix %*% UpperMatrix)
}
factor_machine(matrix(c(1,2,3,1,1,1,2,0,1),
nrow=3,ncol=3))
## [1] "Lower Matrix (L)"
## [,1] [,2] [,3]
## [1,] 1 0 0
## [2,] 2 1 0
## [3,] 3 2 1
## [1] "Upper Matrix (U)"
## [,1] [,2] [,3]
## [1,] 1 1 2
## [2,] 0 -1 -4
## [3,] 0 0 3
## [1] "Multiply (LowerMatrix*UpperMatrix)"
## [,1] [,2] [,3]
## [1,] 1 1 2
## [2,] 2 1 0
## [3,] 3 1 1