How to Solve a System of Equations Using Gaussian Elimination: A Step-by-Step Guide


How to Solve a System of Equations Using Gaussian Elimination: A Step-by-Step Guide

In A Comprehensive Beginner’s Guide to Partial Fraction Decomposition, we encountered several instances where we had to solve a system of linear equations. The systems we had to solve that were in 4 equations, and four unknowns were essentially two systems in 2 equations and two unknowns. However, the truth is that I created the problems in a way so that would happen. This guide will walk you through how to solve a system of equations using Gaussian Elimination.

The following infographic illustrates the concepts covered in this article.

Gaussian Elimination Infographic Resized. Related Article - How to Solve a System of Equations Using Gaussian Elimination: A Step-by-Step Guide.

What is Gaussian Elimination?

Gaussian elimination is a method for solving systems of linear equations. It converts the system into an augmented matrix and applies row operations to achieve a row echelon form. Once the system is in row echelon form, back-substitution is used to find the solutions.

Let’s explain what these terms mean.

Augmented Matrix

An augmented matrix is just the matrix representation for a system of equations. For example, the system

$$\begin{aligned}
x + 2y + 3z &= 7 \\
4x + 5y + 6z &= 10
\end{aligned},$$

has augmented matrix

$$\begin{pmatrix}
1 & 2 & 3 & 7 \\
4 & 5 & 6 & 10
\end{pmatrix}.$$

Row Operations

The row operations are:

  • Swap two rows.
  • Multiply a row by a nonzero constant.
  • Add or subtract a multiple of one row from another row.

For example, subtracting row 1 from row 2 in our example above gives

$$\begin{pmatrix}
1 & 2 & 3 & 7 \\
3 & 3 & 3 & 3
\end{pmatrix}.$$

Row Echelon Form

A matrix in row echelon form satisfies the following criteria::

  • Any row consisting of all zeros is at the bottom of the matrix.
  • For any row consisting of any nonzero entries, the first nonzero entry is a 1. This entry is called a pivot.
  • All entries below the pivots are zero. If, in addition, all entries above the pivots are zero, the matrix is said to be in reduced row echelon form.

The matrix

$$\begin{pmatrix}
1 & 2 & 3 \\
0 & 1 & 2 \\
0 & 0 & 0
\end{pmatrix}$$

is in row echelon form, while

$$\begin{pmatrix}
1 & 0 & -1 \\
0 & 1 & 2 \\
0 & 0 & 0
\end{pmatrix}$$

is in reduced row echelon form.

Steps to Perform Gaussian Elimination

Step 1: Convert the System into an Augmented Matrix

Convert the system into matrix form. Beware of equations with missing variables.

Step 2: Convert to Row Echelon Form or Reduced Row Echelon Form

Use row operations to get the matrix into row echelon form, if the row echelon form has one or more rows containing all zeros continue to reduced row echelon form.

Step 3: Convert Back to Equations

Go back to equation form. If one or more equations contains a contradiction, then there is no solution and you are done.

Step 4: Back-Substitution

Finalize the solution using the substitution method you learned in high school algebra.

Worked Out Example

This example shows the three possible cases for linear systems: no solution, one solution, and infinitely many solutions. Systems with no solution are called inconsistent, while systems with at least one solution are called consistent.

Example 1: Solve the systems:
(a) $$\begin{aligned}
x + 2y + 3z &= 2 \\
4x + 5y + 6z &= 5 \\
7x + 8y + 9z &= 7
\end{aligned}]$$
(b) $$\begin{aligned}
2x + y – z &= 8 \\
-3x – y + 2z &= -11 \\
-2x + y + 2z &= -3
\end{aligned}$$
(c) $$\begin{aligned}
x + 2y + 3z &= 2 \\
4x + 5y + 6z &= 5 \\
7x + 8y + 9z &= 8
\end{aligned}$$

Solution: (a) $$\begin{aligned}
x + 2y + 3z &= 2 \\
4x + 5y + 6z &= 5 \\
7x + 8y + 9z &= 7
\end{aligned}].$$

The augmented matrix for the system is

$$\begin{pmatrix}
1 & 2 & 3 & 2 \\
4 & 5 & 6 & 5 \\
7 & 8 & 9 & 7
\end{pmatrix}.$$

Subtracting 4 times row 1 from row 2 and 7 times row 1 from row 3 we get

$$\begin{pmatrix}
1 & 2 & 3 & 2 \\
0 & -3 & -6 & -3 \\
0 & -6 & -12 & -7
\end{pmatrix}.$$

Dividing row 2 by -3, we obtain

$$\begin{pmatrix}
1 & 2 & 3 & 2 \\
0 & 1 & 2 & 1 \\
0 & -6 & -12 & -7
\end{pmatrix}.$$

Adding 6 times row 2 to row 3, we have

$$\begin{pmatrix}
1 & 2 & 3 & 2 \\
0 & 1 & 2 & 1 \\
0 & 0 & 0 & -1
\end{pmatrix}.$$

In equation form, this is

$$\begin{aligned}
x + 2y + 3z &= 2 \\
y + 2z &= 1 \\
0 &= -1
\end{aligned}.$$

The last equation, 0 = -1, is a contradiction, so this system has no solution.

(b) $$\begin{aligned}
2x + y – z &= 8 \\
-3x – y + 2z &= -11 \\
-2x + y + 2z &= -3
\end{aligned}$$

The augmented matrix for the system is

$$\begin{pmatrix}
2 & 1 & -1 & 8 \\
-3 & -1 & 2 & -11 \\
-2 & 1 & 2 & -3
\end{pmatrix}.$$

Dividing the first row by 2 gives

$$\begin{pmatrix}
1 & \frac{1}{2} & -\frac{1}{2} & 4 \\
-3 & -1 & 2 & -11 \\
-2 & 1 & 2 & -3
\end{pmatrix}.$$

Adding 3 times row 1 to row 2 and 2 times row 1 to row 3, we get

$$\begin{pmatrix}
1 & \frac{1}{2} & -\frac{1}{2} & 4 \\
0 & \frac{1}{2} & \frac{1}{2} & 1 \\
0 & 2 & 1 & 5
\end{pmatrix}.$$

Multiplying row 2 by 2, we obtain

$$\begin{pmatrix}
1 & \frac{1}{2} & -\frac{1}{2} & 4 \\
0 & 1 & 1 & 2 \\
0 & 2 & 1 & 5
\end{pmatrix}.$$

Subtracting 2 times row 2 from row 3, we have

$$\begin{pmatrix}
1 & \frac{1}{2} & -\frac{1}{2} & 4 \\
0 & 1 & 1 & 2 \\
0 & 0 & -1 & 1
\end{pmatrix}.$$

Multiplying row 3 by -1, we arrive at

$$\begin{pmatrix}
1 & \frac{1}{2} & -\frac{1}{2} & 4 \\
0 & 1 & 1 & 2 \\
0 & 0 & 1 & -1
\end{pmatrix}.$$

In equation form, this is

$$\begin{aligned}
x + \frac{1}{2}y – \frac{1}{2}z &= 4 \\
y + z &= 2 \\
z &= -1
\end{aligned}.$$

Substituting z = -1 into the second equation gives

$$y – 1 = 2 \Rightarrow y = 3.$$

Substituting y = 3 and z = -1 into the first equation, we find.

$$x + 2 = 4 \Rightarrow x = 2.$$

Thus, our final solution is

$$x = 2, y = 3, z = -1.$$

(c) $$\begin{aligned}
x + 2y + 3z &= 2 \\
4x + 5y + 6z &= 5 \\
7x + 8y + 9z &= 8
\end{aligned}$$

The augmented matrix for the system is

$$\begin{pmatrix}
1 & 2 & 3 & 2 \\
4 & 5 & 6 & 5 \\
7 & 8 & 9 & 8
\end{pmatrix}.$$

Subtracting 4 times row 1 from row 2 and 7 times row 1 from row 3 we get

$$\begin{pmatrix}
1 & 2 & 3 & 2 \\
0 & -3 & -6 & -3 \\
0 & -6 & -12 & -6
\end{pmatrix}.$$

Dividing row 2 by -3, we obtain

$$\begin{pmatrix}
1 & 2 & 3 & 2 \\
0 & 1 & 2 & 1 \\
0 & -6 & -12 & -6
\end{pmatrix}.$$

Adding 6 times row 2 to row 3, we have

$$\begin{pmatrix}
1 & 2 & 3 & 2 \\
0 & 1 & 2 & 1 \\
0 & 0 & 0 & 0
\end{pmatrix}.$$

We continue to reduced row echelon form. Subtracting 2 times row 2 from row 1, we arrive at

$$\begin{pmatrix}
1 & 0 & -1 & 0 \\
0 & 1 & 2 & 1 \\
0 & 0 & 0 & 0
\end{pmatrix}.$$

In equation form, this is

$$\begin{aligned}
x – z &= 0 \\
y + 2z &= 1
\end{aligned}.$$

Which implies

$$\begin{aligned}
x &= z \\
y &= -2z + 1
\end{aligned}.$$

Letting z = t be the free variable, our final solution is

$$ x = t, y = -2t + 1, z = t.$$

Homogeneous Systems

A homogeneous system has the form

$$\begin{aligned}
a_{11}x_1 + … + a_{1n}x_n &= 0 \\
… &= 0 \\
a_{m1}x_1 + … + a_{mn}x_n &= 0
\end{aligned}.$$

Homogeneous systems always have at least one solution, namely \( x_1 = … = x_n = 0 \). This is called the trivial solution.

Conclusion

Gaussian elimination is a powerful technique for solving systems of linear equations. By following the step-by-step approach on how to solve a system of equations using Gaussian Elimination, you can determine any linear system’s solution(s). With practice, you’ll be able to solve more advanced partial fraction decomposition problems and other mathematical problems where linear systems show up.

Further Reading

Partial Fraction Decomposition Integration Problems with Solutions: A Complete Tutorial – Now that you know about Gaussian Elimination, you have the tools to tackle some of the more difficult partial fraction decomposition problems. Such as those that appear in this article

How to Find the Determinant of a Matrix Step by Step: A Complete Beginner’s Guide – With a solid grasp of the above concepts, you are now ready to learn about determinants.

Frequently Asked Questions

Yes. Gaussian elimination works for any linear system.