# Integration with long division and completing the square

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

This guide covers two algebraic preprocessing techniques to rewrite rational functions into integrable forms: polynomial long division for improper rational integrands, and completing the square for irreducible quadratic denominators, aligned to AP Calculus BC CED requirements.

**Prerequisites:** Basic integration rules for power, logarithmic, and inverse trigonometric functions; Polynomial algebra (long division, factoring); Derivatives of polynomial and rational functions

## Learning objectives

- Rewrite improper rational integrands using polynomial long division for integration
- Complete the square to rewrite irreducible quadratic denominators for inverse trigonometric integration
- Integrate functions of the form $\frac{mx+n}{ax^2+bx+c}$ where the quadratic is irreducible
- Apply these techniques to solve AP-style exam questions

## Integration of Improper Rational Functions via Polynomial Long Division

A rational function $\frac{P(x)}{Q(x)}$ is improper if $\deg(P(x)) \geq \deg(Q(x))$, and cannot be integrated directly using standard templates. Polynomial long division rewrites the improper integrand as:

$$\frac{P(x)}{Q(x)} = S(x) + \frac{R(x)}{Q(x)}$$

where $S(x)$ is the quotient polynomial, and $R(x)$ is the remainder polynomial with $\deg(R(x)) < \deg(Q(x))$. This is analogous to rewriting an improper fraction like $\frac{15}{4}$ as $3 + \frac{3}{4}$: we separate the whole polynomial part from the proper rational remainder, which can then be integrated with other techniques. The entire expression is integrated term-by-term: $S(x)$ uses the power rule, and $\frac{R(x)}{Q(x)}$ is handled with other methods.

**Worked example:** Evaluate $\int \frac{x^3 - 2x^2 + 3x + 2}{x - 1} dx$.

1. 1. Confirm the integrand is improper: $\deg(\text{numerator}) = 3$, $\deg(\text{denominator}) = 1$, so $3 \geq 1$, requiring long division.
2. 2. Perform polynomial long division, giving quotient $x^2 - x + 2$ and remainder 4. The integrand becomes:
3. $$x^2 - x + 2 + \frac{4}{x - 1}$$
4. 3. Integrate term-by-term using the power rule and natural log rule:
5. $$\int \left(x^2 - x + 2 + \frac{4}{x - 1}\right) dx = \frac{x^3}{3} - \frac{x^2}{2} + 2x + 4 \ln|x - 1| + C$$
6. 4. Verify by differentiating the result, which matches the original integrand.

> **Exam tip:** Always check the degree of the numerator and denominator before starting integration. If $\deg(P) \geq \deg(Q)$, you must do long division first — skipping this step guarantees an incorrect result.

## Completing the Square for Irreducible Quadratic Denominators

After long division (or when starting with a proper rational function), you may encounter an irreducible quadratic denominator $ax^2 + bx + c$, where the discriminant $b^2 - 4ac < 0$, so it cannot be factored into real linear terms. Completing the square rewrites the quadratic to match one of two standard inverse trigonometric integral templates.

To complete the square for $ax^2 + bx + c$: 1. Factor the leading coefficient $a$ out of the first two terms. 2. Add and subtract $\left(\frac{b}{2a}\right)^2$ inside the parentheses to form a perfect square, resulting in $a u^2 + k$ where $u = x + \frac{b}{2a}$. This matches the form needed for substitution into the standard templates:

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

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

**Worked example:** Evaluate $\int \frac{1}{x^2 + 4x + 7} dx$.

1. 1. Check discriminant: $b^2 - 4ac = 16 - 28 = -12 < 0$, so denominator is irreducible over the reals.
2. 2. Complete the square: group $x$-terms, add and subtract $(4/2)^2 = 4$:
3. $$(x^2 + 4x) + 7 = (x^2 + 4x + 4) - 4 + 7 = (x + 2)^2 + 3$$
4. 3. Rewrite integral to match the arctangent template, substitute $u = x+2$, $du = dx$:
5. $$\int \frac{1}{u^2 + (\sqrt{3})^2} du$$
6. 4. Apply the arctangent integral formula:
7. $$\frac{1}{\sqrt{3}} \arctan\left(\frac{x + 2}{\sqrt{3}}\right) + C$$

> **Exam tip:** Always factor out the leading coefficient of the quadratic before completing the square if it is not 1. Forgetting this step gives an incorrect constant term that will not match standard inverse trig forms.

## Integrating Linear Over Irreducible Quadratic Functions

A common AP exam integrand is $\frac{mx + n}{ax^2 + bx + c}$ where the denominator is irreducible. You cannot directly apply inverse trig rules here; instead split the numerator into a multiple of the derivative of the denominator plus a constant. The method is:

1. Let $D(x) = ax^2 + bx + c$, compute $D'(x) = 2ax + b$
2. Write $mx + n = A(2ax + b) + B$, solve for constants $A$ and $B$ by equating coefficients
3. Split the integrand into two terms: $\frac{A D'(x)}{D(x)} + \frac{B}{D(x)}$
4. Integrate the first term with the logarithmic rule, and the second term by completing the square and inverse trig rule

The first term is always of the form $\frac{f'(x)}{f(x)}$, which integrates to $\ln|f(x)|$. Since irreducible quadratics are always positive, you can drop the absolute value bar for simplicity.

**Worked example:** Evaluate $\int \frac{3x + 5}{x^2 + 4x + 8} dx$.

1. 1. Confirm denominator is irreducible: $16 - 32 = -16 < 0$. Let $D(x) = x^2 + 4x + 8$, so $D'(x) = 2x + 4$.
2. 2. Split numerator: $3x + 5 = A(2x + 4) + B$. Equate coefficients: $2A = 3 \implies A = 3/2$, then $4A + B = 5 \implies B = -1$.
3. 3. Split the integral:
4. $$\int \left( \frac{\frac{3}{2}(2x + 4)}{x^2 + 4x + 8} + \frac{-1}{x^2 + 4x + 8} \right) dx$$
5. 4. Integrate the first term with the log rule:
6. $$\frac{3}{2} \ln(x^2 + 4x + 8) + C_1$$
7. 5. Integrate the second term by completing the square: $x^2 + 4x + 8 = (x+2)^2 + 2^2$, so:
8. $$\int \frac{-1}{(x+2)^2 + 2^2} dx = -\frac{1}{2} \arctan\left(\frac{x+2}{2}\right) + C_2$$
9. 6. Combine results to get the final antiderivative:
10. $$\frac{3}{2} \ln(x^2 + 4x + 8) - \frac{1}{2} \arctan\left(\frac{x + 2}{2}\right) + C$$

> **Exam tip:** Always drop the absolute value around an irreducible quadratic in the log term, since the quadratic is always positive and never crosses the x-axis, simplifying your final answer.

## AP-Style Concept Check

**Check your understanding**

Test your understanding of core techniques with this AP-style multiple choice question:

1. Which of the following is the antiderivative of $\frac{2x^2 + 5x - 3}{x + 2}$?

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

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

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

## Common pitfalls

- **Wrong:** Stopping after long division and integrating the quotient but forgetting to add the remainder term over the denominator.
  - Why it fails: Students focus on completing the long division calculation and omit the non-zero remainder, which is present in most problems.
  - Correct: After completing long division, always write the full result: $S(x) + \frac{R(x)}{Q(x)}$ before integrating term-by-term.
- **Wrong:** When the degree of the numerator equals the degree of the denominator, skipping long division and trying to use partial fractions or inverse trig directly.
  - Why it fails: Students think you only need long division when the numerator degree is strictly higher, not equal.
  - Correct: Always check for $\deg(P) \geq \deg(Q)$: if degrees are equal, the condition is satisfied, so perform long division first.
- **Wrong:** When completing the square for $2x^2 + 8x + 15$, writing $(2x^2 + 8x) + 15 = (x + 4)^2 - 16 + 15 = (x + 4)^2 - 1$.
  - Why it fails: The student forgot to factor out the leading coefficient 2 from the x terms before completing the square.
  - Correct: Always factor the leading coefficient out of the first two terms first: $2(x^2 + 4x) + 15 = 2(x+2)^2 + 7$.
- **Wrong:** When integrating $\frac{mx + n}{ax^2 + bx + c}$, trying to use inverse trig directly without splitting the numerator.
  - Why it fails: Students see a quadratic denominator and immediately complete the square, forgetting the linear numerator produces a logarithmic term.
  - Correct: Always split the numerator into a multiple of the derivative of the denominator plus a constant before integrating.
- **Wrong:** When applying the arctangent formula to $\int \frac{1}{(2x + 3)^2 + 16} dx$, stopping at $\frac{1}{4} \arctan\left(\frac{2x + 3}{4}\right) + C$.
  - Why it fails: The student forgot the substitution step for $u = 2x + 3$, which requires accounting for the chain rule factor of 2 from $du = 2 dx$.
  - Correct: After rewriting the quadratic, always do the u-substitution explicitly and carry the constant factor through: the correct result here is $\frac{1}{8} \arctan\left(\frac{2x + 3}{4}\right) + C$.

## Cheatsheet

| Category | Formula/Rule | Notes |
| --- | --- | --- |
| Improper rational function | $\frac{P(x)}{Q(x)}, \deg(P) \geq \deg(Q)$ | Requires long division before integration |
| Long division result | $\frac{P(x)}{Q(x)} = S(x) + \frac{R(x)}{Q(x)}, \deg(R) < \deg(Q)$ | $S(x)$ = quotient, $R(x)$ = remainder |
| Completing the square general form | $ax^2 + bx + c = a\left(x + \frac{b}{2a}\right)^2 + \left(c - \frac{b^2}{4a}\right)$ | Factor out $a$ from $x$ terms first |
| Arctangent integral template | $\int \frac{1}{u^2 + a^2} du = \frac{1}{a} \arctan\left(\frac{u}{a}\right) + C$ | For irreducible quadratic denominators |
| Arcsine integral template | $\int \frac{1}{\sqrt{a^2 - u^2}} du = \arcsin\left(\frac{u}{a}\right) + C$ | For difference of squares under square root |
| Linear numerator split | $mx + n = A(2ax + b) + B, A = \frac{m}{2a}$ | Split before integrating linear over irreducible quadratic |
| Log integral rule | $\int \frac{f'(x)}{f(x)} dx = \ln\|f(x)\| + C$ | Drop absolute value for irreducible quadratics |
| Result for $\frac{mx + n}{ax^2 + bx + c}$ | $A \ln(ax^2 + bx + c) + \frac{B}{k} \arctan\left(\frac{u}{k}\right) + C$ | Log term from split, arctan from completed square |

## What's next

This topic is the critical prerequisite for partial fraction decomposition, the next major technique for integrating rational functions in AP Calculus BC. Partial fraction decomposition only works for proper rational functions, so you must master long division to reduce improper integrands before you can split them into partial fractions. Completing the square is also required to integrate the irreducible quadratic terms that often result from partial fraction decomposition, so this skill will be used repeatedly in the next section of the unit. Beyond integration of rational functions, completing the square appears when rewriting quadratics in polar coordinate and area problems later in the course, and the algebraic manipulation skills from this topic are required for almost all non-basic integration problems on the AP exam.

- [Unit 6 Integration and Accumulation of Change Overview](https://www.owlsprep.com/study/ap-calculus-bc-u6-overview/)
- [Integration by Parts (BC Only)](https://www.owlsprep.com/study/ap-calculus-bc-u6-integration-by-parts/)
- [Integration using partial fractions (BC only)](https://www.owlsprep.com/study/ap-calculus-bc-u6-integration-using-partial-fractions/)

---

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-bc-u6-integration-with-long-division-and/
