Gaussian Elimination: Linear Algebra Study Notes
October 11, 2026
๐งฎ Gaussian Elimination
- What Gaussian elimination (row reduction) is and what it is used for
- The three elementary row operations
- Row echelon form vs. reduced row echelon form, and GaussโJordan elimination
- Forward elimination, back substitution, and the matrix-decomposition view
- A worked example solving a 3-variable linear system
- Applications: determinants, matrix inverses, ranks and bases
- Computational efficiency, the Bareiss algorithm, and numerical instability
- Generalizations and pseudocode with partial pivoting
๐ก Overview
Gaussian elimination, also known as row reduction, is an algorithm for solving systems of linear equations. It consists of a sequence of row-wise operations performed on the corresponding matrix of coefficients.
- It can also be used to compute:
- the rank of a matrix
- the determinant of a square matrix
- the inverse of an invertible matrix
- The method is named after Carl Friedrich Gauss (1777โ1855).
- Goal of row reduction: use a sequence of elementary row operations to modify the matrix until the lower left-hand corner of the matrix is filled with zeros, as much as possible.
๐ง Elementary Row Operations
There are three types of elementary row operations:
| Type | Operation |
|---|---|
| 1 | Swapping (interchanging) two rows |
| 2 | Multiplying a row by a nonzero number (non-zero scalar) |
| 3 | Adding a multiple of one row to another row |
- If the matrix is associated to a system of linear equations, these operations do not change the solution set.
- Therefore, if the goal is to solve a system of linear equations, using these row operations can make the problem easier.
๐ Echelon Forms
Leading entries (pivots)
- For each row that does not consist of only zeros, the leftmost nonzero entry is called the leading entry (or pivot) of that row.
- If two leading entries are in the same column, a type 3 row operation can be used to make one of those entries zero.
- Using row swaps, one can always order the rows so that for every non-zero row, the leading entry is to the right of the leading entry of the row above.
Row echelon form
A matrix with the ordering above is said to be in row echelon form.
- The lower left part of the matrix contains only zeros.
- All of the zero rows are below the non-zero rows.
- The word "echelon" is used because one can roughly think of the rows being ranked by their size, with the largest at the top and the smallest at the bottom.
Example of a matrix in row echelon form:
It is in echelon form because the zero row is at the bottom and the leading entry of the second row (in the third column) is to the right of the leading entry of the first row (in the second column). Its leading entries are 2 and 3.
Reduced row echelon form
A matrix is in reduced row echelon form if, furthermore:
- Each nonzero row is above every zero row.
- All of the leading entries are equal to 1 (achievable with a type 2 operation).
- In every column containing a leading entry, all of the other entries in that column are zero (achievable with type 3 operations).
- The leading 1 in each nonzero row is to the right of the leading 1 in the previous row.
Using the three row operations, a matrix can always be transformed into reduced row echelon form. This final form is unique: it is independent of the sequence of row operations used.
Example sequence of row operations
Two elementary operations on different rows are done at the first and third steps. The third and fourth matrices are in row echelon form, and the final matrix is the unique reduced row echelon form:
Gaussian vs. GaussโJordan elimination
| Term | Meaning |
|---|---|
| Gaussian elimination | The process until it has reached its upper triangular, (unreduced) row echelon form |
| GaussโJordan elimination | Using row operations to convert a matrix all the way into reduced row echelon form |
- For computational reasons, when solving systems of linear equations, it is sometimes preferable to stop row operations before the matrix is completely reduced.
โ๏ธ The Algorithm: Two Parts
The process of row reduction uses elementary row operations and can be divided into two parts.
- Forward elimination
- Reduces a given system to row echelon form.
- From this form one can tell whether there are no solutions, a unique solution, or infinitely many solutions.
- Back substitution
- Continues to use row operations until the solution is found.
- In other words, it puts the matrix into reduced row echelon form.
Matrix-decomposition view
Another point of view, very useful for analyzing the algorithm, is that row reduction produces a matrix decomposition of the original matrix.
- The elementary row operations may be viewed as multiplication on the left of the original matrix by elementary matrices.
- A sequence of elementary operations that reduces a single row may be viewed as multiplication by a Frobenius matrix.
- Then:
- the first part of the algorithm computes an LU decomposition
- the second part writes the original matrix as the product of a uniquely determined invertible matrix and a uniquely determined reduced row echelon matrix
๐ Worked Example: Solving a System
Goal: find and describe the set of solutions of
- In practice, one does not usually deal with systems in terms of equations, but makes use of the augmented matrix, which is more suitable for computer manipulations.
- Procedure summary:
- Eliminate from all equations below .
- Eliminate from all equations below .
- This puts the system into triangular form.
- Using back-substitution, solve for each unknown.
First steps
- is eliminated from by adding to .
- Next, is eliminated from by adding to .
- These row operations are labelled as:
Finishing
- Once is also eliminated from the third row, the result is a system in triangular form, and the first part of the algorithm is complete.
- From a computational point of view, it is faster to solve the variables in reverse order (back-substitution).
- The solution is , , . There is a unique solution to the original system.
- Instead of stopping at row echelon form, one can continue to reduced row echelon form. This is sometimes referred to as GaussโJordan elimination, to distinguish it from stopping after reaching echelon form.
๐ Applications
Historically, the first application of row reduction is solving systems of linear equations. Other important applications follow.
Computing determinants
How elementary row operations change the determinant:
| Row operation | Effect on the determinant |
|---|---|
| Swapping two rows | Multiplies the determinant by |
| Multiplying a row by a nonzero scalar | Multiplies the determinant by the same scalar |
| Adding to one row a scalar multiple of another | Does not change the determinant |
If Gaussian elimination applied to a square matrix produces a row echelon matrix , let be the product of the scalars by which the determinant has been multiplied. Then the determinant of is the quotient by of the product of the diagonal elements of :
Cost comparison for an matrix:
| Method | Operations |
|---|---|
| Gaussian elimination | only arithmetic operations |
| Leibniz formula | operations (number of summands times the number of multiplications in each summand) |
| Recursive Laplace expansion | operations if the sub-determinants are memorized and computed only once |
- Even on the fastest computers, the Leibniz and Laplace methods are impractical or almost impracticable for above 20.
Finding the inverse of a matrix
A variant called GaussโJordan elimination can be used to find the inverse of a matrix, if it exists.
- For an square matrix , augment the identity matrix to the right of , forming an block matrix .
- Apply elementary row operations to find the reduced echelon form of this matrix.
- is invertible if and only if it can be reduced to the identity matrix . In that case the right block of the final matrix is .
- If the algorithm cannot reduce the left block to , then is not invertible.
Example. Take
Row-reduce the augmented matrix
Its reduced row echelon form is
Why it works:
- Each row operation is a left product by an elementary matrix.
- On the right, the product of these elementary matrices is (since ).
- On the left, multiplying that product into yields the identity, so .
- Therefore . The procedure works for square matrices of any size.
Computing ranks and bases
Gaussian elimination can be applied to any matrix . For example, some matrices can be transformed to a row echelon form like
where the stars are arbitrary entries and are nonzero entries. This echelon matrix contains a wealth of information about :
- The rank of is 5, since there are 5 nonzero rows in .
- The vector space spanned by the columns of has a basis consisting of its columns 1, 3, 4, 7 and 9 (the columns with in ).
- The stars show how the other columns of can be written as linear combinations of the basis columns.
- All of this also applies to the reduced row echelon form, which is a particular row echelon format.
โฑ๏ธ Computational Efficiency
The number of arithmetic operations is one way of measuring efficiency. To solve a system of equations in unknowns by row operations to echelon form and then solving in reverse order requires:
| Operation | Count |
|---|---|
| Divisions | |
| Multiplications | |
| Subtractions |
- Total: approximately operations.
- Thus the arithmetic complexity (time complexity, where each arithmetic operation takes one unit of time, independent of input size) is .
When this is a good measure of time:
- When the time per arithmetic operation is approximately constant, as with floating-point coefficients or coefficients in a finite field.
- If coefficients are exactly represented integers or rational numbers, intermediate entries can grow exponentially large, so the bit complexity is exponential.
Scale:
- Gaussian elimination and its variants can be used on computers for systems with thousands of equations and unknowns.
- The cost becomes prohibitive for systems with millions of equations; these large systems are generally solved using iterative methods.
- Specific methods exist for systems whose coefficients follow a regular pattern.
Bareiss algorithm
- The first strongly-polynomial time algorithm for Gaussian elimination was published by Jack Edmonds in 1967.
- Independently, and almost simultaneously, Erwin Bareiss discovered another algorithm, based on a remark that applies to a division-free variant of Gaussian elimination.
- It keeps the same arithmetic complexity but has a bit complexity of , and is therefore strongly-polynomial.
How it differs from standard elimination:
- Standard: subtract from each row below the pivot row a multiple of by , where and are the entries in the pivot column of and .
- Bareiss: replace with
- This produces a row echelon form with the same zero entries as standard Gaussian elimination.
Key facts:
- Each matrix entry generated by this variant is the determinant of a submatrix of the original matrix.
- If one starts with integer entries, the divisions are exact and all intermediate and final entries are integers.
- Hadamard's inequality bounds the absolute values of the intermediate and final entries, giving a bit complexity of (soft O notation).
- Since an upper bound on the size of final entries is known, can be obtained with modular computation followed by Chinese remaindering or Hensel lifting.
As a corollary, these problems can be solved in strongly polynomial time with the same bit complexity:
- Testing whether given rational vectors are linearly independent
- Computing the determinant of a rational matrix
- Computing a solution of a rational equation system
- Computing the inverse matrix of a nonsingular rational matrix
- Computing the rank of a rational matrix
Numeric instability
- One possible problem is numerical instability, caused by the possibility of dividing by very small numbers.
- If the leading coefficient of a row is very close to zero, row reduction requires dividing by it, so any error in that number is amplified.
- Gaussian elimination is numerically stable for diagonally dominant or positive-definite matrices.
- For general matrices it is usually considered stable when using partial pivoting, even though there are examples of stable matrices for which it is unstable.
๐ Generalizations
- Gaussian elimination can be performed over any field, not just the real numbers.
- Buchberger's algorithm is a generalization to systems of polynomial equations. It depends heavily on the notion of a monomial order. The choice of an ordering on the variables is already implicit in Gaussian elimination, as the choice to work from left to right when selecting pivot positions.
- Computing the rank of a tensor of order greater than 2 is NP-hard. Therefore, if , there cannot be a polynomial time analog of Gaussian elimination for higher-order tensors (matrices are array representations of order-2 tensors).
๐ป Pseudocode
Gaussian elimination transforms a given matrix into row-echelon form. Here denotes the entry in row and column , with indices starting from 1. The transformation is done in place, so the original matrix is lost, replaced by its row-echelon form.
h := 1 /* Initialization of the pivot row */
k := 1 /* Initialization of the pivot column */
while h โค m and k โค n:
/* Find the k-th pivot: */
i_max := argmax (i = h ... m, abs(A[i, k]))
if A[i_max, k] = 0:
/* No pivot in this column, pass to next column */
k := k + 1
else:
swap rows(h, i_max)
/* Do for all rows below pivot: */
for i = h + 1 ... m:
f := A[i, k] / A[h, k]
/* Fill with zeros the lower part of pivot column: */
A[i, k] := 0
/* Do for all remaining elements in current row: */
for j = k + 1 ... n:
A[i, j] := A[i, j] - A[h, j] * f
/* Increase pivot row and column */
h := h + 1
k := k + 1
- This algorithm differs slightly from the one discussed earlier by choosing a pivot with the largest absolute value (partial pivoting).
- Partial pivoting may be required if, at the pivot place, the entry is zero.
- In any case, choosing the largest possible absolute value of the pivot improves numerical stability when floating point is used.
- Upon completion, the matrix is in row echelon form and the corresponding system may be solved by back substitution.