% This is lecture no. 9 of MH1200/: Linear Algebra I.

\chapter{Elementary Matrices}%
\label{cha:elementary_matrices}

\section{What are Elementary Matrices?}%
\label{sec:what_are_elementary_matrices_}



\begin{definition}
	Elementary Matrix.
	An elementary matrix is any matrix which is obtained from an identity matrix by applying a single elementary row operation.
\end{definition}

\begin{exmp}
	There are three types of elementary row operations, so there will be three types of elementary matrix:
	\[
	\begin{bmatrix}
		1 & 0 & 0 & 0\\
		0 & 1 & 0 & 0\\
		0 & 0 & 1 & 0\\
		0 & 0 & 0 & 1\\
	\end{bmatrix}
	\xrightarrow{R_2 \leftrightarrow R_4}
	\begin{bmatrix}
		1 & 0 & 0 & 0\\
		0 & 0 & 0 & 1\\
		0 & 0 & 1 & 0\\
		0 & 1 & 0 & 0\\
	\end{bmatrix}
	.\]
	\[
	\begin{bmatrix}
		1 & 0\\
		0 & 1\\
	\end{bmatrix}
	\xrightarrow{R_2 \to 7R_2}
	\begin{bmatrix}
		1 & 0\\
		0 & 7\\
	\end{bmatrix}
	.\]
	\[
	\begin{bmatrix}
		1 & 0 & 0\\
		0 & 1 & 0\\
		0 & 0 & 1\\
	\end{bmatrix}
	\xrightarrow{R_1 \to R_1 - 5 R_3}
	\begin{bmatrix}
		1 & 0 & -5\\
		0 & 1 & 0\\
		0 & 0 & 1\\
	\end{bmatrix}
	.\]
\end{exmp}

\subsection{Why are Elementary Matrices Useful?}%
\label{sub:why_are_elementary_matrices_useful_}

The main reason why they are useful is that when you multiply on the left with them they perform elementary row operations for you.

Let $A$ be some $m\times n$ matrix.
Let $B$ be the $m\times n$ matrix which results from applying some elementary row operation to $A$.
Let $E$ be the result of applying the same row operation to $I_m$.
Then:
\[
B=EA
.\]

\begin{exmp}
	The starting matrix is:
	\[
	\begin{bmatrix}
		1 & 0 & 2 & 3\\
		2 & -1 & 3 & 6\\
		1 & 4 & 4 & 0\\
	\end{bmatrix}
	.\]
	And the involved elementary row operation is:
	\[
	R_3 \to R_3 - R_1
	.\]
	The row operation:
	\[
	\begin{bmatrix}
		1 & 0 & 2 & 3\\
		2 & -1 & 3 & 6\\
		1 & 4 & 4 & 0\\
	\end{bmatrix}
	\xrightarrow{R_3 \to R_3 - R_1}
	\begin{bmatrix}
		1 & 0 & 2 & 3\\
		2 & -1 & 3 & 6\\
		0 & 4 & 2 & -3\\
	\end{bmatrix}
	.\]
	Can be represented by the following matrix multiplication:
	\[
	\begin{bmatrix}
		1 & 0 & 0\\
		0 & 1 & 0\\
		-1 & 0 & 1\\
	\end{bmatrix}
	\begin{bmatrix}
		1 & 0 & 2 & 3\\
		2 & -1 & 3 & 6\\
		1 & 4 & 4 & 0\\
	\end{bmatrix}
	=
	\begin{bmatrix}
		1 & 0 & 2 & 3\\
		2 & -1 & 3 & 6\\
		0 & 4 & 2 & -3\\
	\end{bmatrix}
	.\]
	Where:
	\[
	\begin{bmatrix}
		1 & 0 & 0\\
		0 & 1 & 0\\
		-1 & 0 & 1\\
	\end{bmatrix}
	\]
	Comes from:
	\[
	\begin{bmatrix}
		1 & 0 & 0\\
		0 & 1 & 0\\
		0 & 0 & 1\\
	\end{bmatrix}
	\xrightarrow{R_3 \to R_3 - R_1}
	\begin{bmatrix}
		1 & 0 & 0\\
		0 & 1 & 0\\
		-1 & 0 & 1\\
	\end{bmatrix}
	.\]
\end{exmp}

\bigbreak

\begin{exmp}
	Let $A$ be some $5\times 100$ matrix.
	Let:
	\[
	E_1 =
	\begin{bmatrix}
		1 & 0 & 0 & 0 & 0\\
		0 & 0 & 0 & 1 & 0\\
		0 & 0 & 1 & 0 & 0\\
		0 & 1 & 0 & 0 & 0\\
		0 & 0 & 0 & 0 & 1\\
	\end{bmatrix}
	\quad
	\text{and}
	\quad
	E_2 =
	\begin{bmatrix}
		1 & 0 & 0 & 0 & 0\\
		0 & 1 & 0 & 1 & 0\\
		0 & 0 & 1 & 0 & 0\\
		0 & 0 & 0 & 1 & 0\\
		0 & 0 & 0 & 0 & 1\\
	\end{bmatrix}
	.\]
	The matrix:
	\[
	E_1E_2A
	.\]
	corresponds to the matrix $A$ with the following row operations in succession:
	\[
	R_2 \to R_2 + R_4
	.\]
	\[
	R_2 \leftrightarrow R_4
	.\]
\end{exmp}

\subsection{Mechanics of Elementary Matrices}%
\label{sub:mechanics_of_elementary_matrices}

\begin{mdframed}
	\begin{lemma}
		\label{rowoper}
		Row operations respect matrix multiplication.
		Let $R(A)$ denote the result of applying some chosen row operation $R$ to some matrix $A$.
		Then:
		\[
			R(AB) = R(A)B
		.\]
	\end{lemma}
\end{mdframed}

Assuming lemma \ref{rowoper} is true, the proof of the mechanics of elementary matrices is as such:
\[
	R(A) = R(IA) = R(I)A = EA
.\]

\begin{proof}
	To prove lemma \ref{rowoper}, we need to prove that each of the three row operations obey the lemma.
	Consider the row operation:
	\[
	R_i \to R_i + aR_j
	.\]
	We can generalise the matrix $A$ into its rows and the matrix $B$ into its columns:
	\[
	A =
	\begin{bmatrix}
		\leftarrow & A_1 & \rightarrow \\
		& \vdots & \\
		\leftarrow & A_n & \rightarrow \\
	\end{bmatrix}
	\quad
	\text{and}
	\quad
	B =
	\begin{bmatrix}
		\uparrow & & \uparrow\\
		B_1 & \cdots & B_m\\
		\downarrow & & \downarrow\\
	\end{bmatrix}
	.\]
	Then $AB$ is of the form:
	\[
	AB =
	\begin{bmatrix}
		A_1B_1 & \cdots & A_1B_m \\
		\vdots & \ddots & \vdots \\
		A_nB_1 & \cdots & A_nB_m \\
	\end{bmatrix}
	.\]
	The result of the row operation $R(AB)$ is of the form:
	\begin{align*}
		R(AB) & =
		\begin{bmatrix}
			A_1B_1 & \cdots & A_1B_m \\
			\vdots & \ddots & \vdots \\
			A_iB_1 + aA_jB_1 & \cdots & A_iB_m + aA_jB_m \\
			\vdots & \ddots & \vdots \\
			A_nB_1 & \cdots & A_nB_m \\
		\end{bmatrix}
		\intertext{Which can be rewritten as such:}
		& =
		\begin{bmatrix}
			A_1B_1 & \cdots & A_1B_m \\
			\vdots & \ddots & \vdots \\
			(A_i + aA_j)B_1 & \cdots & (A_i + aA_j)B_m \\
			\vdots & \ddots & \vdots \\
			A_nB_1 & \cdots & A_nB_m \\
		\end{bmatrix}
		\intertext{Which is the procuct of two matrices:}
		& =
		\begin{bmatrix}
			A_1\\
			\vdots\\
			A_i + aA_j\\
			\vdots\\
			A_n\\
		\end{bmatrix}
		\begin{bmatrix}
			B_1 & \cdots & B_m\\
		\end{bmatrix}
		\intertext{And is finally of the form:}
		& = R(A)B
	\end{align*}
\end{proof}

\subsection{Elementary Matrices are Invertible}%
\label{sub:elementary_matrices_are_inversible}

A matrix $A$ is invertible if there exists another matrix $A^{-1}$ such that:

\[
	AA^{-1} = A^{-1}A = I_n
.\]

This is intuitive since elementary operations can always be undone by another elementary operation:

\bigbreak
\noindent
For the first row operation:
\begin{align*}
	A
	&
	\xrightarrow{R_i \to R_i + cR_j}
	A^\prime
	\\
	A^\prime
	&
	\xrightarrow{R_i \to R_i - cR_j}
	A
\end{align*}
For the second:
\begin{align*}
	A
	&
	\xrightarrow{R_i \leftrightarrow R_j}
	A^\prime
	\\
	A^\prime
	&
	\xrightarrow{R_i \leftrightarrow R_j}
	A
\end{align*}
For the third:
\begin{align*}
	A
	&
	\xrightarrow{R_i \to c R_i}
	A^\prime
	\\
	A^\prime
	&
	\xrightarrow{R_i \to \frac{1}{c}R_i}
	A
\end{align*}

\section{Characterization of Invertability}%
\label{sec:characterization_of_invertibility}

\begin{thrm}
	\label{invert}
	Let $A$ be a square $n\times n$ matrix.
	The following four statements are equivalent:
	\begin{enumerate}
		\item The matrix $A$ is invertible.
		\item The homogeneous linear system $Ax = 0$ where $x$ is a $n\times 1$ matrix only has the trivial solution where every entry of $x$ is zero.
		\item The reduced row echelon form of $A$ is the identity matrix $I_n$.
		\item The matrix $A$ can be expressed as a product of elementary matrices.
	\end{enumerate}
\end{thrm}

\begin{proof}
	This proof is written in 4 steps, each property implying another property; cyclical implication:
	\[
	\begin{matrix}
		1 & \to & 2\\
		\uparrow & & \downarrow\\
		4 & \leftarrow & 3\\
	\end{matrix}
	\]
	Step 1:
	Let us assume the first statement is true; The matrix $A$ is invertible.
	This means that the inverse $A^{-1}$ exists.
	It must be shown from this that $Ax = 0$ only has a trivial solution.

	\bigbreak
	\noindent
	Let $x$ be any $n\times 1$ column vector solving the equation $Ax=0$.

	\noindent
	Then:
	\begin{align*}
		x & = A^{-1}Ax\\
		  & = A^{-1}0\\
		  & = 0
	\end{align*}
	Thus the only solution is $0$ as required.

	\bigbreak
	Step 2:
	Let us assume that the second statement is true; that $Ax= 0$ only has the trivial solution $x=0$.
	It must be shown from this that the reduced row echelon form of $A$ is the identity matrix $I_n$.

	\bigbreak
	First, start by forming the augmented matrix $(A|0)$ corresponding to the system $Ax=0$.
	Then, apply Gauss-Jordan elimination to put this matrix into reduced row echelon form.

	\bigbreak
	If there is a column without a leading entry in reduced row echelon form, then that column becomes a free parameter for the set of solutions of $Ax=0$.
	However, if there is a free parameter, then there are infinitely many solutions.
	This goes against the initial assumption that there is only one solution, 0.

	\bigbreak
	A square matrix in reduced row echelon form where every column contains a leading entry must be the identity matrix, as required.

	\bigbreak
	Step 3:
	Let us assume that the third statement is true; that the reduced row echelon form of $A$ is the identity matrix $I_n$.
	It must be shown from this that $A$ can be expressed as a product of elementary matrices.

	\bigbreak
	$A$ can be transformed into $I_n$ by a sequence of elementary row operations.
	Thus, by just reversing the operations, $I_n$ can be transformed into $A$ by a sequence of elementary row operations.

	\bigbreak
	\noindent
	It follows that there are elementary matrices $E_1, \dotsc, E_k$ such that:
	\[
	A = E_k \ldots E_1 I_n = E_k \ldots E_1
	.\]
	As required.

	\bigbreak
	Step 4:
	Let us assume that the fourth statement is true; that the matrix $A$ can be expressed as a product of elementary matrices.
	It must be shown from this that $A$ is invertible.

	\bigbreak
	The assumption says that there are elementary matrices $E_1, \dotsc, E_k$ such that:
	\[
	A = E_1 \ldots E_k
	.\]
	Since elementary matrices are invertible, and any product of invertible matrices are invertible, then $A$ is invertible as required:
	\[
		A^{-1} = E_k^{-1} \ldots E_1^{-1}
	.\]
\end{proof}

\subsection{An Algorithm to Find the Inverse}%
\label{sub:an_algorithm_to_find_the_inverse}

Let $A$ be an invertible $n\times n$ matrix.
Form a new matrix by putting the $n\times n$ identity matrix $I_n$ to the right of $A$.
For clarity, a vertical line is usually drawn, separating the matrices like so: $[A|I_n]$.

Since we assume that $A$ is invertible, we know that it implies that the reduced row echelon form of $A$ is the identity matrix $I_n$.
So, if we apply Gauss-Jordan elimination to $A$, we will end up with $I_n$.

\bigbreak
\noindent
The algorithm is:
\begin{enumerate}
	\item Do the same row operations is Gauss-Jordan elimination to transform $A$ into $I_n$ but apply them to $[A|I_n]$.
	\item After this $[A|I_n]$ is transformed into $[I_n|X]$ for some $X$.
	\item $X$ happens to be the inverse of $A$.
\end{enumerate}

\begin{exmp}
	Find the inverse of:
	\[
		A =
		\begin{pmatrix}
			1 & 2 & 3\\
			2 & 5 & 3\\
			1 & 0 & 8\\
		\end{pmatrix}
	.\]
	if it exists.
	\begin{align*}
		\begin{pmatrix}[ccc|ccc]
			1 & 2 & 3 & 1 & 0 & 0\\
			2 & 5 & 3 & 0 & 1 & 0\\
			1 & 0 & 8 & 0 & 0 & 1\\
		\end{pmatrix}
		&
		\xrightarrow{\substack{R_2 \to R_2 - 2R_1 \\ R_3 \to R_3 -R_1}}
		\begin{pmatrix}[ccc|ccc]
			1 & 2 & 3 & 1 & 0 & 0\\
			0 & 1 & -3 & -2 & 1 & 0\\
			0 & -2 & 5 & -1 & 0 & 1\\
		\end{pmatrix}
		\\
		&
		\xrightarrow{R_3 \to R_3 +2R_2}
		\begin{pmatrix}[ccc|ccc]
			1 & 2 & 3 & 1 & 0 & 0\\
			0 & 1 & -3 & -2 & 1 & 0\\
			0 & 0 & -1 & -5 & 2 & 1\\
		\end{pmatrix}
		\\
		&
		\xrightarrow{R_3 \to -R_3}
		\begin{pmatrix}[ccc|ccc]
			1 & 2 & 3 & 1 & 0 & 0\\
			0 & 1 & -3 & -2 & 1 & 0\\
			0 & 0 & 1 & 5 & -2 & -1\\
		\end{pmatrix}
		\\
		&
		\xrightarrow{\substack{R_1 \to R_1 -3R_3 \\ R_2 \to R_2 + 3R_3}}
		\begin{pmatrix}[ccc|ccc]
			1 & 2 & 0 & -14 & 6 & 3\\
			0 & 1 & 0 & 13 & -5 & -3\\
			0 & 0 & 1 & 5 & -2 & -1\\
		\end{pmatrix}
		\\
		&
		\xrightarrow{R_1 \to R_1 -2R_2}
		\begin{pmatrix}[ccc|ccc]
			1 & 0 & 0 & -40 & 16 & 9\\
			0 & 1 & 0 & 13 & -5 & -3\\
			0 & 0 & 1 & 5 & -2 & -1\\
		\end{pmatrix}
	\end{align*}

	Performing Gauss-Jordan elimination on this matrix results in $I_3$.
	This implies that $A$ is invertible, and that the inverse matrix on the right hand side is:
	\[
		A^{-1} =
		\begin{bmatrix}
			-40 & 16 & 9\\
			13 & -5 & -3\\
			5 & -2 & -1\\
		\end{bmatrix}
	.\]
	Because $A$ is invertible, Gauss-Jordan elimination gives some sequence of elementary row operations that transforms $A$ into $I_n$.
	Denote the elementary matrices corresponding to this sequence of operations by:
	\[
	E_1, \dotsc, E_k
	.\]
	And, note that they satisfy the following equation:
	\[
	E_k \ldots E_1 A = I_n
	.\]
	If we then apply this sequence of elementary row operations to the matrix $[A|I_n]$, then we obtain:
	\begin{align*}
		[A|I_n] \to &[E_k \ldots E_1 A|E_k \ldots E_1I_n]\\
			= &[I_n|E_k \ldots E_1]
	\end{align*}
	Showing that the matrix that appears on the right after this sequence of operations is precisely:
	\[
	E_k \ldots E_1
	.\]
	Which is exactly equal to $A^{-1}$.
\end{exmp}
