If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Solving systems of linear equations | Lesson

What are systems of linear equations, and how frequently do they appear on the test?

A system of linear equations is usually a set of two linear equations with two variables.
  • x, plus, y, equals, 5 and 2, x, minus, y, equals, 1 are both linear equations with two variables.
  • When considered together, they form a system of linear equations.
A linear equation with two variables has an infinite number of solutions (for example, consider how left parenthesis, 0, comma, 5, right parenthesis, left parenthesis, 1, comma, 4, right parenthesis, left parenthesis, 2, comma, 3, right parenthesis, etc. are all solutions to the equation x, plus, y, equals, 5). However, systems of two linear equations with two variables can have a single solution that satisfies both solutions.
  • left parenthesis, 2, comma, 3, right parenthesis is the only solution to both x, plus, y, equals, 5 and 2, x, minus, y, equals, 1.
In this lesson, we'll:
  1. Look at two ways to solve systems of linear equations algebraically: substitution and elimination.
  2. Look at systems of linear equations graphically to help us understand when systems of linear equations have one solution, no solutions, or infinitely many solutions.
  3. Explore algebraic methods of identifying the number of solutions that exist for systems with two linear equations.
On your official SAT, you'll likely see 1 to 3 questions that test your ability to solve systems of linear equations—more if you also include systems of linear equations word problems, which are covered in their own lessons.
You can learn anything. Let's do this!

How do I solve systems of linear equations by substitution?

Systems of equations with substitution

Khan Academy video wrapper
Systems of equations with substitution: 2y=x+7 & x=y-4See video transcript

How does substitution work?

Our goal when solving a system of equations is to reduce two equations with two variables down to a single equation with one variable. Since each equation in the system has two variables, one way to reduce the number of variables in an equation is to substitute an expression for a variable.
Consider the following example:
x=2yx+y=3\begin{aligned} x &= 2y \\\\ x+y&=3 \end{aligned}
In a system of equations, both equations are simultaneously true. In other words, since the first equation tells us that x is equal to 2, y, the x in the second equation is also equal to 2, y. Therefore, we can plug in 2, y as a substitute for x in the second equation:
x+y=3(2y)+y=33y=3\begin{aligned} x+y &= 3\\\\ (2y)+y &= 3 \\\\ 3y &= 3 \end{aligned}
From here, we can solve the equation 3, y, equals, 3, then use the value of y to calculate x.
To solve a system of equations using substitution:
  1. Isolate one of the two variables in one of the equations.
  2. Substitute the expression that is equal to the isolated variable from Step 1 into the other equation. This should result in a linear equation with only one variable.
  3. Solve the linear equation for the remaining variable.
  4. Use the solution of Step 3 to calculate the value of the other variable in the system by using one of the original equations.

Let's look at some more examples!

y=3x14x+y=8\begin{aligned} y &= 3x-1 \\\\ 4x +y &= -8 \end{aligned}
What is the solution left parenthesis, x, comma, y, right parenthesis to the system of equations above?

x2y=27x3y=19\begin{aligned} x-2y &= -2 \\\\ 7x -3y &= 19 \end{aligned}
What is the solution left parenthesis, x, comma, y, right parenthesis to the system of equations above?

Try it!

TRY: Follow the steps for substitution
y=2x4x+y=2\begin{aligned} y &=2-x \\\\ 4x+y &=2 \end{aligned}
In the system of equations above, the first equation tells us that y is equal to 2, minus, x. This means we can replace the y in the second equation with
to reduce the equation to a linear equation with a single variable.
Next, we can solve the equation 3, x, plus, 2, equals, 2 for x. The value of x is
.
Finally, since y, equals, 2, minus, x, we can substitute the value of x into the equation to calculate y. The value of y is
.


How do I solve systems of linear equations by elimination?

System of equations with elimination

Khan Academy video wrapper
Systems of equations with elimination: x+2y=6 & 4x-2y=14See video transcript

How does elimination work?

Our goal when solving a system of equations is to reduce two equations with two variables down to a single equation with one variable. Since each equation in the system has two variables, one way to reduce the number of variables is to add or subtract the two equations in the system to cancel out, or eliminate, one of the variables.
Consider the following system of equations:
3xy=72x+y=8\begin{aligned} 3x-y &= 7 \\\\ 2x+y&=8 \end{aligned}
Recall that when we're solving equations, we can perform the same operations to both sides of the equation and maintain the equality. Since the second equation tells us that 2, x, plus, y is equal to 8, we can add 2, x, plus, y to the left side of the first equation, add 8 to the right side of the first equation, and maintain the equality:
3xy=7+ 2x+y=85x+0=15\begin{aligned} 3x\purpleD{-y} &= 7 \\ {+}~2x\purpleD{+y}&=8\\ \hline\\ 5x+0 &=15 \end{aligned}
Notice that the y-terms cancel out and are eliminated as a result of adding the two equations. When solving systems of equations using elimination, we're always looking for opportunities to cancel out terms.
  • If two terms have the opposite coefficients like in the system above (minus, y and y), we can add the two equations to cancel the terms.
  • If two terms have the same coefficients, we can subtract the two equations to cancel the terms.
From here, we can solve the equation 5, x, equals, 15, then use the value of x to calculate y.
Sometimes, the system of equations does not have coefficients that readily cancel out. Consider this example:
3xy=7x+2y=21\begin{aligned} 3x-y &= 7 \\\\ x+2y&=21 \end{aligned}
In this case, we need to find ways to match a pair of coefficients by rewriting one of the equations. There are two ways to do this.
Option 1: We can set the system up for eliminating the y-terms through addition by multiplying both sides of the first equation by 2.
(3xy)2=726x2y=14\begin{aligned} (3x-y)\purpleD{\cdot2} &= 7\purpleD{\cdot2} \\\\ 6x-2y &= 14 \end{aligned}
From here, we can add the second equation to eliminate the y-terms:
6x2y=14+  x+2y=217x+0=35\begin{aligned} 6x\purpleD{-2y} &= 14 \\ {+}~~x\purpleD{+2y}&=21\\ \hline\\ 7x+0 &=35 \end{aligned}
Option 2: We can also set the system up for eliminating the x-terms through subtraction by multiplying both sides of the second equation by 3.
(x+2y)3=2133x+6y=63\begin{aligned} (x+2y)\purpleD{\cdot3} &= 21\purpleD{\cdot3} \\\\ 3x+6y &= 63 \end{aligned}
From here, we can subtract the equation from the first equation to eliminate the x-terms:
3x  y=73x+6y=6307y=56\begin{aligned} 3x\purpleD{-~~y} &= 7 \\ {-}3x\purpleD{+6y}&=63\\ \hline\\ 0-7y &=-56 \end{aligned}
To solve a system of equations using elimination:
  1. Identify a pair of terms in the system that have both the same variable and coefficients with the same magnitude (ex: 2, x and 2, x, or 3, y and minus, 3, y). If necessary, rewrite one or both equations so that a pair of terms have both the same variable and coefficients with the same magnitude.
  2. Add or subtract the two equations in the system to eliminate the terms identified in Step 1. This should result in a linear equation with only one variable.
  3. Solve the linear equation to obtain a value for the variable.
  4. Now that you have figured out the value of one variable, plug that value into either equation to find the value of the other variable.

Let's look at some more examples!

3x+2y=102x2y=5\begin{aligned} 3x+2y&= 10 \\\\ 2x -2y &= 5 \end{aligned}
What is the solution left parenthesis, x, comma, y, right parenthesis to the system of equations above?

3x+2y=104xy=6\begin{aligned} 3x+2y &= 10 \\\\ 4x -y &= 6 \end{aligned}
What is the solution left parenthesis, x, comma, y, right parenthesis to the system of equations above?

Try it!

TRY: spot the mistake for elimination
5x+3y=343x+3y=30\begin{aligned} 5x+3y &= 34 \\\\ 3x+3y &=30 \end{aligned}
The solution steps to the system of equations above are shown in order below. Select the earliest mistake in the solution steps, if any.
Choose 1 answer:


When do I use substitution, and when do I use elimination?

It's up to you!

All systems of linear equations can be solved with either substitution or elimination. On test day, you should use whichever method you're more comfortable with.
Substitution is sometimes easier when:
  • A variable is already isolated: start color #7854ab, x, end color #7854ab, equals, 4, y, plus, 1
  • You can isolate a variable in a single step: minus, 3, x, start color #7854ab, plus, y, end color #7854ab, equals, 7
Elimination is sometimes easier when:
  • Both equations contain an identical term: start color #7854ab, 2, x, end color #7854ab, plus, 3, y, equals, 11 and start color #7854ab, 2, x, end color #7854ab, plus, 7, y, equals, 23
  • The equations contain opposite terms: 2, x, start color #7854ab, plus, 2, y, end color #7854ab, equals, 7 and 5, x, start color #7854ab, minus, 2, y, end color #7854ab, equals, 14
  • An equation contains a term that is an integer multiple of a term in the other equation: 3, x, start color #7854ab, plus, 4, y, end color #7854ab, equals, 26 and 5, x, start color #ca337c, plus, 2, y, end color #ca337c, equals, 20.

Try it!

TRY: Identify multiple ways to solve a system of equations
7x+y=203x=y\begin{aligned} 7x+y &= 20 \\\\ 3x &= y \end{aligned}
Consider the system of equations above. Which of the following can be used to solve the system of equations, and how?
Choose 2 answers:


TRY: Identify multiple ways to solve a system of equations
3x+5y=172x10y=38\begin{aligned} 3x+5y &= 17 \\\\ 2x -10y &= 38 \end{aligned}
Consider the system of equations above. Which of the following can be used to solve the system of equations, and how?
Choose 2 answers:


Self-reflection

Even though we can solve the systems of equations above using either substitution or elimination, ask yourself these questions:
  • For each system, which solution method came to mind first?
  • How comfortable am I with isolating variables?
  • How comfortable am I with multiplying both sides of an equation by a constant?
  • How comfortable am I with adding and subtracting two linear equations?
  • How comfortable am I with making more complex substitutions, e.g., substituting for 5, y instead of y?
  • How comfortable am I with finding least common multiples and using them to set up eliminations?
Your answers to these questions should inform which method you use.

What is the relationship between lines and the number of solutions to systems of linear equations?

Linear systems by graphing

Khan Academy video wrapper
Number of solutions to a system of equationsSee video transcript

Intersections and number of solutions

A linear equation can be represented by a line in the x, y-plane. The solution to a system of linear equations is the point at which the lines representing the linear equations intersect.
Two lines in the x, y-plane can intersect once, never intersect, or completely overlap. Each of these scenarios corresponds to a different number of solutions to the system of equations the two lines represent.
  • If the two lines have two different slopes, then they will intersect once. Therefore, the system of equations has exactly one solution.
  • If the two lines have the same slope but different y-intercepts, then they are parallel lines, and they will never intersect. Therefore, we can say that the system of equations has no solutions.
  • If the two lines have the same slope and the same y-intercept, then they will completely overlap—they are the same line!. When this is the case, we say that the system has infinitely many solutions.

Try it!

TRY: Determine the number of solutions from a graph
The two lines in the x, y-plane above represent a system of linear equations. Because the two lines have
, they
, and the system they represent has
.


How do I determine the number of solutions for systems of linear equations?

How to determine the number of solutions to a system of equations algebraically

Khan Academy video wrapper
Number of solutions to a system of equations algebraicallySee video transcript

How do I identify the number of solutions?

In the previous section, we covered the graphical method of determining the number of solutions to a system of linear equations. However, when we don't have the aid of a graph, we can determine the number of solutions algebraically.
One way to do it is to rewrite both equations in slope-intercept form, y, equals, m, x, plus, b. This allows us to compare the slopes of the lines, m, and their y-intercepts, b, to determine the number of solutions.
  • If the two equations have different m-values, then the system has one solution.
  • If the two equations have the same m-value but different b-values, then the system has no solution.
  • If the two equations have both the same m-value and the same b-value, then the system has infinitely many solutions.
To determine the number of solutions a system of linear equations has using slope-intercept form, y, equals, m, x, plus, b:
  1. Rewrite both equations in slope-intercept form.
  2. Compare the m- and b-values of the equations to determine the number of solutions.

Let's look at an example!

13y=x+2y=3x+6\begin{aligned} \dfrac{1}{3}y &= x +2\\\\ y &=3x+6 \end{aligned}
How many solutions does the system of equations above have?

Try it!

TRY: Identify the number of solutions in slope-intercept form
y=3x1y=3x1\begin{aligned} y &= 3x-1 \\\\ y &=-3x-1 \end{aligned}
In the system of equations above, the two equations have
and
. Therefore, the system has
.


Your turn!

Practice: Solve a system of linear equations using substitution
y=x23x+5y=30\begin{aligned} y &= x-2 \\\\ 3x+5y &=30 \end{aligned}
If left parenthesis, x, comma, y, right parenthesis is a solution to the system of equations above, what is the value of x ?
Choose 1 answer:


Practice: Solve a system of linear equations using elimination
4x+2y=22xy=9\begin{aligned} 4x+2y &= 2 \\\\ 2x-y &=-9 \end{aligned}
The system of equations above has solution left parenthesis, x, comma, y, right parenthesis. What is the value of y ?
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text


Practice: Solve a system of linear equations
2xy=123x7y=7\begin{aligned} 2x-y &= 12 \\\\ 3x-7y &=7 \end{aligned}
Which ordered pair left parenthesis, x, comma, y, right parenthesis satisfies the system of equations shown above?
Choose 1 answer:


Practice: Determine the condition for no solution
ax3y=21bx3y=11\begin{aligned} ax-3y &= 21 \\\\ bx-3y &=11 \end{aligned}
The system of equations above has no solutions. If a and b are positive constants, what is the value of start fraction, a, divided by, b, end fraction ?
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text


Things to remember

To determine the number of solutions a system of linear equations has using slope-intercept form, y, equals, m, x, plus, b:
  1. Rewrite both equations in slope-intercept form.
  2. Compare the m- and b-values of the equations to determine the number of solutions.
  3. If the two equations have different m-values, then the system has one solution.
  4. If the two equations have the same m-value but different b-values, then the system has no solution.
  5. If the two equations have both the same m-value and the same b-value, then the system has infinitely many solutions.

Want to join the conversation?

  • blobby green style avatar for user Rawad bfd
    We have also comparison method not just elimination and substitution
    (11 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Ro5023Da0124
    how can you tell if the variable changes throughout a math sentence.
    (4 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user graceksts
      y=mx+c
      m= a change occurred at a constant rate. maybe per minute/ hour/day. It can be any thing depend on x.
      x is variable that help you find a question. By substitute a value into the equation.
      c is a constant that do not have any variable with it. (c = y-intercept)

      For example:
      Sarah already read a book for 150 pages. She planned to continue reading 20 pages per day. How many pages will she read after 10 days? The time will represent by t.

      For this m= 20 because it's a change occurred at constant rate (20 pages per day)
      x = a variables help us to find the answer. In this case x represents a time in day (per day) ( It can change to any variables that the question told.) (In this case, it t.)
      c = 150 (y- intercept)often an initial value. Since Sarah already reading 150 pages.

      So the equation will be y = 20t + 150

      We want to know the total amount of pages Sarah read in the next 10 days.
      So substitute t(x) with 10.
      y = 20(10) + 150
      y = 350

      Hope this help!
      (18 votes)
  • aqualine ultimate style avatar for user Nicholas Thompson
    That last one was a bit confusing
    (5 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user :)
    I had no idea what happened on that last one
    (4 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Efe Udolu
    A small engineering company has an old machine which produces 30 components per hour and has recently installed a new machine which produces 40 components per hour. Yesterday, both machines were in operation for different periods of time. If 545 components were produced when the total number of hours of operation was 15 hours, determine for how many hours each machine was operating.
    How could you get the system of equations of this question?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Hecretary Bird
      To get a system of equations from a question, you want to find two separate pieces of information that relate the two variables. With those, you'll be able to create two equations and solve the equations.
      Here, we're comparing 2 machines, so the time the old one takes could be our "x", and the new one could be "y". In the first part of the question, we learn about how x and y are related in terms of their rates. We also know that together, they produced 545 parts. Since by multiplying a rate by the time taken you get the total amount of work done, we can make an equation from this. 30 * x is the number of parts that the old machine can make in x hours, and 40 * y is the same for the new machine. Add them together, and we should have 545.
      We get our second equation just from when the question says that the machines took 15 hours together to produce the 545 parts. We write this as x + y = 15. Together, your equations would look like this:
      30x + 40y = 545
      x + y = 15
      And after solving them, you should hopefully get that machine x operated for 5 1/2 hours and y operated for 9 1/2.
      (8 votes)
  • blobby green style avatar for user DarianK
    help
    (2 votes)
    Default Khan Academy avatar avatar for user
    • leafers tree style avatar for user L. E.
      What do you need help with? If it's just the entire thing in general, I'd say go back, reread the practice problems, study each step, and if you need to, look up a more detailed procedure online (like an explanatory video). Perhaps there are some steps that are confusing because you haven't learned the basic skill before that; in which case go back and review whatever you're having difficulty with. And if you can't get it today, that's alright, just put it aside and practice a little every day until it clicks. Writing out the rules, etc. helps too.
      Good luck!
      (1 vote)
  • blobby green style avatar for user luke.kolesnikow
    what if there are differing exponents for an x and y, how do you get an x^2 and an x in the same equation to just find what x is equal to?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Hecretary Bird
      If there are differing exponents for x and y, you have a nonlinear system of equations. These types of questions are pretty rare on the SAT, and you're not guaranteed to see one on every test. To solve such a problem, you can try substitution, just like you would for a normal linear equation. The one caveat is that there doesn't have to be just one solution. Usually the SAT gets around this by specifying that you're finding the solution where for example y=0 or something like that. Here's an example:
      1) y = 2x + 2
      2) x^2 + y^2 = 1
      To solve this, the easiest way to substitute is to put equation 1 into where equation 2 has y:
      x^2 + (2x+2)^2 = 1
      x^2 + (4x^2 + 8x + 4) = 1
      5x^2 + 8x + 3 = 0
      From here, we have a quadratic equation. One way of solving this is with the quadratic formula:
      (-8 +/- sqrt(8^2 - 4*5*3)) / 2*5
      (-8 +/- sqrt(64 - 60)) / 10
      (-8 +/- sqrt(4)) / 10
      (-8 + 2) / 10 = -6/10 = -.6
      (-8 - 2) / 10 = -10/10 = -1
      Here we have two different values for what x could be equal to, so two distinct solutions (we get the y value from plugging each x back into one of the initial equations). We would probably have to choose one of these values because of a condition that the question has in it, and use it somehow for a final answer.
      In summary, on the SAT you can solve nonlinear systems of equations just by substituting, and there's a good chance you could end up having to solve a quadratic on the way.
      (2 votes)
  • blobby green style avatar for user Aranea
    Please help me to learn how to solve systems of linear inequalities. For example, solving systems of inequalities like
    1. Y-X<1 and 3Y>X+6
    2. Y-X<=1 and 3Y>=X+6
    (0 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Hecretary Bird
      On the SAT, you'll only be asked to find the solution of a system of linear inequalities through graphing. Convert each equation to y = mx + b form, then graph the lines themselves. Now shade above the line if the inequality says y is greater than mx + b, and below if y is less. Once you have your two shaded regions, if it's an "and" system of inequalities your solution points are the intersection of both shaded areas. If you have an "or" inequality, your solution is every point that is shaded, both singly and doubly.
      (3 votes)
  • blobby green style avatar for user Imran Uddin
    What is difference between SAT and LCAT (LUMS Common Admission Test)? I mean,to what extent do they differ?
    (0 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user mavrikschor
    Genuinely confused on why we multiply by 2 when we are trying to find the value of "y".
    (0 votes)
    Default Khan Academy avatar avatar for user