Skip to main content
Logo image

Section 1.2 Gaussian elimination

In Section 1.1 we sketched a procedure for solving a linear system \(L\text{.}\) That procedure involved applying a sequence of row operations to \(L\) to obtain a “simpler” system \(L'\text{.}\)
We will fill out this sketch in the next two sections. Specifically, we will
  1. describe precisely what we mean by a “simpler” system,
  2. provide an algorithm (or recipe) that decides exactly what sequence of row operations to apply to obtain this simpler system,
  3. explain how to find all solutions of the resulting simpler system.

Subsection 1.2.1 Row echelon matrices

Our first step in this direction will be to introduce a notational convenience. As you may have noticed, when performing row operations on a system of equations, we essentially treat the unknowns, as well as the plus and equals symbols, as placeholders; the only things that actually change in a given step are the coefficients in the equations. The augmented matrix associated to a linear system is a formal way of extracting just the information of the coefficients from a linear system.

Definition 1.2.1. Augmented matrix.

Let \(L\) be the linear system
\begin{equation*} \eqsys\text{.} \end{equation*}
The augmented matrix associated to \(L\) is the matrix
\begin{equation*} \augmatrix\text{.} \end{equation*}

Remark 1.2.2.

As defined more thoroughly in Definition 2.1.2, a matrix is just a rectangular array of numbers.
Here is our precise formulation of a “simple” linear system; it is a system whose associated augmented matrix is in row echelon form, as described below.

Definition 1.2.3. Row echelon form.

A zero row of a matrix, is a row whose entries are all equal to zero; a nonzero row is a row that contains at least one nonzero entry.
A matrix is in row echelon form if the following conditions hold.
(i)
In any nonzero row the first (i.e., leftmost) nonzero entry is equal to one. A leading one of a matrix is such an entry: i.e., an entry of a row that is equal to one, and that is also the first nonzero entry of that row.
(ii)
All zero rows are grouped together at the bottom of the matrix.
(iii)
Given any two nonzero rows in the matrix, the leading one of the lower row occurs strictly to the right of the leading one of the row above it.
A matrix is in reduced row echelon form if in addition to conditions (i)-(iii) it also satisfies the following condition.
(iv)
Any column of the matrix that contains a leading one has zeros elsewhere. In other words, if a column contains a leading one, then that is the only nonzero entry of that column.
A linear system \(L\) is in row echelon form (resp. reduced row echelon form) if its augmented matrix is in row echelon form (resp. reduced row echelon form).
In practice to decide whether a matrix is in in (reduced) row echelon form, follow these steps:
  1. First verify whether all zero rows are at the bottom.
  2. For each nonzero row, determine whether the first nonzero entry is a 1, and put a box around it.
  3. Make sure your boxes make a staircase pattern.
  4. (For reduced row echelon form only.) Decide whether each column with a box has 0’s everywhere else.

Example 1.2.4. Row echelon versus reduced row echelon form.

For each matrix decide (a) whether it is in row echelon form, and (b) whether it is in reduced row echelon form.
  1. \begin{equation*} \begin{bmatrix}0\amp 2\amp 1\amp 0\amp 0\\ 0\amp 0\amp 0\amp 0\amp 0\\ 0\amp 1\amp 0\amp 0\amp 1\\ 1\amp 0\amp 0\amp 0\amp 0\\ 0\amp 0\amp 0\amp 0\amp 0 \end{bmatrix} \end{equation*}
  2. \begin{equation*} \begin{bmatrix}1\amp 0\amp 0\amp -3\amp -7\\ 0\amp 0\amp 1\amp 2\amp 0\\ 0\amp 0\amp 0\amp 0\amp 1\\ 0\amp 0\amp 0\amp 0\amp 0\\ 0\amp 0\amp 0\amp 0\amp 0 \end{bmatrix} \end{equation*}
Solution.
  1. Below you find the matrix with leading ones boxed. This matrix fails to be in row echelon form (and hence also reduced row echelon form) for a variety of reasons: the zero rows are not all grouped at the bottom; the first row is nonzero, but does not have a leading one; the leading one of the fourth row is to the left of the leading one of the leading one in the row above it.
    \begin{equation*} \begin{bmatrix}0\amp 2\amp 1\amp 0\amp 0\\ 0\amp 0\amp 0\amp 0\amp 0\\ 0\amp \boxed{1}\amp 0\amp 0\amp 1\\ \boxed{1}\amp 0\amp 0\amp 0\amp 0\\ 0\amp 0\amp 0\amp 0\amp 0 \end{bmatrix} \end{equation*}
  2. Below you find the matrix with leading ones boxed. This matrix is in row echelon form: the zero rows (rows 4 and 5) are grouped at the bottom; each nonzero row has a leading one (boxed in the matrix below); the leading ones step strictly to the right as we move down the rows.
    \begin{equation*} \begin{bmatrix}\boxed{1}\amp 0\amp 0\amp -3\amp -7\\ 0\amp 0\amp \boxed{1}\amp 2\amp 0\\ 0\amp 0\amp 0\amp 0\amp \boxed{1}\\ 0\amp 0\amp 0\amp 0\amp 0\\ 0\amp 0\amp 0\amp 0\amp 0 \end{bmatrix} \end{equation*}
    The matrix is not in reduced row echelon form, as the last column contains a leading one in its third row, and a nonzero entry in its first row.

Subsection 1.2.2 Gaussian elimination

We will now describe a systematic procedure, called Gaussian elimination, that allows us to reduce a given linear system \(L\) to a system \(L'\)in row echelon form. In keeping with the foregoing discussion, we will identify a system \(L\) with its augmented matrix \(A\text{.}\) Furthermore, reducing a linear system using elementary operations on equations is now cast as performing elementary row operations on matrices. At the risk of redundancy we now officially translate a number of our former notions regarding reduction of linear systems to the setting of matrices.

Definition 1.2.5. Elementary row operations on matrices.

An elementary row operation is one of the three following types of matrix operations. Let \(A\) be a given \(m\times n\) matrix, and denote by \(r_i\) the \(i\)-th row of \(A\text{.}\)
Scalar multplication
Multiply a row by a nonzero number \(c\ne 0\text{:}\) i.e., replace \(r_i\) with \(c\,r_i\text{,}\) the result of multiplying all entries of the row by \(c\text{.}\)
Row swap
Swap two rows of \(A\text{.}\)
Row addition
Add a multiple of one row to another: i.e., replace \(r_i\) with \(r_i+cr_j\) for some \(c\text{,}\) \(i\text{,}\) and \(j\text{.}\)
The act of transforming a matrix using elementary row operations is called row reduction.
Two matrices are row equivalent if the one can be obtained from the other by performing a finite sequence of elementary row operations.

Remark 1.2.6. Notation.

Our former elementary operation notation easily transfers to row operations on matrices. The expressions
\begin{align*} A\amp \xrightarrow{c\,r_i} B \amp A\amp \xrightarrow{r_i\leftrightarrow r_j} B\amp A\amp\xrightarrow{r_i+c\,r_j} B \end{align*}
denote the operations that replace row \(r_i\) in \(A\) with \(c\, r_i\text{,}\) swap rows \(r_i\) and \(r_j\) in \(A\text{,}\) and replace \(r_i\) in \(A\) with \(r_i+c\, r_j\text{,}\) respectively.
At last we are ready to define Gaussian elimination. In its essence this is simply a procedure, or algorithm, that takes an input matrix \(A\) and row reduces it to a matrix \(B\) in row echelon form. It is important to note that although we employ Gaussian elimination in this chapter primarily to the end of simplifying and solving linear systems, this is not its only application. Indeed, we will come back to the procedure again and again, in a great variety of contexts and to greatly diverse ends. Gaussian elimination is one of linear algebra’s most important tools. We memorialize this here as an official principle.

Definition 1.2.8. Gaussian elimination.

Gaussian elimination is the algorithm described below. It takes as an input a matrix \(A\) and returns as an output a row equivalent matrix \(B\) in row echelon form.
Step 1
Find the leftmost nonzero column and perform a row swap to move the row with this nonzero entry to the top of the matrix.
Step 2
Scale the new top row to produce a leading one in the row. Call this new row \(r\text{.}\)
Step 3
For each row \(r_i\) below \(r\) perform a row operation of the form \(r_i+c\,r\) to replace all entries below the leading one of \(r\) with zeros.
Step 4
Begin again with Step 1 applied to the matrix consisting of all rows below \(r\text{.}\) Continue until the matrix is in row echelon form.

Subsection Model example

Use the following example as a model of how to both perform and annotate the steps in Gaussian elimination. When first learning this procedure, make sure to follow it to the letter. In particular, in the spirit of the mandate issued in Remark 1.1.16, you should only perform one row operation at a time, and only in the sequence prescribed in Steps 1-4 of Definition 1.2.8.
\begin{align*} \begin{bmatrix}0\amp 0\amp -2\amp 0\amp 7\amp 12\\ 2\amp 4\amp -10\amp 6\amp 12\amp 28\\ 2\amp 4\amp -5\amp 6\amp -5\amp -1 \end{bmatrix} \amp \xrightarrow[\hspace{35pt}]{r_1\leftrightarrow r_2} \begin{bmatrix}2\amp 4\amp -10\amp 6\amp 12\amp 28\\ 0\amp 0\amp -2\amp 0\amp 7\amp 12\\ 2\amp 4\amp -5\amp 6\amp -5\amp -1 \end{bmatrix}\\ \amp \xrightarrow[\hspace{35pt}]{\frac{1}{2}r_1} \begin{bmatrix}1\amp 2\amp -5\amp 3\amp 6\amp 14\\ 0\amp 0\amp -2\amp 0\amp 7\amp 12\\ 2\amp 4\amp -5\amp 6\amp -5\amp -1 \end{bmatrix}\\ \amp \xrightarrow[\hspace{35pt}]{r_3-2r_1} \begin{bmatrix}1\amp 2\amp -5\amp 3\amp 6\amp 14\\ 0\amp 0\amp -2\amp 0\amp 7\amp 12\\ 0\amp 0\amp 5\amp 0\amp -17\amp -29 \end{bmatrix}\amp \text{ (now done with first row) }\\ \amp \xrightarrow[\hspace{35pt}]{-\frac{1}{2}r_2} \begin{bmatrix}1\amp 2\amp -5\amp 3\amp 6\amp 14\\ 0\amp 0\amp 1\amp 0\amp -7/2\amp -6\\ 0\amp 0\amp 5\amp 0\amp -17\amp -29 \end{bmatrix}\\ \amp \xrightarrow[\hspace{35pt}]{r_3+(-5)r_2} \begin{bmatrix}1\amp 2\amp -5\amp 3\amp 6\amp 14\\ 0\amp 0\amp 1\amp 0\amp -7/2\amp -6\\ 0\amp 0\amp 0\amp 0\amp 1/2\amp 1 \end{bmatrix}\amp \text{ (now done with 2nd row)}\\ \amp \xrightarrow[\hspace{35pt}]{2r_3} \begin{bmatrix}1\amp 2\amp -5\amp 3\amp 6\amp 14\\ 0\amp 0\amp 1\amp 0\amp -7/2\amp -6\\ 0\amp 0\amp 0\amp 0\amp 1\amp 2 \end{bmatrix} \end{align*}
The matrix outputted by Gaussian elimination is guaranteed to be in row echelon form, but it may not be in reduced row echelon form. Gauss-Jordan elimination describes a systematic way to continue reducing to this even simpler state.

Definition 1.2.9. Gauss-Jordan elimination.

Gauss-Jordan elimination is the algorithm described below. It takes as an input a matrix \(A\) and returns a row equivalent matrix \(B\) in reduced row echelon form.
Steps 1-4
Apply Gaussian elimination to transform \(A\) to a matrix in row echelon form.
Step 5
Find the rightmost column of the matrix containing a leading one. Let \(r_i\) be the row containing this leading one. For each row \(r_j\) above \(r_i\) perform a row operation of the form \(r_i+c\,r_j\) to replace all entries above the leading one with zeros.
Step 6
Begin again with Step 5 applied to the next column to the left that contains a leading one. Continue until the matrix is in reduced row echelon form.
Continuing our previous example:
\begin{align*} \begin{bmatrix}1\amp 2\amp -5\amp 3\amp 6\amp 14\\ 0\amp 0\amp 1\amp 0\amp -7/2\amp -6\\ 0\amp 0\amp 0\amp 0\amp 1\amp 2 \end{bmatrix} . \amp \xrightarrow[\hspace{35pt}]{r_2+7/2r_3}\amp \begin{bmatrix}1\amp 2\amp -5\amp 3\amp 6\amp 14\\ 0\amp 0\amp 1\amp 0\amp 0\amp 1\\ 0\amp 0\amp 0\amp 0\amp 1\amp 2 \end{bmatrix} .\\ \amp \xrightarrow[\hspace{35pt}]{r_1-6r_3}\amp \begin{bmatrix}1\amp 2\amp -5\amp 3\amp 0\amp 2\\ 0\amp 0\amp 1\amp 0\amp 0\amp 1\\ 0\amp 0\amp 0\amp 0\amp 1\amp 2 \end{bmatrix} .\\ \amp \xrightarrow[\hspace{35pt}]{r_1+5r_2}\amp \begin{bmatrix}1\amp 2\amp 0\amp 3\amp 0\amp 7\\ 0\amp 0\amp 1\amp 0\amp 0\amp 1\\ 0\amp 0\amp 0\amp 0\amp 1\amp 2 \end{bmatrix} \text{.} \end{align*}
Definition 1.2.8 and Definition 1.2.9 are really theorems in disguise, and we make this official in Theorem 1.2.10.
We will make heavy use of the first two results of Theorem 1.2.10. The proofs of these statements are not difficult, but not especially illuminating. Accordingly we omit them here, and point the interested reader to Robert Beezer’s A First Course in Linear Algebra 1 . (See Theorem REMEF 2 .)
The third statement of Theorem 1.2.10, that every matrix is row equivalent to a unique matrix in reduced row echelon form, does in fact have an enlightening proof. We will postpone this proof, however, until we have a little more theory at our disposal. (See Corollary 2.4.17.) Until then we will conscientiously not make use of this fact when developing any of our further theory.

Example 1.2.11. Row echelon form is not unique.

Show that a matrix \(A\) may be row equivalent to two or more matrices in row echelon form.
Solution.
Take \(A=\begin{bmatrix} 1 \amp 1 \\ 1 \amp 2 \end{bmatrix}\text{.}\) This row reduces to \(B=\begin{bmatrix} 1 \amp 1 \\ 0 \amp 1 \end{bmatrix}\) using Gaussian elimination; and it row reduces further to \(C=\begin{bmatrix}1\amp 0\\ 0\amp 1\end{bmatrix}\) using Gauss-Jordan elimination. Thus we see that \(A\) is row equivalent to two different matrices in row echelon form. (According to Theorem 1.2.10, the matrix \(C\) is the only matrix in reduced row echelon that is row equivalent to \(A\text{.}\))
In the first Sage cell below you find a recursive implementation of Gaussian elimination in Sage that includes explanatory comments. Evaluate this cell in order to load the row_echelon_form function. The second cell allows you to apply the Gaussian elimination algorithm to a matrix of your choosing. As you can see, the show function provides a nice version of the output.
Sage has its own row reduction method, rref, which transforms a matrix to reduced row echelon form. Let’s compare the outputs of these two algorithms.
The following activities could be useful for implementing Gaussian elimination in a manner that shows all intervening steps. Use the empty Sage cell below to experiment.
  • Modify the row_echelon_form code to make a non-recursive algorithm.
  • Add show commands to your non-recursive version of row_echelon_form to show steps in the row reduction.

Exercises 1.2.3 Exercises

WeBWork Exercises

1.
Determine if the matrix
\begin{equation*} \left[\begin{array}{rrrrr} 1 \amp 1 \amp 0 \amp -7 \amp 0 \\ 0 \amp 0 \amp 1 \amp -3 \amp 0 \\ 0 \amp 0 \amp 0 \amp 0 \amp 1\end{array}\right] \end{equation*}
is in echelon form, reduced row echelon form, or neither. Choose the most appropriate answer.
Answer:
  • select
  • echelon form
  • reduced row echelon form
  • not in echelon form
.
Answer.
\(\text{reduced row echelon form}\)
Solution.
SOLUTION: Reduced row echelon form.
2.
Consider the matrix
7 0 -6
-7 -9 6
5 2 -5
(a) On the matrix above, perform the row operation \(5 R_{3} + R_{1} \to R_{1}\text{.}\) The new matrix is:
(b) On the original matrix, perform the row operation \(7 R_{2} \to R_{2}\text{.}\) The new matrix is:
(c) On the original matrix, perform the row operation \(R_{1} \leftrightarrow R_{3}\text{.}\) The new matrix is:
Answer 1.
\(32\)
Answer 2.
\(10\)
Answer 3.
\(-31\)
Answer 4.
\(-7\)
Answer 5.
\(-9\)
Answer 6.
\(6\)
Answer 7.
\(5\)
Answer 8.
\(2\)
Answer 9.
\(-5\)
Answer 10.
\(7\)
Answer 11.
\(0\)
Answer 12.
\(-6\)
Answer 13.
\(-49\)
Answer 14.
\(-63\)
Answer 15.
\(42\)
Answer 16.
\(5\)
Answer 17.
\(2\)
Answer 18.
\(-5\)
Answer 19.
\(5\)
Answer 20.
\(2\)
Answer 21.
\(-5\)
Answer 22.
\(-7\)
Answer 23.
\(-9\)
Answer 24.
\(6\)
Answer 25.
\(7\)
Answer 26.
\(0\)
Answer 27.
\(-6\)
3.
On the augmented matrix \(A\) below , perform all three row operations in the order given, ((a) followed by (b) followed by (c)) and then write the resulting augmented matrix.
\begin{equation*} A = \displaystyle\left[\begin{array}{rrr|r} 1 \amp -2 \amp 1 \amp -2 \cr 4 \amp -7 \amp 1 \amp 2 \cr -2 \amp 3 \amp -1 \amp 3 \cr \end{array}\right] \end{equation*}
\((a) R_2 = -4 r_1 + r_2\)
\((b) R_3 = 2 r_1 + r_3\)
\((c) R_3 = 1 r_2 + r_3\)
Answer 1.
\(1\)
Answer 2.
\(-2\)
Answer 3.
\(1\)
Answer 4.
\(-2\)
Answer 5.
\(0\)
Answer 6.
\(1\)
Answer 7.
\(-3\)
Answer 8.
\(10\)
Answer 9.
\(0\)
Answer 10.
\(0\)
Answer 11.
\(-2\)
Answer 12.
\(9\)

Written Exercises

Exercise Group.
Explain why each of the following matrices fails to be in row echelon form.
4.
\(A=\begin{bmatrix} 1 \amp 2\amp 2\amp -3\\ 0\amp -3\amp 4\amp 0\\ 0\amp 0\amp 0\amp 1 \end{bmatrix}\)
Solution.
The first nonzero term in the second row is not a one.
5.
\(A=\begin{bmatrix} 0\amp 1\amp 2\amp -3\\ 0\amp 1\amp 4\amp 0\\ 0\amp 0\amp 0\amp 1 \end{bmatrix}\)
6.
\(A=\begin{bmatrix} 1\amp 1\amp 2\amp -3\\ 0\amp 0\amp 0\amp 0\\ 0\amp 1\amp 1\amp 1 \end{bmatrix}\)
Exercise Group.
For each of the given linear systems, find an equivalent system in row echelon form. Use augmented matrices and follow the Gaussian elimination algorithm to the letter.
7.
\begin{equation*} \begin{linsys}{4} x_1\amp +\amp 2x_2\amp =\amp x_3\amp +\amp x_4\amp +\amp 3\\ 3x_1\amp +\amp 6x_2\amp =\amp 2x_3\amp -\amp 4x_4\amp +\amp 8\\ -x_1\amp +\amp 2x_3\amp =\amp 2x_2\amp -\amp x_4\amp -\amp 1 \end{linsys} \end{equation*}
Solution.
First bring the system into standard form:
\begin{equation*} L\colon \ \begin{linsys}{4} x_1\amp +\amp 2x_2\amp -\amp x_3\amp-\amp x_4\amp=\amp 3\\ 3x_1\amp +\amp 6x_2\amp - \amp 2x_3\amp + \amp 4x_4\amp =\amp 8\\ -x_1\amp - \amp 2x_2 \amp +\amp 2x_3\amp + \amp x_4\amp = \amp -1 \end{linsys}\text{.} \end{equation*}
Then perform Gaussian elimination on the associated augmented matrix:
\begin{align*} \begin{bmatrix}1\amp 2\amp -1\amp -1\amp 3\\ 3\amp 6\amp -2\amp 4\amp 8\\ -1\amp -2\amp 2\amp 1\amp -1 \end{bmatrix} \amp \xrightarrow[\hspace{35pt}]{r_2-3r_1}\amp \begin{bmatrix}1\amp 2\amp -1\amp -1\amp 3\\ 0\amp 0\amp 1\amp 7\amp -1\\ -1\amp -2\amp 2\amp 1\amp -1 \end{bmatrix}\\ \amp \xrightarrow[\hspace{35pt}]{r_3+r_1 }\amp \begin{bmatrix}1\amp 2\amp -1\amp -1\amp 3\\ 0\amp 0\amp 1\amp 7\amp -1\\ 0\amp 0\amp 1\amp 0\amp 2 \end{bmatrix}\\ \amp \xrightarrow[\hspace{35pt}]{r_3-r_2 }\amp \begin{bmatrix}1\amp 2\amp -1\amp -1\amp 3\\ 0\amp 0\amp 1\amp 7\amp -1\\ 0\amp 0\amp 0\amp -7\amp 3 \end{bmatrix}\\ \amp \xrightarrow[\hspace{35pt}]{-\frac{1}{7}r_3}\amp \begin{bmatrix}1\amp 2\amp -1\amp -1\amp 3\\ 0\amp 0\amp 1\amp 7\amp -1\\ 0\amp 0\amp 0\amp 1\amp -\frac{3}{7} \end{bmatrix}\text{.} \end{align*}
The corresponding equivalent system is
\begin{equation*} L'\colon \ \begin{linsys}{4} x_1\amp +\amp 2x_2\amp -\amp x_3\amp-\amp x_4\amp=\amp 3\\ \amp \amp \amp \amp x_3\amp + \amp 7x_4\amp =\amp -1\\ \amp \amp \amp \amp \amp \amp x_4\amp = \amp -\frac{3}{7} \end{linsys}\text{.} \end{equation*}
8.
\begin{equation*} \begin{linsys}{4} x_1\amp +\amp x_2\amp -\amp x_3\amp +\amp x_4\amp =\amp 1\\ -2x_1\amp -\amp 2x_2\amp +\amp 2x_3\amp -\amp 2x_4\amp =\amp -2\\ x_1\amp +\amp x_2\amp +\amp x_3\amp +\amp 2x_4\amp =\amp 3 \end{linsys} \end{equation*}
9.
\begin{equation*} \begin{linsys}{3} 2x_1 \amp +\amp 2x_2 \amp +\amp 2x_3\amp =\amp 0\\ -2x_1 \amp +\amp 5x_2 \amp +\amp 2x_3\amp =\amp 1\\ 8x_1 \amp +\amp x_2 \amp +\amp 4x_3\amp =\amp -1 \end{linsys} \end{equation*}
10.
\begin{equation*} \begin{linsys}{3} \amp \amp -2b \amp +\amp 3c\amp =\amp 1\\ 3a \amp +\amp 6b \amp -\amp 3c\amp =\amp -2\\ 6a \amp +\amp 6b \amp +\amp 3c\amp =\amp 5 \end{linsys} \end{equation*}
11.
\begin{equation*} \begin{linsys}{5} \amp \amp \amp \amp T_3\amp +\amp T_4\amp +\amp T_5 \amp =\amp 0\\ -T_1\amp -\amp T_2 \amp +\amp 2T_3 \amp -\amp 3T_4\amp +\amp T_5 \amp =\amp 0\\ T_1\amp + \amp T_2 \amp -\amp 2T_3 \amp \amp \amp -\amp T_5 \amp =\amp 0\\ 2T_1\amp + \amp 2T_2 \amp -\amp T_3 \amp \amp \amp +\amp T_5 \amp =\amp 0 \end{linsys} \end{equation*}
linear.ups.edu/fcla
linear.ups.edu/fcla/section-RREF.html#theorem-REMEF