[<< wikibooks] Algebra/Completing the Square
== Derivation ==
The purpose of "completing the square" is to either factor a prime quadratic equation or to more easily graph a parabola. The procedure to follow is as follows for a quadratic equation

y
=
a

x

2

+
b
x
+
c

{\displaystyle y=ax^{2}+bx+c}
:
1. Divide everything by a, so that the number in front of

x

2

{\displaystyle x^{2}}
is a perfect square (1):

y
a

=

x

2

+

b
a

x
+

c
a

{\displaystyle {\frac {y}{a}}=x^{2}+{\frac {b}{a}}x+{\frac {c}{a}}}
2. Now we want to focus on the term in front of the x. Add the quantity

(

b

2
a

)

2

{\displaystyle \left({\frac {b}{2a}}\right)^{2}}
to both sides:

y
a

+

(

b

2
a

)

2

=

x

2

+

b
a

x
+

(

b

2
a

)

2

+

c
a

{\displaystyle {\frac {y}{a}}+\left({\frac {b}{2a}}\right)^{2}=x^{2}+{\frac {b}{a}}x+\left({\frac {b}{2a}}\right)^{2}+{\frac {c}{a}}}
3. Now notice that on the right, the first three terms factor into a perfect square:

x

2

+

b
a

x
+

(

b

2
a

)

2

=

(

x
+

b

2
a

)

2

{\displaystyle x^{2}+{\frac {b}{a}}x+\left({\frac {b}{2a}}\right)^{2}=\left(x+{\frac {b}{2a}}\right)^{2}}
Multiply this back out to convince yourself that this works.
4. Therefore the completed square form of the quadratic is:

y
a

+

(

b

2
a

)

2

=

(

x
+

b

2
a

)

2

+

c
a

{\displaystyle {\frac {y}{a}}+\left({\frac {b}{2a}}\right)^{2}=\left(x+{\frac {b}{2a}}\right)^{2}+{\frac {c}{a}}}
or, multiplying through by a,

== Explanation of Derivation ==

1. Divide everything by a, so that the number in front of

x

2

{\displaystyle x^{2}}
is a perfect square (1):

x

2

+

b
a

x
+

c
a

=

a

{\displaystyle x^{2}+{\frac {b}{a}}x+{\frac {c}{a}}={a}}
Think of this as expressing your final result in terms of 1 square x.  If your initial equation is

2. Now we want to focus on the term in front of the x. Add the quantity

(

b

2
a

)

2

{\displaystyle \left({\frac {b}{2a}}\right)^{2}}
to both sides:

y
a

+

(

b

2
a

)

2

=

x

2

+

b
a

x
+

(

b

2
a

)

2

+

c
a

{\displaystyle {\frac {y}{a}}+\left({\frac {b}{2a}}\right)^{2}=x^{2}+{\frac {b}{a}}x+\left({\frac {b}{2a}}\right)^{2}+{\frac {c}{a}}}

3. Now notice that on the right, the first three terms factor into a perfect square:

x

2

+

b
a

x
+

(

b

2
a

)

2

=

(

x
+

b

2
a

)

2

{\displaystyle x^{2}+{\frac {b}{a}}x+\left({\frac {b}{2a}}\right)^{2}=\left(x+{\frac {b}{2a}}\right)^{2}}
Multiply this back out to convince yourself that this works.
4. Therefore the completed square form of the quadratic is:

y
a

+

(

b

2
a

)

2

=

(

x
+

b

2
a

)

2

+

c
a

{\displaystyle {\frac {y}{a}}+\left({\frac {b}{2a}}\right)^{2}=\left(x+{\frac {b}{2a}}\right)^{2}+{\frac {c}{a}}}
or, multiplying through by a,

== Example ==
The best way to learn to complete a square is through an example. Suppose you want to solve the following equation for x.