ASSIGNMENT 2

IS 605 FUNDAMENTALS OF COMPUTATIONAL MATHEMATICS - 2019

1. Problem set 1

  1. Show that AT A 6= AAT in general. (Proof and demonstration.)
A = matrix(c(3, 4, 1, 2), ncol= 2, byrow = T)

A
##      [,1] [,2]
## [1,]    3    4
## [2,]    1    2
AT = t(A)
AT
##      [,1] [,2]
## [1,]    3    1
## [2,]    4    2
ATA = AT %*% A
ATA
##      [,1] [,2]
## [1,]   10   14
## [2,]   14   20
AAT = A %*% AT
AAT
##      [,1] [,2]
## [1,]   25   11
## [2,]   11    5
ATA == AT
##       [,1]  [,2]
## [1,] FALSE FALSE
## [2,] FALSE FALSE

(2) For a special type of square matrix A, we get AT A = AAT. Under what conditions

could this be true? (Hint: The Identity matrix I is an example of such a matrix).

A = matrix(c(1,0,0,0,1,0,0,0,1), ncol=3, byrow=T)
A
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    0    1    0
## [3,]    0    0    1
AT = t(A)
AT
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    0    1    0
## [3,]    0    0    1
ATA = AT %*% A
ATA
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    0    1    0
## [3,]    0    0    1
AAT = A %*% AT
AAT
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    0    1    0
## [3,]    0    0    1
ATA == AT
##      [,1] [,2] [,3]
## [1,] TRUE TRUE TRUE
## [2,] TRUE TRUE TRUE
## [3,] TRUE TRUE TRUE

2. 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.

fact <- function(A, L, x) {
 
c <- ncol(A)
r <- nrow(A)

if(x >= c){
  return(list(L,x))
}

else {
  for (i in (x+1):r){
    mult <- (-A[i,x]/A[x,x])
    L[i,x] <- round(-mult,2)
    A[i,] <- A[i,] + mult * A[x, ]
  }
  print(A)
}
fact(A, L, x + 1)
}


A <- matrix(c(1, 4, -3, -2, 8, 5, 3, 4, 7), nrow=3, ncol=3, byrow = TRUE)
print(A)
##      [,1] [,2] [,3]
## [1,]    1    4   -3
## [2,]   -2    8    5
## [3,]    3    4    7
matrix1 <- fact(A, diag(nrow(A)), 1)
##      [,1] [,2] [,3]
## [1,]    1    4   -3
## [2,]    0   16   -1
## [3,]    0   -8   16
##      [,1] [,2] [,3]
## [1,]    1    4 -3.0
## [2,]    0   16 -1.0
## [3,]    0    0 15.5

Source:

https://www.khanacademy.org/math/precalculus/precalc-matrices/modal/a/properties-of-matrix-multiplication