This method uses "Completing the squares." If you are not comfortable with this method then I'd suggest you look at some examples first.
Now complete the square:
There might be a "cooler" way to derive this, but I think this is the most "transparent" method. (The one that clearly shows where everything comes from.)