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

Solve by completing the square: Integer solutions

We can use the strategy of completing the square to solve quadratic equations. If the solutions are integers, we can solve by factoring as well. Created by Sal Khan.

Want to join the conversation?

  • starky tree style avatar for user LOW DOG
    why would we divide the 8 and then do 4² i do not get this at all.
    (13 votes)
    Default Khan Academy avatar avatar for user
    • area 52 green style avatar for user Eirian
      Square of binomials (x+a)^2, when you expand them, always have the form x^2+2ax+a^2. What Sal did was divide the coefficient of the second term (equivalent to 2a of the 2ax), 8 in this example, by 2 to get a, which is 4. He then squared it (4^2) to get the last term, a^2.
      (10 votes)
  • piceratops ultimate style avatar for user Woohoo
    Are there more simple ways to do this?
    (I mean, this is pretty simple, and I understand it, but I'm just am curious if there are easier ways)
    (7 votes)
    Default Khan Academy avatar avatar for user
    • mr pink green style avatar for user David Severin
      By subtracting 85, you get x^2-8x-84=0, so factor by finding two numbers that multiply to be 84 and subtract to get 8, so try a few until you find -14+6 so factors are (x-14)(x+6)=0. By zero product rule, x=14 or x=-6. Or you could put into a graphing calculator and find x intercepts. Simple may be a matter of opinion. Completing the square and quadratic formula work well with solutions that include a radical.
      (9 votes)
  • blobby green style avatar for user Matej Šarlija
    Still wobbly on the fact that the sqrt(100) is +/- 10 instead of "just" 10. Help :).
    (3 votes)
    Default Khan Academy avatar avatar for user
  • male robot hal style avatar for user Vinay Sharma
    At (x-4)^2 - 100.
    can be rewritten as (x-4)^2 -(10)^2
    here, we can use the difference of squares as well
    (x-4+10) (x-4-10) = 0
    (x+6) (x-14) =0
    So, x roots are -6 and 14.
    I apologize if it seems misleading :)
    (5 votes)
    Default Khan Academy avatar avatar for user
  • stelly green style avatar for user roomforsushi
    Why does x^2-8x+16 equal to (x-4)^2 at
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Trevor Burch
    I'm not getting how he got (x-4)^2
    (1 vote)
    Default Khan Academy avatar avatar for user
    • leafers sapling style avatar for user Dia J
      He got (x-4)^2 because (x-4)^2 is technically (x-4)(x-4). (x-4) times (x-4) is x^2 - 4x - 4x + 16 using FOIL, and x^2 - 4x - 4x + 16 can be simplified to x^2 - 8x + 16, which is what Sal got to make the equation a complete square.

      Hope this helps!
      (6 votes)
  • sneak peak blue style avatar for user Stephen Earley
    Why don't we take the plus or minus square root of the x-4?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • mr pink green style avatar for user David Severin
      Lets suppose you could add the ± on both sides of the equation. This would create 4 possibilities:
      (x-4) = 10, (x-4)=-10, -(x-4)=10 and -(x-4)=-10. Looking at the second 1, divide by negative 1 to get (x-4)=-10 and you are back at the second one. Doing the same thing on the 4th, you get (x-4)=10 which is the same as the first. So you really only need to do it on one side, the other side will just repeat what you already have.
      (3 votes)
  • blobby green style avatar for user st.lareyes
    always she if the quadratic equations is on standar form "ax2+bx+c"
    (2 votes)
    Default Khan Academy avatar avatar for user
  • aqualine ultimate style avatar for user MahinV
    What if the other side of the equation has an X? My question asks, X^2 - 4x + 4 = 2x
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Doug NineNine
    Something I'm struggling to understand in the big picture, I know I'm missing something simple.

    When we solve for x^2 - 8x - 1 = 85 and we get x=14 and x=-6, how come we can't take those points (14,85) (-6,85) and plot them on our graph? I know that 14 & -6 are the x intercepts and would be at (14,0) and (-6,0), but then what is the equation x^2 - 8x - 1 = 85 saying? I'm looking at it like we have a function f(x) = x^2 - 8x - 1 and f(-6) evaluates to 85 so (-6,85) should be a point on the graph but clearly that's wrong so what is the right way to think about x^2 - 8x -1 = 85 in relation to the graph?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • mr pink green style avatar for user David Severin
      First off, I assume it really is x^2 - 8x + 1 = 85 because 14*6=84, and if you subtract 85, you end with x^2-8x-84=0 (not 86). If you start with x^2-8x-84=0, you do get the two intercepts of (14,0) and (-6,0). However, if you graph x^2-8x+1 on one line and y=85, you do get the two answers (-6,85) and (14,85) as the place where x^2-8x+1 and y=85 meet. If you put the whole thing into a calculator such as DESMOS, you will end up with two vertical lines, one at -6 and one at 14. Since there is only one variable, it would be more appropriate to graph on a number line rather than a coordinate plane.
      (1 vote)

Video transcript

- [Instructor] So we're given this equation here. And what I want you to do is pause this video and see if you can solve it. What x values satisfy the equation? All right, now let's work through this together. So one technique could be just, let's just try to complete the square here on the left-hand side. So to do that, let me write it this way, x squared minus eight x. And then I have, I'll write the plus one out here, is equal to 85. Now if I wanna complete the square, I just have to think, "What can I add to both sides of this equation "that could make this part of the left-hand expression "a perfect square?" Well, if I look at this negative eight coefficient on the first-degree term, I could say, "Okay, let me take half of negative eight." That would be negative four. And then, negative four squared is going to be positive 16. So I'm gonna add positive 16 on the left-hand side. And if I want, I could then subtract a 16 from the left-hand side. Or I could add a 16 on the right-hand side. Notice, I've just done the same thing to both sides of this equation. And why was that useful? Well, now what I've just put in parentheses is a perfect square. This is the same thing as x minus four squared. It was by design. We looked at that negative eight. Half of that is negative four. You square it, you get 16. And you can verify, x minus four times x minus four is, indeed, equal to this. And then we have plus one is going to be equal to, what's 85 plus 16? That is 101. And now we wanna get rid of this one on the left-hand side. And the easiest way we can do that is subtract one from both sides. That way we'll just isolate that x minus four squared. And we are left with x minus four squared. Four squared, these cancel out, is going to be equal to 100. Now if something squared is equal to 100, that means that the something is equal to the positive or the negative square root of a hundred. Or that that something, x minus four, is equal to positive or negative 10. Positive or negative 10. All I did is took the plus or minus square root of a hundred. And this makes sense. If I took positive 10 squared, I'll get a hundred. If I take negative 10 squared, I get a hundred. So x minus four could be either one of those. And now I just add four to both sides of the equation. And then what do I get? I get x is equal to four plus or minus 10. Or another way of thinking about it, I could write it as x is equal to, four plus 10 is 14. And then four minus 10 is equal to negative six. So these are two ways to solve it. But there's other ways to solve this equation. We could, right from the get-go, try to subtract 85 from both sides. Some people feel more comfortable solving quadratics if they have that quadratic expression be equal to zero. And if you did that, you would get x squared minus eight x minus 84 is equal to zero. All I did is I subtracted 85 from both sides of this equation to get this right over here. Now this one we can approach in two different ways. We can complete the square again. Or we could just try to factor. If we complete the square, we're going to see something very similar to this. Actually, let me just do that really fast. If I look at this part, right over there, I could say x squared minus eight x. And then once again, half of negative eight is negative four. That squared is plus 16. And then I'd have minus 84. So let me do that in that blue color so we can keep track. Minus 84. And then if I added 16 on the left-hand side, I could either add that to the right-hand side so both sides have 16 added to it. Or if I wanna maintain the equality, I could just subtract 16 from the left-hand side. So I've added 16, subtracted 16. I haven't changed the left-hand side's value. And then that would be equal to zero. This part right over here, this is x minus four squared. This part right over here is minus 100 is equal to zero. And then you add a hundred to both sides of this and you get exactly this step right over here. Now another way that we could've approached it without completing the square. We could've said x squared minus eight x minus 84 is equal to zero. And think about what two numbers if I multiply them I get negative 84. So they'd have to have different signs, since when I take their product I get a negative number. And when I add them together I get negative eight. And there we could just look at the factorization of negative 84, of 84 generally. It could be two times, let's just think about 84. 84 could be two times 42. And obviously, one of them would have to be negative, one of them would have to be positive in order to get to negative 84. But the difference between these two numbers, if one was positive and one was negative is a lot more than eight. So that doesn't work. So let's try, let's see, I'll do a few in my head. Three times 28. But still that difference is way more than eight. Four times, four times, let's see, (mumbles). Four times 21, no, that difference between four and 21 is still larger than eight. Let's see, five doesn't go into it. Six times 14, that's interesting now. Okay, so let's think about this. So six times 14 is equal to 84. One of them has to be negative. And since when we take the sum of the two numbers, we get a negative number, that means the larger one is negative. So let's see, six times negative 14 is negative 84. Six plus negative 14 is, indeed, equal to negative eight. So we can factor this as x plus six times x minus 14 is equal to zero. And so the product of those two things is equal to zero. That means if either of them is equal to zero, that would make the entire expression equal to zero. So we could say x plus six is equal to zero. Or x minus 14 is equal to zero. Subtract six from both sides here. We get x is equal to negative six. Or add 14 to both sides here. Or x is equal to 14. Exactly what we got up here.