01 / 21
∫

Integration:
Long Division & Completing the Square

Master two powerful algebraic techniques that simplify complex rational integrands into forms you already know how to integrate.

AP Calculus

Why Algebraic Prep Before Integrating?

Not every integrand is ready for a direct formula. When you face a rational function where the numerator's degree is greater than or equal to the denominator's (i.e., \(\deg(P) \geq \deg(D)\)), or a quadratic in the denominator that isn't a perfect square, you need to rewrite before you integrate.

What is Polynomial Long Division?

When you have \(\displaystyle\int \frac{P(x)}{D(x)}\,dx\) and \(\deg(P) \geq \deg(D)\), the fraction is called improper. Polynomial long division rewrites it as:

Now \(Q(x)\) is a simple polynomial you integrate with the power rule, and \(\frac{R(x)}{D(x)}\) is a proper fraction: often a logarithm or arctangent form.

What is Completing the Square?

When the denominator contains an irreducible quadratic like \(x^2 + bx + c\), completing the square rewrites it as:

This produces the form \(u^2 + a^2\), which unlocks the arctangent integration formula: \(\displaystyle\int \frac{du}{u^2+a^2} = \frac{1}{a}\arctan\!\left(\frac{u}{a}\right)+C\).

The Two Key Formulas

Natural Log Form
\(\displaystyle\int \frac{1}{u}\,du = \ln|u|+C\)

Used after long division leaves a linear denominator.
Arctangent Form
\(\displaystyle\int \frac{du}{u^2+a^2} = \frac{1}{a}\arctan\!\left(\frac{u}{a}\right)+C\)

Used after completing the square produces \(u^2+a^2\).

When to Use Which Technique?

Long Division Completing the Square
Trigger \(\deg(\text{num}) \geq \deg(\text{den})\) Irreducible quadratic \(ax^2+bx+c\) in denominator
Goal Split into polynomial + proper fraction Rewrite as \(u^2+a^2\) form
Result Power rule + \(\ln\) or \(\arctan\) \(\arctan\) (or \(\ln\) with substitution)
Example \(\frac{x^2}{x+1}\) \(\frac{1}{x^2+4x+8}\)

Decision Flowchart

\(\displaystyle\int\frac{P(x)}{D(x)}\,dx\)
\(\deg(P) \geq \deg(D)\)?
(improper?)
YES Long Division
\(Q(x)+\frac{R(x)}{D(x)}\)
NO Already proper: check denominator also Quadratic in denominator? YES Complete the Square
→ \(\arctan\) form
NO Other methods (PFD, sub...)

Step-by-Step: Long Division

1
Check degrees. Confirm \(\deg(\text{numerator}) \geq \deg(\text{denominator})\).
2
Divide leading terms. Divide the leading term of the numerator by the leading term of the denominator.
3
Multiply and subtract. Multiply the result by the entire denominator, then subtract from the numerator.
4
Repeat until the remainder has a lower degree than the denominator.
5
Integrate each piece using power rule, \(\ln\), or \(\arctan\) as needed.

Example 1: \(\displaystyle\int \frac{x^2+3}{x+1}\,dx\)

Step 1: \(\deg(x^2+3)=2 \geq \deg(x+1)=1\) → use long division
Step 2: \(x^2 \div x = x\). Multiply: \(x(x+1)=x^2+x\). Subtract: \((x^2+3)-(x^2+x) = -x+3\)
Step 3: \(-x \div x = -1\). Multiply: \(-1(x+1)=-x-1\). Subtract: \((-x+3)-(-x-1)=4\)
Result: \(\displaystyle\frac{x^2+3}{x+1} = x - 1 + \frac{4}{x+1}\)

Step-by-Step: Completing the Square

1
Identify the quadratic \(ax^2+bx+c\) in the denominator. Factor out \(a\) if \(a \neq 1\).
2
Take half of \(b\), square it. Write \(\left(x+\frac{b}{2}\right)^2 - \frac{b^2}{4} + c\).
3
Simplify to \(u^2+a^2\) form. Let \(u = x+\frac{b}{2}\) and \(a^2 = c - \frac{b^2}{4}\).
4
Apply the arctangent formula: \(\displaystyle\int\frac{du}{u^2+a^2}=\frac{1}{a}\arctan\!\left(\frac{u}{a}\right)+C\).

Example 2: \(\displaystyle\int \frac{dx}{x^2+6x+13}\)

Step 1: Denominator is \(x^2+6x+13\). Here \(b=6\), \(c=13\).
Step 2: Half of 6 is 3. Square it: \(9\). Write: \((x+3)^2 - 9 + 13 = (x+3)^2+4\)
Step 3: Let \(u = x+3\), \(a^2 = 4\), so \(a = 2\).
Step 4: Apply the formula directly.

Example 3: Both Techniques Together

Evaluate \(\displaystyle\int\frac{x^2+2x+3}{x^2+2x+5}\,dx\).

Degree check: \(\deg = 2 = 2\) → long division first
Divide: \(\frac{x^2+2x+3}{x^2+2x+5} = 1 + \frac{-2}{x^2+2x+5}\)
Complete the square: \(x^2+2x+5 = (x+1)^2+4\)
Integrate:

Visualizing Completing the Square

\(x^2 + 6x + 13\)
Original quadratic rewrite
\((x + 3)^2 + 4\)
\(u^2 + a^2\) form
\(u = x + 3\)
substitution variable
\(a^2 = 4,\; a = 2\)
constant term
\(\displaystyle\int\frac{du}{u^2+a^2} = \frac{1}{a}\arctan\!\left(\frac{u}{a}\right)+C\)
\(= \frac{1}{2}\arctan\!\left(\frac{x+3}{2}\right)+C\)

Handling a Linear Numerator

When the numerator is not just a constant, split the integral. For \(\displaystyle\int\frac{2x+5}{x^2+4x+8}\,dx\), rewrite the numerator to match the derivative of the denominator:

Denominator derivative: \(\frac{d}{dx}(x^2+4x+8) = 2x+4\)
Split: \(\frac{2x+5}{x^2+4x+8} = \frac{2x+4}{x^2+4x+8} + \frac{1}{x^2+4x+8}\)
First part: \(\displaystyle\int\frac{2x+4}{x^2+4x+8}\,dx = \ln|x^2+4x+8|+C_1\)
Second part: Complete the square → \(\frac{1}{2}\arctan\!\left(\frac{x+2}{2}\right)+C_2\)

Common Mistakes to Avoid

✕ Skipping Division
Trying to use partial fractions or substitution on an improper fraction. Always divide first when \(\deg(P) \geq \deg(D)\).
✕ Forgetting \(du\)
After completing the square with \(u=x+h\), forgetting that \(du = dx\). The substitution is automatic here, but the shift changes limits in definite integrals.
✕ Wrong Sign in Square
Writing \((x+3)^2+9+13\) instead of \((x+3)^2-9+13\). Remember: you add and subtract \((b/2)^2\).

Summary Reference

Integrand Type Technique Result Form
\(\frac{x^n+\cdots}{x^m+\cdots}\), \(n\geq m\) Long division Polynomial + proper fraction
\(\frac{1}{x^2+bx+c}\) Complete the square \(\frac{1}{a}\arctan\!\left(\frac{u}{a}\right)+C\)
\(\frac{Ax+B}{x^2+bx+c}\) Split + both techniques \(\ln|\cdot| + \arctan(\cdot) + C\)
\(\frac{x^n+\cdots}{x^2+bx+c}\), \(n\geq 2\) Long division, then complete sq. Polynomial + \(\ln\) + \(\arctan\) + \(C\)

Question 1 of 5

What is the first step when evaluating \(\displaystyle\int\frac{x^3+1}{x+2}\,dx\)?

Question 2 of 5

Completing the square on \(x^2 + 8x + 20\) gives:

Question 3 of 5

Evaluate \(\displaystyle\int\frac{x^2}{x-1}\,dx\).

Question 4 of 5

Evaluate \(\displaystyle\int\frac{dx}{x^2+2x+10}\).

Question 5 of 5

To evaluate \(\displaystyle\int\frac{x^2+x+1}{x^2+4x+5}\,dx\), what combination of techniques is needed?