Calculus · Grade 12 and undergraduate

Integrating with Long Division and Completing the Square

Quick answer

Some integrands match no rule until they are rewritten. When a rational function's numerator has degree at least that of its denominator, long division splits it into a polynomial plus a proper fraction: (x² + 1)/(x + 1) = x − 1 + 2/(x + 1). When a quadratic denominator has no real roots, completing the square turns it into u² + a², and ∫ du/(u² + a²) = (1/a) arctan(u/a) + C. Both steps are algebra done before the calculus starts.

What you'll learn

  • Use long division to integrate a top-heavy rational function
  • Complete the square in a quadratic denominator
  • Integrate 1/(u² + a²) with the arctangent
  • Split a linear numerator into a logarithm part and an arctangent part

Rewrite first, then integrate

The integral ∫x2+1x+1 dx\int \tfrac{x^2 + 1}{x + 1}\,dx matches no rule: the numerator is not the derivative of the denominator, and there is no quotient rule for integrals. The way in is algebra. Rewrite the integrand as a sum of pieces that each match a rule, then integrate the pieces.

Two rewrites handle most fractions of polynomials: long division and completing the square.

Long division

When the numerator’s degree is at least the denominator’s, divide:

x2+1x+1=x−1+2x+1\frac{x^2 + 1}{x + 1} = x - 1 + \frac{2}{x + 1}

Check by multiplying back: (x+1)(x−1)+2=x2+1(x + 1)(x - 1) + 2 = x^2 + 1. Each piece now integrates on sight.

Why dividing is the right move

A fraction whose numerator is at least as big as its denominator is like the improper fraction 73\tfrac{7}{3}, which is 2+132 + \tfrac{1}{3}. Division splits off the whole part, a polynomial, which integrates term by term. What remains has a numerator of lower degree than its denominator, and that is the shape the log rule, substitution and the arctangent need. Divide until the numerator’s degree is less than the denominator’s; then integrate.

Completing the square

A quadratic denominator with no real roots, such as x2+4x+5x^2 + 4x + 5, cannot be factored. Complete the square instead: x2+4x+5=(x+2)2+1x^2 + 4x + 5 = (x + 2)^2 + 1. With u=x+2u = x + 2, the integral becomes one the arctangent answers:

∫duu2+1=arctan⁡u+C∫duu2+a2=1aarctan⁡ua+C\int \frac{du}{u^2 + 1} = \arctan u + C \qquad\qquad \int \frac{du}{u^2 + a^2} = \frac{1}{a}\arctan\frac{u}{a} + C

The second form follows from the first with u=awu = aw.

Completing the square is a shift Two bell-shaped curves of the same shape and height 1. The dashed one, y = 1/(x² + 1), peaks at x = 0. The solid one, y = 1/(x² + 4x + 5), is the same curve moved 2 units left, peaking at x = −2. -4-221xy
  • y = 1/(x² + 1)
  • y = 1/((x + 2)² + 1)
Completing the square is a shift

The graph shows why this works: 1(x+2)2+1\tfrac{1}{(x + 2)^2 + 1} is the curve 1x2+1\tfrac{1}{x^2 + 1} moved 22 units left, so its antiderivative is arctan⁡x\arctan x moved 22 units left, arctan⁡(x+2)\arctan(x + 2).

Worked examples

Common mistakes

Practice problems

  1. Find ∫x2+3x+2x+1 dx\displaystyle\int \frac{x^2 + 3x + 2}{x + 1}\,dx.

    Answer

    x22+2x+C\tfrac{x^2}{2} + 2x + C

    Full solution

    The numerator factors: x2+3x+2=(x+1)(x+2)x^2 + 3x + 2 = (x + 1)(x + 2), so the fraction is x+2x + 2 (for x≠−1x \ne -1).

  2. Find ∫xx+2 dx\displaystyle\int \frac{x}{x + 2}\,dx.

    Answer

    x−2ln⁡∣x+2∣+Cx - 2\ln\lvert x + 2 \rvert + C

    Full solution

    xx+2=(x+2)−2x+2=1−2x+2\tfrac{x}{x + 2} = \tfrac{(x + 2) - 2}{x + 2} = 1 - \tfrac{2}{x + 2}.

  3. Find ∫x3−1x−1 dx\displaystyle\int \frac{x^3 - 1}{x - 1}\,dx.

    Answer

    x33+x22+x+C\tfrac{x^3}{3} + \tfrac{x^2}{2} + x + C

    Full solution

    Dividing gives x3−1=(x−1)(x2+x+1)x^3 - 1 = (x - 1)(x^2 + x + 1), so the integrand is x2+x+1x^2 + x + 1.

  4. Find ∫2x2+1x2+1 dx\displaystyle\int \frac{2x^2 + 1}{x^2 + 1}\,dx.

    Answer

    2x−arctan⁡x+C2x - \arctan x + C

    Full solution

    2x2+1x2+1=2(x2+1)−1x2+1=2−1x2+1\tfrac{2x^2 + 1}{x^2 + 1} = \tfrac{2(x^2 + 1) - 1}{x^2 + 1} = 2 - \tfrac{1}{x^2 + 1}.

  5. Find ∫dxx2+2x+2\displaystyle\int \frac{dx}{x^2 + 2x + 2}.

    Answer

    arctan⁡(x+1)+C\arctan(x + 1) + C

    Full solution

    x2+2x+2=(x+1)2+1x^2 + 2x + 2 = (x + 1)^2 + 1.

  6. Find ∫dxx2+9\displaystyle\int \frac{dx}{x^2 + 9}.

    Answer

    13arctan⁡x3+C\tfrac{1}{3}\arctan\tfrac{x}{3} + C

    Full solution

    Use ∫duu2+a2=1aarctan⁡ua+C\int \tfrac{du}{u^2 + a^2} = \tfrac{1}{a}\arctan\tfrac{u}{a} + C with a=3a = 3.

  7. Find ∫dxx2−4x+8\displaystyle\int \frac{dx}{x^2 - 4x + 8}.

    Answer

    12arctan⁡x−22+C\tfrac{1}{2}\arctan\tfrac{x - 2}{2} + C

    Full solution

    x2−4x+8=(x−2)2+4x^2 - 4x + 8 = (x - 2)^2 + 4, so u=x−2u = x - 2 and a=2a = 2.

  8. Evaluate ∫01dxx2+1\displaystyle\int_0^1 \frac{dx}{x^2 + 1}.

    Answer

    π4\tfrac{\pi}{4}

    Full solution

    arctan⁡1−arctan⁡0=π4−0\arctan 1 - \arctan 0 = \tfrac{\pi}{4} - 0.

  9. Find ∫2x+2x2+2x+5 dx\displaystyle\int \frac{2x + 2}{x^2 + 2x + 5}\,dx.

    Answer

    ln⁡(x2+2x+5)+C\ln\left(x^2 + 2x + 5\right) + C

    Full solution

    The numerator is the derivative of the denominator, so substitute u=x2+2x+5u = x^2 + 2x + 5. No arctangent is needed. The absolute value can go, since x2+2x+5=(x+1)2+4>0x^2 + 2x + 5 = (x + 1)^2 + 4 > 0.

  10. A student writes ∫dxx2+6x+10=ln⁡∣x2+6x+10∣+C\displaystyle\int \frac{dx}{x^2 + 6x + 10} = \ln\left\lvert x^2 + 6x + 10 \right\rvert + C. What went wrong?

    Hint

    Differentiate the student’s answer. Does it give back the integrand?

    Answer

    The numerator is not the derivative of the denominator. Completing the square gives arctan⁡(x+3)+C\arctan(x + 3) + C.

    Full solution

    The derivative of the student’s answer is 2x+6x2+6x+10\tfrac{2x + 6}{x^2 + 6x + 10}, not 1x2+6x+10\tfrac{1}{x^2 + 6x + 10}.

    Instead, x2+6x+10=(x+3)2+1x^2 + 6x + 10 = (x + 3)^2 + 1, and ∫dx(x+3)2+1=arctan⁡(x+3)+C\int \tfrac{dx}{(x + 3)^2 + 1} = \arctan(x + 3) + C.

Frequently asked questions

When should I use long division before integrating?

When the numerator's degree is at least the denominator's. Divide first, so that what is left is a polynomial plus a fraction with a smaller numerator.

What is the integral of 1/(x² + a²)?

(1/a) arctan(x/a) + C.

When do I complete the square?

When the denominator is a quadratic with no real roots, such as x² + 4x + 5. Completing the square makes it (x + 2)² + 1, which leads to the arctangent.

What if the numerator is x + 3 instead of 1?

Split it into a multiple of the denominator's derivative, which integrates to a logarithm, plus a constant, which integrates to an arctangent.

How do I know whether to use a logarithm or an arctangent?

If the numerator is a constant multiple of the denominator's derivative, substitute and get a logarithm. If it is a constant over an irreducible quadratic, complete the square and get an arctangent.

What to learn next