Matrices and Systems of Equations Advanced. This lesson goes beyond core Algebra II. You can skip it.

Learning goals

  • Write an augmented matrix with the variables stripped away
  • Apply the three row operations, each reversible
  • Reduce to row-echelon form, then back-substitute
  • Read a contradiction row as no solution
  • Use a pivot in every variable column to tell one solution from infinitely many

From equations to a grid of numbers

A matrix is a rectangular array of numbers, written inside square brackets. Nothing more mysterious than that. Here is one with two rows and three columns:

[238547]\left[\begin{array}{ccc} 2 & 3 & 8 \\ 5 & 4 & 7 \end{array}\right]

The reason a matrix is useful right now is that a system of linear equations is already a grid of numbers in disguise. Take the system

2x+3y=8,5x+4y=7.\begin{aligned} 2x + 3y &= 8, \\ 5x + 4y &= 7. \end{aligned}

Line up the variables in the same order in every equation, keep the constants on the right, and read off the coefficients row by row. The two coefficients on the left of each equation become the first two columns, and the constant becomes a third column. To remember that the third column plays a different role, we draw a vertical bar in front of it. The result is the augmented matrix of the system:

[238547]\left[\begin{array}{cc|c} 2 & 3 & 8 \\ 5 & 4 & 7 \end{array}\right]

The bar stands for the equals signs. Everything left of it is a coefficient of a variable; the single column to its right holds the constants. Drop the bar and the first two columns on their own form the coefficient matrix. The augmented matrix carries strictly more information, because it remembers the right-hand sides too, which is why it is the one we reduce.

A system and its augmented matrixThe coefficients 2, 3 and 5, 4 and the constants 8 and 7 of the two equations become the rows of the augmented matrix, with a vertical bar separating the constant column.2x + 3y = 85x + 4y = 7coefficientsxy238547
The system on the left and its augmented matrix on the right hold exactly the same information. Every step of the solution works on the numbers alone, because the letters x and y never did any of the arithmetic.

Two small conventions keep the translation honest. A variable that is written with no number in front of it has coefficient 11, so x−y=1x - y = 1 becomes the row [ 1 −1∣1 ][\,1 \ {-1} \mid 1\,], coefficients and constant together. A variable that is missing from an equation has coefficient 00. That 00 is not optional: it holds the column open so the other coefficients stay in their correct places, exactly the placeholder job a zero does in place value. Write x+z=4x + z = 4 inside a three-variable system and its row is [ 1 0 1∣4 ][\,1 \ 0 \ 1 \mid 4\,], with the 00 marking the absent yy.

Check your understanding

Write the augmented matrix for the system x+z=5x + z = 5 and 2x−y+3z=42x - y + 3z = 4, keeping the variable order x,y,zx, y, z in every column. Which matrix is correct?

Answer choices

Dimensions and entries

A matrix with mm rows and nn columns is called an m×nm \times n matrix (say ”mm by nn”), always rows first. The augmented matrix above is 2×32 \times 3. To point at one number inside a matrix AA, we name its row and its column: the entry in row ii and column jj is written aija_{ij}. That notation uses the same letter as the matrix, but lowercase, with the row number first and the column number second. So in

A=[238547],A = \left[\begin{array}{cc|c} 2 & 3 & 8 \\ 5 & 4 & 7 \end{array}\right],

the entry a11=2a_{11} = 2 sits in the top left, a13=8a_{13} = 8 is the first constant, and a21=5a_{21} = 5 is the coefficient of xx in the second equation. Row first, column second, every time. That is the entire vocabulary you need; matrices carry much more machinery in later chapters, but here the matrix exists only to organize elimination, so this is where we stop.

Check your understanding

A system has the equations 2x+3y=82x + 3y = 8 and 5x+4y=75x + 4y = 7. In its augmented matrix, what is the entry a21a_{21} (row 2, column 1)?

Answer choices

The three row operations

Elimination lets you do three things to a system without changing which values of the variables solve it. Written on the augmented matrix, where each row is one equation, they become the three row operations:

  1. Swap two rows. (Ri↔RjR_i \leftrightarrow R_j.) You are just listing the equations in a different order.
  2. Multiply a row by a nonzero constant. (Ri→kRiR_i \to kR_i with k≠0k \ne 0.) You are scaling one whole equation, both sides at once.
  3. Add a multiple of one row to another. (Ri→Ri+kRjR_i \to R_i + kR_j.) This is the elimination step itself: you add a chosen multiple of one equation to a second so that a variable cancels in the second.

These are the only moves you are allowed, and every one of them is reversible, which is the property that matters. Swapping back undoes a swap; dividing by kk undoes a multiply; subtracting the same multiple undoes an addition. Reversibility is what protects the whole system, together, not row by row: if a set of values satisfies every equation before the move, it still satisfies every equation after, and if it satisfies every equation after the move, undoing the move recovers the original system, so those values must have solved that too. Nothing gets in or out of the solution set either way. Multiplying by 00 is the one move left out, because it is not reversible: it turns an equation into 0=00 = 0, which is true no matter what, and there is no way back to what the row used to say.

Check your understanding

Which of these is not a legal row operation on an augmented matrix?

Answer choices

Row-echelon form and back-substitution

The goal of the row operations is to reach row-echelon form, the matrix version of the triangular shape you drove systems toward in the previous lessons. The leading entry of a row is its first nonzero number, and we call it a pivot. A matrix is in row-echelon form when each pivot sits strictly to the right of the pivot in the row above, and any all-zero rows lie at the bottom. For a square system with a single solution this makes a clean staircase: the entries below the diagonal are all zero.

Row-echelon form as a staircaseThe leading entries lie on the diagonal, circled, and the three zeros below the diagonal are highlighted, so the bottom row gives one variable directly.xyz111601-1-10013
Row-echelon (triangular) form. Each circled leading entry sits one column to the right of the one above it, and every entry in the triangle below them is zero. The bottom row pins the last variable down, and from there you climb back up.

Once the matrix is triangular, you translate the bottom row back into an equation and solve it, then work upward. Each row you climb into has only one new variable in it. The variables to the right of that row’s pivot were already pinned down by the rows below. The entries to the left of the pivot are zero, by the staircase shape itself. So you substitute the values you already have and solve for that one remaining variable. Working from the bottom up like this is called back-substitution, and it is the reason the triangular shape is worth chasing.

Row reduction in action

Worked example 1 Solve a 2×22\times2 system by row reduction

Solve the system

x+2y=5,3x−y=1.\begin{aligned} x + 2y &= 5, \\ 3x - y &= 1. \end{aligned}

Write the augmented matrix, keeping the variables in the order x,yx, y:

[1253−11]\left[\begin{array}{cc|c} 1 & 2 & 5 \\ 3 & -1 & 1 \end{array}\right]

The first column already has a 11 on top, a convenient pivot. Clear the 33 beneath it by replacing R2R_2 with R2−3R1R_2 - 3R_1. That means subtracting 33 times every entry of row 11, the constant included, from the matching entry of row 22:

(3, −1∣1)−3⋅(1, 2∣5)=(3−3, −1−6∣1−15)=(0, −7∣−14).(3,\ -1 \mid 1) - 3 \cdot (1,\ 2 \mid 5) = (3 - 3,\ -1 - 6 \mid 1 - 15) = (0,\ -7 \mid -14).[1250−7−14]\left[\begin{array}{cc|c} 1 & 2 & 5 \\ 0 & -7 & -14 \end{array}\right]

Now scale row 22 so its pivot becomes 11, replacing R2R_2 with −17R2-\tfrac{1}{7}R_2:

[125012]\left[\begin{array}{cc|c} 1 & 2 & 5 \\ 0 & 1 & 2 \end{array}\right]

The matrix is triangular. Read the bottom row back as an equation: it says y=2y = 2. Back-substitute into the top row, which reads x+2y=5x + 2y = 5:

x+2(2)=5  ⟹  x=1.x + 2(2) = 5 \;\Longrightarrow\; x = 1.

The solution is (x,y)=(1,2)(x, y) = (1, 2). A quick check in the original second equation confirms it: 3(1)−2=13(1) - 2 = 1.

Check your understanding

Starting from [137259]\left[\begin{array}{cc|c} 1 & 3 & 7 \\ 2 & 5 & 9 \end{array}\right], replace R2R_2 with R2−2R1R_2 - 2R_1. What is the new row 22?

Answer choices

Worked example 2 Solve a 3×33\times3 system by row reduction

Solve the system

x+y+z=6,2x+3y+z=11,x−y+2z=5.\begin{aligned} x + y + z &= 6, \\ 2x + 3y + z &= 11, \\ x - y + 2z &= 5. \end{aligned}

Build the augmented matrix:

[1116231111−125]\left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 2 & 3 & 1 & 11 \\ 1 & -1 & 2 & 5 \end{array}\right]

Use the pivot 11 in the top left to clear the rest of column 11. Replace R2R_2 with R2−2R1R_2 - 2R_1 and R3R_3 with R3−R1R_3 - R_1:

[111601−1−10−21−1]\left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 0 & 1 & -1 & -1 \\ 0 & -2 & 1 & -1 \end{array}\right]

Now the pivot 11 in row 22, column 22 clears the −2-2 below it. Replace R3R_3 with R3+2R2R_3 + 2R_2:

[111601−1−100−1−3]\left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 0 & 1 & -1 & -1 \\ 0 & 0 & -1 & -3 \end{array}\right]

Scale row 33 to make its pivot 11, replacing R3R_3 with −R3-R_3:

[111601−1−10013]\left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 0 & 1 & -1 & -1 \\ 0 & 0 & 1 & 3 \end{array}\right]

This is triangular, so back-substitute from the bottom. Row 33 gives z=3z = 3. Row 22 reads y−z=−1y - z = -1:

y−3=−1  ⟹  y=2.y - 3 = -1 \;\Longrightarrow\; y = 2.

Row 11 reads x+y+z=6x + y + z = 6, and both other values are known:

x+2+3=6  ⟹  x=1.x + 2 + 3 = 6 \;\Longrightarrow\; x = 1.

The solution is (x,y,z)=(1,2,3)(x, y, z) = (1, 2, 3), the values the echelon matrix in the figure above was built from.

Check your understanding

Reduce [1172−12]\left[\begin{array}{cc|c} 1 & 1 & 7 \\ 2 & -1 & 2 \end{array}\right] to row-echelon form and back-substitute. What is the solution (x,y)(x, y)?

Answer choices

When a row gives it away

Not every system has a single solution. In the previous lessons you saw that a linear system always has exactly one solution, no solution, or infinitely many. In matrix form, no solution announces itself in a single tell-tale row; infinitely many takes a little more reading, which the next two examples and the rule after them will show you how to do.

Worked example 3 Spot the no-solution and infinitely-many cases

Start with a system that has no solution:

x+y=2,2x+2y=5.\begin{aligned} x + y &= 2, \\ 2x + 2y &= 5. \end{aligned}

Reduce its augmented matrix by replacing R2R_2 with R2−2R1R_2 - 2R_1:

[112225]  ⟶  [112001]\left[\begin{array}{cc|c} 1 & 1 & 2 \\ 2 & 2 & 5 \end{array}\right] \;\longrightarrow\; \left[\begin{array}{cc|c} 1 & 1 & 2 \\ 0 & 0 & 1 \end{array}\right]

Translate the bottom row back into an equation. Its coefficients are all zero, but the constant is not: it reads 0x+0y=10x + 0y = 1, that is, 0=10 = 1. No values of xx and yy can make that true, so the system has no solution. A row of the form [ 0  0 ∣ c ][\,0 \ \ 0 \ \mid\ c\,] with c≠0c \ne 0 is the matrix shouting contradiction.

Now change a single number so the system has infinitely many solutions:

x+y=2,2x+2y=4.\begin{aligned} x + y &= 2, \\ 2x + 2y &= 4. \end{aligned}

The same operation R2→R2−2R1R_2 \to R_2 - 2R_1 now gives:

[112224]  ⟶  [112000]\left[\begin{array}{cc|c} 1 & 1 & 2 \\ 2 & 2 & 4 \end{array}\right] \;\longrightarrow\; \left[\begin{array}{cc|c} 1 & 1 & 2 \\ 0 & 0 & 0 \end{array}\right]

This time the bottom row is entirely zero, standing for 0=00 = 0. That is true for every choice of values, so it adds no constraint at all: the second equation was really just the first one doubled. What remains is the single equation x+y=2x + y = 2, and any pair of numbers that adds to 22 satisfies it: try (2,0)(2, 0), or (1,1)(1, 1), or (0,2)(0, 2), and each one checks out. To describe every such pair at once, let yy stand for any number, and give it the name tt so it is clear it is no longer fixed; then x=2−tx = 2 - t matches it. Every (2−t, t)(2 - t,\, t) is a solution, one for each value of tt. The system is dependent, with a whole line of solutions.

The pattern is worth stating plainly, because it is how you diagnose a system straight from its reduced matrix. First check for a contradiction: a row of zeros on the left with a nonzero constant on the right, [ 0 ⋯ 0∣c ][\,0 \ \cdots\ 0 \mid c\,] with c≠0c \ne 0, means no solution, full stop. If no such row appears, the system is consistent, and the count of solutions comes down to one thing: does every variable column have a pivot? If it does, each variable is pinned to a single value, and the solution is unique. If some variable column has no pivot, that variable is free. You assign each free variable a parameter, one per pivot-free column, and solve for the pivoted variables in terms of those parameters, giving infinitely many solutions.

A row that is entirely zero, [ 0 ⋯ 0∣0 ][\,0 \ \cdots\ 0 \mid 0\,], carries no information on its own: it just means one equation added nothing new. It often shows up alongside the infinitely-many case, since one equation adding nothing is one less piece of information to pin a variable down with, but it is the missing pivot that decides the solution count, not the zero row itself. A zero row can appear in a system with more equations than unknowns, one of them redundant, while every unknown still has its own pivot from the other equations, giving one solution despite the zero row.

Check your understanding

While reducing a system's augmented matrix, you reach a row whose left entries are all zero but whose constant is 44, standing for the equation 0=40 = 4. What does this tell you about the system?

Answer choices

Check your understanding

A system of three equations in two unknowns, xx and yy, reduces to the augmented matrix [102013000]\left[\begin{array}{cc|c}1&0&2\\0&1&3\\0&0&0\end{array}\right]. The bottom row is entirely zero. How many solutions does the system have?

Answer choices

Common mistakes

Practice

Multiple Choice Questions (MCQ)

Progressively harder sets of questions. Each opens on its own page.

Core practice

Practice problems at the level of the course, to be worked out on paper. Hints one at a time, then the answer or the full worked solution, with your progress kept in this browser.

Core practice Work it out on paper 10 problems Start →
More practice (optional)

Extra sets, as hard as the Challenge set. Each one opens on its own page.

More resources (optional)

Other explanations of this lesson, if you want a second take.

Go deeper (optional)

You can skip this and keep going. Read it if you want to know more.

Why the three row operations preserve the solution set

The main lesson gives the reason in plain words: every row operation is reversible, so it cannot create or destroy a solution. Here is the same claim checked equation by equation.

Each row operation preserves the solution set#

A solution of a system is a choice of values for the variables that makes every equation true at once. We check each operation against that definition.

Reordering the rows changes nothing about the equations themselves, only the order in which they are listed. So a choice of values that satisfies all of them before the swap satisfies all of them after. The solution set is untouched.

Multiplying row RiR_i by a nonzero constant kk replaces the equation EE with kEkE. Any values that make EE true make kEkE true, since multiplying both sides of a true equation by kk keeps it true. Conversely, any values that make kEkE true also make EE true, because k≠0k \ne 0 lets you divide both sides by kk and recover EE. So EE and kEkE have precisely the same solutions, and the rest of the system is unchanged. This is exactly where the word nonzero earns its place. Multiplying by 00 would turn EE into 0=00 = 0, which every choice of values satisfies, and the original equation could never be recovered. That step would throw a genuine constraint away.

Adding kk times row RjR_j to row RiR_i replaces the equation EiE_i with Ei+kEjE_i + kE_j, while EjE_j itself stays in the system. Suppose some values satisfy the original system. Then they make both EiE_i and EjE_j true, so they make Ei+kEjE_i + kE_j true as well, and they still satisfy the untouched EjE_j. So every old solution is a solution of the new system. For the reverse, suppose some values satisfy the new system. They make Ei+kEjE_i + kE_j true and, because EjE_j is still present, they make EjE_j true too. Subtracting kk times EjE_j from Ei+kEjE_i + kE_j returns EiE_i, so those values satisfy EiE_i as well. Every new solution is therefore an old solution. The two systems have identical solution sets.

Since each operation leaves the solution set exactly as it was, any sequence of them does too. Whatever you reduce the matrix to, you may read its solutions as the solutions of the system you started with.

A bit of history (optional)

Two thousand years ago in China, a clerk facing three unknowns wrote nothing down. There was no letter xx, no equals sign, and no page of algebra to fill. There was a board, and a bag of small counting rods.

Each equation became one column of rods laid on the board. Set the columns side by side and the whole system was there, a rectangle of numbers with nothing else in it. The procedure that reduced the rectangle had a name, fangcheng, and a home: the eighth chapter of the Nine Chapters on the Mathematical Art.

Every clerk running it met the same obstacle. Clearing an unknown means subtracting one column from another, and sooner or later that asks you to take a larger number from a smaller. The board answered with color. Rods came in two colors, and the second color counted an amount owed rather than held. Negative quantities were ordinary working tools on that table, because the method could not run without them.

Now consider what that rectangle really is. The unknowns have disappeared completely, and the coefficients are laid out in a grid. The permitted moves are to scale a line of numbers and to subtract it from another, the same two moves this lesson calls row operations, done on columns instead of rows because the rods laid each equation sideways. That is the augmented matrix of this lesson, turned on its side and kept in rods on a table rather than in ink on a page.