# Integration with long division and completing the square

> AP Calculus AB · Unit 6: Integration and Accumulation of Change
> Source: https://www.owlsprep.com/study/ap-calculus-ab-u6-integration-with-long-division-and/

This guide covers algebraic preprocessing techniques for integrating rational functions for AP Calculus AB, including long division for improper rationals and completing the square for irreducible quadratics, with worked examples and exam tips.

**Prerequisites:** Antiderivatives of $1/x$, $1/(a^2+x^2)$, and basic polynomials; Polynomial long division; Completing the square for quadratic functions

## Learning objectives

- Rewrite improper rational functions via polynomial long division for integration
- Rewrite irreducible quadratics via completing the square for integration
- Integrate preprocessed rational functions using known antiderivative rules
- Evaluate definite integrals of rational functions using the Fundamental Theorem of Calculus

## Integration of Improper Rational Functions via Long Division

For a rational function $f(x) = \frac{N(x)}{D(x)}$, if the degree of the numerator $N(x)$ is greater than or equal to the degree of the denominator $D(x)$, the function is called improper. Improper rationals cannot be integrated directly with basic rules, so we use polynomial long division to rewrite them into a form we can integrate.

$$\frac{N(x)}{D(x)} = Q(x) + \frac{R(x)}{D(x)}, \quad \deg(R(x)) < \deg(D(x))$$

Where $Q(x)$ is the quotient polynomial and $R(x)$ is the remainder. By linearity of integration, we can integrate each term separately using rules you already know.

**Worked example:** Evaluate the indefinite integral $\int \frac{x^3 - 2x^2 + 3x - 4}{x + 1} dx$

1. Check degrees: numerator degree is 3, denominator degree is 1. Since $3 \geq 1$, the integrand is improper, so long division is required.
2. Divide $x^3 - 2x^2 + 3x - 4$ by $x + 1$: $x^3 \div x = x^2$, multiply $x^2(x+1) = x^3 + x^2$, subtract to get $-3x^2 + 3x$. Next, $-3x^2 \div x = -3x$, multiply $-3x(x+1) = -3x^2 - 3x$, subtract to get $6x - 4$. Next, $6x \div x = 6$, multiply $6(x+1) = 6x + 6$, subtract to get remainder $-10$. Result:
3. $$\frac{x^3 - 2x^2 + 3x - 4}{x + 1} = x^2 - 3x + 6 - \frac{10}{x+1}$$
4. Split the integral by linearity of integration:
5. $$\int \left(x^2 - 3x + 6 - \frac{10}{x+1}\right) dx = \int x^2 dx - 3\int x dx + 6\int 1 dx - 10\int \frac{1}{x+1} dx$$
6. Integrate term-by-term to get the final antiderivative:
7. $$\frac{x^3}{3} - \frac{3x^2}{2} + 6x - 10\ln|x+1| + C$$

> **tip**
>
> Always check the degrees of numerator and denominator before starting integration. Skipping this step and trying u-substitution will waste time and lead to incorrect answers on exam day.

*Calculator:* forbidden

## Completing the Square for Irreducible Quadratics

When you have a proper rational function with a quadratic denominator, first calculate the discriminant $b^2 - 4ac$. If the discriminant is negative, the quadratic is irreducible (cannot be factored over the reals), so we use completing the square to rewrite it to match the inverse tangent antiderivative form.

1. Factor the leading coefficient $a$ out of the first two terms: $a\left(x^2 + \frac{b}{a}x\right) + c$
2. Add and subtract $\left(\frac{b}{2a}\right)^2$ inside the parentheses: $a\left[\left(x + \frac{b}{2a}\right)^2 - \left(\frac{b}{2a}\right)^2\right] + c$
3. Simplify the constant term: $a(x+h)^2 + k$, where $h = \frac{b}{2a}$ and $k = c - \frac{b^2}{4a}$

$$\int \frac{1}{u^2 + a^2} du = \frac{1}{a} \arctan\left(\frac{u}{a}\right) + C$$

**Worked example:** Evaluate the indefinite integral $\int \frac{x + 5}{x^2 + 4x + 8} dx$

1. Check the discriminant of the denominator: $b^2 - 4ac = 4^2 - 4(1)(8) = -16 < 0$, so the quadratic is irreducible, complete the square.
2. Complete the square on the denominator:
3. $$x^2 + 4x + 8 = (x^2 + 4x + 4) + (8 - 4) = (x + 2)^2 + 2^2$$
4. The derivative of the denominator is $2x + 4 = 2(x+2)$, so rewrite the numerator as $x + 5 = (x + 2) + 3$, then split the integral:
5. $$\int \frac{(x+2) + 3}{(x+2)^2 + 4} dx = \int \frac{x+2}{(x+2)^2 + 4} dx + 3\int \frac{1}{(x+2)^2 + 4} dx$$
6. Integrate the first term with substitution: the quadratic is always positive, so we drop the absolute value, giving $\frac{1}{2}\ln(x^2 + 4x + 8) + C_1$.
7. Integrate the second term using the inverse tangent rule:
8. $$3\int \frac{1}{w^2 + 2^2} dw = \frac{3}{2}\arctan\left(\frac{x+2}{2}\right) + C_2$$
9. Combine terms to get the final antiderivative:
10. $$\frac{1}{2}\ln(x^2 + 4x + 8) + \frac{3}{2}\arctan\left(\frac{x+2}{2}\right) + C$$

> **tip**
>
> AP Calculus AB only tests this technique for irreducible quadratics; partial fractions for factorable quadratics is BC-only content. A negative discriminant confirms you should use completing the square here.

*Calculator:* forbidden

## Evaluating Definite Integrals

Most AP exam questions on this topic ask for a definite integral, which combines the algebraic preprocessing above with the Fundamental Theorem of Calculus, Part 2 (FTC 2): $\int_a^b f(x) dx = F(b) - F(a)$, where $F(x)$ is any antiderivative of $f(x)$. Always confirm the integrand is continuous over the entire interval of integration.

**Worked example:** Evaluate the definite integral $\int_0^2 \frac{x^2 + 2x + 2}{x + 1} dx$

1. Check degrees: numerator degree 2 > denominator degree 1, so long division is required.
2. Divide to get the simplified integrand:
3. $$\frac{x^2 + 2x + 2}{x + 1} = x + 1 + \frac{1}{x+1}$$
4. Find the antiderivative (we can ignore the constant of integration for definite integrals): $F(x) = \frac{x^2}{2} + x + \ln|x+1|$
5. Apply FTC 2 and simplify known values:
6. $$F(2) - F(0) = \left(\frac{4}{2} + 2 + \ln 3\right) - \left(0 + 0 + \ln 1\right) = 4 + \ln 3$$

> **tip**
>
> Simplify known values like $\ln(1) = 0$ and $\arctan(0) = 0$ immediately to reduce arithmetic errors.

*Calculator:* forbidden

## AP-Style Concept Check

**Check your understanding**

Test your understanding with these AP-style questions:

1. Which of the following is the antiderivative of $\int \frac{2x^2 + 5x + 9}{x + 2} dx$?

   - $x^2 + x - 7 \ln|x + 2| + C$
   - $2x + 1 + \frac{7}{x + 2} + C$
   - $\frac{x^3}{3} + \frac{x^2}{2} + 7 + C$
   - $x^2 + x + 7 \ln|x + 2| + C$

   *Answer:* $x^2 + x + 7 \ln|x + 2| + C$

   *Why:* Correct: After long division, the integrand simplifies to $2x + 1 + \frac{7}{x+2}$, which integrates to this result.

2. What is the exact value of $\int_0^2 \frac{x^3 - 2x^2 + x}{x^2 - 2x + 2} dx$?

   - $2 + \frac{\pi}{2}$
   - $2 - \frac{\pi}{2}$
   - $\frac{\pi}{2} - 2$
   - $-2 - \frac{\pi}{2}$

   *Answer:* $2 - \frac{\pi}{2}$

   *Why:* Correct: After long division, completing the square, and applying FTC 2, the exact value is $2 - \frac{\pi}{2}$.

*Calculator:* forbidden

## Common pitfalls

- **Wrong:** Forgetting to check numerator/denominator degrees, trying u-substitution directly on $\frac{x^2 + 3x + 2}{x + 1}$
  - Why it fails: Students rush into integration without checking the form, assuming all rational functions work with u-substitution
  - Correct: Always compare degrees first; if numerator degree ≥ denominator degree, do long division first
- **Wrong:** Incorrectly completing the square for $2x^2 + 4x + 5$ as $2(x+1)^2 + 5$ instead of $2(x+1)^2 + 3$
  - Why it fails: Students forget to multiply the subtracted constant by the leading coefficient when moving it outside parentheses
  - Correct: After completing the square inside the parentheses, multiply the subtracted constant by the leading coefficient before adding to the trailing constant
- **Wrong:** Splitting $\frac{x + 5}{(x + 2)^2 + 4}$ as $\frac{x}{(x + 2)^2 + 4} + \frac{5}{(x + 2)^2 + 4}$ instead of $\frac{(x+2) + 3}{(x + 2)^2 + 4}$
  - Why it fails: Students do not match the numerator to the derivative of the denominator, leading to an unsolvable integral
  - Correct: Always rewrite the linear numerator as a multiple of the $(x+h)$ term from completing the square, plus a constant remainder
- **Wrong:** Writing the antiderivative of $\frac{1}{(x+h)^2 + k^2}$ as $k \arctan\left(\frac{x+h}{k}\right) + C$ instead of $\frac{1}{k} \arctan\left(\frac{x+h}{k}\right) + C$
  - Why it fails: Students mix up derivative and integral rules for inverse tangent
  - Correct: Quickly differentiate your antiderivative to confirm it matches the original integrand
- **Wrong:** Reversing bounds when applying FTC 2, calculating $F(a) - F(b)$ instead of $F(b) - F(a)$
  - Why it fails: Students rush on exam day and misremember the order of subtraction
  - Correct: Always write 'F(upper) minus F(lower)' explicitly on your paper before calculating

## Cheatsheet

| Category | Formula/Rule | Notes |
| --- | --- | --- |
| Improper Rational Division | $\frac{N(x)}{D(x)} = Q(x) + \frac{R(x)}{D(x)}, \deg(R) < \deg(D)$ | Use when $\deg(N) \geq \deg(D)$ |
| Integral of $1/u$ | $\int \frac{1}{u} du = \ln\|u\| + C$ | Keep absolute value unless argument is always positive |
| Completing the Square | $ax^2 + bx + c = a\left(x + \frac{b}{2a}\right)^2 + \left(c - \frac{b^2}{4a}\right)$ | Use for irreducible quadratics with negative discriminant |
| Inverse Tangent Integral | $\int \frac{1}{u^2 + a^2} du = \frac{1}{a} \arctan\left(\frac{u}{a}\right) + C$ | Use after completing the square for irreducible denominators |
| Split Linear Numerator | $\frac{mx + n}{(x+h)^2 + k^2} = \frac{(x+h) + C}{(x+h)^2 + k^2}$ | Rewrite to split into a log term and an arctan term |
| FTC for Definite Integrals | $\int_a^b f(x) dx = F(b) - F(a)$ | Always subtract lower bound from upper bound |
| Drop Absolute Value for Quadratics | $\ln\|ax^2 + bx + c\| = \ln(ax^2 + bx + c)$ | Only valid if discriminant is negative (quadratic is always positive) |

## What's next

This topic builds critical algebraic fluency for all integration problems involving rational functions, a core skill for AP Calculus AB. Mastery of long division and completing the square ensures you can rewrite any rational function that cannot be integrated as-written into a sum of simpler functions whose antiderivatives you already know. These skills are required for many higher-weighted topics on the AP exam, including differential equations, area between curves, and volumes of solids of revolution. Without solid command of these preprocessing steps, you will be unable to solve many accumulation, area, and differential equation problems that appear regularly on both multiple-choice and free-response sections.

- [Selecting techniques for antidifferentiation](https://www.owlsprep.com/study/ap-calculus-ab-u6-selecting-techniques-for-antidifferentiation/)
- [Differential Equations Overview](https://www.owlsprep.com/study/ap-calculus-ab-u7-overview/)
- [Modeling situations with differential equations](https://www.owlsprep.com/study/ap-calculus-ab-u7-modeling-situations-with-differential-equations/)

---

From [OwlsPrep](https://www.owlsprep.com) — free study guides for A-Level, IB, AP and IGCSE, written against the official syllabus. Canonical page: https://www.owlsprep.com/study/ap-calculus-ab-u6-integration-with-long-division-and/
