Completing the square formula