Solving an equation by completing the square