Gaussian Elimination (REF) Calculator
Transform a matrix into row echelon form (REF) using Gaussian elimination and elementary row operations. REF arranges pivot entries in a staircase pattern, making it useful for solving linear systems and determining matrix rank.
A
Learn About Gaussian Elimination (REF)
Gaussian elimination applies sequential elementary row operations to transform an arbitrary rectangular matrix $\mathbf{A} \in \mathbb{R}^{m \times n}$ into a staircase structure called Row Echelon Form (REF).
REF preserves the linear row relationships and rank of the original matrix while greatly simplifying computations for matrix rank, vector span, linear independence, and linear system solving via back-substitution.
Definition and Conditions of Row Echelon Form
A matrix is in Row Echelon Form if and only if it satisfies three structural conditions:
- Zero Rows at Bottom: Any rows consisting entirely of zeros are grouped at the bottom.
- Staircase Leading Pivots: The leading non-zero entry (pivot) of each non-zero row lies strictly to the right of the leading pivot in the row above it.
- Zeros Below Pivots: All entries in the same column strictly below a leading pivot are zero.
In GammaCalculator, each pivot entry is normalized to $1$ during forward elimination ($R_r \leftarrow \frac{1}{\text{pivot}} R_r$).
Elementary Row Operations (EROs)
Gaussian elimination relies on three reversible operations that preserve the matrix row space:
- Row Swap ($R_i \leftrightarrow R_j$): Swap two rows when the active diagonal entry is zero.
- Row Scaling ($R_i \leftarrow c R_i$, $c \ne 0$): Multiply a row by a non-zero scalar to normalize the pivot to $1$.
- Row Addition / Elimination ($R_j \leftarrow R_j - c R_i$): Add a scalar multiple of the pivot row to eliminate entries below the pivot.
Key Distinction: REF vs. RREF
- Row Echelon Form (REF): Forward elimination clears entries strictly below each pivot. Entries above pivots remain untouched. REF is not mathematically uniqueβdifferent operation sequences produce different valid REF matrices.
- Reduced Row Echelon Form (RREF): A subsequent backward elimination phase clears entries above each pivot as well, creating a strictly unique canonical matrix for any input.
Worked Numerical Example
Transform the following $3 \times 3$ matrix into REF:
- Normalize Row 1:
- Eliminate Below Pivot 1:
- $R_2 \leftarrow R_2 - 4R_1 \implies [4-4, \, 9-8, \, -3-(-4)] = [0, 1, 1]$
- $R_3 \leftarrow R_3 + 2R_1 \implies [-2+2, \, -3+4, \, 7-2] = [0, 1, 5]$
- Eliminate Below Pivot 2:
Pivot $2$ is already $1$. Eliminate Row 3 entry:
- Normalize Row 3:
The resulting matrix is in Row Echelon Form:
With 3 non-zero rows, $\operatorname{rank}(\mathbf{A}) = 3$. Entries above the pivots remain in place.
Why is Row Echelon Form not unique while RREF is unique?
In REF, entries above pivot positions are not eliminated, so different row operation sequences yield different numbers above pivots. In contrast, RREF enforces zeros above every pivot and unit pivots, guaranteeing a mathematically unique canonical form.
How does Gaussian elimination determine matrix rank?
The rank of a matrix equals the number of non-zero rows (or leading pivots) in its Row Echelon Form. Because elementary row operations do not alter linear dependencies among rows, the number of independent rows remains strictly invariant throughout elimination.
Can Gaussian elimination be performed on non-square matrices?
Yes. Gaussian elimination applies to any $m \times n$ rectangular matrix. Tall matrices ($m > n$) typically develop zero rows at the bottom. Wide matrices ($m < n$) contain at most $m$ pivots, leaving at least $n - m$ non-pivot columns corresponding to free variables.
What is partial pivoting and why is it used?
In floating-point numerical implementations, partial pivoting searches the current column for the entry with the largest absolute value and swaps it into the pivot position. This minimizes division by near-zero numbers, preventing roundoff error propagation. In exact rational arithmetic (`Fraction`), row swaps are only required when the active pivot is zero.
- Ancient Chinese Origins: Although named after Carl Friedrich Gauss (who formalized it in 1809 for celestial orbit calculations), Gaussian elimination was described in the ancient Chinese text The Nine Chapters on the Mathematical Art, compiled during the Han dynasty around 150 BCE.
- Computational Complexity: Transforming an $n \times n$ matrix into Row Echelon Form requires approximately $\frac{2}{3}n^3$ arithmetic operations. This $O(n^3)$ scaling makes Gaussian elimination vastly superior to determinant formulas such as Cramer's rule ($O(n!)$) for solving linear systems.