Scientia sine finibus

Linear Algebra / Unit 2, Systems of Linear Equations / Topic 2.2

Units and Topics

Unit 2. Systems of Linear Equations

2.2 Row Reduction

This topic organizes elimination into a fixed procedure, called row reduction. The procedure works on the table of numbers of a system, and it works for any number of equations and unknowns.

You need Topic 2.1 for this topic.

1. The Augmented Matrix

In Topic 2.1, the numbers of a system were kept in a table, with one row for each equation. When the right sides are added to the table as a last column, the table is called the augmented matrix of the system. A vertical line separates the coefficients from the right sides.

x + y + z = 6 2x − y + z = 3 x + 2y − z = 2 11162−11312−12

Each row is one equation. Each column on the left of the line belongs to one unknown. If an unknown is missing from an equation, its coefficient is 0, and the 0 must be written in the table.

2. The Three Row Operations

Elimination changes a system into a simpler system that has the same solutions. In the table, three operations do this.

OperationNotation
Add a multiple of one row to another rowR₂ → R₂ − 2R₁
Multiply a row by a number that is not 0R₃ → 3R₃
Exchange two rowsR₂ ↔ R₃

The notation R₂ → R₂ − 2R₁ means that row 2 is replaced by row 2 minus 2 times row 1. Row 1 does not change. The operation is applied to all of the entries of the row, including the entry on the right of the line.

None of the three operations changes the solutions of the system. The first operation adds a multiple of one equation to another equation, the second multiplies both sides of an equation by the same number, and the third changes the order of the equations. Each operation can also be undone by another operation of the same kind.

3. Row Echelon Form

The goal of the first stage is a table with zeros below a staircase of entries. Work from the left column to the right.

Step 1. Use row 1 to make zeros below the first entry of column 1.

R₂ → R₂ − 2R₁ R₃ → R₃ − R₁ 11160−3−1−901−2−4

Step 2. Move to column 2. Exchanging rows 2 and 3 puts a 1 in the second position of row 2, which keeps the numbers simple.

R₂ ↔ R₃ 111601−2−40−3−1−9

Step 3. Use row 2 to make a zero below it in column 2.

R₃ → R₃ + 3R₂ 111601−2−400−7−21

The first entry in a row that is not 0 is called the pivot of that row. In the last table, the pivots are 1, 1, and −7. A matrix is in row echelon form when it satisfies two conditions.

  • Each pivot is to the right of the pivot in the row above it.
  • Any rows that contain only zeros are at the bottom.

The word echelon refers to the staircase shape that the pivots make. Reaching this form is called Gaussian elimination.

A row exchange is necessary when the entry in the pivot position is 0 and an entry below it is not 0. In Step 2 the exchange was a choice. It avoided fractions.

4. Back Substitution

A matrix in row echelon form is solved from the bottom row to the top row. Write the rows of the last table as equations.

x + y + z = 6 y − 2z = −4 −7z = −21 z = 3the third equation, divided by −7y = −4 + 2(3) = 2the second equation, with z = 3x = 6 − 2 − 3 = 1the first equation, with y = 2 and z = 3

The solution is (1, 2, 3), as in Topic 2.1.

5. Reduced Row Echelon Form

The row operations can continue until the solution can be read from the table with no substitution. First make each pivot equal to 1. Then use each pivot to make zeros above it, starting with the last pivot.

R₃ → −1/7R₃ 111601−2−40013 R₂ → R₂ + 2R₃ R₁ → R₁ − R₃ 110301020013 R₁ → R₁ − R₂ 100101020013

The rows now state x = 1, y = 2, and z = 3.

A matrix is in reduced row echelon form when it is in row echelon form and it also satisfies two more conditions.

  • Each pivot is 1.
  • Each pivot is the only entry in its column that is not 0.

Continuing to this form is called Gauss-Jordan elimination.

A matrix has many row echelon forms, because different choices of operations lead to different tables. It has only one reduced row echelon form. Two people who use different operations reach the same reduced table.

Try it: choose the row operations

Reduce the matrix to reduced row echelon form. Choose an operation, choose the rows, type the number c, and press Apply. The number c can be a whole number, a decimal, or a fraction such as −1/3. The line under the controls shows the operation before you apply it.

    6. The Procedure in Order

    Row reduction follows the same order for any system.

    1. Start with the first column. If the entry in the pivot position is 0, exchange the row with a lower row that has an entry in that column that is not 0.
    2. Add multiples of the pivot row to the rows below it, so that all of the entries below the pivot are 0.
    3. Move one row down and one column to the right, and repeat. If a column has no entry that can be a pivot, move to the next column in the same row.
    4. When the matrix is in row echelon form, either use back substitution, or continue to the reduced form.

    A computer solves large systems in this way. A system with 1000 equations and 1000 unknowns takes a computer a fraction of a second.

    Common Mistakes

    • Applying an operation to the coefficients but not to the right side. The operation applies to the whole row.
    • Changing the wrong row. In R₂ → R₂ − 2R₁, row 2 changes and row 1 stays the same.
    • Leaving out a 0 for a missing unknown. The equation x + z = 4 has the row 1, 0, 1, 4.
    • Multiplying a row by 0. This operation destroys an equation, and it is not allowed.
    • Making a sign error when subtracting a negative entry. Write the multiple of the row first, and then add.
    • Doing two operations at the same time that use each other’s results. Finish one operation before starting the next.

    Summary

    TermMeaning
    Augmented matrixThe coefficients of a system with the right sides as a last column
    Row operationsAdd a multiple of a row to another row, multiply a row by a number that is not 0, exchange two rows
    PivotThe first entry in a row that is not 0
    Row echelon formEach pivot is to the right of the pivot above it, and rows of zeros are at the bottom
    Back substitutionSolving the equations of an echelon form from the bottom to the top
    Reduced row echelon formEchelon form in which each pivot is 1 and is the only entry in its column that is not 0

    Practice

    Work each problem on paper first. Then open the answer to check your work.

    1. Write the augmented matrix of the system 2x + y = 5 and x − 3y = −1.

    2151−3−1

    2. Apply R₂ → R₂ − 3R₁ to 1243713, and then solve the system.

    new row 2 = (3 − 3, 7 − 6, 13 − 12) = (0, 1, 1)row 2 minus 3 times row 1y = 1the second rowx = 4 − 2(1) = 2the first row, with y = 12 + 2 = 4the check in the first equation6 + 7 = 13the check in the second equation

    3. Is the matrix 123400120105 in row echelon form?

    No. The pivot of row 3 is in column 2, which is to the left of the pivot of row 2 in column 3.

    Exchanging rows 2 and 3 gives a matrix in row echelon form.

    4. Reduce 1253411 to reduced row echelon form, and read the solution.

    R₂ → R₂ − 3R₁gives the row (0, −2, −4)R₂ → −1/2R₂gives the row (0, 1, 2)R₁ → R₁ − 2R₂gives the row (1, 0, 1)

    The solution is x = 1 and y = 2.

    5. Solve by row reduction: x + y + z = 6, 2x + 3y + z = 11, and x + 2y + 3z = 14.

    R₂ → R₂ − 2R₁gives the row (0, 1, −1, −1)R₃ → R₃ − R₁gives the row (0, 1, 2, 8)R₃ → R₃ − R₂gives the row (0, 0, 3, 9)z = 3the third row states 3z = 9y = −1 + 3 = 2back substitution in the second rowx = 6 − 2 − 3 = 1back substitution in the first row

    The solution is (1, 2, 3).

    6. Solve by row reduction: y + 2z = 7, x + 2y + z = 7, and 2x + y + 3z = 14.

    The first row is (0, 1, 2, 7). Its first entry is 0, so exchange rows 1 and 2.

    R₃ → R₃ − 2R₁gives the row (0, −3, 1, 0)R₃ → R₃ + 3R₂gives the row (0, 0, 7, 21)z = 3the third row states 7z = 21y = 7 − 6 = 1back substitution in the second rowx = 7 − 2 − 3 = 2back substitution in the first row

    The solution is (2, 1, 3).

    Python Practice

    Step 1. Store an augmented matrix

    Python reads the code one line at a time, from the top to the bottom. The equals sign stores the value on its right under the name on its left, and print shows a result. The name np stands for NumPy, the part of Python that works with vectors and matrices.

    A matrix is typed one row at a time. Each row goes inside its own square brackets, and all of the rows go inside one more pair of square brackets. The code below stores the augmented matrix of the system in Practice Problem 5: x + y + z = 6, 2x + 3y + z = 11, and x + 2y + 3z = 14. The last number in each row is the right side.

    The part dtype=float tells Python to store the entries as decimal numbers. Without it, Python stores whole numbers only, and a later division would give a wrong result.

    Python

    Python prints each entry with a period after it, because the entries are stored as decimal numbers.

    Step 2. Read one row

    Python counts rows from 0, not from 1. Row 1 of the matrix is M[0], row 2 is M[1], and row 3 is M[2].

    Python

    The result is row 2 of the matrix. Now change the last line so that it prints row 3.

    Python

    Step 3. Do a row operation

    The operation R₂ → R₂ − 2R₁ is written as M[1] = M[1] - 2 * M[0]. The right side calculates row 2 minus 2 times row 1, and the equals sign stores the result as the new row 2.

    Python

    Row 2 is now 0, 1, −1, −1.

    In the next box, add one line before the print line that does the operation R₃ → R₃ − R₁. Click at the end of the second line and press Enter to make a new line.

    Python

    Step 4. Reach row echelon form

    The next box already has the two operations from Step 3. Add one more line before the print line, so that the entry below the second pivot becomes 0. Decide which operation is needed from the matrix at the end of Step 3.

    Python

    Step 5. Continue to the reduced form

    The code below starts from the row echelon form and continues to the reduced row echelon form. The second line divides row 3 by 3, so that its pivot is 1. The / sign means division. The third line uses row 3 to make a zero above its pivot in row 2.

    Python

    Rows 2 and 3 now state y = 2 and z = 3. Row 1 still has the entries 1, 1, 1, 6.

    In the next box, add the operations that make zeros above the pivots in row 1. You can use two lines, one for each operation.

    Python

    The last column of the reduced matrix is the solution (1, 2, 3).

    Step 6. Compare with the built-in solver

    The instruction np.linalg.solve from Topic 2.1 does row reduction for you. It needs the matrix of coefficients and the vector of right sides.

    Python

    The result is [1. 2. 3.], the same solution as in Step 5. Small rounding errors in the last digits are normal.

    Quiz

    This quiz has 5 questions on this topic. A question asks you either to choose one answer or to type numbers. The page grades your answers and explains each one. A number can be typed as a whole number, a decimal, a fraction such as 1/3, or a calculation such as sqrt(18)/2 or arccos(1/2). The page shows the value of a calculation next to the box. Angles in a calculation are in degrees. The Calculator button under each question opens a calculator. Your answers are saved in your browser, so they are still on the page when you come back to it.

    Choose how your answers are checked

    1. Which matrix is the augmented matrix of the system x + 2y = 4, 3x − y = 5?

    2. Apply the operation R₂ → R₂ − 2R₁ to the matrix 132275. Write the new second row.

    3. Which of these matrices is in row echelon form?

    4. Solve by back substitution the system with the augmented matrix 128039.

    5. Which of these matrices is in reduced row echelon form?

    Next: Topic 2.3, The Solutions of a System