## Using Matrices to Solve Systems of Equations if (parent.playingGame) document.writeln('<i><font color = AA00DD>Game Version</font></i>')

This tutorial: Part B: Solving a System by Gauss-Jordan
Some Online Resources for This Topic:

In this tutorial, we put row operations to work for us in solving systems of equations. (If you are not familiar with row operations, go to Part A of this tutorial by pressing "Previous Topic" on the sidebar.) First of all, let's start with a complicated looking system of equations, such as

 \frac{x}{2} + \frac{2y}{3} = \frac{1}{6} -2x + \frac{y}{4} = \frac{1}{2}
Augmented matrix:   \mat{$\frac{1}{2} , \frac{2}{3}, \frac{1}{6}$!-2,\frac{1}{4} , \frac{1}{2} }
We shall do some row operations on the augmented matrix to change, or reduce it as follows:
\mat{$\frac{1}{2} , \frac{2}{3}, \frac{1}{6}$,! -2,\frac{1}{4} , \frac{1}{2}}    A bunch of row operations

\mat4{$1, 0 , -0.2$! , , ! 0 , 1 , 0.4}
Original matrix Reduced matrix
Q Big deal. What is the point of doing that?
A Look at the matrix on the right. If we translate its rows back into equations (see the preceding tutorial for help on this), we get:
Row 1: 1x + 0y = -0.2, that is, x = -0.2
Row 2: 0x + 1y = 0.4, that is, y = 0.4
In other words, we have the solution of the system: x = -0.2, y = 0.4.

Q OK I'm impressed. So, how do you come up with the row operations to accomplish this magical transformation?
A We will be doing the row reduction in several steps. One of the key steps is called clearing a column, and we are going to discuss that first before revealing the entire process to you. To clear a column, we first need to designate one of the nonzero entries of the matrix as a pivot.

Click on an entry to designate it as a pivot.

By clearing the pivot column, or pivoting, we mean using row operations of type aRi ± bRj to wind up with a matrix in which the pivot is the only non-zero number in its column. In other words, everything else in that column is "cleared away" (equal to zero).

Here are some matrices with the pivot column cleared:

\mat2{$3 , 4 , 1$! 0, 35, 14}       \mat2{$4 , 2 , 1 , -3$! 0 , 11 , 0 ,-1!0, 35, 14, 4}       \mat2{$12 , 0 , 1 , -3$! 0,  -3  , 11 , 0 !0, 0, 35, 4}
Q How do I come up with the operations to clear a column?
A Before we reveal the secret, let's take a look at how its done in a simple case:
\mat4{$3 , 4 , 1$! -8 , 1 , 2,3R_2 + 8R_1}       \mat4{$3, 4 , 1$! 0 , 35, 14}
Write down the row operation aR_i ± bR_2 needed to clear the pivot column.
Rule: The coefficients a and b must be whole numbers, and a negative sign is not permitted at the beginning of the row operation.
Examples of permitted row operations: 3R1+4R2,  5R1-6R2,  R1+R2,  R1-3R2
Examples of disallowed row operations: -3R1+4R2,  -5R1-6R2,  (1/2)R1+3R2

Repeat, but notice that this time the pivot column is the second column, and the in the second column needs to change to zero.

Q HELP!!! I'm still stumped. How do I come up with the row operations necessary to clear the pivot column?
A Here is a mechanical way to set up the row operations, illustrated with three examples.
How to Clear a Column

1. Once the pivot is selected, focus on the "pivot column". This is the column that contains the pivot you have already designated:

 \mat2{$3 , 4 , 1$! , , ! -8 , 1 , 2} \mat2{$2 , 3 , 4 , 1$! 0 ,  2 , 4 , 1! 0 , -6 , 1 , 2} \mat2{$2 , 4 , 0 , 4$! 0 , 5 , 2 , 1! 0 , 0 ,  1  , 2}

2. To clear the pivot column, you will need to get zeros in place of all the blue-colored entries by changing their rows. Next to each row you want to change -- that is, next to each row with a blue entry that is not already zero -- write the name of that row on the left, and the pivot row (the row that contains the pivot) on the right:

 \mat2{$3 , 4 , 1$! , , ! -8 , 1 , 2,   R_2     R_1} \mat2{$2 , 3 , 4 , 1$,   R_1     R_2! 0 ,  2 , 4 , 1! 0 , -6 , 1 , 2 ,   R_3     R_2} \mat2{$2 , 4 , 0 , 4$! 0 , 5 , 2 , 1 ,   R_2     R_3! 0 , 0 ,  1  , 2}

3. Next to the blue row label, write the absolute value of the red number, and next to the red row label, write the absolute value of the blue number:

 \mat2{$3 , 4 , 1$! , , ! -8 , 1 , 2, 3R_2     8R_1} \mat2{$2 , 3 , 4 , 1$, 2R_1     3R_2! 0 ,  2 , 4 , 1! 0 , -6 , 1 , 2 , 2R_3     6R_2} \mat2{$2 , 4 , 0 , 4$! 0 , 5 , 2 , 1 , 1R_2   2R_3! 0 , 0 ,  1  , 2}

4. If the blue and red entries have the same sign, insert a minus (-), but if they have different signs, insert a plus (+):

 \mat2{$3 , 4 , 1$! , , ! -8 , 1 , 2, 3R_2 + 8R_1} \mat2{$2 , 3 , 4 , 1$, 2R_1 - 3R_2! 0 ,  2 , 4 , 1! 0 , -6 , 1 , 2 , 2R_3 + 6R_2*} \mat2{$2 , 4 , 0 , 4$! 0 , 5 , 2 , 1 , R_2 - 2R_3! 0 , 0 ,  1  , 2}

The result of doing these operations will be to clear the pivot column. (Try them!)

*NOTE We can (and should!) use smaller numbers when the coefficients have a common factor. For instance, instead of using 2R_3 + 6R_2 as we did in the center matrix, it is better to use R_3 + 3R_2 (divide the original coefficients 2 and 6 by the common factor 2). Similarly, 8R_3 - 12R_2 could be replaced by 2R_3 - 3R_2 (divide by the common factor 4). The result of using the smaller coefficients will be a matrix with smaller entries.

Example for you Write down the row operations aR_i ± bR_2 needed to clear the pivot column.

### How to Reduce a Matrix

We are now ready to write down the steps needed to completely reduce a matrix (and hence write down the solution of the system of equations it may represent).
Step 1: Clear all fractions and/or Decimals (if any).

We clear fractions and decimals by multiplying the rows that contain them by suitable integers.

In the example we are considering, we can do this by multiplying the first row by 6 and the second row by 4 as follows:

\mat{$\frac{1}{2} , \frac{2}{3}, \frac{1}{6}$, 6R_1 ! -2,\frac{1}{4} , \frac{1}{2} , 4R_2}       \mat4{$3, 4 , 1$! , , ! -8 , 1 , 2}
Example of Step 1 for you:
Enter the row instructions necessary to eliminate fractions and decimals, and also apply them.! (For example, to enter the instruction that multiplies Row 1 by 20, type 20R1. To leave a row alone, leave the instruction blank.)

Step 2: Designate the first nonzero entry in the first row as the pivot and clear its column.

Terminology: The first nonzero entry in a row is called the leading entry of that row.

Thus, the pivot will be the first element in the first row, unless it is zero, in which case we would use the first one that is nonzero in that row. (If the whole row is zero, then we skip this step.)

In the example we are considering, the pivot is therefore the (1, 1)-entry:

\mat4{$3 , 4 , 1$! -8 , 1 , 2,3R_2 + 8R_1}       \mat4{$3, 4 , 1$! 0 , 35, 14}
Examples of Step 2 for you: Clear the column of the indicated pivot. If a row does not need a row operation, leave its instruction blank.
Hint Consider using the Online Pivot & Gauss-Jordan Utility to assist you.

Repeat for the following matrix. If a row does not need a row operation, leave its instruction blank.

Simplification Step: If at any stage of the process, all the entries in a row are divisible of an integer, divide by that integer -- a Type 2 operation.

In the example we are considering, we notice that the entries in Row 2 are divisible by 7, so we divide that row by 7; that is, we multiply by 1/7:

\mat{$3, 4 , 1$! 0 , 35, 14 , \frac{1}{7}R_2}       \mat5{$3, 4 , 1$! 0 , 5, 2}           \mat{$3, -6 , 0, 27$,\frac{1}{3}R_1 ! 0 , -39, 13 , 0, \frac{1}{13}R_2 ! 1, 0 , 5, 2}       \mat5{$1 , -2 , 0 , 9$! 0, -3, 1 , 0 ! 1, 0 , 5, 2}

Although simplification steps are optional, they are enormously helpful as they help keep the entries small. For instance, in the above example on the left, if we skipped the simplification step we would have to deal with entries like 35 and 14 from here on.

In this page, and also in the Online Pivot & Gauss-Jordan Utility, you can enter this row operation as (1/7)R2 (and not R2/7).

Caution Do not divide by a number if it results in fractions. After Step 1, we deal only with integer matrices until the very last step.

Step 3: Designate the leading entry in the next row as the pivot and clear its column. Repeat this step until the last row.

Thus, the pivot will be the first nonzero entry in that row. If the whole row is zero, then we go to the next row.

In the example we are considering, the leading entry in Row 2 is the 5, so we pivot on it:

\mat4{$3, 4 , 1$, 5R_1 - 4R_2! 0 ,  5 , 2}       \mat4{$15 , 0 , -3$! 0 , 5 , 2}

Since there are no more rows, we are finished with Step 3.

Example of all the steps so far for you: Follow the instructions given to do all the steps so far:
Click on the first pivot.
Final Step: Turn all the leading entries into 1s by dividing each row by the value of its leading entry.

In the example we were considering earlier (see Step 3 above) we wound up with the following matrix after Step 3 (the leading entries are boxed):

\mat4{$15 , 0 , -3$! 0 ,  5  , 2}
To turn the leading entries into 1s, we divide the first row by 15 and the second by 5:
\mat4{$15 , 0 , -3$, \frac{1}{15}R_1! 0 , 5 , 2, \frac{1}{5}R_2}       \mat4{$1 , 0 , -\frac{3}{15}$! 0 , 1 , \frac{2}{5}}
And we are done! Translating the rows back into equations gives us the solution:
x = -\frac{3}{15} or -0.2
y = \frac{2}{5} or 0.4
(If you scroll back to the top of the page and press the "Show Row Operations" button you will see all the operations in all the steps that led to this result.)
Example of Final Step for you: Below is a matrix in which the columns of all the leading entries have been cleared. Enter the row operations for the last step and the resulting matrix.

The solution of the associated system is therefore
 x = y = z =

Q Do we always get the leading entries going down diagonally like we have been seeing in the above examples?
A Not always; we might, for instance, get a zero where we expect to see the next leading entry, or a whole row of zeros. In the next tutorial we consider such things.

You are now ready to go on to

Top of Page

Last Updated: September, 2009