IS605 Assignment 2

  1. Problem set 1
  1. Show that \(\mathbf{A}^\intercal\) A \(\neq\) A\(\mathbf{A}^\intercal\) in general. (Proof and demonstration.)

In this 2 by 2 matrix the matrix mulitplicaiton of its transpose is not equal to the matrix muliplicaiton of its transpose. Matrix multiplcation is not communtive, order counts.

#Matrix A 
A <-matrix(c(-2,3,4,-1,2,6),nrow=3, ncol=2)

A
##      [,1] [,2]
## [1,]   -2   -1
## [2,]    3    2
## [3,]    4    6
#Transpose A
t(A)
##      [,1] [,2] [,3]
## [1,]   -2    3    4
## [2,]   -1    2    6
#Matrix multplication of A traspose A
A %*% t(A)
##      [,1] [,2] [,3]
## [1,]    5   -8  -14
## [2,]   -8   13   24
## [3,]  -14   24   52
#Matrix multiplication of A A transpose
t(A) %*% A
##      [,1] [,2]
## [1,]   29   32
## [2,]   32   41
  1. For a special type of square matrix A, we get \(\mathbf{A}^\intercal\) A = A\(\mathbf{A}^\intercal\) . Under what conditions could this be true? (Hint: The Identity matrix I is an example of such a matrix). Please typeset your response using LaTeX mode in RStudio. If you do it in paper, please either scan or take a picture of the work and submit it. Please ensure that your image is legible and that your submissions are named using your rst initial, last name, assignment and problem set within the assignment. E.g. LFulton_Assignment2_PS1.png

The only time \(\mathbf{A}^\intercal\) A = A\(\mathbf{A}^\intercal\) is when the detminants are equal or are the identity matrix

A <-matrix(c(2,0,0,-2),nrow=2, ncol=2)
A
##      [,1] [,2]
## [1,]    2    0
## [2,]    0   -2
t(A)
##      [,1] [,2]
## [1,]    2    0
## [2,]    0   -2
A %*% t(A)
##      [,1] [,2]
## [1,]    4    0
## [2,]    0    4
t(A) %*% A
##      [,1] [,2]
## [1,]    4    0
## [2,]    0    4
det(A)
## [1] -4
det(t(A))
## [1] -4
  1. Problem set 2 Matrix factorization is a very important problem. There are supercomputers built justto do matrix factorizations. Every second you are on an airplane, matrices are being factorized. Radars that track lights use a technique called Kalman ltering. At the heart of Kalman Filtering is a Matrix Factorization operation. Kalman Filters are solving linear systems of equations when they track your ight 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.

In factorization Matrix A must = Lower Triangile * Upper Triangle

THE MATRIX

library(matlib)
#MATRIX
a <- matrix(c(3,3,1,6,9,1,6,9,3), nrow=3, ncol=3)
a
##      [,1] [,2] [,3]
## [1,]    3    6    6
## [2,]    3    9    9
## [3,]    1    1    3

Upper Triagle

#uPPER TRIANGLE FACTORING
b<-a
b[2,]<-(-1*b[1,]+b[2,]) #1*R1 + R2
b
##      [,1] [,2] [,3]
## [1,]    3    6    6
## [2,]    0    3    3
## [3,]    1    1    3
b[3,]<-(-1/3*b[1,]+b[3,])#1/3R1 + R3
b
##      [,1] [,2] [,3]
## [1,]    3    6    6
## [2,]    0    3    3
## [3,]    0   -1    1
b[3,]<-(1/3*b[2,]+b[3,])#1/3R2 + R3
b
##      [,1] [,2] [,3]
## [1,]    3    6    6
## [2,]    0    3    3
## [3,]    0    0    2

Lower Triangle

#LOWER TRIANGLE
c<-matrix(c(1,0,0,1,1,0,.3,-.3,1),nrow=3,ncol=3, byrow=TRUE)
c
##      [,1] [,2] [,3]
## [1,]  1.0  0.0    0
## [2,]  1.0  1.0    0
## [3,]  0.3 -0.3    1
b
##      [,1] [,2] [,3]
## [1,]    3    6    6
## [2,]    0    3    3
## [3,]    0    0    2

Matrix (A) 3, 3, 1, 6, 9, 1, 6, 9, 3 = Matrix (C) 1, 1, 0.3, 0, 1, -0.3, 0, 0, 1 * Matrix (B) 3, 0, 0, 6, 3, 0, 6, 3, 2

round(c%*%b,0)
##      [,1] [,2] [,3]
## [1,]    3    6    6
## [2,]    3    9    9
## [3,]    1    1    3
a
##      [,1] [,2] [,3]
## [1,]    3    6    6
## [2,]    3    9    9
## [3,]    1    1    3