Tricki
a repository of mathematical know-how

Revision of How to solve quadratic equations from Sun, 19/04/2009 - 02:20

Quick description

A quadratic equation is an equation like x^2-3x+2=0: it takes an unknown x and forms an equation out of x^2, x and a number. This article explains several approaches to solving equations of this kind, ending up with the famous formula x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}, which is the formula for the solutions of the equation ax^2+bx+c=0. One of the themes of this article is that there are many circumstances where one should not use this formula.

Prerequisites

Before trying to understand quadratic equations you need to understand about multiplying out brackets. For example, you should know how to work out that (x+5)(x-3)=x^2+2x-15, though in one or two places this article has reminders about how this process works. (These reminders can be found if you click on text that is underlined with a dotted line.) More generally, you should also be comfortable with the idea of letting letters stand for numbers. You will also need to know about negative numbers, and to know basic facts about them, such as that the product of two negative numbers is always positive.

Method 1: factorizing by trial and error

Let us think about the example above, of the equation x^2-3x+2=0. It turns out that if you multiply x-1 by x-2 you get x^2-3x+2. To see this in more detail, note that

(x-1)(x-2)=x(x-2)-1(x-2)=x^2-2x-x+2=x^2-3x+2
Therefore, we can rewrite the equation x^2-3x+2=0 as (x-1)(x-2)=0.

This is very helpful, because if you have two numbers that multiply together to give 0, then one of the two numbers has to be 0. Therefore if (x-1)(x-2)=0 we can deduce that x-1=0 or x-2=0, which tells us that x is either 1 or 2.

It may seem as though the problem is now completely solved, but mathematicians like to be careful under circumstances like this. Strictly speaking, what we have shown is that if x^2-3x+2=0, then x is either 1 or 2; but we have not shown that x=1 and x=2 are solutions to the equation x^2-3x+2=0. (To put that another way, we know that we cannot have any solutions other than 1 or 2, but we still haven't checked that 1 and 2 are solutions.)

So let us quickly check this: if x=1 then x^2-3x+2=1-3+2=0, and if x=2 then x^2-3x+2=4-6+2=0. So 1 and 2 are indeed solutions. A better way of seeing that they are both solutions is to note that they are obviously both solutions of the equation (x-1)(x-2)=0, which, as we have seen, is a rewriting of the original equation.

Very important point: quadratic equations can (and usually do) have more than one solution.

So far, we do not have anything like a method for solving quadratic equations: in the above example, once we had been shown that x^2-3x+2 was equal to (x-1)(x-2), it was then straightforward to solve the equation. But what do you do if there is nobody to give you a big clue like this?

Let's think about this question with the help of another example: the equation x^2-3x-10=0. What we would very much like is two numbers s and t with the property that (x-s)(x-t)=x^2-3x-10, since then we would be able to use exactly the same reasoning as we used for x^2-3x+2.

How do we find such a pair of numbers s and t? The question is difficult as it stands because (x-s)(x-t) looks very different in form from x^2-3x-10. But we can do something about that: we just have to multiply out the brackets. Then we get x^2-sx-tx+st, which equals x^2-(s+t)x+st. This is because

 (x-s)(x-t)=x(x-t)-s(x-t)=x^2-xt-sx+st=x^2-sx-tx+st=x^2-(s+t)x+st.
This is a great help, because it tells us that what we are looking for is two numbers s and t such that s+t=3 and st=-10. Why? Because if s+t=3 and st=-10, then x^2-(s+t)x+st=x^2-3x-10, just as we wanted.

In words, we would like s and t to add up to 3 and to multiply together to give -10. This tells us straight away that one of s and t needs to be negative and one positive. Let's go for s being positive and t being negative, and let's write t=-u, where u is positive. If we do that, then what we want in terms of s and u is that s-u should equal 3, and su should equal 10. Can we find two numbers with a difference of 3 that multiply together to give 10? Yes of course we can: 2 and 5. So we take s to be 5 and u to be 2, which tells us that t is -2.

If s=5 and t=-2, then (x-s)(x-t)=(x-5)(x+2), so what we have just shown is that x^2-3x-10 can be rewritten as (x-5)(x+2). Therefore, the equation x^2-3x-10 is equivalent to the equation (x-5)(x+2)=0. And now we see that one of x-5 or x+2 must be 0, so x=5 or x=-2.

What we have just done is called factorizing the expression x^2-3x-10: we have written it as a product of the two factors x-5 and x+2. We did that by searching for factors of the form x-s and x-t, working out what properties s and t would have to have, and then finding a pair of numbers s and t that had those properties. It is actually more usual (though mathematically less natural) to search for factors of the form x+s and x+t, so let us quickly rerun the argument in its more usual form.

First, we multiply out (x+s)(x+t) to obtain x^2+(s+t)x+st. This tells us that we want to find s and t with s+t=-3 and st=-10. And this time we find that we can take s=-5 and t=2, which gives us (x-5)(x+2) again.

Summary of method 1. If you want to write x^2+ax+b in the form (x+s)(x+t) then you need to find s and t that add up to a and multiply together to give b. This works even if one or both of a and b is negative. Sometimes one can find such a pair s and t by simple trial and error.

General discussion

Let's try this method with the equation x^2+4x+2=0. Method 1 tells us to look for two numbers s and t that add up to 4 and multiply together to give 2. This is impossible unless s and t are both positive. Why? Well, if st=2, then s and t are either both positive or both negative. But if they are both negative then s+t cannot equal 4. But the only way of getting s and t to multiply together to give 2, at least if they are both whole numbers, is to take s=1 and t=2 or vice versa. But 1 and 2 do not add up to 4.

Could we perhaps find s and t that are not whole numbers, with s+t=4 and st=2? This is the question we shall think about next.

It doesn't seem to be easy to find a pair s and t of this kind by trial and error. We want to do something more systematic. So let's see if we can solve the pair of simultaneous equations s+t=4 and st=2. A natural way of doing this is to use the first equation to tell us that t=4-s and to substitute this into the second equation. If we do that then the second equation becomes s(4-s)=2. Multiplying out the bracket gives us 4s-s^2=2, and if we take everything over to the right-hand side then we get 0=2-4s+s^2, which we could rewrite as s^2-4s+2=0. Now we have an equation in just one variable. Can we solve it?

Unfortunately, apart from the minus sign and the fact that the variable is called s rather than x, this equation is exactly the equation we started with! Our attempt to solve the original equation systematically has led us round in a big circle. (The minus sign doesn't help us because if we substitute t=-s we really do get exactly the same equation, so this one is of equivalent difficulty.) Before we see how to break out of this circle, let us discuss another method for solving quadratic equations.

Method 2: some kinds of quadratic equations are easy to solve

A quadratic equation doesn't have to be in the form x^2+ax+b=0. For example, (x+2)(x-4)=0 is a quadratic equation, since it is equivalent to the equation x^2-2x-8=0 (as you will see if you multiply out the brackets). And if you are asked to solve the equation (x+2)(x-4)=0 then the answer is easy: x must be -2 or 4.

Here's another easy quadratic equation: x^2-5=0. Here the coefficient of x is 0, and this is what makes the equation easy: all we have to do is rearrange it as x^2=5, and we see immediately that the answer is x=\pm\sqrt{5}.

Very important principle. If you know that x^2 is equal to a positive number t then what you know about x is that it is equal to either \sqrt{t} or -\sqrt{t}. This is what underlies the fact that quadratic equations tend to have two solutions.

Can we extend our repertoire of quadratic equations that are easy to solve? Yes we can. Here's a variant of the equation we've just solved: (x-3)^2=5. What that equation says is that if you take x, subtract 3 from it and square the result then you get 5. So to get x all you have to do is reverse the process: take (plus or minus) square roots and add 3. That is, we start by deducing that x-3=\pm\sqrt{5} and from that we obtain the solution x=3\pm\sqrt{5}. (This is an example of an easy equation of the general type discussed in the article What makes some equations so much easier to solve than others?)

It is very important to understand that this slightly complicated looking-expression is not just the solution of the equation (x-3)^2=5it is obviously the solution. And the reason it's obvious is a combination of the argument in the previous paragraph and the simple observation that if you subtract 3 from either 3+\sqrt{5} or 3-\sqrt{5} and square the result then you will get 5.

Another important principle: any equation of the form (x-u)^2=v is easy to solve, and the solution is x=u\pm\sqrt{v}.

One can of course also solve equations of the form (x+u)^2=v: this time the solution will be x=-u\pm\sqrt{v}.

Method 3: completing the square

Why is it interesting to discuss special cases where it happens to be easy to solve quadratic equations? It doesn't seem to help us with the equation x^2+4x+2=0, for instance. What are we supposed to do when a quadratic equation is not given to us in a nice convenient form that makes it easy to solve?

Well, the idea of method 1 was to put an equation into a convenient form, in that case a form such as (x-s)(x-t)=0 or (x+s)(x+t)=0. The problem was that when we tried to find a systematic way of doing that, we ended up back where we started. But that doesn't imply that we will always end up back where we started whenever we try to put a quadratic equation into a convenient form. So why don't we take the equation x^2+4x+2=0 and try to put it into the form (x+u)^2=v, which we know how to solve?

Again, if we want to be systematic about this, then what we should do is rewrite the equation (x+u)^2=v and see what we can learn about u and v if we are to obtain the equation x^2+4x+2=0. So we expand the bracket in the equation (x+u)^2=v to obtain x^2+2ux+u^2=v, and then we bring u over to the left-hand side to obtain x^2+2ux+u^2-v=0.

This will be the same as the equation x^2+4x+2=0 if 2u=4 and u^2-v=2. And luckily for us this has given us two equations for u and v that are very easy to solve: we just solve the first one to get u=2, and plug that into the second one to get 4-v=2, which tells us that v=2 as well.

What this shows is that we can rewrite the equation x^2+4x+2=0 as (x+2)^2=2. (If you want to check this, then expand (x+2)^2 and rearrange the second equation. But we know we'll get the first equation because we carefully chose u and v to make sure that that would happen.) And now we have an equation in a form that we know how to solve: the solution is x=-2\pm\sqrt{2}.

This process is called completing the square. The idea is that when we have an equation like x^2+4x+2=0, we regard x^2+4x as part of a squared bracket—that is, something of the form (x+u)^2. Now (x+u)^2=x^2+2ux+u^2, so since our partial square is x^2+4x, we had better take u to be 2. Then we get x^2+4x+4. This addition of 4 "completes" x^2+4x and makes it into (x+2)^2. Of course, we can't just add 4 unless we subtract it again, so the correct thing to say is that x^2+4x=(x+2)^2-4. From this it follows that x^2+4x+2=(x+2)^2-2, so the equation x^2+4x+2=0 is equivalent to the equation (x+2)^2=2.

Quadratic equations where the leading coefficient is not 1

So far we have been looking at equations of the form x^2+ax+b=0. But quadratic equations can be more general than this. For example, the equation 2x^2+7x-4=0 is a quadratic equation, but now there is a coefficient of 2 in front of x^2.

It is sometimes possible to solve these more general quadratic equations by trial and error, just as it is for the simpler ones. One way of doing it for this example is to write 2x^2+7x-4=(rx+s)(tx+u) and see what we can say about r, s, t and u. Multiplying out the brackets on the right-hand side gives us

 (rx+s)(tx+u)=rx(tx+u)+s(tx+u)=rtx^2+rux+stx+su=rtx^2+(ru+st)x+su.

So we would like rt to be 2, ru+st to be 7, and su to be -4.

This looks quite complicated, but because 2 is a small number, if there is going to be an easy solution then it won't take too long to find it. Let's try taking r=1 and t=2. Then we need u+2s to be 7 and su to be -4. That tells us that u will have to be odd (if it's a whole number) so we don't have much choice other than u=1 and s=-4 or u=-1 and s=4. Of these two possibilities, only the second gives us u+2s=7, so we end up taking u=-1 and s=4.

Putting all this back, we have shown that 2x^2+7x-4=(x+4)(2x-1), so the solution to the equation 2x^2+7x-4=0 is x=-4 or x=1/2.

Useful fact. If the leading coefficient is not one, then there may be solutions given by simple fractions.

In fact, a sort of converse to this statement is also true: if the leading coefficient is 1 (that is, if the equation is of the easier form x^2+ax+b=0), then solutions must either be whole numbers or irrational numbers.

What if we want to solve the more general quadratic equations more systematically in cases where trial and error doesn't work? In that case there is a simple trick: divide the whole equation by the leading coefficient. For example, the above equation is clearly equivalent to the equation x^2+(7/2)x-2=0. And now we're back to the first situation.

Notice that we can solve the equation x^2+(7/2)x-2=0 by our first trial-and-error method: we need two numbers that add up to 7/2 and multiply together to give 2. It seems likely that one of the numbers will be a multiple of 1/2, and once one is thinking along those lines it doesn't take too long to come up with s=4 and t=-1/2, which leads us to the equation (x+4)(x-1/2)=0, which again gives the solution x=-4 or x=1/2. (We didn't quite get the same product of brackets as before, but it's equivalent, since x-1/2=0 if and only if 2x-1=0.)

Method 4: the quadratic formula

This article has attempted to convince you that there are several good ways of solving quadratic equations. Not every method is good for every single quadratic equation, but some methods, such as trial and error, are very short and simple when they work. So if you have a quadratic equation to solve, it is worth stopping for a few seconds to consider what the best method might be. Completing the square always works, and in that sense it is the best method. And since it always works, we can try applying it to a completely general quadratic equation ax^2+bx+c=0 to see what we get.

The first step is to divide everything by a, to get x^2+(b/a)x+(c/a)=0. Now we complete x^2+(b/a)x to make it into a square (x+u)^2. Since (x+u)^2=x^2+2ux+u^2, we need to take u=b/2a. That is, for this value of u we will have x^2+(b/a)x=(x+u)^2-u^2. In other words again, x^2+(b/a)x=(x+(b/2a))^2-(b/2a)^2.

It follows that the equation x^2+(b/a)x+(c/a)=0 is equivalent to the equation (x+b/2a)^2-(b/2a)^2+(c/a)=0. This equation in its turn is equivalent to the equation (x+b/2a)^2=(b/2a)^2-(c/a).

We now have a slightly complicated looking equation, but it is easy to solve, since we can just take (plus or minus) square roots and then subtract b/2a from both sides. That is, first we note that x+b/2a=\pm\sqrt{(b/2a)^2-(c/a)} and then we rearrange so that we can say x=-(b/2a)\pm\sqrt{(b/2a)^2-(c/a)}.

This doesn't quite look like the usual quadratic formula. But if we multiply both sides by 2a we find that 2ax=-b\pm\sqrt{b^2-4ac}. If this doesn't seem obvious to you, the reason is that multiplying a square root by 2a is the same as multiplying what's inside the square root by 4a^2, at least if you don't worry too much about which square root you are taking, which we don't need to here as we're taking both square roots. And now we can divide both sides by 2a to obtain the usual formula x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}. But if you prefer the formula we had at the end of the previous paragraph, it is just as valid.

If you have the appetite for more formulae, there is a nice one to remember for when the coefficient of x has a factor of 2 in it. If you start with the quadratic equation ax^2+2bx+c=0, then the solution is x=\frac{-b\pm\sqrt{b^2-ac}}a. To see this, all we have to do is replace b by 2b in the usual formula. We then get the solution x=\frac{-2b\pm\sqrt{4b^2-4ac}}{2a}. We can then cancel a factor of 2 on the top and the bottom to obtain the simpler formula x=\frac{-b\pm\sqrt{b^2-ac}}a.

If a=1, then this becomes simpler still. That is, we are now looking at the equation x^2+2bx+c=0. Using the simpler formula and setting a=1, we find that the solution is x=-b\pm\sqrt{b^2-c}. As a reality check, let us see this by completing the square: we find that x^2+2bx=(x+b)^2-b^2, so the equation is equivalent to (x+b)^2-b^2+c=0, or (x+b)^2=b^2-c, which does indeed have the solution x=-b\pm\sqrt{b^2-c}. This shows us why the extra factor of 2 simplifies the formula: when you square a bracket (x+u)^2 you get x^2+2ux+u^2, so if you're trying to make something that already has a factor of 2 in the coefficient of x, it helps.

These formulae are often useful when one has quadratic equations with variable coefficients. For example, a quadratic equation that sometimes comes up is x^2-2x\cos\theta+1=0. The last simple formula tells us that the solution to this is x=\cos\theta\pm\sqrt{\cos^2\theta-1}, which equals \cos\theta\pm\sqrt{-\sin^2\theta}, which is \cos\theta\pm i\sin\theta, where i is the square root of -1. If you know about complex numbers, you will recognise this as e^{\pm i\theta}. (If you don't, then you can ignore this example.)

Method 5: Turn the equation into a different problem and then solve it

In method 1 we saw that finding s and t such that s+t=a and st=b can solve the quadratic equation x^2+ax+b=0 and in the general comment we found that finding such s and t is really equivalent to solving x^2+ax+b=0 so let's try to solve the system \begin{cases} s+t=a \\ st=b \end{cases} instead. Since the equations in s and t are symmetrical we can assume for simplicity that s\leq t.

Isolating one variable in one equation and substituting on the other ends up generating an equivalent quadratic equation, one way out of this is to think about the mean M=\frac{a}{2} of the numbers s and t.

If we rewrite both numbers using the mean M we get s=M-k and t=M+k were k =\frac{t-s}{2} (and k\geq 0 ) substituting that on the equation st=b we get (M-k)(M+k)= b so M^2-k^2=b and k=\sqrt{M^2-b}.

since s=M-k and t=M+k with M=\frac{a}{2} we have s=\frac{a}{2}-\sqrt{(\frac{a}{2})^2-b} and t=\frac{a}{2}+\sqrt{(\frac{a}{2})^2-b}, which are really the quadratic formulas for x^2+ax+b=0.

Comments

Method 5

I just added method 5 but maybe it should put somewhere else in the article letting the last method be the quadratic formula.

Is that method really in the spirit of this Tricki? Or it should be somewhere else?

I just remembered this method from my reflections about the quadratic equation and felt it was a good idea.

Thanks for this great site everybody.

I had a vague plan to convert

I had a vague plan to convert an old blog post of mine on solving cubics into a Tricki article. If so, then this Method 5 would fit in naturally there.

For now, the title of the method suggests a rather general idea, but I wonder whether it really is. Perhaps it should be given a more specific title such as "Think of a good substitution." In this case, the basic idea is to think of the two roots as a+b and a-b and solve for a and b, which turns out to be easy. And one can motivate the idea by the observation that in specific instances we observe that the solutions are of the form u\pm\sqrt{v}.

Added later: that article now exists