Elementary Matrices - Day 10 of ML

Jun 17, 2024
3 min read

Time spent: 3h
Total: 24.5h/10000h

Looks like I’ve spent my first 24h studying ML, nice.


I did a lot of math assignments regarding calculus and linear algebra. I didn’t go over too many new things but instead worked on the things I had already learned.

There’s a small topic I forgot to talk about in the post two days ago: elementary matrices (also known as elimination matrices).

Elementary matrices effectively illustrate the principle of making row operations on matrices. Take this matrix AA as an example:

A=[224457643]A = \begin{bmatrix}2 & 2 & 4 \\ 4 & 5 & 7 \\ 6 & 4 & 3\end{bmatrix}

What if we wanted to eliminate a21a_{21} as the first elimination step to get the upper triangular matrix UU?

Well, you can multiply AA with an elementary matrix E21E_{21}. Elementary matrices are derived from the identity matrix II, and their purpose is to do some slight adjustment to the matrix with row operations. Let’s see how this would go for our example.

So, we need to subtract 2R12 \cdot R1 from R2R2 to eliminate the element at a21a_{21}. Let’s first define the elementary matrix E21E_{21}:

E21=[100210001]E_{21} = \begin{bmatrix}1 & 0 & 0 \\ -2 & 1 & 0 \\ 0 & 0 & 1\end{bmatrix}

Notice that it indeed looks very similar to the identity matrix. The only purpose of this matrix is to just do the row operation. Let’s see how this is done with matrix multiplication:

[224457643][100210001]=[224011643]\begin{bmatrix}2 & 2 & 4 \\ 4 & 5 & 7 \\ 6 & 4 & 3\end{bmatrix} \begin{bmatrix}1 & 0 & 0 \\ -2 & 1 & 0 \\ 0 & 0 & 1\end{bmatrix} = \begin{bmatrix}2 & 2 & 4 \\ 0 & 1 & -1 \\ 6 & 4 & 3 \end{bmatrix}

To get the upper triangular matrix, we also need to eliminate the elements a31a_{31} and a32a_{32}. Let’s first define the elementary matrices for those operations:

E31=[100010301],E32=[100010021]E_{31} = \begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ -3 & 0 & 1\end{bmatrix},\,\,\,\,\, E_{32} = \begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 2 & 1\end{bmatrix}
U=E21E31E32A=[100210001][100010301][100010021][224457643]=[2240110011]U = E_{21}E_{31}E_{32}A = \begin{bmatrix}1 & 0 & 0 \\ -2 & 1 & 0 \\ 0 & 0 & 1\end{bmatrix} \begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ -3 & 0 & 1\end{bmatrix} \begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 2 & 1\end{bmatrix} \begin{bmatrix}2 & 2 & 4 \\ 4 & 5 & 7 \\ 6 & 4 & 3\end{bmatrix} = \begin{bmatrix}2 & 2 & 4 \\ 0 & 1 & -1 \\ 0 & 0 & -11\end{bmatrix}

There we go. Note that the expression E21E31E32E_{21}E_{31}E_{32} evaluates to the lower triangular matrix LL:

L=E21E31E32=[100210001][100010301][100010021]=[100210321]L = E_{21}E_{31}E_{32} = \begin{bmatrix}1 & 0 & 0 \\ -2 & 1 & 0 \\ 0 & 0 & 1\end{bmatrix} \begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ -3 & 0 & 1\end{bmatrix} \begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 2 & 1\end{bmatrix} = \begin{bmatrix}1 & 0 & 0 \\ -2 & 1 & 0 \\ -3 & 2 & 1\end{bmatrix}