Using completing squares to solve equations