Skip to main content
Mathematics LibreTexts

3.5 Solving Systems of Linear Equations

  • Page ID
    153026
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\dsum}{\displaystyle\sum\limits} \)

    \( \newcommand{\dint}{\displaystyle\int\limits} \)

    \( \newcommand{\dlim}{\displaystyle\lim\limits} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \(\newcommand{\longvect}{\overrightarrow}\)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)
    Learning Objectives

    By the end of this section, you will:

    • know the definition of a system of linear equations and how they relate to intersections of lines
    • be able to solve \(2 \times 2\) systems of linear equations with the substitution and elimination methods
    • be able to solve \(3 \times 3 \) systems of linear equations with the elimination method

    The other day, I was exploring an ancient tomb on a trip to Egypt. As I came around a corner, a wall of stone suddenly slid into place behind me, and I was confronted by an enchanted sphinx angry at the invasion of its privacy (fair). It showed me a flat plank balanced on a fulcrum point, and three lumps of solid gold. "This first lump is exactly 2kg," it intoned. "If you can determine the weights of the other two lumps, I will release you—and what's more, you can keep the gold." Obviously, I figured it out and survived to write this textbook. How did I do it?

    I gingerly placed the blocks on the plank such that they perfectly balanced each other, and noted the distances from the fulcrum. Then I did it again in a different configuration.

    balance 2.png

    balance 1.png

    I nicknamed the weights of the unknown blocks with the variables \(A\) and \(B\). I know that in order to be perfectly balanced, the sum of the moments (turning effect of the weight of each block on a lever, aka the weight of the block multiplied by the distance from the fulcrum) must balance out on either side of the plank. This fact gave me two equations that must be true:

    \[ \begin{cases}40B + 20(2) = 40A \\ 10A + 20B = 50(2) \end{cases} \notag \]

    All I had to do is figure out how to find values for \(A\) and \(B\) that would satisfy both equations simultaneously. This is called a system of two linear equations in two unknowns (\(2\times 2\)), because in each equation the variables only appear to the first power. How did I do this? First, I organized my terms, rewriting the system as

    \[ \begin{cases}40A - 40B = 40 \\ 10A + 20B = 100 \end{cases} \notag \]

    Then I noticed that every term in the first equation has a factor of \( 40\) in common, so I divided both sides by \(40\) just to clean things up. I also divided the second equation by \(10\). At this point, I had two choices. The first is called substitution, and the second is called elimination. Both are equally easy in this particular example, so let me show you.

    Example \(\PageIndex{1}\)

    Solve the system of equations \( \begin{cases}A - B = 1 \\ A + 2B = 10 \end{cases} \) two ways.

    Solution

    Substitution Method: This method takes advantage of the fact that the top equation can easily be solved for one of the variables; I choose \(A\). Algebra results in \(A = B+1\). Now if \(A\) is equal to \(B+1\), I can substitute \((B+1)\) wherever \(A\) appears in the second equation without changing anything, technically. This gives me an equation with only one unknown, easily solved!

    \[ \textcolor{red}{A} + 2B = 10 \quad \longrightarrow \quad \textcolor{red}{(B+1)} + 2B = 10 \quad \longrightarrow \quad \cdots \quad \longrightarrow \quad B = 3 \notag \]

    So gold lump \(B\) is 3kg! To figure out \(A\), I just sub that value in for \(B\) in either original equation. The first one is easy.

    \[ A - 3 = 1 \quad \longrightarrow \quad A = 4 \notag \]

    Elimination Method: This method will always work, even if equations are too ugly to solve nicely for one variable. The idea is that if two things are equal, \(X = Y\), and two other things are also equal, \(W = Z\), then adding the equations will give another true equation, \(X + W = Y + Z\). To make this fact useful, I first multiply through one equation by whatever factor is needed to make the \(A\) or \(B\) terms match, but have opposite signs. For example, multiplying through the first equation by \(2\) gives me

    \[ \begin{cases}2 \cdot (A - B) = 1 \cdot 2 \\ A + 2B = 10 \end{cases} \quad \longrightarrow \quad \begin{cases}2A \textcolor{red}{ - 2B} = 2 \\ A \textcolor{red}{+ 2B} = 10 \end{cases} \notag \]

    To add the equations, all you have to do is make sure all the \(A\) and \(B\) and constant terms are lined up vertically, and then add down each "column." I get

    \[ \begin{cases}2A \textcolor{red}{ - 2B} = \textcolor{green}{2} \\ A \textcolor{red}{+ 2B} = \textcolor{green}{10} \end{cases} \quad \overset{\text{add}}{\longrightarrow} \quad 3A \textcolor{red}{+0B} = \textcolor{green}{12} \notag \]

    The \(0B\) is of course nothing, I'm just trying to show you what happened there. Now I have a single equation with one unknown, \(3A = 12\), which solves to get \(A = 4\)kg. To find \(B\), just plug into an original equation again, say, \(4 - B = 1 \), telling me that \(B = 3\)kg. Confirmed!

    It seems many students default to the substitution method, but I myself have always prefered the elimination method because it's more useful when systems get more complicated, and like Post Malone, when I started ballin' I was young. You can pick what you like, and I won't judge, but you do have to get the right answer in the end... Let's hit a quick formal definition and summarize.

    \( 2 \times 2 \) Linear Systems

    Systems of Equations
    • A system of equations is a set of equations that have the exact same variables, for which a solution is a set of values chosen for each variable that will satisfy all of the equations simultaneously.
    • A linear equation is an equation in which all variables appear only to the first power, such as \(ax + by = c\) or \(ax + by + cz = d\), where \(a,b,c,d\) are constant coefficients. In general and formally, a linear equation in \(n\) variables can be written in the form
      \[ a_1 x_1 + a_2 x_2 + ... + a_n x_n = c, \notag \]
      where \(a_1, a_2, ..., a_n\) are constant coefficients and \(x_1, x_2, ..., x_n\) are different variables.
    • A system of linear equations is, shocker, a system in which all the equations are linear equations.

    To solve a system of two linear equations in two unknowns, you can use...

    • Substitution: Solve one equation for a particular variable, then sub in for that variable in the second equation, yielding an equation with one unknown, and solve that. Then plug that result into an original equation to find the second unknown.
    • Elimination: Multiply one or both equations by whatever is needed such that, for a particular variable, the equation's terms have opposite coefficients. Then line up all the variable terms and constant terms in columns correctly and add down the columns, yielding an equation with one unknown, and solve that. Then plug the result into an original equation to get the other unknown.
    Exercise \(\PageIndex{1}\)

    Solve the linear systems using both methods.

    1. \( \begin{cases}5A - B = 10 \\ 10A + B = 20 \end{cases} \)

    2. \( \begin{cases}A + B = 6 \\ 2A -4B = 24 \end{cases} \)

    3. \( \begin{cases}2A + 3B = 4 \\ 3A + 2B = -4 \end{cases} \)

    Answer
    1. \(A = 2, B = 0\)
    2. \(A = 8, B = -2\)
    3. \( A = -4, B = 4\) (Hint: multiply the first equation by \(3\) and the second equation by \(-2\) and use elimination.)

    Okay now, remember in last section how, given two equations of lines, we wanted to find their intersection point? It all came down to finding values for \(x\) and \(y\) that would satisfy both equations. Aha! You already solved a \(2 \times 2\) system of equations without knowing. Which method did we use? Technically it was substitution, because by setting the right hand sides equal to each other, we were subbing in one expression for \(y\) into the other equation.

    \[ \begin{cases} \textcolor{red}{y = 2x + 1} \\ y = 3x - 4 \end{cases} \quad \longrightarrow \quad \textcolor{red}{2x+1} = 3x - 4 \notag \]

    You can always think of a \( 2\times 2\) linear system as a question of two lines intersecting or not (it literally has LINE in the name). Thus there are three options for the outcome of solving a \( 2\times 2\):

    intersections.png

    A system of two linear equations in two unknowns can have:

    • one unique solution (the equations' lines intersect once)
    • no solutions (the equations' lines are parallel and never intersect; in this case the system is called inconsistent)
    • infinitely many solutions (the equations' lines are smack on top of each other, the same line really, and have all points in common)

    We've seen the first case, but what will it look like in practice when the other two cases appear? Investigate the systems below.

    Exercise \(\PageIndex{2}\)

    1.\( \begin{cases} x + y = 3 \\ 3x + 3y = 9 \end{cases} \)

    2. \( \begin{cases} 2x + 3y = 4 \\ -4x -6y = -7 \end{cases} \)

    Answer

    1. Say you start trying to do substitution, so you solve the first equation for \(y\), \(y = -x + 3\), and sub into the second equation. You get

    \[ 3x + 3(-x+3) = 9 \quad \longrightarrow \quad 3x - 3x + 9 = 9 \quad \longrightarrow \quad 9 = 9 \notag \]

    Well, uh, that's certainly a fact, but I didn't get any information about \(x\)??? Now what? Look back at the equations...did you notice that the second one is just a constant multiple of the first one? I can make the equations match if I multiply the first one by \(3\). Both equations describe the same line. I have infinitely many solutions to this system.

    2. I don't love substitution for this one because I'll have fractions, so let's try elimination. If I am trying to make the \(x\) terms matching opposites, I could multiply the first equation through by 2, to get

    \[ \begin{cases} 4x + 6y = 8 \\ -4x -6y = -7 \end{cases} \notag \]

    But now when I go to add down the columns, both the \(x\)'s and the \(y\)'s kill each other off! I end up with the statement \( 0 = 1 \), which in this universe is NOT TRUE. There is NO solution to this system.

    So that's what those look like. Let's ramp it up.

    \( 3 \times 3\) Linear Systems

    There's no reason you can only solve systems with two equations and two unknowns. As long as I have enough equations giving me enough information, I can solve systems involving as many unknowns as I want!

    Example \(\PageIndex{2}\)

    In addition to running De Wolf's De Washing Machines manufacturing company, I also sell illegal exotic ant farms on the black market. I'm smuggling in three new varieties of ant: East African siafu army ants, Costa Rican Ecitons, and Brazilian leaf-cutters. All in all I should acquire 12 colonies, and I have $600 to spend on this restock. Army ants cost $60 per colony, Ecitons cost $40, and leaf-cutters cost $50. I definitely want to have twice as many leaf-cutters as army ants, because they're fun to watch. Denoting the number of each type of colony as \(A, E,\) and \(L\), respectively, write a system of equations using all of these requirements.

    Solution

    If I want 12 new colonies in all, the total of \(A, E, \) and \(L\) should be 12. This gives me one equation, \(A + E + L = 12\). If I have $600 to spend, I use the individual cost information to set up another equation about the money involved,

    \[ 60A + 40E + 50L = 600 \notag \]

    Finally, if I want twice as many leaf-cutters as army ants, I want \(L\) to be \(2 \cdot A\), giving the equation \(L = 2A\). This is now a system of three equations with three unknowns. I write them together with a brace, organizing each equation so the variables are in the same order. Since there is no \( E\) term in the third equation, I put in a placeholder \(0E\).

    \[ \begin{cases} A + E + L = 12 \\ 60A + 40E + 50L = 600 \\ 2A + 0E - L = 0\end{cases} \notag \]

    Solving a \(3 \times 3\) comes down to reducing it to a \(2 \times 2\) system, solving that, and then going back for the third variable. You can use a variety of strategies to achieve this. Since this one has an equation that already contains only two variables, substitution is a great idea.

    Example \(\PageIndex{3}\)

    Solve the system \( \begin{cases} A + E + L = 12 \\ 60A + 40E + 50L = 600 \\ 2A + 0E - L = 0\end{cases} \)

    Solution

    Using the third equation, \(L = 2A\), we sub \(2A\) for \(L\) in the other two equations and simplify everything we can. This will result in a nice \(2 \times 2\) system.

    \[ \begin{cases} A + E + 2A = 12 \\ 60A + 40E + 50(2A) = 600 \end{cases} \quad \longrightarrow\quad \begin{cases} 3A + E = 12 \\ 16A + 4E = 60 \end{cases} \notag \]

    Solve this smaller system with whatever method you prefer, to find \(A = 3\) and \(E = 3\). Then plug \(3\) in for \(A\) in the third equation to get \(L = 2A = 6\). I should order 3 colonies of army ants, 3 of Ecitons, and 6 of leaf-cutters.

    If you don't have that nice freebie of one equation only having two variables in it, you have to make it from scratch. Use elimination on two of the equations to do this.

    Example \(\PageIndex{4}\)

    Solve the system \( \begin{cases} 3x+y-z = 1 \\ 2x+y+z = 4 \\ -x-y+2z = 0 \end{cases} \).

    Solution

    I notice that the first equation has a \(y\) term while the third equation has a \(-y\) term. Extracting those two, I add them to eliminate the \(y\) terms.

    \[ \begin{cases} 3x+y-z = 1 \\ -x-y+2z = 0 \end{cases} \quad \overset{\text{add}}{\longrightarrow} \quad 2x +z = 1 \notag \]

    I can now solve that equation for \(z = 1-2x\) and substitute it into two equations from the system. I must be sure to use the middle equation that I had ignored so far, but other than that I choose the first one.

    \[ \begin{cases} 3x+y-\textcolor{red}{(1-2x)} = 1 \\ 2x+y+\textcolor{red}{(1-2x)} = 4 \end{cases} \quad \longrightarrow \quad \begin{cases} 5x + y = 2 \\ y = 3 \end{cases} \notag \]

    Ope, in that second one it actually turned out to simplify all the way to part of the answer! We now know \(y = 3\). (If this doesn't happen, just solve the \(2\times 2\) like usual.) Now, I can plug that in to find \(x\):

    \[ 5x + 3 = 2 \quad \longrightarrow \quad x = -\frac{1}{5} \notag \]

    and plug THAT into \(z = 1-2x\) to find \(z\):

    \[ z = 1-2\left( -\frac{1}{5} \right) = \frac{7}{5} \]

    The solution to the system is \(x = -\frac{1}{5}, y = 3, z = \frac{7}{5} \).

    You might be wondering, is there a way to see these systems as questions about intersections? Yes, but when there are three variables involved, we're living in 3D space rather than on the 2D coordinate plane. Linear equations like the above in \(x, y,\) and \(z\) are the equations of flat planes through 3D space. This is what the equations from the last system look like in space:

    planes.png

    The solution we found is the point in 3D space that I marked with the bright orange ball there--the point where all three planes intersect simultaneously! Here is a picture of a no-solutions situation: two of the planes are parallel, so there is no place where all three planes intersect at once.

    no solutions.png

    And here is a picture of an infinitely-many-solutions situation: the planes all intersect each other on a single line that goes on forever, so that's infinitely many points that they have in common.

    inf solutions.png

    Now you try!

    Exercise \(\PageIndex{3}\)

    Solve the systems, or state if a system has no solutions:

    1. \( \begin{cases} x+2y + z = 3 \\ y - z = -4 \\-x - 2y +3z = 9 \end{cases} \)

    2. \( \begin{cases}x+y +z = 4\\ x + 3y + 3z = 10 \\ 2x + y - z = 3 \end{cases} \)

    3. \( \begin{cases} x+y-z = 1 \\ 2x+2y-2z = 3 \\ 2z = 2 \end{cases} \)

    Answer
    1. \(x = 2, y = -1, z = 3\)
    2. \( x = 1, y = 2, z = 1\)
    3. No solution.

    This page titled 3.5 Solving Systems of Linear Equations is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Lydia de Wolf.

    • Was this article helpful?