High School Modules > Algebra by Gregory A. Moore
Completing the Square
The square root principle, the method of completing the square and its application to solving second degree equations.
[Directions : Execute the Code Resource section first. Although there will be no output immediately, these definitions are used later in this worksheet.]
0. Code
| > | restart; |
| > | SquarerootSolve := proc(eq) local EQ,EQ1, EQ2,L,R,s1,s2; print(`\nOriginal Problem :`); print(eq); EQ := sqrt(lhs(eq)) = sqrt(rhs(eq)); print(`\nTake squareroot of each side`); print(EQ);print(` `); print(`\nDon't forget the +/-`); print(lhs(EQ), ` = (+/-) `, rhs(EQ));print(` `); L := op(1,op(1,simplify( abs(sqrt(lhs(EQ)))))); R := rhs(EQ); EQ1 := L = R; EQ2 := L = -R; print(`\nNow break this into two linear equations`); print( EQ1,EQ2); s1 := solve(EQ1,x); s2 := solve(EQ2,x); print(`\nThe solutions are : `); print( s1, s2 ); end proc: |
| > | CompleteSteps := proc(EQ) #ONLY for leading coefficient = +1 or -1 local EQ2,EQ3,C,b, lt ; print(`\nOriginal Equation :`); print(EQ); EQ2 := sort(op(1,EQ)-op(2,EQ), x); C := coeff(EQ2,x,0); EQ3 := EQ2 - C = - C; print(`\n1. Put x terms on left and the number term on right :`); print(EQ3); print(` `); lt := coeff(EQ2,x,2); lt:= lt/abs(lt); if( lt = -1) then EQ3 := lt*lhs(EQ3) = lt*rhs(EQ3); print(`(If the coefficient of x^2 is negative then multiply both sides by -1)`); print(EQ3); fi; b := coeff( lhs(EQ3), x); print(`\n2. Take half of the x coefficinet`,b, ` and square it, add both sides`); print(EQ3); print(cat(`+ `, convert((b/2)^2, string), ` +`, convert((b/2)^2, string) )); print(`_______ ___`); EQ2 := lhs(EQ3) + (b/2)^2 = rhs(EQ3) + (b/2)^2; print(EQ2); print(` `); print(factor(lhs(EQ2)) = rhs(EQ2)); factor(lhs(EQ2)) = rhs(EQ2); sqrt(lhs(%)) = sqrt(rhs(%)); print(`\n3. Take the square root of each side (with + or -)`); print(`\n4. Now solve the two linear equations :`); print(solve(%, x)); end proc: |
| > | CompleteStepsMore := proc(EQ) #ONLY for case when leading coef 1 local EQ2,EQ3,A,B,C,b, lt, sg, subEQ, rEQ,g ; print(`\nOriginal Equation :`); print(EQ); subEQ := sort(op(1,EQ)-op(2,EQ), x); A := coeff(subEQ,x,2); B := coeff(subEQ,x,1); C := coeff(subEQ,x,0); g := A; if( B <> 0 ) then g := gcd( g, B); fi; if( C <> 0 ) then g := gcd( g, C); fi; EQ3 := (subEQ - C)/g = - C/g; lt := coeff((subEQ/g),x,2); if(lt=1) then CompleteSteps(EQ3); else print(` `); print(`\n1. Factor out any common terms and put x terms on left and the number term on right :`); print(EQ3); print(` `); A := A/g; sg := A/abs(A); if( sg = -1) then EQ3 := -lhs(EQ3) = -rhs(EQ3); print(`\n(If the coefficient of x^2 is negative, then multiply both sides by -1)`); print(EQ3); fi; lt := abs(A); subEQ := lhs(EQ3)/lt; rEQ := rhs(EQ3); print(`\n Factor the leading coefficient from the left side`); print(cat(lt,`(`,subEQ,`) = `, rEQ)); b := coeff( subEQ, x); print(`\n2. Take half of the x coefficient`,b, ` and square it to get `, (b/2)^2); print(`..then MULTIPLY it by leading coefficient factor`,lt, ` and add to both sides :`); subEQ := subEQ + (b/2)^2; print(cat( lt,`(`,subEQ,`) = `,rEQ,` + `,lt,`*`,(b/2)^2, `)` )); rEQ := rEQ + lt*(b/2)^2; EQ2 := lt*subEQ = rEQ; print(`\n3. Take the square root of each side (with +/-)`); EQ2 := factor(lhs(EQ2)) = rhs(EQ2); print(EQ2); EQ3 := sqrt(lhs(%)) = sqrt(rhs(%)); lt:= op(1, lhs(EQ3)); rEQ := rhs(EQ3); subEQ := op(1, op(2, lhs(EQ2))); print(` `); print(`\n4. Now solve the two linear equations :`); print(cat( lt,`(`, subEQ ,`) = `, rEQ )); print(cat( lt,`(`, convert(subEQ, string) ,`) = `, -rEQ )); print(` `); print( lt*subEQ = rEQ); print( lt*subEQ = -rEQ); print(` `); print(x = {solve(EQ2, x)}); fi; end proc: |
1. The Square Root Principle
Here is a straight forward problem. You can probably guess the answers; but, lets use this as an example of this solution method.
| > | SquarerootSolve(x^2 = 9); |
| > | SquarerootSolve(x^2 = 324); |
That works fine enough for perfect squares. How about for numbers which are NOT perfect squares?
| > | SquarerootSolve(x^2 = 8); |
| > | SquarerootSolve(x^2 = 75); |
What if the expression being squared is not just x?
| > | SquarerootSolve( (x-3)^2 = 25 ); |
| > | SquarerootSolve( (3*x+2)^2 = 40 ); |
| > | SquarerootSolve( ((x+1)/2)^2 = 49 ); |
2. The Idea of Completing the Square (leading coef = 1)
First note the difference between the
complete squares
of binomials and incomplete squares.
| > | for k from 1 to 10 do `Perfect Square = `, (x+k)^2=expand((x+k)^2), ` Incomplete Square = `, expand( (x+k)^2 - k^2); od; |
| > | for k from 1 to 10 do `Perfect Square = `, (x-k)^2=expand((x-k)^2), ` Incomplete Square = `, expand( (x-k)^2 - k^2); od; |
The incomplete squares are "missing" the constant term. We can make these "incomplete squares" become complete by adding the term that will make them complete. But how do we figure out what that is?
| > | (x + a)^2: % = expand(%); |
Notice that the last term is the square of a , while the middle coefficient is twice a !
| > | (x + 7)^2: % = expand(%); |
Notice that the last term is the square of 7 , while the middle coefficient is twice 7. Therefore, if we new the middle term,
2a
, we could divide it by 2 to get
a
, and then square a to get the "missing" constant term.
_________________________________________________________________________________
Lets try an experiment with this idea. We'll start with an incomplete square and try to complete it.
| > | Expression := x^2 + 18*x; |
| > | `The middle coefficient is `; b := coeff(Expression, x, 1); |
| > | a := b/2; a2 := a^2; |
Now if we add the square of a to the original expression and try to factor it, we SHOULD get a perfect square!
| > | Expression + a2: % = factor(%); |
And we do! It works!
Lets try some more examples.
| > | x^2 + 24*x; a := coeff(%, x, 1)/2; %% + %^2 = factor( %% + %^2); |
| > | x^2 + 100*x; a := coeff(%, x, 1)/2; %% + %^2 = factor( %% + %^2); |
It also works if the middle coefficient is negative.
| > | x^2 - 30*x; a := coeff(%, x, 1)/2; %% + %^2 = factor( %% + %^2); |
| > | x^2 - 84*x; a := coeff(%, x, 1)/2; %% + %^2 = factor( %% + %^2); |
It even works if the middle term is odd! However, a will end up being a fraction.
| > | x^2 + 5*x; a := coeff(%, x, 1)/2; %% + %^2 = factor( %% + %^2); |
| > | x^2 + 21*x; a := coeff(%, x, 1)/2; %% + %^2 = factor( %% + %^2); |
So thats it. We halve then middle coefficient, then square it and add that number to make an incomplete square, complete.
3. Solving Equations by Completing the Square (leading coef = 1)
To complete the square on an equation which is not in "square = square" form, we need to do a little preparation, and then use the method above. First, we write
| > | CompleteSteps( x^2 + 6*x - 7= 0); |
You may notice that the last problem is actually much more easily solved by simply factoring the original equation. However, this method also works where factoring fails, and gives us answers not possible via integer factoring.
| > | CompleteSteps( x^2 + 6*x + 7= 0); |
| > | CompleteSteps( x^2 + 20*x + 36 = 0); |
| > | CompleteSteps( x^2 - 20*x + 36 = 0); |
It also works when there answers are not real. <Intermediate Algebra use only>
| > | CompleteSteps( x^2 + 8*x - 11= 0); |
| > | CompleteSteps( x^2 + 6*x + 20= 0); |
Note that the problem might be slightly obscured to begin with because the terms are not in the "right places." We can easily fix that by putting them back in order.
| > | CompleteSteps( x + 10 = x^2); |
Sometimes we have an additional step - to make sure that the coefficient on x^2 is positive 1.
| > | CompleteSteps( 2 - x^2 = x); |
| > | CompleteSteps( 8 - x^2 = 5*x); |
There is also a built-in function for completing the square.
| > | student[completesquare](x^2 + 6*x = 7); solve(%, x); |
4. More Difficult Equations to solve (leading coef 1)
| > | CompleteStepsMore( 2*x^2 + 3*x + 1 = 0); |
| > | CompleteStepsMore( 3 - 2*x = 4*x^2); solve( 3 - 2*x = 4*x^2); |
| > | CompleteStepsMore( 5*x^2 + x - 1 = 0); solve(5*x^2 + x - 1 = 0, x); |
Sometimes, the equation only appears to have a leading coefficient other than one.
| > | CompleteStepsMore( 100*x^2 + 200*x + 100 = 0); |
Lets try this big guy.
| > | CompleteStepsMore( 3600*x^2-15120*x+15876=0 ); |
Not so big after all!
5. Equations of Parabolas and Circles
PARABOLAS
Its very nice to express parabolas in the form : y = (x-a)^2 + b or (y-b) = (x-a)^2, because we can immediately read the vertex as being (a,b). This makes it easy to graph and easy to find the maximum or minimum point of the parabola. When we are given an equation for a parabola which is NOT in the form, our new friend "completing the square" can come to the rescue.
| > | y = x^2 + 6*x + 7; student[completesquare](%,x); |
| > | y = x^2 + 46*x ; student[completesquare](%,x); |
| > | y = x^2 + 9*x + 3; student[completesquare](%,x); |
This works for downward parabolas also.
| > | y = -x^2 + 20*x - 23; student[completesquare](%,x); |
This also works for parabolas which have some vertical stretching or compression. These more generalized parabolas are expressable in the form y = c(x-a)^2 + b, or (y-b) = c(x-a)^2.
| > | y = 4*x^2 + 9*x - 11; student[completesquare](%,x); |
| > | y = 1205*x^2 + 4030*x ; student[completesquare](%,x); |
| > | y = -20000*x^2 + 926*x -8; student[completesquare](%,x); |
CIRCLES
To find the equation of a circle in center-radius form - (x-h)^2 + (y-k)^2 = r^2 - its sometimes necessary to perform completion of the square on BOTH x and y! Although it may appear to be double trouble, its only the same process performed twice.
Here is an example. First we complete the square with respect to x.
| > | x^2 + 6*x + y^2 -8*y = 7; student[completesquare](%,x); |
To tidy things up a bit, lets add 9 to both sides. This gets all of the loose constants onto the right side, where they are safely away from dangerously spinning variables.
| > | lhs(%) + 9 = rhs(%) + 9; |
Now lets do it again - but this time with respect to y.
| > | student[completesquare](%,y); |
Tidy up a bit ....
| > | lhs(%) + 16 = rhs(%) + 16; |
There it is! The center is (-3,4) and the radius is sqrt(32).
Lets try another example.
| > | x^2 - 200*x + y^2 + 200*y = 0; student[completesquare](%,x); |
| > | lhs(%) + 10000 = rhs(%) + 10000; |
| > | student[completesquare](%,y); |
| > | lhs(%) + 10000 = rhs(%) + 10000; |
© 2002 Waterloo Maple Inc