Day 3

RREF and Matlab

Elementary Matrices and Row Operations

Two matrices \(A\) and \(B\) are row equivalent if \(B\) can be obtained from \(A\) by some sequence of row operations. The row operations are the following:

  1. Swap two rows
  2. Replace row \(R_{1}\) with \(aR_{1}\) for some nonzero scalar \(a\).
  3. Given two rows \(R_{1}\) and \(R_{2}\) we can replace \(R_{1}\) with \(R_{1}+aR_{2}\) for some scalar \(a\).

RREF

A matrix is in reduced row echelon form (RREF) if it satisfies all of the following:

  1. All nonzero rows are above any rows of all zeros
  2. The leading entry in each nonzero row is strictly to the right of the leading entry of the row above it.
  3. The leading entry of each nonzero row is \(1\).
  4. Each column containing a leading \(1\) (also known as a pivot) has all zeros in the rest of the column.

An algorithm to find rref(\(A\))

Start with the \(m\times n\) matrix \(A\)

for \(r\in\{1,2,\ldots,m\}\)

Step 1:

Find the first nonzero entry in row \(r\), say it is in column \(c\). If the whole row is zero, then move on to the next step.

Step 2:

Multiply the row by \(1/A(r,c)\)

Step 3:

For each row \(r'\neq r\) replace row \(r'\) with itself plus the appropriate multiple of row \(r\) so that the entry in row \(r'\), column \(c\) is zero.

end 

Rearrange the rows so that each pivot is to the right of the one above it.

Example.

 

\[A = \begin{bmatrix} 0 & 0 & 0 & 0\\ 0 & 2 & 1 & -1\\ 3 & 2 & 0 & 6\end{bmatrix} \sim \begin{bmatrix} 0 & 0 & 0 & 0\\ 0 & 1 & \frac{1}{2} & -\frac{1}{2}\\ 3 & 2 & 0 & 6\end{bmatrix} \sim \begin{bmatrix} 0 & 0 & 0 & 0\\ 0 & 1 & \frac{1}{2} & -\frac{1}{2}\\ 3 & 0 & -1 & 7\end{bmatrix} \]

\[ \sim \begin{bmatrix} 0 & 0 & 0 & 0\\ 0 & 1 & \frac{1}{2} & -\frac{1}{2}\\ 1 & 0 & -\frac{1}{3} & \frac{7}{3}\end{bmatrix}  \sim \begin{bmatrix} 1 & 0 & -\frac{1}{3} & \frac{7}{3}\\ 0 & 1 & \frac{1}{2} & -\frac{1}{2}\\ 0 & 0 & 0 & 0 \end{bmatrix} = \text{rref}(A)\]

  1. Multiply Row 2 by \(\frac{1}{2}\)
  2. Replace Row 3 with (Row 3) - 2(Row 2)
  3. Multiply Row 3 by \(\frac{1}{3}\)
  4. Swap rows 1 and 3

Example.

\[A = \begin{bmatrix} 0 & 2 & -2 & 0\\ 0 & 2 & 1 & -1\\ 3 & 2 & 0 & 6\end{bmatrix} \sim \begin{bmatrix} 0 & 1 & -1 & 0\\ 0 & 2 & 1 & -1\\ 3 & 2 & 0 & 6\end{bmatrix} \sim  \begin{bmatrix} 0 & 1 & -1 & 0\\ 0 & 0 & 3 & -1\\ 3 & 2 & 0 & 6\end{bmatrix}\]

\[ \sim \begin{bmatrix} 0 & 1 & -1 & 0\\ 0 & 0 & 3 & -1\\ 3 & 0 & 2 & 6\end{bmatrix} \sim \begin{bmatrix} 0 & 1 & -1 & 0\\ 0 & 0 & 1 & -\frac{1}{3}\\ 3 & 0 & 2 & 6\end{bmatrix}\sim \begin{bmatrix} 0 & 1 & 0 & -\frac{1}{3}\\ 0 & 0 & 1 & -\frac{1}{3}\\ 3 & 0 & 2 & 6\end{bmatrix} \]

  • Multiply Row 1 by \(\frac{1}{2}\)
  • Replace Row 2 with (Row 2) - 2(Row 1)
  • Replace Row 3 with (Row 3) - 2(Row 1)
  • Multiply Row 2 by \(\frac{1}{3}\)

\[\sim \begin{bmatrix} 0 & 1 & 0 & -\frac{1}{3}\\ 0 & 0 & 1 & -\frac{1}{3}\\ 3 & 0 & 0 & \frac{20}{3}\end{bmatrix} \sim \begin{bmatrix} 0 & 1 & 0 & -\frac{1}{3}\\ 0 & 0 & 1 & -\frac{1}{3}\\ 1 & 0 & 0 & \frac{20}{9}\end{bmatrix} \sim\cdots\sim \begin{bmatrix} 1 & 0 & 0 & \frac{20}{9}\\ 0 & 1 & 0 & -\frac{1}{3}\\ 0 & 0 & 1 & -\frac{1}{3}\end{bmatrix}\]

  • Replace Row 1 with (Row 1) + (Row 2)
  • Replace Row 3 with (Row 3) - 2(Row 2)
  • Multiply Row 3 by \(\frac{1}{3}\)
  • Swap rows 2 and 3, then rows 1 and 2

Linear Algebra Day 3

By John Jasper

Linear Algebra Day 3

  • 309