Problem Set 1

Part 1

Show that: \[A^TA \neq AA^T \]

Proof:

One of the basic laws of matrices is:

\[AB \neq BA \]

This law shows that matrix multiplication is not commutative, therefore \[A^TA \neq AA^T \]

Demonstation:

Generate a random matrix A:

##      [,1] [,2] [,3]
## [1,]    5   12    4
## [2,]   13   13    7
## [3,]    8    7   13
##      [,1] [,2] [,3]
## [1,]    5   13    8
## [2,]   12   13    7
## [3,]    4    7   13

\[A^TA:\]

##      [,1] [,2] [,3]
## [1,]  258  285  215
## [2,]  285  362  230
## [3,]  215  230  234

\[AA^T: \]

##      [,1] [,2] [,3]
## [1,]  185  249  176
## [2,]  249  387  286
## [3,]  176  286  282

The example above shows that generally, the products of matrix multiplication are not equal when multiplication order is inversed.

Part 2

For a special type of square matrix A, we get: \[A^TA = AA^T \] Under what conditions could this be true? (Hint: The Identity matrix I is an example of such a matrix).

This is true when the transpose of A is equal to A.

Demonstration:

##      [,1] [,2] [,3]
## [1,]    1    0    1
## [2,]    0    1    0
## [3,]    1    0    1
##      [,1] [,2] [,3]
## [1,] TRUE TRUE TRUE
## [2,] TRUE TRUE TRUE
## [3,] TRUE TRUE TRUE

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.

To solve this question, I used an algorithm from this site.

Generate a random 3x3 matrix:

##      [,1] [,2] [,3]
## [1,]    3   16    6
## [2,]    3   14   16
## [3,]    3    4   19

The function returns the following lower form matrix:

##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    1    1    0
## [3,]    1    6    1

The function returns the following upper form matrix:

##      [,1] [,2] [,3]
## [1,]    3   16    6
## [2,]    0   -2   10
## [3,]    0    0  -47

Test that the product of the lower and upper form matrices is equal to the original matrix:

##      [,1] [,2] [,3]
## [1,] TRUE TRUE TRUE
## [2,] TRUE TRUE TRUE
## [3,] TRUE TRUE TRUE