Integrating functions using long division and completing the square