AP Calculus BC • Integration and Accumulation of Change

Integrating Functions Using Long Division and Completing the Square

Transform rational integrands into recognizable antiderivative forms through algebraic manipulation.

AP Calculus BC illustration with summation, combined graphs, and an orbit
Inside this lesson 10 sections 5 questions 9 figures

SECTION 1

Historical Context & Motivation

The quest to evaluate integrals of rational functions stretches back to the earliest days of calculus. When Newton and Leibniz independently developed the fundamental framework of integration in the late seventeenth century, they quickly encountered rational expressions—quotients of polynomials—that resisted direct antidifferentiation. The challenge was clear: while basic power-rule integrals were straightforward, a rational function like ∫(x³ + 2x)/(x² + 1) dx required algebraic preprocessing before any integration rule could apply. Over the next two centuries, mathematicians systematized a collection of algebraic techniques—including polynomial long division and completing the square—that convert unwieldy integrands into standard forms whose antiderivatives are known.

1670s • Newton & Leibniz Formalize Calculus

Both Newton and Leibniz independently develop the fundamental theorem of calculus, linking differentiation and integration and motivating the search for antiderivatives of increasingly complex functions.

1702 • Leibniz & Bernoulli on Rational Integration

Leibniz and Johann Bernoulli debate the integration of rational functions, leading to early versions of partial fraction decomposition and the recognition that polynomial long division is a necessary first step when the degree of the numerator meets or exceeds that of the denominator.

1768 • Euler's Integral Tables

Euler publishes systematic treatments of integrals involving arctan and logarithmic forms, codifying the standard results that arise after completing the square in quadratic denominators.

1800s • Textbook Codification

Algebraic manipulation techniques—long division, completing the square, and partial fractions—become standard curricular content in calculus courses throughout European and American universities.

The central question these techniques address is deceptively simple: how do we integrate a rational function that does not match any standard form? Long division handles the case where the numerator's degree is at least as large as the denominator's, reducing the integrand to a polynomial plus a proper fraction. Completing the square handles the case where an irreducible quadratic in the denominator must be rewritten to match an arctangent or logarithmic template. Together, these two algebraic tools unlock a wide class of integrals that would otherwise seem impenetrable.

SECTION 2

Core Principles & Definitions

Before diving into computation, it is essential to understand the structural criteria that determine which algebraic technique to apply. A rational function is any function of the form P(x)/Q(x) where P and Q are polynomials. The relationship between the degrees of P and Q dictates the strategy: if deg(P) ≥ deg(Q), perform long division first; if the denominator contains an irreducible quadratic, completing the square converts it into a form amenable to standard inverse-trigonometric or logarithmic antiderivatives.

1

Improper vs. Proper Rational Functions

A rational function P(x)/Q(x) is improper if deg(P) ≥ deg(Q) and proper if deg(P) < deg(Q). Long division converts an improper rational function into a polynomial plus a proper fraction.
2

Polynomial Long Division

Analogous to integer long division, this algorithm divides P(x) by Q(x) to produce a quotient polynomial S(x) and a remainder R(x) such that P(x)/Q(x) = S(x) + R(x)/Q(x), where deg(R) < deg(Q).
3

Completing the Square

This technique rewrites ax² + bx + c as a(x − h)² + k, converting the quadratic into a sum-of-squares form that matches the derivative templates of arctan(x) or ln|x² + a²|.
4

Standard Antiderivative Templates

∫ 1/(x² + a²) dx = (1/a) arctan(x/a) + C and ∫ x/(x² + a²) dx = (1/2) ln(x² + a²) + C. These are the target forms that completing the square enables.
5

Decision Criterion

Always check degree first. If deg(P) ≥ deg(Q), perform long division before any other technique. If the resulting proper fraction has an irreducible quadratic denominator, complete the square.
✦

KEY TAKEAWAY

Think of long division and completing the square as the algebraic "translators" of integration. Just as an engineer converts a complex signal into component frequencies before analyzing it (Fourier decomposition), you convert a complex rational integrand into simpler pieces—polynomials, logarithmic forms, and arctangent forms—before integrating each one. Neither technique is an integration rule itself; each is a preprocessing step that makes the actual integration possible.

SECTION 3

Visual Explanation — The Decision Flowchart

Decision Flowchart: Integrating Rational FunctionsGiven ∫ P(x)/Q(x) dxdeg(P) ≥ deg(Q)?(Improper?)YESPerform LongDivisionS(x) + R(x)/Q(x)integrate S(x); focus on R(x)/Q(x)NOIrreducible quadraticin denominator?YESComplete theSquareNOUse partial fractions / u-sub
This flowchart illustrates the decision process for integrating a rational function P(x)/Q(x). Begin by comparing degrees: if the numerator's degree meets or exceeds the denominator's, long division is mandatory. After obtaining a proper fraction, check whether the denominator contains an irreducible quadratic; if so, completing the square converts it into a standard arctangent or logarithmic template.

The flowchart above encodes the essential decision logic. Notice that long division and completing the square are not mutually exclusive—a single integral may require long division followed by completing the square on the resulting proper fraction. The key is to proceed sequentially: reduce the degree first, then transform the denominator's structure. This systematic approach ensures you never waste time attempting to integrate an expression that hasn't yet been simplified into a recognizable template.

SECTION 4

Mathematical Framework

Polynomial Long Division for Integration

Given a rational function P(x)/Q(x) with deg(P) ≥ deg(Q), polynomial long division yields a unique quotient S(x) and remainder R(x) satisfying the following identity.

LONG DIVISION IDENTITY

P(x)/Q(x)=S(x)+R(x)/Q(x),deg(R)<deg(Q)P(x)/Q(x) = S(x) + R(x)/Q(x), deg(R) < deg(Q)

S(x) is the quotient polynomial, R(x) is the remainder. The integral splits: ∫ P(x)/Q(x) dx = ∫ S(x) dx + ∫ R(x)/Q(x) dx. The first integral is a straightforward polynomial integral; the second is a proper rational function that may require further techniques.

Completing the Square for Integration

When the denominator of a proper fraction is an irreducible quadratic ax² + bx + c (with b² − 4ac < 0), we rewrite it in the form a(x − h)² + k, which matches the standard arctangent and logarithmic templates. The completing-the-square transformation is given below.

COMPLETING THE SQUARE

ax2+bx+c=a(x+b/(2a))2+(c−b2/(4a))ax² + bx + c = a(x + b/(2a))² + (c − b²/(4a))

Here h = −b/(2a) and k = c − b²/(4a). The expression (x + b/(2a))² + k/a (when a = 1) directly matches the form x² + a² needed for the arctangent integral.

ARCTANGENT TEMPLATE

∫1/(u2+a2)du=(1/a)arctan(u/a)+C∫ 1/(u² + a²) du = (1/a) arctan(u/a) + C

After completing the square, let u = x + b/(2a) so that du = dx. The resulting integral fits this template directly. This is one of the most frequently tested standard antiderivatives on the AP Calculus BC exam.

LOGARITHMIC TEMPLATE

∫u/(u2+a2)du=(1/2)ln(u2+a2)+C∫ u/(u² + a²) du = (1/2) ln(u² + a²) + C

When the numerator is a linear function of u (not a constant), split it into a part matching the derivative of the denominator and a constant part. The derivative-matching part yields a logarithm; the constant part yields an arctangent.

💡

Splitting a Linear Numerator

For ∫ (Ax + B)/(u² + a²) du, write the numerator as (A/2) · d/du(u² + a²) + (B − A·something). Concretely, if you have ∫ (2x + 5)/(x² + 4) dx, rewrite as ∫ 2x/(x² + 4) dx + ∫ 5/(x² + 4) dx. The first integral yields ln(x² + 4) and the second yields (5/2) arctan(x/2) + C.

SECTION 5

Detailed Breakdown of Each Technique

Long Division: Step-by-Step Procedure

  1. Step 1: Arrange both P(x) and Q(x) in descending powers of x, inserting zero-coefficient placeholders for any missing powers.
  2. Step 2: Divide the leading term of P(x) by the leading term of Q(x) to obtain the first term of the quotient S(x).
  3. Step 3: Multiply Q(x) by this term and subtract from P(x). The result is the new dividend.
  4. Step 4: Repeat until the degree of the new dividend is strictly less than deg(Q). The accumulated terms form S(x); the final dividend is R(x).
Long Division Example: (x³ + 3x² + 5x + 4) ÷ (x + 1)x² + 2x + 3x + 1x³ + 3x² + 5x + 4← dividend−(x³ + x²)← x² × (x+1)2x² + 5x−(2x² + 2x)← 2x × (x+1)3x + 4−(3x + 3)← 3 × (x+1)1← remainderResult:(x³ + 3x² + 5x + 4)/(x + 1) = x² + 2x + 3 + 1/(x + 1)Integral:∫ = x³/3 + x² + 3x + ln|x + 1| + C
This diagram traces each step of dividing x³ + 3x² + 5x + 4 by x + 1. Each subtraction (shown in color) corresponds to one term of the quotient. The remainder 1 produces the proper fraction 1/(x + 1), whose antiderivative is ln|x + 1|.

Completing the Square: Step-by-Step Procedure

  1. Step 1: Factor the leading coefficient a from the x² and x terms: a(x² + (b/a)x) + c.
  2. Step 2: Take half the coefficient of x inside the parentheses, square it, and add and subtract it: a(x² + (b/a)x + (b/(2a))² − (b/(2a))²) + c.
  3. Step 3: Rewrite the perfect square trinomial: a(x + b/(2a))² + (c − b²/(4a)). Identify u = x + b/(2a) and k² = (c − b²/(4a))/a.
  4. Step 4: Substitute u into the integral and apply the arctangent or logarithmic template as appropriate.
Integrand Form After Completing the SquareAntiderivative
∫ 1/((x − h)² + k²) dx(1/k) arctan((x − h)/k) + C
∫ (x − h)/((x − h)² + k²) dx(1/2) ln((x − h)² + k²) + C
∫ 1/√(k² − (x − h)²) dxarcsin((x − h)/k) + C

Standard antiderivative forms obtained after completing the square

SECTION 6

Worked Examples

Example 1: Long Division Followed by Integration

Evaluate ∫ (x³ − 2x + 4)/(x² + 1) dx

  1. 1

    Step 1 — Check Degrees

    The numerator has degree 3 and the denominator has degree 2. Since deg(P) = 3 ≥ deg(Q) = 2, we must perform polynomial long division first.
  2. 2

    Step 2 — Perform Long Division

    Divide x³ − 2x + 4 by x² + 1. Note the missing x² term in the dividend, so write it as x³ + 0x² − 2x + 4. The leading term x³ ÷ x² = x. Multiply: x(x² + 1) = x³ + x. Subtract: (x³ + 0x² − 2x + 4) − (x³ + 0x² + x + 0) = −3x + 4. Since deg(−3x + 4) = 1 < deg(x² + 1) = 2, we stop.
    (x³ − 2x + 4)/(x² + 1) = x + (−3x + 4)/(x² + 1)
  3. 3

    Step 3 — Integrate the Polynomial Part

    ∫ x dx = x²/2.
    x²/2
  4. 4

    Step 4 — Integrate the Proper Fraction

    Split ∫ (−3x + 4)/(x² + 1) dx = −3 ∫ x/(x² + 1) dx + 4 ∫ 1/(x² + 1) dx. For the first integral, note that d/dx(x² + 1) = 2x, so ∫ x/(x² + 1) dx = (1/2) ln(x² + 1). For the second integral, use the standard form ∫ 1/(x² + 1) dx = arctan(x).
    −3 · (1/2) ln(x² + 1) + 4 arctan(x) = −(3/2) ln(x² + 1) + 4 arctan(x)
  5. 5

    Step 5 — Combine Results

    Add the polynomial integral and the proper fraction integral together.
    ∫ (x³ − 2x + 4)/(x² + 1) dx = x²/2 − (3/2) ln(x² + 1) + 4 arctan(x) + C

Example 2: Completing the Square for Integration

Evaluate ∫ 1/(x² + 6x + 13) dx

  1. 1

    Step 1 — Verify Proper Fraction

    The numerator is 1 (degree 0) and the denominator is x² + 6x + 13 (degree 2). Since 0 < 2, this is already a proper fraction. No long division needed.
  2. 2

    Step 2 — Check the Discriminant

    Compute b² − 4ac = 36 − 52 = −16 < 0. The quadratic is irreducible over the reals, so we must complete the square.
  3. 3

    Step 3 — Complete the Square

    x² + 6x + 13 = (x² + 6x + 9) + 4 = (x + 3)² + 4 = (x + 3)² + 2².
    x² + 6x + 13 = (x + 3)² + 2²
  4. 4

    Step 4 — Apply the Arctangent Template

    Let u = x + 3, so du = dx. The integral becomes ∫ 1/(u² + 2²) du = (1/2) arctan(u/2) + C. Substituting back gives the result.
    ∫ 1/(x² + 6x + 13) dx = (1/2) arctan((x + 3)/2) + C

SECTION 7

Strengths, Limitations & When to Use Each Technique

CriterionLong DivisionCompleting the Square
When to Usedeg(P) ≥ deg(Q)Irreducible quadratic in the denominator of a proper fraction
OutputPolynomial + proper fractionExpression matching arctan or arcsin template
StrengthsMechanical, always works for improper fractions; no judgment calls requiredUnlocks inverse trig integrals; essential when partial fractions aren't applicable
LimitationsOnly reduces degree; doesn't resolve the resulting proper fraction aloneOnly applies to quadratics; higher-degree denominators require factoring first
Common ErrorsForgetting to include zero-coefficient placeholders; sign errors during subtractionArithmetic mistakes computing b²/(4a); forgetting to substitute back for x

Comparison of the two algebraic preprocessing techniques for integration

✦

KEY TAKEAWAY

Long division and completing the square are complementary, not competing, tools. Think of them like different surgical instruments in an operating room: long division is the scalpel that removes the "excess" polynomial tissue (the improper part), while completing the square is the precision forceps that reshape the remaining quadratic into an operable form. In a single integral you may need both—first the scalpel, then the forceps.

SECTION 8

Connection to Partial Fractions and Advanced Techniques

Long division and completing the square serve as the gateway to a more powerful technique: partial fraction decomposition. In the AP Calculus BC curriculum, partial fractions apply exclusively to proper rational functions—which is precisely why long division is a prerequisite skill. When the denominator factors into distinct linear factors, partial fractions alone suffice; when the denominator contains irreducible quadratic factors, completing the square becomes essential during the integration of the resulting terms. Thus, the techniques covered in this lesson are not merely stand-alone tools but foundational components of the full partial-fraction integration pipeline.

FeatureLong Division / Completing the SquarePartial Fraction Decomposition
ScopeAlgebraic preprocessing; transforms integrand structureDecomposition of proper fractions into simpler addends
When UsedBefore decomposition; whenever degree condition or irreducible quadratic is presentAfter long division; when the denominator factors into two or more distinct factors
ResultPolynomial + proper fraction, or expression matching arctan/ln templateSum of simpler fractions: A/(x − r), (Bx + C)/(x² + bx + c), etc.
AP Exam NoteFrequently tested as an embedded step within a larger integration problemBC-only topic; often combined with these preprocessing techniques in free-response questions

How this lesson's techniques relate to partial fraction decomposition

Looking ahead, these same algebraic skills appear in contexts beyond rational integration. In series analysis, long division of power series produces Maclaurin expansions of rational functions. In differential equations, completing the square arises when solving second-order linear ODEs with constant coefficients via Laplace transforms. Mastering these techniques here creates transferable algebraic fluency that will serve you throughout the rest of the AP Calculus BC curriculum and into college-level mathematics.

SECTION 9

Practice Problems

Question 1: CONCEPTUAL

Which of the following is the correct first step when evaluating ∫ (x⁴ + x)/(x² − 3) dx?
  • A. Apply partial fraction decomposition to the integrand.
  • B. Perform polynomial long division because the degree of the numerator exceeds the degree of the denominator.
  • C. Complete the square on x² − 3.
  • D. Use the substitution u = x² − 3.
  • E. Factor x⁴ + x as x(x³ + 1) and cancel common factors with the denominator.
Show answer (B)
B is correct. The numerator has degree 4 and the denominator has degree 2, making this an improper rational function. The mandatory first step is polynomial long division to reduce it to a polynomial plus a proper fraction. A is wrong because partial fractions require a proper fraction as input. C is wrong because x² − 3 is not an irreducible quadratic (it factors as (x − √3)(x + √3) over the reals), and completing the square does not address the improper-fraction issue. D is wrong because u-substitution does not resolve the degree mismatch; du = 2x dx does not cleanly cancel the numerator. E is wrong because x⁴ + x and x² − 3 share no common factors, so cancellation is impossible.

Question 2: BASIC CALCULATION

Evaluate ∫ (x² + 3)/(x − 1) dx.
  • A. x²/2 + x + 4 ln|x − 1| + C
  • B. x²/2 + x + 3 ln|x − 1| + C
  • C. x²/2 − x + 4 ln|x − 1| + C
  • D. x²/2 + x − 4 ln|x − 1| + C
  • E. x² + x + 4 ln|x − 1| + C
Show answer (A)
A is correct. Performing long division: x² + 3 divided by x − 1 gives quotient x + 1 with remainder 4. So (x² + 3)/(x − 1) = x + 1 + 4/(x − 1). Integrating term by term: ∫ x dx = x²/2, ∫ 1 dx = x, and ∫ 4/(x − 1) dx = 4 ln|x − 1|. Combined: x²/2 + x + 4 ln|x − 1| + C. B is wrong because it uses the constant 3 from the original numerator instead of the correct remainder 4. C is wrong because the quotient term is +x, not −x. D is wrong because the coefficient of the logarithm is positive (remainder +4, not −4). E is wrong because ∫ x dx = x²/2, not x².

Question 3: INTERMEDIATE

Evaluate ∫ 1/(x² − 4x + 8) dx.
  • A. (1/2) arctan((x − 2)/2) + C
  • B. arctan((x − 2)/2) + C
  • C. (1/4) arctan((x − 2)/4) + C
  • D. (1/2) arctan((x + 2)/2) + C
  • E. (1/2) ln(x² − 4x + 8) + C
Show answer (A)
A is correct. Complete the square: x² − 4x + 8 = (x² − 4x + 4) + 4 = (x − 2)² + 2². Let u = x − 2, du = dx. Then ∫ 1/(u² + 4) du = (1/2) arctan(u/2) + C = (1/2) arctan((x − 2)/2) + C. B is wrong because it omits the 1/a = 1/2 factor from the arctangent formula. C is wrong because it uses a = 4 instead of a = 2; the completed-square constant is 4 = 2², so a = 2. D is wrong because the shift is x − 2, not x + 2; the vertex is at x = 2 since −b/(2a) = 4/2 = 2. E is wrong because a logarithmic result requires the numerator to match the derivative of the denominator (which would be 2x − 4, not 1).

Question 4: APPLIED

5 pts
A particle moves along the x-axis with velocity v(t) = (2t³ + t² − 3t + 5)/(t² + 1) meters per second for t ≥ 0. (a) Perform polynomial long division to rewrite v(t) as the sum of a polynomial and a proper rational function. (2 points) (b) Find the position function x(t) given that x(0) = 0. Express your answer in exact form. (3 points)
Show answer
Rubric (5 points total): (a) Long Division — 2 points • 1 point: Correctly performing the long division of 2t³ + t² − 3t + 5 by t² + 1 to obtain quotient 2t + 1. • 1 point: Correctly identifying the remainder −5t + 4, so v(t) = 2t + 1 + (−5t + 4)/(t² + 1). Division: 2t³ ÷ t² = 2t. Multiply: 2t(t² + 1) = 2t³ + 2t. Subtract: (2t³ + t² − 3t + 5) − (2t³ + 2t) = t² − 5t + 5. Next: t² ÷ t² = 1. Multiply: 1(t² + 1) = t² + 1. Subtract: (t² − 5t + 5) − (t² + 1) = −5t + 4. Result: v(t) = 2t + 1 + (−5t + 4)/(t² + 1). (b) Integration — 3 points • 1 point: Correctly integrating the polynomial part: ∫(2t + 1) dt = t² + t. • 1 point: Correctly splitting and integrating the proper fraction: ∫(−5t + 4)/(t² + 1) dt = −(5/2) ln(t² + 1) + 4 arctan(t). The −5t part uses the logarithmic template since d/dt(t² + 1) = 2t, and the +4 part uses the arctangent template. • 1 point: Applying the initial condition x(0) = 0 to determine C and stating the final answer. At t = 0: 0 + 0 − (5/2) ln(1) + 4 arctan(0) + C = 0, so C = 0. Final answer: x(t) = t² + t − (5/2) ln(t² + 1) + 4 arctan(t).

Question 5: CRITICAL THINKING

3 pts
Evaluate ∫ (x² + 2x + 3)/(x² + 2x + 5) dx. Your solution must clearly indicate where long division and completing the square are each used.
Show answer
Rubric (3 points total): • 1 point: Recognizing that deg(P) = deg(Q) = 2 and performing long division. Dividing x² + 2x + 3 by x² + 2x + 5: the leading terms give quotient 1. Multiply: 1 · (x² + 2x + 5) = x² + 2x + 5. Subtract: (x² + 2x + 3) − (x² + 2x + 5) = −2. Thus (x² + 2x + 3)/(x² + 2x + 5) = 1 − 2/(x² + 2x + 5). • 1 point: Completing the square on x² + 2x + 5 = (x + 1)² + 4 = (x + 1)² + 2², and setting up the arctangent integral. • 1 point: Correctly evaluating the final integral: ∫ 1 dx − 2 ∫ 1/((x + 1)² + 4) dx = x − 2 · (1/2) arctan((x + 1)/2) + C = x − arctan((x + 1)/2) + C. This problem requires both techniques in a single integral: long division because the degrees are equal (deg(P) = deg(Q)), and completing the square because x² + 2x + 5 is irreducible (discriminant = 4 − 20 = −16 < 0).

SUMMARY

Lesson Summary

Summary

When faced with an integral of a rational function P(x)/Q(x), the first diagnostic question is always about degree comparison: if deg(P) ≥ deg(Q), apply polynomial long division to express the integrand as S(x) + R(x)/Q(x) with deg(R) < deg(Q). The polynomial part S(x) integrates immediately via the power rule. For the proper fraction R(x)/Q(x), examine the denominator: if it contains an irreducible quadratic (negative discriminant), apply completing the square to rewrite it in the form (x − h)² + k², which directly matches the arctangent template ∫ 1/(u² + a²) du = (1/a) arctan(u/a) + C or the logarithmic template when the numerator contains the derivative of the denominator.

These two techniques are not standalone integration methods but rather algebraic preprocessing steps that convert integrands into recognizable forms. They are foundational to the broader technique of partial fraction decomposition tested on the AP Calculus BC exam. Remember the decision flowchart: check degrees first (long division if needed), then inspect the denominator's factorization (completing the square for irreducible quadratics). Mastery of these skills ensures you can integrate any rational function systematically.

Varsity Tutors • AP Calculus BC • Integrating Functions Using Long Division and Completing the Square