Completing the square for x2 terms