RREF and Matlab
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:
A matrix is in reduced row echelon form (RREF) if it satisfies all of the following:
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)\]
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} \]
\[\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}\]