\documentclass

CUNY DATA605_Wk2

Zachary Herold

February 6, 2019


Problem Set 1

CASE 1: A is not a square matrix (i.e. m # of rows ≠ n # of columns )

Recall the rule, if A is an n × m matrix and B is an m × p matrix, then AB is an n x p matrix by definition.

Assume A is an m x n matrix.

\[ \begin{equation*} \mathbf{A} = \begin{bmatrix}a_{11}&a_{12}&\cdots &a_{1n}\\a_{21}&a_{22}&\cdots &a_{2n}\\\vdots &\vdots &\ddots &\vdots \\a_{m1}&a_{m2}&\cdots &a_{mn}\\\end{bmatrix} \end{equation*} \]

Therefore AT is an n x m matrix.

\[ \begin{equation*} \mathbf{A^T} =\begin{bmatrix}a_{11}&a_{21}&\cdots &a_{m1}\\a_{12}&a_{22}&\cdots &a_{m2}\\\vdots &\vdots &\ddots &\vdots \\a_{1n}&a_{2n}&\cdots &a_{nm}\\\end{bmatrix} \end{equation*} \]

A(AT) is an m x m matrix.

\[ \begin{equation*} \mathbf{A_{m x n}} * \mathbf{A^T_{n x m}} = \mathbf{B_{m x m}} \end{equation*} \]

(AT)A is an n x n matrix.

\[ \begin{equation*} \mathbf{A^T_{n x m}} * \mathbf{A_{m x n}} = \mathbf{C_{n x n}} \end{equation*} \]

Since m ≠ n, the two matrices are not of the same dimensions, and thus they cannot be equal.


CASE 2: A is a square matrix (i.e. m # of rows = n # of columns )

Illustrate with a 2 x 2 matrix first.

\[ \begin{equation*} \mathbf{A} = \begin{bmatrix}a&b\\c&d\end{bmatrix} \end{equation*} \]

\[ \begin{equation*} \mathbf{A^T} = \begin{bmatrix}a&c\\b&d\end{bmatrix} \end{equation*} \]

\[ \begin{equation*} \mathbf{A(A^T)} = \begin{bmatrix}a&b\\c&d\end{bmatrix} * \begin{bmatrix}a&c\\b&d\end{bmatrix} = \begin{bmatrix}a^2 + b^2&ac + bd\\ac+bd&c^2+d^2\end{bmatrix} \end{equation*} \]

\[ \begin{equation*} \mathbf{A^T(A)} = \begin{bmatrix}a&c\\b&d\end{bmatrix} * \begin{bmatrix}a&b\\c&d\end{bmatrix} = \begin{bmatrix}a^2 + c^2&ab + cd\\ab+cd&b^2+d^2\end{bmatrix} \end{equation*} \]

The matrices are equal if and only if the following expression is true.

\[ \begin{equation*} \begin{bmatrix}a^2 + b^2&ac + bd\\ac+bd&c^2+d^2\end{bmatrix} = \begin{bmatrix}a^2 + c^2&ab + cd\\ab+cd&b^2+d^2\end{bmatrix} ? \end{equation*} \]

The system of necessary conditions is rewritten here:

\[ \begin{equation*} a^2 + b^2 = a^2+c^2\\ c^2 + d^2 = b^2+d^2\\ ac + bd = ab+cd\\ \end{equation*} \]

First, we note that the following must be true.

\[ \begin{equation*} b^2 = c^2 \end{equation*} \]

CASE 1: Assume

\[ \begin{equation*} b = c \end{equation*} \]

In this case, \[ \begin{equation*} \mathbf{A} = \mathbf{A^T} \end{equation*} \]

\[ \begin{equation*} If (c = b), \mathbf{A(A^T)} = \mathbf{A^T(A)} = \begin{bmatrix}a&b\\b&d\end{bmatrix} * \begin{bmatrix}a&b\\b&d\end{bmatrix} = \begin{bmatrix}a^2 + b^2&ab + bd\\ab+bd&b^2+d^2\end{bmatrix} \end{equation*} \]

CASE 2: Assume

\[ \begin{equation*} c = -b \end{equation*} \]

\[ \begin{equation*} a^2 + b^2 = a^2+(-b)^2\\ (-b)^2 + d^2 = b^2+d^2\\ a(-b) + bd = ab+(-b)d\\ \end{equation*} \]

The first two equations hold and the third can be simplified as follows.

\[ \begin{equation*} -ab + bd = ab-bd\\ 2ab = 2bd\\ ab = bd\\ a = d\\ \end{equation*} \]

Therefore, if c = -b, a must equal d for A(AT) = AT(A).

\[ \begin{equation*} If (c = -b ∧ a = d), \mathbf{A(A^T)} = \mathbf{A^T(A)} = \\\begin{bmatrix}a&b\\-b&a\end{bmatrix} * \begin{bmatrix}a&-b\\b&a\end{bmatrix} =\\ \begin{bmatrix}a&-b\\b&a\end{bmatrix} * \begin{bmatrix}a&b\\-b&a\end{bmatrix} =\\\begin{bmatrix}a^2 + b^2&0\\0&a^2+b^2\end{bmatrix} =\\(a^2 + b^2) \begin{bmatrix}1&0\\0&1\end{bmatrix} \end{equation*} \]

This can be generalized to matrices with m rows and columns greater than 2. The conditions for A(AT) = AT(A) are:

(1) A matrix must be symmetrical along the diagonal, or

(2) The multiplication of the matrix and its transpose must be the identity matrix multipled by some scalar.

*****
### Problem Set 2

Write an R function to factorize a square matrix A into LU or LDU, whichever you prefer.
Since I already did a LU Decomposition for a 3x3 matrix in Week 1’s assignment, here I generalize the function to any square matrix, and additionally decompose the diagonal matrix.

## Warning: package 'MASS' was built under R version 3.5.2

Verifying the decomposition using Archetype K from the text.

## [1] "Lower Triangular Matrix"
##      [,1]     [,2]     [,3]     [,4]     [,5]    
## [1,]        1        0        0        0        0
## [2,]      6/5        1        0        0        0
## [3,]       -3 -165/118        1        0        0
## [4,]    27/10   93/118   -81/20        1        0
## [5,]      9/5    21/59    -12/5    12/19        1
## [1] ""
## [1] "Diagonal Matrix"
##      [,1]   [,2]   [,3]   [,4]   [,5]  
## [1,]     10      0      0      0      0
## [2,]      0 -118/5      0      0      0
## [3,]      0      0  20/59      0      0
## [4,]      0      0      0  19/10      0
## [5,]      0      0      0      0  -2/19
## [1] ""
## [1] "Upper Triangular Matrix"
##      [,1]   [,2]   [,3]   [,4]   [,5]  
## [1,]      1    9/5   12/5   12/5   -6/5
## [2,]      0      1  87/59  72/59   9/59
## [3,]      0      0      1  51/10     -6
## [4,]      0      0      0      1 -30/19
## [5,]      0      0      0      0      1
## [1] ""
## [1] "Original Matrix"
##      [,1] [,2] [,3] [,4] [,5]
## [1,]   10   18   24   24  -12
## [2,]   12   -2   -6    0  -18
## [3,]  -30  -21  -23  -30   39
## [4,]   27   30   36   37  -30
## [5,]   18   24   30   30  -20
## [1] ""
## [1] "Re-composed Matrix for Verification"
##      [,1] [,2] [,3] [,4] [,5]
## [1,]   10   18   24   24  -12
## [2,]   12   -2   -6    0  -18
## [3,]  -30  -21  -23  -30   39
## [4,]   27   30   36   37  -30
## [5,]   18   24   30   30  -20
## [1] ""
## [1] "The two matrices are identical: TRUE"

Note: My function currently breaks down when zeroes appear in the lower portion of the Original Matrix and/or when they appear after row operations. For the a-factorizations that occurs in the function, I would have to build a test to conditionally enable row swaps if zeroes are discovered.