We've updated our
Privacy Policy effective December 15. Please read our updated Privacy Policy and tap

TEXT

Study Guides > Finite Math

Reading: Solving Systems with Gaussian Elimination

German mathematician Carl Friedrich Gauss (1777–1855). Carl Friedrich Gauss lived during the late 18th century and early 19th century, but he is still considered one of the most prolific mathematicians in history. His contributions to the science of mathematics and physics span fields such as algebra, number theory, analysis, differential geometry, astronomy, and optics, among others. His discoveries regarding matrix theory changed the way mathematicians have worked for the last two centuries. In this section, we will learn Gaussian elimination for solving systems, using matrices.

Writing the Augmented Matrix of a System of Equations

matrix can serve as a device for representing and solving a system of equations. To express a system in matrix form, we extract the coefficients of the variables and the constants, and these become the entries of the matrix. We use a vertical line to separate the coefficient entries from the constants, essentially replacing the equal signs. When a system is written in this form, we call it an augmented matrix. For example, consider the following 2 × 2system of equations. 3x + 4y = 7 4x − 2y = 5 We can write this system as an augmented matrix (please note that a more common formatting for augmented matrices has a solid vertical line running through the matrix, rather than a line on each row): [latex-display]\displaystyle{\left[\matrix{{3}&{4}&{\mid}&{7}\\{4}&-{2}&{\mid}&{5}}\right][/latex-display] We can also write a matrix containing just the coefficients. This is called the coefficient matrix. [latex-display]\displaystyle{\left[\matrix{{3}&{4}\\{4}&-{2}}\right]}[/latex-display] A three-by-three system of equations such as 3xy z = 0 x + y = 5 2x − 3z = 2 has a coefficient matrix [latex-display]\displaystyle{\left[\matrix{{3}&-{1}&-{1}\\{1}&{1}&{0}\\{2}&{0}&-{3}}\right][/latex-display] and is represented by the augmented matrix [latex-display]\displaystyle{\left[\matrix{{3}&-{1}&-{1}&{\mid}&{0}\\{1}&{1}&{0}&{\mid}&{5}\\{2}&{0}&-{3}&{\mid}&{2}}\right][/latex-display] Notice that the matrix is written so that the variables line up in their own columns: x-terms go in the first column, y-terms in the second column, and z-terms in the third column. It is very important that each equation is written ax + by + cz = d in standard form so that the variables line up. When there is a missing variable term in an equation, the coefficient is 0.

How To

Given a system of equations, write an augmented matrix.
  1. Write the coefficients of the x-terms as the numbers down the first column.
  2. Write the coefficients of the y-terms as the numbers down the second column.
  3. If there are z-terms, write the coefficients as the numbers down the third column.
  4. Draw a vertical line and write the constants to the right of the line.

Example 1

  1. Write the augmented matrix for the given system of equations.

x + 2y z = 3 2x y + 2z = 6 x 3y + 3z = 4

2.  Write the augmented matrix of the given system of equations.

4x − 3y = 11

3x + 2y = 4

Solutions

  1. The augmented matrix displays the coefficients of the variables, and an additional column for the constants. [latex]\displaystyle{\left[\matrix{{1}&{2}&-{1}&{\mid}&{3}\\{2}&-{1}&{2}&{\mid}&{6}\\{1}&-{3}&{3}&{\mid}&{4}}\right]}[/latex]
  2. [latex]\displaystyle{\left[\matrix{{4}&-{3}&{\mid}&{11}\\{3}&{2}&{\mid}&{4}}\right]}[/latex]

Writing a System of Equations from an Augmented Matrix

We can use augmented matrices to help us solve systems of equations because they simplify operations when the systems are not encumbered by the variables. However, it is important to understand how to move back and forth between formats in order to make finding solutions smoother and more intuitive. Here, we will use the information in an augmented matrix to write the system of equations in standard form.

Example 2

  1. Find the system of equations from the augmented matrix. [latex]\displaystyle{\left[\matrix{{1}&-{3}&-{5}&{\mid}&-{2}\\{2}&-{5}&-{4}&{\mid}&{5}\\-{3}&{5}&{4}&{\mid}&{6}}\right]}[/latex]
  2. Write the system of equations from the augmented matrix. [latex]\displaystyle{\left[\matrix{{1}&-{1}&{1}&{\mid}&{5}\\{2}&-{1}&{3}&{\mid}&{1}\\{0}&{1}&{1}&{\mid}&-{9}}\right]}[/latex]

Solutions

  1. When the columns represent the variables x, y, and z,[latex]\displaystyle{\left[\matrix{{1}&-{3}&-{5}&{\mid}&-{2}\\{2}&-{5}&-{4}&{\mid}&{5}\\-{3}&{5}&{4}&{\mid}&{6}}\right]}\arrow{\left[\matrix{{x}-{3}{y}-{5}{z}=-{2}\\{2}{x}-{5}{y}-{4}{z}={5}\\-{3}{x}+{5}{y}+{4}{z}={6}}\right][/latex]
  2. [latex]\displaystyle{\left[\matrix{{x}-{y}+{z}={5}\\{2}{x}-{y}+{3}{z}={1}\\{y}+{z}=-{9}}\right][/latex]

Performing Row Operations on a Matrix

Now that we can write systems of equations in augmented matrix form, we will examine the various row operations that can be performed on a matrix, such as addition, multiplication by a constant, and interchanging rows. Performing row operations on a matrix is the method we use for solving a system of equations. In order to solve the system of equations, we want to convert the matrix to row-echelon form, in which there are ones down the main diagonal from the upper left corner to the lower right corner, and zeros in every position below the main diagonal as shown. Row-echelon form: [latex-display]\displaystyle{\left[\matrix{{1}&{a}&{b}\\{0}&{1}&{d}\\{0}&{0}&{1}}\right][/latex-display] We use row operations corresponding to equation operations to obtain a new matrix that is row-equivalent in a simpler form. Here are the guidelines to obtaining row-echelon form.
  1. In any nonzero row, the first nonzero number is a 1. It is called a leading 1.
  2. Any all-zero rows are placed at the bottom on the matrix.
  3. Any leading 1 is below and to the right of a previous leading 1.
  4. Any column containing a leading 1 has zeros in all other positions in the column.
To solve a system of equations we can perform the following row operations to convert the coefficient matrix to row-echelon form and do back-substitution to find the solution.
  1. Interchange rows. (Notation: [latex]\displaystyle{R}_{{i}}\left\rightarrow{R}_{{j}}[/latex])
  2. Multiply a row by a constant. (Notation: [latex]\displaystyle{c}{R}_{{i}}[/latex])
  3. Add the product of a row multiplied by a constant to another row. (Notation: [latex]\displaystyle{R}_{{i}}+{c}{R}_{{j}}[/latex])
Each of the row operations corresponds to the operations we have already learned to solve systems of equations in three variables. With these operations, there are some key moves that will quickly achieve the goal of writing a matrix in row-echelon form. To obtain a matrix in row-echelon form for finding solutions, we use Gaussian elimination, a method that uses row operations to obtain a 1 as the first entry so that row 1 can be used to convert the remaining rows.

Gaussian Elimination

The Gaussian elimination method refers to a strategy used to obtain the row-echelon form of a matrix. The goal is to write matrix Awith the number 1 as the entry down the main diagonal and have all zeros below. [latex-display]\displaystyle{A}={\left[\matrix{{a}_{{11}}&{a}_{{12}}&{a}_{{13}}\\{a}_{{21}}&{a}_{{22}}&{a}_{{23}}\\{a}_{{31}}&{a}_{{32}}&{a}_{{33}}}\right]{\stackrel{{\text{After Gaussian elimination}}}{\right\arrow}}{A}={\left[\matrix{{1}&{b}_{{12}}&{b}_{{13}}\\{0}&{1}&{b}_{{23}}\\{0}&{0}&{1}}\right][/latex-display] The first step of the Gaussian strategy includes obtaining a 1 as the first entry, so that row 1 may be used to alter the rows below.

How To

Given an augmented matrix, perform row operations to achieve row-echelon form.
  1. The first equation should have a leading coefficient of 1. Interchange rows or multiply by a constant, if necessary.
  2. Use row operations to obtain zeros down the first column below the first entry of 1.
  3. Use row operations to obtain a 1 in row 2, column 2.
  4. Use row operations to obtain zeros down column 2, below the entry of 1.
  5. Use row operations to obtain a 1 in row 3, column 3.
  6. Continue this process for all rows until there is a 1 in every entry down the main diagonal and there are only zeros below.
  7. If any rows contain all zeros, place them at the bottom.

Example 3

  1. Solve the given system by Gaussian elimination.2 x + 3y = 6 x y = [latex]\displaystyle\frac{{1}}{{2}}[/latex]
  2. Solve the given system by Gaussian elimination.4 x + 3y = 11 x − 3y = −1
  3. Use Gaussian elimination to solve the given 2 × 2 system of equations.2 x + y = 14 x + 2y = 6
  4. Solve the system of equations. 3x + 4y = 12 6x + 8y = 24
  5. Perform row operations on the given matrix to obtain row-echelon form. [latex]\displaystyle{\left[\matrix{{1}&-{3}&{4}&{\mid}&{3}\\{2}&-{5}&{6}&{\mid}&{6}\\-{3}&{3}&{4}&{\mid}&{6}}\right]}[/latex]
  6. Write the system of equations in row-echelon form. [latex]\displaystyle{\left[\matrix{{x}-{2}{y}+{3}{z}={9}\\-{x}+{3}{y}=-{4}\\{2}{x}-{5}{y}+{5}{z}={17}}\right][/latex]

Solutions

  1. First, we write this as an augmented matrix. [latex]\displaystyle{\left[\matrix{{2}&{3}&{\mid}&{6}\\{1}&-{1}&{\mid}&\frac{{1}}{{2}}}\right][/latex]We want a 1 in row 1, column 1. This can be accomplished by interchanging row 1 and row 2.[latex]\displaystyle{R}_{{1}}\rightarrow{R}_{{2}}{\left[\matrix{{1}&-{1}&{\mid}&\frac{{1}}{{2}}\\{2}&{3}&{\mid}&{6}}\right][/latex]
  2. We now have a 1 as the first entry in row 1, column 1. Now let's obtain a 0 in row 2, column. This can be accomplished by multiplying row 1 by –2 and then adding the result to row [latex]\displaystyle-{2}{R}_{{1}}+{R}_{{2}}={R}_{{2}}\arrow{\left[\matrix{{1}&{1}&{\mid}&\frac{{1}}{{2}}\\{0}&{5}&{\mid}&{5}}\right][/latex]We only have one more step, to multiply row 2 by [latex]\displaystyle\frac{{1}}{{5}}[/latex]Use back-substitution. The second row of the matrix represents y = 1. Back-substitute y = 1 into the first equation. [latex]\displaystyle{\left[\matrix{{x}-{({1})}=\frac{{1}}{{2}}\\{x}=\frac{{3}}{{2}}}\right][/latex]The solution is the point [latex]\displaystyle{(\frac{{3}}{{2}},{1})}[/latex].
  3. (2,1)
  4. Write the system as an augmented matrix. [latex]\displaystyle{\left[\matrix{{2}&{1}&{\mid}&{1}\\{4}&{2}&{\mid}&{6}}\right][/latex]Obtain a 1 in row 1, column 1. This can be accomplished by multiplying the first row by [latex]\displaystyle\frac{{1}}{{2}}[/latex]Next, we want a 0 in row 2, column 1. Multiply row 1 by –4 and add row 1 to row 2.[latex]\displaystyle-{4}{R}_{{1}}+{R}_{{2}}={R}_{{2}}\rightarrow{\left[\matrix{{1}&\frac{{1}}{{2}}&{\mid}&\frac{{1}}{{2}}\\{0}&{0}&{\mid}&{4}}\right][/latex]The second row represents the equation 0 = 4. Therefore, the system is inconsistent and has no solution.
  5. Perform row operations on the augmented matrix to try and achieve row-echelon form. [latex]\displaystyle{A}={\left[\matrix{{3}&{4}&{\mid}&{12}\\{6}&{8}&{\mid}&{24}}\right][/latex]The matrix ends up with all zeros in the last row: 0 y = 0. Thus, there are an infinite number of solutions and the system is classified as dependent. To find the generic solution, return to one of the original equations and solve for y. [latex]\displaystyle{\left[\matrix{{3}{x}+{4}{y}={12}\\{4}{y}={12}-{3}{x}\\{y}={3}-\frac{{3}}{{4}}{x}}\right][/latex]So the solution to this system is [latex]\displaystyle{({x},{3}-\frac{{3}}{{4}}{x})}[/latex].
  6. The first row already has a 1 in row 1, column 1. The next step is to multiply row 1 by –2 and add it to row 2. Then replace row 2 with the result. [latex]\displaystyle-{2}{R}_{{1}}+{R}_{{2}}={R}_{{2}}\rightarrow{\left[\matrix{{1}&-{3}&{4}&{\mid}&{3}\\{0}&{1}&-{2}&{\mid}&{0}\\-{3}&{3}&{4}&{\mid}&{6}}\right][/latex]Next, obtain a zero in row 3, column 1.[latex]\displaystyle{3}{R}_{{1}}+{R}_{{3}}={R}_{{3}}\rightarrow{\left[\matrix{{1}&-{3}&{4}&{\mid}&{3}\\{0}&{1}&-{2}&{\mid}&{0}\\{0}&-{6}&{16}&{\mid}&{15}}\right][/latex]Next, obtain a zero in row 3, column 2.[latex]\displaystyle{6}{R}_{{2}}+{R}_{{3}}={R}_{{3}}\rightarrow{\left[\matrix{{1}&-{3}&{4}&{\mid}&{3}\\{0}&{1}&-{2}&{\mid}&{0}\\{0}&{0}&{4}&{\mid}&{15}}\right][/latex]The last step is to obtain a 1 in row 3, column 3.[latex]\displaystyle\frac{{1}}{{2}}{R}_{{3}}={R}_{{3}}\rightarrow{\left[\matrix{{1}&-{3}&{4}&{\mid}&{3}\\{0}&{1}&-{2}&{\mid}&-{6}\\{0}&{0}&{1}&{\mid}&\frac{{21}}{{2}}}\right][/latex]
  7. [latex]\displaystyle{\left[\matrix{{1}&-\frac{{5}}{{2}}&\frac{{5}}{{2}}&{\mid}&\frac{{17}}{{2}}\\{0}&{1}&{5}&{\mid}&{9}\\{0}&{0}&{1}&{\mid}&{2}}\right][/latex]

Solving a System of Linear Equations Using Matrices

We have seen how to write a system of equations with an augmented matrix, and then how to use row operations and back-substitution to obtain row-echelon form. Now, we will take row-echelon form a step farther to solve a 3 by 3 system of linear equations. The general idea is to eliminate all but one variable using row operations and then back-substitute to solve for the other variables.

Example 4

  1. Solve the system of linear equations using matrices. x y + z = 8 2x + 3y z = −2 3x 2y 9z = 9
  2. Solve the following system of linear equations using matrices. x − 2y + z = −1 2x + 3y = 2 y − 2z = 0
  3. Solve the system using matrices. x + 4y z = 4 2x + 5y + 8z = 15 x + 3y − 3z = 1

Solutions

  1. First, we write the augmented matrix. [latex]\displaystyle{\left[\matrix{{1}&-{1}&{1}&{\mid}&{8}\\{2}&{3}&-{1}&{\mid}&-{2}\\{3}&-{2}&-{9}&{\mid}&{9}}\right][/latex]Next, we perform row operations to obtain row-echelon form.[latex]\displaystyle-{2}{R}_{{1}}+{R}_{{2}}={R}_{{2}}\rightarrow{\left[\matrix{{1}&-{1}&{1}&{\mid}&{8}\\{0}&{5}&-{3}&{\mid}&-{18}\\{3}&-{2}&-{9}&{\mid}&{9}}\right][/latex]The easiest way to obtain a 1 in row 2 of column 1 is to interchange R2 and R3. [latex]\displaystyle{R}_{{2}}\rightarrow{R}_{{3}}\rightarrow{\left[\matrix{{1}&-{1}&{1}&{\mid}&{8}\\{0}&{1}&-{12}&{\mid}&-{15}\\{0}&{5}&-{3}&{\mid}&-{18}}\right][/latex]The last matrix represents the equivalent system.[latex]\displaystyle{\left[\matrix{{x}-{y}+{z}={8}\\{y}-{12}{z}=-{15}\\{z}={1}}\right][/latex]Using back-substitution, we obtain the solution as [latex]\displaystyle{({4},-{3},{1})}[/latex].
  2. Write the augmented matrix, [latex]\displaystyle\left[\matrix{-{1}&-{2}&{1}&{\mid}&-{1}\\{2}&{3}&{0}&{\mid}&{2}\\{0}&{1}&-{2}&{\mid}&{0}}\right][/latex]First, multiply row 1 by –1 to get a 1 in row 1, column 1. Then, perform row operations to obtain row-echelon form. [latex]\displaystyle-{R}_{{1}}\rightarrow{\left[\matrix{{1}&{2}&-{1}&{\mid}&{1}\\{2}&{3}&{0}&{\mid}&{2}\\{0}&{1}&-{2}&{\mid}&{0}}\right][/latex]The last matrix represents the following system.

x + 2yz = 1 y − 2z = 0 0 = 0

We see by the identity 0 = 0, that this is a dependent system with an infinite number of solutions. We then find the generic solution. By solving the second equation for y and substituting it into the first equation we can solve for z in terms of x.

[latex]\displaystyle{{x}+{2}{y}-{z}={1}, {y}={2}{z}\\{x}+{2}{\left({2}{z}\right)}-{z}={1}}\\{{x}+{3}{z}={1}}\\{3z}={1}-{x}\\{z}=\frac{{{1}-{x}}}{{3}}[/latex]

Now we substitute the expression for z into the second equation to solve for y in terms of x.

[latex-display]\displaystyle{{y}-{2}{z}={0}, {z}=\frac{{{1}-{x}}}{{3}}\\{y}-{2}{\left(\frac{{{1}-{x}}}{{3}}\right)}={0}\\{y}=\frac{{{2}-{2}{x}}}{{3}} ={0}[/latex-display] The generic solution is [latex]\displaystyle{({x},\frac{{{2}-{2}{x}}}{{3}},\frac{{{1}-{x}}}{{3}})}[/latex].

3.  (1,1,1)


Q&A

Can any system of linear equations be solved by Gaussian elimination? Yes, a system of linear equations of any size can be solved by Gaussian elimination.

How To

Given a system of equations, solve with matrices using a calculator.
  1. Save the augmented matrix as a matrix variable [A], [B], [C], . . .
  2. Use the ref( function in the calculator, calling up each matrix variable as needed.

Example 5

  1. Solve the system of equations.5 x + 3y + 9z = −1−2 x + 3yz = −2x − 4y + 5z = 1
  2. Carolyn invests a total of $12,000 in two municipal bonds, one paying 10.5% interest and the other paying 12% interest. The annual interest earned on the two investments last year was $1,335. How much was invested at each rate?
  3. Ava invests a total of $10,000 in three accounts, one paying 5% interest, another paying 8% interest, and the third paying 9% interest. The annual interest earned on the three investments last year was $770. The amount invested at 9% was twice the amount invested at 5%. How much was invested at each rate?
  4. A small shoe company took out a loan of $1,500,000 to expand their inventory. Part of the money was borrowed at 7%, part was borrowed at 8%, and part was borrowed at 10%. The amount borrowed at 10% was four times the amount borrowed at 7%, and the annual interest on all three loans was $130,500. Use matrices to find the amount borrowed at each rate.

Solutions

  1. Write the augmented matrix for the system of equations. [latex]\displaystyle{\left[\matrix{{5}&{3}&{9}&{\mid}&-{1}\\-{2}&{3}&-{1}&{\mid}&-{2}\\-{1}&-{4}&{5}&{\mid}&-{1}}\right][/latex]On the matrix page of the calculator, enter the augmented matrix above as the matrix variable [A] [latex]\displaystyle{[{A}]}={\left[\matrix{{5}&{3}&{9}&{\mid}&-{1}\\-{2}&{3}&-{1}&{\mid}&-{2}\\-{1}&-{4}&{5}&{\mid}&-{1}}\right][/latex] Use the ref( function in the calculator, calling up the matrix variable ) Evaluate. [latex]\displaystyle{\left[\matrix{{1}&\frac{{3}}{{5}}&\frac{{9}}{{5}}&{\mid}&-\frac{{1}}{{5}}\\{0}&{1}&\frac{{13}}{{21}}&{\mid}&-\frac{{4}}{{7}}\\{0}&{0}&{1}&{\mid}&-\frac{{24}}{{187}}}\right]\rightarrow{\left[\matrix{{x}+\frac{{3}}{{5}}{y}+\frac{{9}}{{5}}{z}=-\frac{{1}}{{5}}\\{y}+\frac{{13}}{{21}}{z}=-\frac{{4}}{{7}}\\{z}=-\frac{{24}}{{187}}}\right][/latex]Using back-substitution, the solution is [latex]\displaystyle{(\frac{{61}}{{187}},-\frac{{92}}{{187}},-\frac{{24}}{{187}})}[/latex].
  2. We have a system of two equations in two variables. Let x = the amount invested at 10.5% interest, and y = the amount invested at 12% interest. [latex]\displaystyle{\left[\matrix{{x}+{y}={12000}\\{0.105}{x}+{0.12}{y}={1335}}\right][/latex]As a matrix, we have[latex]\displaystyle{\left[\matrix{{1}&{1}&{\mid}&{12000}\\{0.015}&{0.12}&{\mid}&{1335}}\right][/latex]Multiply row 1 by –0.015 and add the result to row 2.[latex]\displaystyle{\left[\matrix{{1}&{1}&{\mid}&{12000}\\{0}&{0.015}&{\mid}&{75}}\right][/latex]Then,0.015 y = 75 y = 5,000So 12000 – 5000=7000.Thus, $5,000 was invested at 12% interest and $7,000 at 10.5% interest.
  3. We have a system of three equations in three variables. Let x be the amount invested at 5% interest, let y be the amount invested at 8% interest, and let z be the amount invested at 9% interest. Thus, x + y + z = 10,000 0.05x + 0.08y + 0.09z = 770 2x z = 0 As a matrix, we have [latex]\displaystyle{\left[\matrix{{1}&{1}&{1}&{\mid}&{10000}\\{0.05}&{0.08}&{0.09}&{\mid}&{770}\\{2}&{0}&-{1}&{\mid}&{0}}\right][/latex]Now, we perform Gaussian elimination to achieve row-echelon form.[latex]\displaystyle-{0.05}{R}_{{1}}+{R}_{{2}}={R}_{{2}}\arrow{\left[\matrix{{1}&{1}&{1}&{\mid}&{10000}\\{0}&{0.03}&{0.04}&{\mid}&{270}\\{2}&{0}&-{1}&{\mid}&{0}}\right][/latex].  The third row tells us [latex]\displaystyle-\frac{{1}}{{3}}{z}=-{2000}[/latex]; thus, z = 6000. The second row tells us [latex]\displaystyle{y}+\frac{{4}}{{3}}{z}={9000}[/latex]. Substituting z = 6000, we get[latex]\displaystyle{\left[\matrix{{y}+\frac{{4}}{{3}}{({6000})}={9000}\\{y}+{8000}={9000}\\{y}={1000}}}\right][/latex]The first row tells us x + y + z = 10000. Substituting y = 1000 and z = 6000, we get x + 1,000 + 6,000 = 10,000; x = 3,000. The answer is $3,000 invested at 5% interest, $1,000 invested at 8%, and $6,000 invested at 9% interest.
  4. $150,000 at 7%, $750,000 at 8%, $600,000 at 10%

Media

Access these online resources for additional instruction and practice with solving systems of linear equations using Gaussian elimination.  

Key Concepts

  • An augmented matrix is one that contains the coefficients and constants of a system of equations.
  • A matrix augmented with the constant column can be represented as the original system of equations.
  • Row operations include multiplying a row by a constant, adding one row to another row, and interchanging rows.
  • We can use Gaussian elimination to solve a system of equations.
  • Row operations are performed on matrices to obtain row-echelon form.
  • To solve a system of equations, write it in augmented matrix form. Perform row operations to obtain row-echelon form. Back-substitute to find the solutions.
  • A calculator can be used to solve systems of equations using matrices.
  • Many real-world problems can be solved using augmented matrices.

OpenStax, Precalculus, "Solving Systems with Gaussian Elimination," licensed under a CC BY 3.0 license. Mathispower4u, " Ex 2: Solve a System of Two Equations with Using an Augmented Matrix (Row Echelon Form)," licensed under a Standard YouTube license. Mathispower4u, "Ex 2: Solve a System of Three Equations with Using an Augmented Matrix (Row Echelon Form)," licensed under a Standard YouTube license. Mathispower4u, " Augmented Matrices on the TI83/84," licensed under a Standard YouTube license.