AP® CALCULUS AB & BC · UNIT 6

Integrating with Long Division and Completing the Square

Rewrite rational and quadratic expressions before integrating. Use colorful worked examples to check the algebra, choose a matching antiderivative, and evaluate definite integrals.

Topic 6.10 study notes8 worked examples · 8 practice questionsUpdated 11 November 2026
Calculus notebook with limit and integral symbols, a compass and pencil on an olive and cream study desk

1. What Topic 6.10 asks you to do

Rewrite an integrand into an equivalent form before choosing an antiderivative. Polynomial long division separates a polynomial part from a proper rational remainder. Completing the square makes a quadratic's shift and scale visible.

AP Calculus AB & BC · Topic 6.10. Use these algebraic rewrites to find indefinite integrals and evaluate definite integrals. Check that the rewrite preserves the original domain.

2. When to use polynomial long division

Let N be the numerator polynomial and D the denominator polynomial. If degN≥degD, polynomial division writes

N=DQ+R.

Here Q is the quotient and R is the remainder. The remainder is zero or has degree less than degD. On the original domain, where D≠0, divide by D to get

ND=Q+RD.

For example, x3+2xx2+1 calls for division. The numerator of x+1x2+3 already has lower degree, so that fraction is proper.

  1. Order both polynomials by descending powers. Include a zero coefficient for any missing power when you set up the subtraction.
  2. Divide the leading terms to find the next quotient term.
  3. Multiply the entire divisor by that term, then subtract and bring down the next term.
  4. Repeat until the remainder is zero or has lower degree than the divisor. Verify by multiplying the quotient by the divisor and adding the remainder.

Integrate the polynomial term by term. For the remainder, look for a derivative of the denominator, a completed square, or another suitable technique.

3. How to complete the square

For a quadratic ax2+bx+c with a≠0, factor a from the two terms involving x. Half the coefficient of x inside the parentheses is b2a. Add and subtract its square inside those parentheses.

The resulting form is

ax2+bx+c=a(x−h)2+k,

where h=−b2a and k=c−b24a. The same a multiplies the term you add and the term you subtract. That is why k contains b24a.

For example, x2+4x+13 becomes (x+2)2+9. The shift is h=−2, and the nonnegative square plus 9 makes the denominator positive for every real input.

If the denominator can be written as a[(x−h)2+r2] with r>0, factor out the constant and match the arctangent form. A difference of squares under a square root can instead produce the arcsine form. Check the signs and the original domain before choosing a formula.

4. Recognize the antiderivative form

Let r>0. After the shift u=x−h, match the complete integrand, including the differential and any outside constant. Angles are in radians.

Antiderivatives to recognize after rewriting
Integrand in uAntiderivative family
1u2+r21rarctan(ur)+C
1r2−u2arcsin(ur)+C
1uln|u|+C

The arctangent row works for all real u. The arcsine integrand requires −r<u<r; its endpoints make the denominator zero. The logarithm row applies on either side of u=0, with a constant chosen on each interval.

If a numerator is proportional to the derivative of its denominator, try the logarithmic rule first. When only part of the numerator matches, split off that part before handling the remainder.

Extra reference: the inverse secant form

For r>0 and |u|>r, take I=∫1uu2−r2du. Use the usual inverse secant branch, equivalently the inverse cosine of the reciprocal:

I=1rarcsec(|u|r)+C.

The absolute value lets the same expression differentiate correctly on both separate intervals. The endpoints remain excluded.

5. Worked examples: indefinite and definite integrals

Example 1 · Divide by a linear denominator

Find I=∫x2+3x+5x+2dx.

1 · Compare degrees and divide

The numerator has degree 2 and the divisor has degree 1. The leading terms x2 and x give the first quotient term x.

Two rounds of polynomial division
Quotient termProduct to subtractNew remainder
xx2+2xx+5
1x+23

2 · Check the quotient and remainder

The quotient is x+1 and the remainder is 3. Expanding (x+2)(x+1)+3 gives the numerator back.

x2+3x+5x+2=x+1+3x+2

3 · Integrate and check the domain

I=x22+x+3ln|x+2|+C

The derivative gives x+1+3x+2. The original integrand excludes x=−2, so use a separate constant on each interval.

What the quotient and remainder show

image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/ −6 −4 −2 0 2 4 x −10 −5 0 5 10 y Rational function Quotient Vertical asymptote
The solid curves are the original rational function. The dashed oblique line is the quotient y=x+1; the difference is 3x+2. The dotted guide at x=−2 marks the vertical asymptote. The branches stay separate.

Example 2 · Stop when the remainder has lower degree

Rewrite I=∫x3−2x2+4x2−1dx using long division, and integrate its polynomial part.

1 · Track the missing power and subtract

Include a zero coefficient on x in the numerator. After subtracting x(x2−1), the remainder is −2x2+x+4. Subtracting −2(x2−1) leaves x+2.

ND=x−2+x+2x2−1

The quotient is x−2, and the degree of the remainder is 1.

2 · Integrate the polynomial part

P(x)=x22−2x
I=P(x)+∫x+2x2−1dx

The full remainder numerator x+2 is not a constant multiple of 2x. A direct denominator substitution alone does not finish this fraction. Use the rewrite on intervals excluding x=−1 and x=1.

Show the BC preview for the remaining fraction

Topic 6.12 covers this partial fraction step. For x≠±1, the remainder splits as

x+2x2−1=32(x−1)−12(x+1).

Keep the polynomial primitive and find the logarithmic primitive separately:

P(x)=x22−2x
L(x)=32ln|x−1|−12ln|x+1|
I=P(x)+L(x)+C.

Differentiating recovers the original integrand on any interval that avoids both poles.

Example 3 · Complete the square to reveal arctangent

Find I=∫1x2+4x+13dx.

1 · Find the shifted quadratic

Half of 4 is 2, and its square is 4. Add and subtract 4.

x2+4x+13=(x+2)2+9

2 · Substitute and recognize the scale

Let u=x+2, so du=dx and the denominator is u2+32.

I=13arctan(u3)+C

3 · Substitute back and differentiate

I=13arctan(x+23)+C

The derivative simplifies to 1(x+2)2+9, which is defined for every real x.

Example 4 · Keep the leading coefficient outside

Find I=∫12x2+8x+10dx.

1 · Factor and complete the square

Let D(x)=2x2+8x+10. Factor 2, then complete the square inside the parentheses.

D(x)=2(x2+4x+5)
D(x)=2[(x+2)2+1]

2 · Integrate with the outside factor

Use u=x+2, so du=dx. The integral becomes

I=12∫1u2+1du.

3 · Return to the original variable

I=12arctan(x+2)+C

The derivative includes the factor 12; its denominator expands to 2x2+8x+10.

Example 5 · Split a logarithm term from an arctangent term

Find I=∫2x+3x2+4x+5dx.

1 · Match part of the numerator to the derivative

Let D=x2+4x+5. Then D′=2x+4, so the numerator is D′−1.

2x+3D=D′D−1D

2 · Recognize both patterns

The first term has primitive ln|D|. For the second, complete the square: D=(x+2)2+1. Its reciprocal has primitive arctan(x+2).

3 · Preserve the subtraction

I=lnD−arctan(x+2)+C

The completed square shows D>0, so lnD is valid. Differentiating the answer gives D′−1D, as required.

Example 6 · Evaluate a definite integral after shifting and scaling

Evaluate I=∫−511x2+4x+13dx.

1 · Complete the square and choose the new variable

The denominator is (x+2)2+9. Let u=x+23, giving dx=3du. The denominator becomes 9(u2+1).

2 · Convert both bounds

Map the original bounds to the new variable
BoundOriginal xNew u
Start−5−1
End11
I=13∫−1111+u2du

3 · Evaluate in the new variable

I=13[arctanu]−11
I=13(π4+π4)=π6

The denominator is positive throughout the interval, so this definite integral equals the shaded area.

The completed square reveals the vertex

image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/ −6 −5 −4 −3 −2 −1 0 1 2 x 0 5 10 15 20 25 D x ( )
The denominator D(x)=(x+2)2+9 has vertex (−2,9). At x=−5 and x=1, its value is 18. It stays positive on the entire real line.

The reciprocal is the integrand

image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/ −6 −5 −4 −3 −2 −1 0 1 2 x 0.00 0.03 0.06 0.09 0.12 f x ( )
The peak of 1D(x) is at (−2,19). The shaded region runs from −5 to 1; its exact area is π6.

Example 7 · Use long division and completing the square together

Find I=∫x2+2x+5x2+2x+2dx.

1 · Divide the polynomials of equal degree

The quotient is 1. Subtract the denominator from the numerator to get remainder 3.

ND=1+3D

Here D=x2+2x+2.

2 · Complete the square in the remainder's denominator

D=(x+1)2+1

The polynomial term integrates to x. The remaining reciprocal gives an arctangent.

3 · Combine and verify

I=x+3arctan(x+1)+C

The derivative is 1+3D, and D is positive for every real input.

Example 8 · Recognize arcsine when the square is subtracted

Find I=∫15+4x−x2dx.

1 · Complete the square under the radical

The radicand 5+4x−x2 becomes 9−(x−2)2. The denominator must be positive, so the original domain is −1<x<5.

2 · Scale to the arcsine form

Let u=x−23. Then dx=3du, and the denominator is 31−u2. The factors of 3 cancel.

I=∫11−u2du

3 · Substitute back and check the interval

I=arcsin(x−23)+C

The derivative gives the original reciprocal radical for −1<x<5. The endpoints remain excluded.

6. Check the algebra, domain, and bounds

  • Compare degrees before integrating a rational function. Check long division by multiplying the quotient by the divisor and adding the remainder.
  • Keep the leading coefficient when completing the square. Expand the new expression to verify every term.
  • Match the form and the scale. A positive sum of squares in the denominator can give arctangent. A positive square minus a variable square under a root can give arcsine. Check the differential and all outside factors.
  • Preserve the original domain. A cancelled factor can still leave an excluded point. For a definite integral, verify the conditions for applying the Fundamental Theorem on the interval.
  • Check the final answer. Differentiate an indefinite answer and include C. For a definite answer, use bounds that match the variable and verify the endpoint subtraction.

On an AP response, show the algebraic rewrite that makes the integrand recognizable. Then show your antiderivative and, for a definite integral, the evaluation at both bounds.

7. Practice with step-by-step solutions

Problem 1

Find I=∫x2+5x+1dx.

Show solution 1

Solution

The quotient is x−1 and the remainder is 6. Work on an interval where x≠−1.

I=x22−x+6ln|x+1|+C

Problem 2

Find I=∫x3+xx2+1dx.

Show solution 2

Solution

The numerator is x(x2+1). Division gives quotient x and zero remainder; the denominator never vanishes.

I=x22+C

An extra arctangent term would change the derivative. Differentiate the answer to get x, exactly the simplified integrand.

Problem 3

Find I=∫1x2+6x+13dx.

Show solution 3

Solution

Complete the square to get (x+3)2+4. The scale in the arctangent formula is 2.

I=12arctan(x+32)+C

Problem 4

Find I=∫1x2−4x+8dx.

Show solution 4

Solution

The completed square is (x−2)2+4. The shift is now 2, so the argument uses x−2.

I=12arctan(x−22)+C

Problem 5

Find I=∫13x2+6x+12dx.

Show solution 5

Solution

Factor the denominator as 3[(x+1)2+3]. Keep the outside factor 13 and use scale 3.

I=133arctan(x+13)+C

Problem 6

Evaluate I=∫02x2+3x+5x+2dx.

Show solution 6

Solution

Use the antiderivative from Example 1. The interval avoids the pole. The polynomial part changes by 4, and the log part changes by 3[ln(4)−ln(2)].

I=4+3ln(2)

Problem 7

Find I=∫x2−1x−1dx and state the restriction.

Show solution 7

Solution

Cancel the common factor to get x+1 wherever x≠1. Cancellation does not define the original fraction at 1.

I=x22+x+C

Use this result on each of the two intervals separated by 1; the constants can differ.

Problem 8

Evaluate I=∫011x2−2x+2dx.

Show solution 8

Solution

The denominator is (x−1)2+1, so a primitive is arctan(x−1). Evaluate in the original variable.

I=arctan(0)−arctan(−1)
I=π4

8. Continue studying integration

Review Topic 6.8's antiderivative rules and Topic 6.9's substitution steps when matching a rewritten integrand.