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

Worked example: Rewriting & solving equations by completing the square

Sal solves x²-2x-8=0 by rewriting the equation as (x-1)²-9=0 (which is done by completing the square!).

Want to join the conversation?

  • purple pi teal style avatar for user Raghav Arora
    At , Can we use the identity (a^2 - b^2) = (a-b)(a+b) for the terms (x-1)^2 and 9?
    Can't we just factor these terms as (x - 4)(x + 2)?
    (10 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user christoffer.whetstone
    hi David, i'm having trouble understanding equations with fractions like 50-1/2x^2=23 and i don't know which way to solve it.
    (7 votes)
    Default Khan Academy avatar avatar for user
    • stelly blue style avatar for user Kim Seidel
      You can eliminate the fraction by multiply by 2. Since the problem will be easier to solve if x^2 is positve, change that to multiply by -2 to change the signs at the sam time.
      Your new equation is: -100+x^2 = -46

      I would use square root method to solve.
      -- Add 100 to both sides
      -- Take the square root of both sides.

      Hope this helps.
      (10 votes)
  • male robot hal style avatar for user josh
    Couldn't this problem be solved by just doing this?

    (1 vote)
    Default Khan Academy avatar avatar for user
    • stelly blue style avatar for user Kim Seidel
      Yes it could because the quadratic was factorable. But, not all quadratics are factorable. So, we need to learn other techniques. The video was trying to demonstrate how to complete the square which is one technique that works for all quadratics (factorable or not).
      (18 votes)
  • blobby blue style avatar for user ✨ Sofia Utama 💯
    At about , what's the point of writing x²-2x-8=0 in the form, (x+a)²+b?
    Also- isn't -8 in the equation already a²?? Confusion..
    (2 votes)
    Default Khan Academy avatar avatar for user
    • female robot grace style avatar for user loumast17
      This is called vertex form, and as the name implied it very easily lets you tell the vertex (the max or min of a parabola.) Specifically it is (-a, b)

      it is also much easier to get the 0s which would be +/- sqrt(-b) - a. not as easy as factored form of course.

      When it comes to graphing, vertex form is the easiest by far to recognize transformations. Specifically you want want it written as A(B(x-C))^2 + D Where A is the vertical stetch, B is the horizontal shrink, C is the horizontal shift and D is the vertical shift. You could also Not have B if you factor it out like this.

      A(B(x-C))^2 + D
      AB^2(x-C)^2 + D
      Then you would just have AB^2 as one component which would account for both vertical and horizontal stretches and shrinks.

      I hope this all made sense, if not though just let me know what you didn't understand and I can explain.

      Also the -8 is the constant in x²-2x-8=0, so it is c. Then there isn't a -8 in the vertex form, (x-1)² - 9 = 0

      And (x-1)² - 9 tells us there are no stretches or shrinks, the graph is just the normal x² graph moved right 1 and down 9 units.

      Again, let me know if you have any questions about my answer.
      (10 votes)
  • blobby green style avatar for user Daniel Thomas
    I'm probably getting ahead of myself here (thinking back over the many years I can almost remember parts to my answer), but why - in some videos - does Sal say "X=a AND X=b," while in others he uses the verbiage "or."

    In other words, he verbalizes the solutions in these two ways:
    1) X=a AND X=b
    2) X=a OR X=b

    I can't imagine it can be "and," in addition to "or." I presume "or" is restricted only by real-life scenarios (where a negative solution wouldn't make sense), but if this is the case -- aren't we implying that mathematics (as we currently understand it) isn't always correct?

    Thanks for looking!
    (3 votes)
    Default Khan Academy avatar avatar for user
    • mr pink green style avatar for user David Severin
      For these purposes, either is okay because we are finding solutions, In words, it would be 'x is a and x is b' for and, and 'x is a or b' for or. I really prefer the or not just because it requires less words, The reason is if you ever get into set theory, these two words have a lot more meaning ( and means the union or intersection of two sets, or means the total elements of the two sets),
      In real life scenarios, the or would not help because negative numbers that do not make sense to the problem would be called extraneous solutions, and would not show up as part of the answer, so the answer would just be x=a. This is also true when you get to Algebra II and start dividing polynomials such that any answer that would make the denominator zero would be extraneous. Merely interchanging language does not invalidate the process we use to get solutions.
      (5 votes)
  • winston baby style avatar for user (☞゚ヮ゚)☞(.-.)☜(゚ヮ゚☜)
    How do you know when to add or subtract? e.g
    at _, is it positive or a negative?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • starky ultimate style avatar for user Piquon
    in this problem, It might be quicker to factor by the perfect square method straight away as in:
    -> x²-2x-8=0 ->『find two numbers that simultaneously multiply to -8 and add up to -2, then rewrite the equation substituting in those numbers in place of the original middle term』x²+2x-4x-8=0 -> 『factor by grouping』(x+2)(x-4)=0 ->『set each term to 0 and obtain the roots』x①=-2 , x②=4
    Hope you find this useful ^//^
    (2 votes)
    Default Khan Academy avatar avatar for user
  • starky ultimate style avatar for user Alessandro V. Santoro
    Hello everyone!

    Theoretically, can one complete the square of higher degree polynomials? I doubt so but would like to see what others think.
    (2 votes)
    Default Khan Academy avatar avatar for user
  • hopper cool style avatar for user Kevin
    This new way of solving is to difficult. Is there another way to solve this equation? What is the other way?
    (1 vote)
    Default Khan Academy avatar avatar for user
  • piceratops seedling style avatar for user Melvin Tehubijuluw
    Hi all,

    So after struggeling with the exercise "Practise: Completing the square (intermediate)". I noticed an odd thing.

    I'm not sure if I am correct, but when rewriting equations, the output for a given X, should stay the same right? Otherwise the rewritten equations wouldn't be the same, because the output is different.

    I couldn't solve the following equation:
    2x^2 -9X + 7 =

    The hints suggested that you can solve it in the following way:

    1: 2X^2-9X = -7
    2: X^2 -(9/2)X = -(7/2)
    3: X^2 -(9/2)X = -(7/2) + (81/16)
    4: (X-9/4)^2 = 25/16

    Let's pick an X value, for example X = 1.
    I have rewritten equation 2 to have the 25/16 on the left hand side.

    Equation 1: 2(1^2) -(9 x 1) + 7 = 0
    Equation 2: (1-9/4)^2 -(25/16) != 0 but is equal to: 1.5625

    Is there anyone who can explain why this is a valid solution?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • female robot grace style avatar for user loumast17
      There are several problems.

      To answer your question thogh (1-9/4)^2 - (25/16) does equal 0.

      (1-9/4)^2 - 25/16
      (-5/4)^2 - 25/16
      25/16 - 25/16

      Second, when you completed the square your step 3 shpuld look like

      3: X^2 -(9/2)X + (81/16)= -(7/2) + (81/16)

      because (x-9/4)^2 = x^2 - (9/2)x + 81/16

      Third,since you divided by 2 in step 2, you need to multiply both sides by 2 in step 4 to get the completely correct answer. so 2(x-9/4)^2 = 25/8

      Also setting x = 1 in this still is correct. But both 2(x-9/4)^2 = 25/8 and (X-9/4)^2 = 25/16 have the same roots

      Let me know if you need any more help.
      (3 votes)

Video transcript

- [Voiceover] So let's see if we can solve this quadratic equation right over here: x squared minus two x minus eight is equal to zero. And actually, they're cutting down some trees outside, so my apologies if you hear some chopping of trees. I'll try to ignore it myself. All right. So back to the problem at hand, and there's actually several ways that you could attack this problem. We could just try to factor the left-hand side and go that way, but the way we're going to tackle it is by completing the square. Now what does that mean? Well that means that I wanna write, I wanna write the left-hand side of this equation into the form x plus a squared plus b, and we'll see if we can write the left-hand in this form that we can actually solve it in a pretty straightforward way. So let's see if we could do that. Well let's just remind ourselves how we need to rearrange the left-hand side in order to get to this form. If I were to expand out x plus a squared, let me do that in a different color. So if I were to expand out x plus a squared, that is x squared plus two a x, I'll make that plus sign you can see, plus two a x, plus a squared, and of course you still have that plus b there, plus b. So let's see if we can write this in that form. So, what I'm going to do, this is what you typically do when you try to complete the square. All right. The x squared minus two x. Now I'm gonna have a little bit of a gap and I'm gonna have minus eight, and I have another a little bit of a gap and I'm gonna say equals zero. So I just rewrote this equation, but I gave myself some space so I can add or subtract some things that might make it a little bit easier to get into this form. So, if we just match our terms, x squared, x squared, two a x, negative two x. So, if this is two a x, that means that two a is negative two, two a is equal to negative two or a is equal to negative one. Another way to think about it, your a is going to be half of your first degree coefficient or the coefficient on the x term. So the coefficient of the x term is a negative two, half of that is a negative one. And then we wanna have, and then we want to have an a squared. So if a is negative one, a squared would be plus one. So let's throw a plus one there. But like we've done and said before, we can't just willy-nilly add something on one side of equation without adding it to the other or without subtracting it again on that same side. Otherwise, you're fundamentally changing the truth of the equation. So if I add one on that side, I even have to add one on the, if I add one of the left side, I even have to add one on the right side to make the equation still hold true or I could add one and subtract one from the left-hand side, so I'm not really changing the value of the left-hand side. All I've done is added one and subtracted one from the left-hand side. Now why did I do this again? Well now, I've been able, I haven't changed its value. I just added and subtracted the same thing, but this part of the left-hand side now matches this pattern right over here, x squared plus two a x, where a is negative one, so it's minus two x, plus a squared, plus negative one squared and then this, this part right over here is the plus b. So we already know that b is equal to negative nine. Negative eight minus one is negative nine, and so that's going to be our b right over there. And so we can rewrite this as, what I squared off in green, that's gonna be x plus a squared. So we could write it as x plus and I could write a is negative one. Actually, let me, I could write it like that first. x plus a squared or x plus negative one. Well, let's just x minus one, so I'm just gonna write it as x minus negative one squared and then we have minus nine, minus nine is equal to zero, is equal to zero. And then I can add nine to both side, so I just have this squared expression on the left-hand side, so let's do that. Let me add nine to both sides. And what I am going to be left with, so let me just, on the left-hand side, those cancel out. That's why added the nine. I'm just gonna be left with the x minus one squared. It's going to be equal to, on this side, zero plus nine is nine. So if x minus one, let me do that in blue color. So, it's gonna be nine. And so if x minus one squared is nine, if I have something square is equal to nine, that means that that something is either going to be the positive or the negative square root of nine. So it's either gonna be positive or negative three. So we can say x minus one is equal to positive three or x minus one is equal to negative three and you could see that here. If x minus one is three, three squared is nine. If x minus one is negative three, negative three squared is nine. And so here, we can just add one to both sides of this equation, add one to both sides of this equation, and you get x is equal to four or x is, if we add one to both sides of this equation, we get, my digital ink is acting up, I don't know. All right. Then we get x is equal to negative three plus one is negative two. So, x could be equal to four or x could be equal to negative two, and we're done. Now, some of you might be saying, "Well, why did we go through the trouble "of completing the square? "I might have been able to just factor this "and then solve it that way." And you could have, actually, for this particular problem. Completing the square is very powerful because you could actually always apply this, and in the future, what you will learn in the quadratic formula and the quadratic formula actually comes directly out of completing the square. In fact, when you're applying he quadratic formula, you're essentially applying the result of completing the square. So hopefully you found that fun.