This site is a work in progress. New lessons are added regularly. Contact us

Matrices and Systems of Equations

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
  • Recognize a zero row as a dependent system
  • Require a pivot in every variable column for uniqueness

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 xy=1x - y = 1 contributes a row of 11 and 1-1. 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,11, 0, 1, with the 00 marking the absent yy.

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. (RiRjR_i \leftrightarrow R_j.) You are just listing the equations in a different order.
  2. Multiply a row by a nonzero constant. (RikRiR_i \to kR_i with k0k \ne 0.) You are scaling one whole equation, both sides at once.
  3. Add a multiple of one row to another. (RiRi+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. Because you can always walk backward, no information is lost, and the reduced system has neither gained nor lost any solutions. Here is the argument in full.

Why the three row operations preserve 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 k0k \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.

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, because everything below its pivot is zero. So you substitute the values you already have and solve for that one new 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,3xy=1.\begin{aligned} x + 2y &= 5, \\ 3x - y &= 1. \end{aligned}

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

[125311]\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 R23R1R_2 - 3R_1. Subtract 33 times each entry of row 11 from row 22:

[1250714]\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.

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

Solve the system

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

Build the augmented matrix:

[1116231111125]\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 R22R1R_2 - 2R_1 and R3R_3 with R3R1R_3 - R_1:

[111601110211]\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:

[111601110013]\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:

[111601110013]\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 yz=1y - z = -1:

y3=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.

When a row gives it away

Not every system has a single solution. In the previous lessons you met the trichotomy: a linear system has exactly one solution, no solution, or infinitely many. In matrix form these last two cases announce themselves during reduction, in a single tell-tale row.

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 R22R1R_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 c0c \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 R2R22R1R_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. Let y=ty = t be free; then x=2tx = 2 - t, and every (2t,t)(2 - t,\, t) is a solution. 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. A row of zeros on the left with a nonzero constant on the right, [0  0c][\,0 \ \cdots\ 0 \mid c\,] with c0c \ne 0, means no solution. A row that is entirely zero, [0  00][\,0 \ \cdots\ 0 \mid 0\,], carries no information and signals a dependent system, which has infinitely many solutions as long as no contradiction row appears elsewhere. In that dependent case, each variable column without a pivot is a free variable. You assign each free variable a parameter, one parameter per pivot-free column, and solve for the pivoted variables in terms of those parameters. If neither kind of row shows up and every variable ends with its own pivot, the solution is unique.

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

Common mistakes

Practice

Multiple Choice Questions (MCQ)

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

Free Response Questions (FRQ)

Longer questions in parts, to be worked out on paper. Progressive hints, the answer on its own so you can check yourself and try again, then the full worked solution, plus a rubric to mark your own work against.

Free response Work it out on paper 5 questions 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.

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. The coefficients are laid out in rows and columns. The permitted moves are to scale a line of numbers and to subtract it from another. That is the augmented matrix of this lesson, and two of its three row operations, kept in rods on a table rather than in ink on a page.