Gaussian Elimination to Solve Systems - Questions with Solutions

\( \) \( \) \( \) \( \) \( \)

Examples and questions with their solutions on how to solve systems of linear equations using the Gaussian ( row echelon form ) and the Gauss-Jordan ( reduced row echelon form ) methods are presented.
The methods presented here find their explanations in the more general method of solving a system of linear equations by elimination. The Gauss-Jordan method of elimination is at the heart of linear algebra. It is a computationally efficient and powerful method that may also be used to find the inverse of a matrix, the determinant of a matrix, the rank of matrix and can also be used to express a matrix in terms of elementary matrices.
An online calculator to row reduce augmented matrices is included.
A good review of augmented matrices and matrices in reduced row echelon form is needed in order to undestand the Gauss and Gauss-Jordan methods described here.



Gaussian Elimination or Row echelon Form of an Augmented Matrix

\( \) \( \) \( \)

Example 1
Solve the system of linear equations given below by rewriting the augmented matrix of the system in row echelon form .
\( \left\{ \begin{array}{lcl} x + y - z & = & - 3 \\ 2 x + 3 y - 8 z & = & - 18 \\ 5x + 6y - 10 z & = & - 25 \end{array} \right. \)

Solution to Example 1
The augmented matrix of the system is given by.
\(\begin{bmatrix} 1 & 1 & - 1 &|& -3\\ 2 & 3 & - 8 &|& - 18\\ 5 & 6 & - 10 &|& - 25 \end{bmatrix} \)

Step 1: Produce a pivot , if any, in column 1 using any of the three row operations or their combinations.
Add -2 times row (1) to row (2) and add -5 times row (1) to row (3)

\( \color{red}{\begin{matrix} \\ R_2 - 2R_1\\ R_3 - 5R_1\\ \end{matrix}} \begin{bmatrix} \color{blue}1 & 1 & - 1 &|& -3\\ \color{red}0 & 1 & - 6 &|& - 12\\ \color{red}0 & 1 & - 5 &|& - 10 \end{bmatrix} \)


Step 2: Produce a pivot , if any, in column 2 using any of the three row operations or their combinations.
Add - 1 times row (2) to row (3)

\( \color{red}{\begin{matrix} \\ \\ R_3 - R_2\\ \end{matrix}} \begin{bmatrix} \color{blue}1 & 1 & - 1 &|& -3\\ \color{red}0 & \color{blue}1 & - 6 &|& - 12\\ \color{red}0 & \color{red}0 & \color{blue}1 &|& 2 \end{bmatrix} \)     (I)

Note that the operation in step 2 has also produced a pivot in column (3)

The above matrix is in row echelon form . The corresponding system is given by
\( \left\{ \begin{array}{lcl} x + y - z & = & - 3 \\ y - 6 z & = & - 12 \\ z & = & 2 \end{array} \right. \)
which can be solved by back substitution starting from the last equation.
\( z = 2 \) , \( y = 6 z - 12 = 6(2) - 12 = 0 \) , \( x = - y + z - 3 = 0 + 2 - 3 = - 1\)
which give the solution to the given system as
\( \begin{equation} \begin{array}{ccl} x & = & -1 \\ y & = & 0 \\ z & = & 2 \end{array} \end{equation} \)

We now continue with more steps based on the three row operations to obtain an augmented matrix in reduced row echelon form a method called Gauss-Jordan method of elimination described below.
Gaussian Elimination to Solve a 3 by 3 System of Equations .

Gauss-Jordan Method or Reduced Row Echelon Form of an Augmented Matrix

A matrix is in reduced row echelon form if it is in row echelon form and with zeros above and below the leading 1's. The method of obtaining the reduced row echelon form of a matrix is called the Gauss-Jordan method.
We continue with the row operations on the last augmented matrix (I) \( \begin{bmatrix} \color{blue}1 & 1 & - 1 &|& -3\\ \color{red}0 & \color{blue}1 & - 6 &|& - 12\\ \color{red}0 & \color{red}0 & \color{blue}1 &|& 2 \end{bmatrix} \) in the above example to produce zeros above the leading 1's (pivot) as follows.

We now start from the rightmost column with a pivot which is here column (3).

Step 3: Use any of the three row operations or their combinations to produce zeros above the 1 in column (3) row (3).
Add 6 times row (3) to row (2)
\( \color{red}{\begin{matrix} \\ R_2 + 6R_3\\ \\ \end{matrix}} \) \(\begin{bmatrix} 1 & 1 & - 1 &|& -3\\ 0 & 1 & 0 &|& 0\\ 0 & 0 & 1 &|& 2 \end{bmatrix} \)

Add row (3) to row (1)
\( \color{red}{\begin{matrix} R_1+R_3\\ \\ \\ \end{matrix}} \) \(\begin{bmatrix} \color{blue}1 & 1 & \color{red}0 &|& - 1\\ \color{red}0 & \color{blue}1 & \color{red}0 &|& 0\\ \color{red}0 & \color{red}0 & \color{blue}1 &|& 2 \end{bmatrix} \)

Step 4: Use any of the three row operations or their combinations to produce zeros above the 1 in column (2) row (2). >
Add -1 times row (2) to row (1)
\( \color{red}{\begin{matrix} R_1-R_2\\ \\ \\ \end{matrix}} \) \(\begin{bmatrix} \color{blue}1 & \color{red}0 & \color{red}0 &|& - 1\\ \color{red}0 & \color{blue}1 & \color{red}0 &|& 0\\ \color{red}0 & \color{red}0 & \color{blue}1 &|& 2 \end{bmatrix} \)

The advantage of rewriting the augmented matrix in reduced row echelon form is that it gives the solution to the given system of equations without further calculations as follows:
\( \begin{equation} \begin{array}{ccl} x & = & -1 \\ y & = & 0 \\ z & = & 2 \end{array} \end{equation} \)




Example 2
Write the augmented matrix of the system below in reduced row echelon form and find the solution to the given system.
\( \left\{ \begin{array}{lcl} 2x - y - z + w & = & -2 \\ - x + y + 2z + 2 w & = & - 5 \\ 3x + y - z - 3w & = & 8 \\ 2x + 2y - 2 z - w & = & 6 \end{array} \right. \)

Solution to Example 2
The augmented matrix to the given system is as follows
\(\begin{bmatrix} 2 & -1 & -1 & 1 &|& - 2\\ -1 & 1 & 2 & 2 &|& -5\\ 3 & 1 & -1 & -3 &|& 8 \\ 2 & 2 & -2 & - 1 &|& 6 \end{bmatrix} \)


Step 1: Produce a pivot , if any, in column 1
We start by reducing the entries in column (1) to zero except row (1).
Row (2) has -1 at the first column and could therefore be used in row (1). Interchange rows (1) and (2)
\( \color{red}{\begin{matrix} R_2 \\ R_1\\ \\ \\ \end{matrix}} \) \(\begin{bmatrix} -1 & 1 & 2 & 2 &|& -5\\ 2 & -1 & -1 & 1 &|& - 2\\ 3 & 1 & -1 & -3 &|& 8 \\ 2 & 2 & -2 & - 1 &|& 6 \end{bmatrix} \)

Multiply row(1) by -1.
\( \color{red}{\begin{matrix} -R_1 \\ \\ \\ \\ \end{matrix}} \) \(\begin{bmatrix} 1 & -1 & -2 & -2 &|& 5\\ 2 & -1 & -1 & 1 &|& - 2\\ 3 & 1 & -1 & -3 &|& 8 \\ 2 & 2 & -2 & - 1 &|& 6 \end{bmatrix} \)

The entries in column (1) of Rows (2), (3) and (4) have to be reduced to zero as follows: add - 2 × row (1) to row (2), add - 3 × row (1) to row (3) and add - 2 × row (1) to row (4) to obtain
\( \color{red}{\begin{matrix} \\ R_2 - 2R_1\\ R_3 - 3R_1\\ R_4 - 2R_1 \end{matrix}} \) \(\begin{bmatrix} \color{blue}1 & -1 & -2 & -2 &|& 5\\ \color{red}{0} & 1 & 3 & 5 &|& - 12\\ \color{red}{0} & 4 & 5 & 3 &|& -7 \\ \color{red}{0} & 4 & 2 & 3 &|& -4 \end{bmatrix} \)


Step 2: Produce a pivot, if any, in column 2
Row (2) starts with a 1, hence we need to reduce the entries in column (2) of rows (3) and (4) as follows: add -4 × row (2) to row (3) and add - 4 × row(2) to row (4).
\( \color{red}{\begin{matrix} \\ \\ R_3 - 4R_2\\ R_4 - 4R_2 \end{matrix}} \) \(\begin{bmatrix} \color{blue}1 & -1 & -2 & -2 &|& 5\\ \color{red}{0} & \color{blue}1 & 3 & 5 &|& - 12\\ \color{red}{0} & \color{red}{0} & -7 & -17 &|& 41 \\ \color{red}{0} & \color{red}{0} & -10 & -17 &|& 44 \end{bmatrix} \)

Row (3) starts with -7, hence we need to reduce the entry in column(3) of row (4) which is achieved in two steps as follows: multiply row (4) by -7
\( \color{red}{\begin{matrix} \\ \\ \\ - 7 R_4 \end{matrix}} \) \(\begin{bmatrix} 1 & -1 & -2 & -2 &|& 5\\ \color{red}{0} & 1 & 3 & 5 &|& - 12\\ \color{red}{0} & \color{red}{0} & -7 & -17 &|& 41 \\ \color{red}{0} & \color{red}{0} & 70 & 119 &|& -308 \end{bmatrix} \)


Step 3: Produce a pivot, if any, in column 3
Add 10 × row(3) to row (4)

\( \color{red}{\begin{matrix} \\ \\ \\ R_4 + 10 R_3 \end{matrix}} \) \(\begin{bmatrix} 1 & -1 & -2 & -2 &|& 5\\ \color{red}{0} & 1 & 3 & 5 &|& - 12\\ \color{red}{0} & \color{red}{0} & -7 & -17 &|& 41 \\ \color{red}{0} & \color{red}{0} & \color{red}{0} & - 51 &|& 102 \end{bmatrix} \)

Multiply row (3) by \( -\frac{1}{7} \)
\( \color{red}{\begin{matrix} \\ \\ -\frac{1}{7} R_3\\ \\ \end{matrix}} \) \(\begin{bmatrix} \color{blue}1 & -1 & -2 & -2 &|& 5\\ \color{red}{0} & \color{blue}1 & 3 & 5 &|& - 12\\ \color{red}{0} & \color{red}{0} & \color{blue}1 & 17/7 &|& -41/7 \\ \color{red}{0} & \color{red}{0} & \color{red}{0} & - 51 &|& 102 \end{bmatrix} \)

Step 4: Produce a pivot in column 4 if any

Multiply row (4) by -1/51
\( \color{red}{\begin{matrix} \\ \\ \\ -R_4/51 \end{matrix}} \) \(\begin{bmatrix} \color{blue}1 & -1 & -2 & -2 &|& 5\\ \color{red}{0} & \color{blue}1 & 3 & 5 &|& - 12\\ \color{red}{0} & \color{red}{0} & \color{blue}1 & 17/7 &|& -41/7 \\ \color{red}{0} & \color{red}{0} & \color{red}{0} & \color{blue}1 &|& -2 \end{bmatrix} \)

We have rewritten the augmented matrix in row echelon form. We now continue the process to produce an augmented matrix in reduced row echelon form.

Step 5: We now need to produce zeros above the leading 1 in row (4)

Add 2 × row(4) to row(1), add -5 × row(4) to row(2) and add -17 × row(4) to row(3).

\( \color{red}{\begin{matrix} R_1+2R_4\\ R_2- 5R_4\\ R_3 - (17/7) R_4\\ \\ \end{matrix}} \) \(\begin{bmatrix} \color{blue}1 & -1 & -2 & \color{red}{0} &|& 1\\ \color{red}{0} & \color{blue}1 & 3 & \color{red}{0} &|& - 2\\ \color{red}{0} & \color{red}{0} &\color{blue}1 & \color{red}{0} &|& -1 \\ \color{red}{0} & \color{red}{0} & \color{red}{0} & \color{blue}1 &|& -2 \end{bmatrix} \)

Step 6: We now need to produce zeros above the leading 1 in row (3)

Add 2 × row(3) to row(1) and add -3 × row(3) to row(2).
\( \color{red}{\begin{matrix} R_1+2R_3\\ R_2 - 3R_3\\ \\ \\ \end{matrix}} \) \(\begin{bmatrix} \color{blue}1 & -1 & \color{red}{0} & \color{red}{0} &|& -1\\ \color{red}{\color{red}{0}} & \color{blue}1 & \color{red}{0} & \color{red}{0}&|& 1\\ \color{red}{0} & \color{red}{0} & \color{blue}1 & \color{red}{0} &|& -1 \\ \color{red}{0} & \color{red}{0} & \color{red}{0} & \color{blue}1 &|& -2 \end{bmatrix} \)

Step 7: We now need to produce zeros above the leading 1 in row (2)

Add row(2) to row(1).
\( \color{red}{\begin{matrix} R_1+R_2\\ \\ \\ \\ \end{matrix}} \) \(\begin{bmatrix} \color{blue}1 & \color{red}{0} & \color{red}{0} & \color{red}{0} &|& 0\\ \color{red}{0} & \color{blue}1 & \color{red}{0} & \color{red}{0}&|& 1\\ \color{red}{0} & \color{red}{0} & \color{blue}1 & \color{red}{0} &|& -1 \\ \color{red}{0} & \color{red}{0} & \color{red}{0} & \color{blue}1 &|& -2 \end{bmatrix} \)

We now read the solutions:
\( x = 0 , \; y = 1, \;z = -1 ,\;w = -2 \)



Questions with Solution

Use the Gauss-Jordan method to solve the systems of equations below.
  1. \( \left\{ \begin{array}{lcl} x + y & = & -1 \\ - x + y & = & 5 \end{array} \right. \)

  2. \( \left\{ \begin{array}{lcl} x + y & = & - 2 \\ 2x + 2z & = & - 6\\ x + y + 2 z & = & -4 \end{array} \right. \)

  3. \( \left\{ \begin{array}{lcl} x + y & = & -3\\ 2x + 2y - w & = & -2\\ x + z & = & -2\\ x + y + z + 2w & = & -13 \end{array} \right. \)

Solutions to the Above Questions


  1. Augmented matrix
    \(\begin{bmatrix} 1 & 1 & -1 \\ -1 & 1 & 5 \\ \end{bmatrix} \)

    \( \color{red}{\begin{matrix} \\ R_2+R_1 \end{matrix}} \) \(\begin{bmatrix} 1 & 1 &|& -1\\ 0 & 2&|& 4\\ \end{bmatrix} \)

    \( \color{red}{\begin{matrix} \\ (1/2) × R_2 \end{matrix}} \) \(\begin{bmatrix} 1 & 1 &|& -1\\ 0 & 1&|& 2\\ \end{bmatrix} \)

    \( \color{red}{\begin{matrix} R_1 - R_2\\ \\ \end{matrix}} \) \(\begin{bmatrix} 1 & 0 &|& -3\\ 0 & 1&|& 2\\ \end{bmatrix} \)
    Matrix in reduced row echelon form; solution:\( (x,y) = (-3,2)\)


  2. Augmented matrix
    \(\begin{bmatrix} 1 & 1 & 0 & -2 \\ 2 & 0 & 2 & -6\\ 1 & 1 & 2 & -4 \end{bmatrix} \)

    \( \color{red}{\begin{matrix} \\ R_2 - 2R_1\\ R_3 - R_1 \end{matrix}} \) \(\begin{bmatrix} 1 & 1 & 0 & -2 \\ 0 & -2 & 2 & -2\\ 0 & 0 & 2 & -2 \end{bmatrix} \) ,

    \( \color{red}{\begin{matrix} \\ R_2 - R_3\\ \\ \end{matrix}} \) \(\begin{bmatrix} 1 & 1 & 0 & -2 \\ 0 & -2 & 0 & 0\\ 0 & 0 & 2 & -2 \end{bmatrix} \) ,

    \( \color{red}{\begin{matrix} \\ -(1/2)R_2\\ (1/2)R_3\\ \end{matrix}} \) \(\begin{bmatrix} 1 & 1 & 0 & -2 \\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & -1 \end{bmatrix} \) ,

    \( \color{red}{\begin{matrix} R_1- R_2\\ \\ \\ \end{matrix}} \) \(\begin{bmatrix} 1 & 0 & 0 & -2 \\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & -1 \end{bmatrix} \) ,

    Matrix in reduced row echelon form; solution: \( (x,y,z)=(-2,0,-1)\)


  3. Augmented matrix
    \(\begin{bmatrix} 1 & 1 & 0 & 0 &|& -3 \\ 2 & 2 & 0 & -1 &|& -2\\ 1 & 0 & 1 & 0 &|& -2 \\ 1 & 1 & 1 & 2 &|& - 13 \end{bmatrix} \)

    \( \color{red}{\begin{matrix} \\ R_2-2R_1\\ R_3 - R_1\\ R_4 - R_1 \end{matrix}} \) \(\begin{bmatrix} 1 & 1 & 0 & 0 &|& -3 \\ 0 & 0 & 0 & -1 &|& 4\\ 0 & -1 & 1 & 0 &|& 1 \\ 0 & 0 & 1 & 2 &|& - 10 \end{bmatrix} \)

    Interchange row(2) and row(3)
    \( \color{red}{\begin{matrix} \\ R_3\\ R_2\\ \\ \end{matrix}} \) \(\begin{bmatrix} 1 & 1 & 0 & 0 &|& -3 \\ 0 & -1 & 1 & 0 &|& 1 \\ 0 & 0 & 0 & -1 &|& 4\\ 0 & 0 & 1 & 2 &|& - 10 \end{bmatrix} \)

    Interchange row(3) and row(4)
    \( \color{red}{\begin{matrix} \\ \\ R_4\\ R_3\\ \end{matrix}} \) \(\begin{bmatrix} 1 & 1 & 0 & 0 &|& -3 \\ 0 & -1 & 1 & 0 &|& 1 \\ 0 & 0 & 1 & 2 &|& - 10\\ 0 & 0 & 0 & -1 &|& 4 \end{bmatrix} \)

    \( \color{red}{\begin{matrix} \\ -R_2\\ \\ -R_4\\ \end{matrix}} \) \(\begin{bmatrix} 1 & 1 & 0 & 0 &|& -3 \\ 0 & 1 & -1 & 0 &|& -1 \\ 0 & 0 & 1 & 2 &|& - 10\\ 0 & 0 & 0 & 1 &|& -4 \end{bmatrix} \)

    \( \color{red}{\begin{matrix} \\ \\ R_3-2R_4\\ \\ \end{matrix}} \) \(\begin{bmatrix} 1 & 1 & 0 & 0 &|& -3 \\ 0 & 1 & -1 & 0 &|& -1 \\ 0 & 0 & 1 & 0 &|& - 2\\ 0 & 0 & 0 & 1 &|& -4 \end{bmatrix} \)

    \( \color{red}{\begin{matrix} \\ R_2+R_3\\ \\ \\ \end{matrix}} \) \(\begin{bmatrix} 1 & 1 & 0 & 0 &|& -3 \\ 0 & 1 & 0 & 0 &|& -3 \\ 0 & 0 & 1 & 0 &|& - 2\\ 0 & 0 & 0 & 1 &|& -4 \end{bmatrix} \)

    \( \color{red}{\begin{matrix} R_1-R_2\\ \\ \\ \\ \end{matrix}} \) \(\begin{bmatrix} 1 & 0 & 0 & 0 &|& 0 \\ 0 & 1 & 0 & 0 &|& -3 \\ 0 & 0 & 1 & 0 &|& - 2\\ 0 & 0 & 0 & 1 &|& -4 \end{bmatrix} \)

    Matrix in reduced row echelon form;; solution: \( (x,y,z,w) = (0,-3,-2,-4) \)

More References and links

  1. linear algebra
  2. Write a Matrix in Reduced Row Echelon Form
  3. The Three Row Operations on Augmented Matrices
  4. Solve a system of linear equations by elimination
  5. inverse of a matrix
  6. elementary matrices
  7. Row echelon form
  8. Gaussian Elimination