AP Calculus AB and BC

Long Division and Completing the Square for Integrals

Before integrating a rational function, compare degrees. If the numerator's degree is at least the denominator's, do polynomial long division to get a polynomial plus a smaller fraction. If the denominator is a quadratic with no real roots, complete the square so the integral matches the arctangent form.

Algebra first, calculus second

Some rational integrands match no antiderivative rule as written, and no substitution fixes them. In these cases the integrand has to be rewritten with algebra before any calculus starts. Topic 6.10, Integrating Functions Using Long Division and Completing the Square, covers the two rewrites in this guide.

What you seeMoveWhat it produces
Degree of numerator is greater than or equal to degree of denominatorPolynomial long divisionA polynomial plus a fraction whose numerator has lower degree than its denominator
A constant over a quadratic with no real rootsComplete the squareThe form 1u2+a2\frac{1}{u^2 + a^2}, which integrates to an arctangent

Check for a substitution before either move. If the numerator is a constant multiple of the derivative of the denominator, as in ∫2xx2+9 dx\int \frac{2x}{x^2 + 9}\,dx, then u=x2+9u = x^2 + 9 finishes the problem as a natural log and no rewriting is needed.

Long division when the numerator is too big

A rational function is called improper when the degree of its numerator is greater than or equal to the degree of its denominator. Dividing rewrites it as a quotient polynomial plus a remainder over the original denominator:

N(x)D(x)=Q(x)+R(x)D(x),where the degree of R is less than the degree of D\frac{N(x)}{D(x)} = Q(x) + \frac{R(x)}{D(x)}, \quad \text{where the degree of } R \text{ is less than the degree of } D

The polynomial Q(x)Q(x) integrates with the power rule. The leftover fraction is simpler than the original and usually integrates to a natural log, an arctangent, or a combination. For example, dividing x2x^2 by x+1x + 1 gives quotient x−1x - 1 and remainder 11, so

∫x2x+1 dx=∫(x−1+1x+1)dx=x22−x+ln⁡∣x+1∣+C\int \frac{x^2}{x + 1}\,dx = \int \left(x - 1 + \frac{1}{x + 1}\right)dx = \frac{x^2}{2} - x + \ln|x + 1| + C

Check the division by multiplying back

Quotient times divisor plus remainder must rebuild the numerator. Here (x−1)(x+1)+1=x2−1+1=x2(x - 1)(x + 1) + 1 = x^2 - 1 + 1 = x^2. This takes a few seconds and catches most sign errors.

Completing the square for the arctangent form

The target is this antiderivative rule, where aa is a positive constant:

∫1u2+a2 du=1aarctan⁡(ua)+C\int \frac{1}{u^2 + a^2}\,du = \frac{1}{a}\arctan\left(\frac{u}{a}\right) + C

A quadratic such as x2+6x+13x^2 + 6x + 13 does not look like u2+a2u^2 + a^2 until the x2x^2 and xx terms are packed into a single square. For a quadratic with leading coefficient 11:

x2+bx+c=(x+b2)2+(c−b24)x^2 + bx + c = \left(x + \frac{b}{2}\right)^2 + \left(c - \frac{b^2}{4}\right)

Take half the coefficient of xx, square it, and split the constant so that amount joins the square. For x2+6x+13x^2 + 6x + 13, half of 66 is 33 and 32=93^2 = 9, so x2+6x+13=(x2+6x+9)+4=(x+3)2+4x^2 + 6x + 13 = (x^2 + 6x + 9) + 4 = (x + 3)^2 + 4. Now u=x+3u = x + 3 and a=2a = 2.

The arctangent form needs the leftover constant c−b24c - \frac{b^2}{4} to be positive. That is the same as the discriminant b2−4cb^2 - 4c being negative, which means the quadratic has no real roots. If the leading coefficient is not 11, factor it out of the whole quadratic before completing the square.

The same move handles a quadratic under a square root. Completing the square can turn the radicand into a2−u2a^2 - u^2, which matches ∫1a2−u2 du=arcsin⁡(ua)+C\int \frac{1}{\sqrt{a^2 - u^2}}\,du = \arcsin\left(\frac{u}{a}\right) + C.

A decision order for rational integrands

  1. Look for a substitution. If the numerator is a constant multiple of the derivative of the denominator, use uu equal to the denominator.
  2. Compare degrees. If the numerator's degree is greater than or equal to the denominator's, divide first.
  3. Look at the remaining denominator. If it is linear, the fraction integrates to a natural log.
  4. If it is a quadratic with no real roots, complete the square and use the arctangent form.
  5. If it is a quadratic that factors into different linear factors, the BC technique of partial fractions applies.

Sometimes one fraction needs two tools. In 2x+5x2+4x+13\frac{2x + 5}{x^2 + 4x + 13} the derivative of the denominator is 2x+42x + 4, so split the numerator as (2x+4)+1(2x + 4) + 1. The first piece is a substitution that gives ln⁡(x2+4x+13)\ln(x^2 + 4x + 13), and the second piece is 1(x+2)2+9\frac{1}{(x + 2)^2 + 9}, an arctangent with a=3a = 3.

Common mistakes

  • Integrating an improper fraction without dividing. Rules like the natural log pattern do not apply until the fraction is proper.
  • Dropping the remainder. The quotient alone is not equal to the original fraction.
  • Skipping placeholder terms. When dividing x3+1x^3 + 1 by x−2x - 2, write the numerator as x3+0x2+0x+1x^3 + 0x^2 + 0x + 1 so the columns line up.
  • Forgetting the 1a\frac{1}{a} in front of the arctangent, or writing arctan⁡(u)\arctan(u) in place of arctan⁡(ua)\arctan\left(\frac{u}{a}\right).
  • Using a2a^2 as aa. In (x+3)2+4(x + 3)^2 + 4 the constant is a2=4a^2 = 4, so a=2a = 2.
  • Integrating 1x2+6x+13\frac{1}{x^2 + 6x + 13} as a natural log of the denominator. That would need 2x+62x + 6 in the numerator.

Quick check

Differentiate your answer. The derivative of 12arctan⁡(x+32)\frac{1}{2}\arctan\left(\frac{x + 3}{2}\right) is 12⋅11+(x+3)24⋅12=14+(x+3)2\frac{1}{2} \cdot \frac{1}{1 + \frac{(x + 3)^2}{4}} \cdot \frac{1}{2} = \frac{1}{4 + (x + 3)^2}, which matches the integrand.

Worked examples

Worked example

Long division with a linear denominator

Evaluate ∫2x2+3x−1x+2 dx\int \frac{2x^2 + 3x - 1}{x + 2}\,dx.

  1. Compare degrees. The numerator has degree 22 and the denominator has degree 11, so divide first.
  2. Divide 2x2+3x−12x^2 + 3x - 1 by x+2x + 2. The first term of the quotient is 2x2x, since 2x(x+2)=2x2+4x2x(x + 2) = 2x^2 + 4x. Subtracting leaves −x−1-x - 1. The next term is −1-1, since −1(x+2)=−x−2-1(x + 2) = -x - 2. Subtracting leaves a remainder of 11.
  3. Check by multiplying back: (2x−1)(x+2)+1=2x2+3x−2+1=2x2+3x−1(2x - 1)(x + 2) + 1 = 2x^2 + 3x - 2 + 1 = 2x^2 + 3x - 1.
  4. Rewrite the integral: ∫(2x−1+1x+2)dx\int \left(2x - 1 + \frac{1}{x + 2}\right)dx.
  5. Integrate term by term: x2−x+ln⁡∣x+2∣+Cx^2 - x + \ln|x + 2| + C.

x2−x+ln⁡∣x+2∣+Cx^2 - x + \ln|x + 2| + C

Worked example

Completing the square

Evaluate ∫1x2+6x+13 dx\int \frac{1}{x^2 + 6x + 13}\,dx.

  1. Check the simpler options. The numerator is not a multiple of 2x+62x + 6, so substitution with uu equal to the denominator fails. The discriminant is 62−4(13)=−16<06^2 - 4(13) = -16 < 0, so the quadratic has no real roots and does not factor.
  2. Complete the square: half of 66 is 33, and 32=93^2 = 9, so x2+6x+13=(x+3)2+4x^2 + 6x + 13 = (x + 3)^2 + 4.
  3. Match the arctangent form with u=x+3u = x + 3, du=dxdu = dx, and a=2a = 2: the integral is ∫1u2+22 du\int \frac{1}{u^2 + 2^2}\,du.
  4. Apply the rule: 12arctan⁡(u2)+C=12arctan⁡(x+32)+C\frac{1}{2}\arctan\left(\frac{u}{2}\right) + C = \frac{1}{2}\arctan\left(\frac{x + 3}{2}\right) + C.

12arctan⁡(x+32)+C\frac{1}{2}\arctan\left(\frac{x + 3}{2}\right) + C

Worked example

Both moves in one definite integral

Evaluate ∫−11x2+2x+7x2+2x+5 dx\int_{-1}^{1} \frac{x^2 + 2x + 7}{x^2 + 2x + 5}\,dx.

  1. Compare degrees. Both are degree 22, so divide. The numerator is the denominator plus 22, so x2+2x+7x2+2x+5=1+2x2+2x+5\frac{x^2 + 2x + 7}{x^2 + 2x + 5} = 1 + \frac{2}{x^2 + 2x + 5}.
  2. Complete the square in the remaining denominator: x2+2x+5=(x+1)2+4x^2 + 2x + 5 = (x + 1)^2 + 4.
  3. Integrate. With u=x+1u = x + 1 and a=2a = 2, ∫2(x+1)2+4 dx=2⋅12arctan⁡(x+12)=arctan⁡(x+12)\int \frac{2}{(x + 1)^2 + 4}\,dx = 2 \cdot \frac{1}{2}\arctan\left(\frac{x + 1}{2}\right) = \arctan\left(\frac{x + 1}{2}\right). An antiderivative of the whole integrand is x+arctan⁡(x+12)x + \arctan\left(\frac{x + 1}{2}\right).
  4. Evaluate from −1-1 to 11: at x=1x = 1 the value is 1+arctan⁡(1)=1+π41 + \arctan(1) = 1 + \frac{\pi}{4}, and at x=−1x = -1 it is −1+arctan⁡(0)=−1-1 + \arctan(0) = -1.
  5. Subtract: (1+π4)−(−1)=2+π4\left(1 + \frac{\pi}{4}\right) - (-1) = 2 + \frac{\pi}{4}.

2+π4≈2.7852 + \frac{\pi}{4} \approx 2.785

Frequently asked questions

How do I know when to use long division before integrating?

Compare the degrees of the numerator and denominator. If the numerator's degree is greater than or equal to the denominator's, divide first. If it is lower, the fraction is already proper and division does nothing.

When does completing the square lead to an arctangent?

When the integrand is a constant over a quadratic that has no real roots, which means its discriminant is negative. Completing the square then gives (x+h)2+a2(x + h)^2 + a^2 with a2>0a^2 > 0, and ∫1(x+h)2+a2 dx=1aarctan⁡(x+ha)+C\int \frac{1}{(x + h)^2 + a^2}\,dx = \frac{1}{a}\arctan\left(\frac{x + h}{a}\right) + C. A constant numerator multiplies the result.

What if the denominator is a quadratic that does factor?

Then completing the square does not give the arctangent form, because the leftover constant is negative or zero. A quadratic with two different real roots splits into two linear factors, and the fraction is handled with partial fractions, which is a BC topic.