How to Integrate Rational Functions: Long Division and Partial Fractions

Integrating rational functions is one of the most systematic techniques in calculus. This guide covers the complete strategy: when to use substitution, when long division is needed, and when to apply partial fractions — with worked examples for every case.

A rational function has the form \int \frac{P(x)}{Q(x)}\,dx where P(x) and Q(x) are polynomials. Every such integral can be expressed using polynomials, logarithms, and arctangents — no other functions are needed.

When Substitution Works

Before reaching for heavy machinery, check whether a simple u-substitution handles the rational function. This works when the numerator is (or can be scaled to be) the derivative of the denominator.

The key identity to recognize:

\int \frac{u'(x)}{u(x)}\,dx = \ln|u(x)| + C

Example: Compute \int \frac{2x}{x^2+1}\,dx.

The numerator 2x is exactly the derivative of the denominator x²+1. Let u = x²+1, so du = 2x dx, and the integral collapses:

\int \frac{2x}{x^2+1}\,dx = \ln(x^2+1) + C

No absolute value is needed because x²+1 > 0 for all real x. This same check should always be the first step — if it works, you save a lot of work.

When Long Division Is Required

When the numerator degree is greater than or equal to the denominator degree, the fraction is called improper. You must perform polynomial long division first, turning the improper fraction into a polynomial plus a proper fraction.

Example 1: Compute \int \frac{x^3+x}{x^2+1}\,dx.

Dividing x³+x by x²+1:

\frac{x^3+x}{x^2+1} = x + \frac{0}{x^2+1} = x

The remainder is zero — this improper fraction collapses to a polynomial.

\int \frac{x^3+x}{x^2+1}\,dx = \int x\,dx = \frac{x^2}{2} + C

Example 2: Compute \int \frac{x^2+3x+4}{x+1}\,dx.

Long division gives:

\frac{x^2+3x+4}{x+1} = x + 2 + \frac{2}{x+1}

Now integrate term by term — the polynomial part is easy, the remaining proper fraction uses the logarithm rule:

\int \frac{x^2+3x+4}{x+1}\,dx = \frac{x^2}{2} + 2x + 2\ln|x+1| + C

When Partial Fractions Are Required

For proper rational functions whose denominators factor nontrivially, use partial fraction decomposition. The idea: split a complicated fraction into a sum of simpler pieces, each of which has a known integration rule.

Example: Compute \int \frac{5x-1}{(x+1)(x-2)}\,dx.

Using partial fraction decomposition:

\frac{5x-1}{(x+1)(x-2)} = \frac{2}{x+1} + \frac{3}{x-2}

Each piece is now a basic logarithm integral:

\int \frac{5x-1}{(x+1)(x-2)}\,dx = 2\ln|x+1| + 3\ln|x-2| + C

The three factor types — distinct linear, repeated linear, and irreducible quadratic — each produce a different integral pattern, covered in the next section.

Integration Results by Factor Type

Each type of denominator factor leads to a predictable integration rule. Memorizing these three patterns covers every rational-function integral you'll encounter.

Linear Denominator → Logarithm

A distinct linear factor (x - a) integrates to a natural logarithm with absolute value:

\int \frac{1}{x-a}\,dx = \ln|x-a| + C

Any constant coefficient simply pulls through:

\int \frac{A}{x-a}\,dx = A\ln|x-a| + C

Repeated Linear Factor → Power Rule

A repeated factor (x - a)ⁿ with n ≥ 2 uses the power rule (rewrite as (x - a)⁻ⁿ):

\int \frac{1}{(x-a)^n}\,dx = -\frac{1}{(n-1)(x-a)^{n-1}} + C \quad (n \neq 1)

Example:

\int \frac{1}{(x-3)^2}\,dx = -\frac{1}{x-3} + C

Irreducible Quadratic Factor → Arctangent

An irreducible quadratic (one with no real roots) of the form x² + a² integrates to an arctangent:

\int \frac{1}{x^2+a^2}\,dx = \frac{1}{a}\arctan\!\left(\frac{x}{a}\right) + C

Example:

\int \frac{1}{x^2+4}\,dx = \frac{1}{2}\arctan\!\left(\frac{x}{2}\right) + C

For more general irreducible quadratics x² + bx + c, first complete the square to bring them into the (x - h)² + k form, then apply the arctangent rule. For example, to compute \int \frac{1}{x^2+2x+5}\,dx, complete the square in the denominator:

x^2+2x+5 = (x+1)^2 + 4, so the integral becomes:

\int \frac{1}{(x+1)^2+4}\,dx = \frac{1}{2}\arctan\!\left(\frac{x+1}{2}\right) + C

Want to check your understanding?

Our interaction checks test whether you truly understand a concept — not just whether you can repeat a procedure.

Try an interaction check

Strategy Decision Tree

Use this decision flow to pick the right method on any rational-function integral:

  1. Step 1 — Check for u-substitution. Is the numerator (up to a constant multiple) the derivative of the denominator? If yes, apply u = denominator and you're done.
  2. Step 2 — Compare degrees. Is the numerator degree ≥ denominator degree? If yes, perform polynomial long division first. Integrate the quotient polynomial directly; apply further steps to the remainder fraction.
  3. Step 3 — Factor the denominator. Fully factor the denominator into distinct linear, repeated linear, and irreducible quadratic pieces.
  4. Step 4 — Decompose into partial fractions. Write one partial fraction per factor type. Solve for the unknowns by substituting convenient x values or by comparing coefficients.
  5. Step 5 — Integrate each piece. Linear factors give logarithms, repeated factors use the power rule, and irreducible quadratics give arctangents (after completing the square if needed).
  6. Step 6 — Add the constant. Don't forget the + C.

Worked Calculus Examples

Three complete examples at increasing difficulty, showing the full decision process.

Example A — Repeated Linear Factor

Compute \int \frac{x^2+2}{x(x-1)^2}\,dx.

Check: numerator degree 2 < denominator degree 3, so the fraction is proper. u-substitution does not apply. Factor is already given, with a repeated factor (x-1)². Set up partial fractions:

\frac{x^2+2}{x(x-1)^2} = \frac{A}{x} + \frac{B}{x-1} + \frac{C}{(x-1)^2}

Clear denominators:

x^2+2 = A(x-1)^2 + Bx(x-1) + Cx

Solve: A = 2 (set x=0), C = 3 (set x=1), B = -1 (compare x^2 coefficients).

Integrate each piece:

\int \frac{x^2+2}{x(x-1)^2}\,dx = 2\ln|x| - \ln|x-1| - \frac{3}{x-1} + C

Example B — Factoring First

Compute \int \frac{3x+1}{x^2-x-2}\,dx.

Check: the denominator factors as x^2-x-2 = (x-2)(x+1). Proper fraction; use partial fractions:

\frac{3x+1}{(x-2)(x+1)} = \frac{A}{x-2} + \frac{B}{x+1}

Solve: A = \frac{7}{3} (set x=2), B = \frac{2}{3} (set x=-1).

\int \frac{3x+1}{x^2-x-2}\,dx = \frac{7}{3}\ln|x-2| + \frac{2}{3}\ln|x+1| + C

Example C — Long Division First

Compute \int \frac{x^3+1}{x^2+x}\,dx.

Check: numerator degree 3 ≥ denominator degree 2. Factor the denominator: x^2+x = x(x+1). Perform long division:

\frac{x^3+1}{x^2+x} = x - 1 + \frac{x+1}{x(x+1)} = x - 1 + \frac{1}{x}

The remainder simplifies because (x+1)/(x(x+1)) = 1/x. Now integrate:

\int \frac{x^3+1}{x^2+x}\,dx = \frac{x^2}{2} - x + \ln|x| + C

Common Integration Traps

Forgetting to do long division first

Partial fractions only work on proper fractions. Always check degrees before attempting decomposition — if numerator degree ≥ denominator degree, divide first.

Missing the absolute value in logarithms

The integral of 1/(x-a) is ln|x-a| + C, not ln(x-a) + C. The absolute value matters because the domain includes x < a.

Using wrong template for repeated factors

A factor (x-a)² needs two terms: A/(x-a) plus B/(x-a)². Using only B/(x-a)² leaves the decomposition incomplete.

Wrong template for irreducible quadratic

For a quadratic factor x²+bx+c, the numerator is Ax+B (linear), not just A (constant).

Forgetting to complete the square

For integrals like 1/(x²+2x+5), you must complete the square to get (x+1)²+4 before applying the arctangent rule.

Practice Integrals

Work through these from easiest to hardest. Answers given below for self-check.

  1. Compute \int \frac{1}{x-5}\,dx
  2. Compute \int \frac{2x+1}{x^2+x+1}\,dx
  3. Compute \int \frac{3}{(x-2)^2}\,dx
  4. Compute \int \frac{1}{x^2+9}\,dx
  5. Compute \int \frac{x+4}{x^2-4}\,dx
  6. Compute \int \frac{x^2}{x-1}\,dx
  7. Compute \int \frac{1}{x^2+4x+13}\,dx
  8. Compute \int \frac{5}{x^2+2x}\,dx

Answers

  1. \ln|x-5| + C
  2. \ln|x^2+x+1| + C (u-substitution)
  3. -\frac{3}{x-2} + C
  4. \frac{1}{3}\arctan(x/3) + C
  5. \frac{3}{2}\ln|x-2| - \frac{1}{2}\ln|x+2| + C
  6. \frac{x^2}{2} + x + \ln|x-1| + C (long division first)
  7. \frac{1}{3}\arctan\!\left(\frac{x+2}{3}\right) + C
  8. \frac{5}{2}\ln|x| - \frac{5}{2}\ln|x+2| + C

Related Guides

Frequently Asked Questions

How do you know when to use partial fractions for integration?

Use partial fractions when you have a proper rational function (numerator degree less than denominator degree) whose denominator can be factored into linear and/or irreducible quadratic factors. If the fraction is improper, perform polynomial long division first.

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

The integral of 1/(x-a) is ln|x-a| + C. This is the most basic result from partial fraction integration and appears whenever you decompose into distinct linear factors.

When does arctangent appear in integration?

Arctangent appears when integrating fractions with irreducible quadratic denominators of the form 1/(x²+a²). After completing the square if necessary, the integral becomes (1/a)arctan(x/a) + C.

What is the difference between substitution and partial fractions?

Substitution works when the numerator is (or can be adjusted to be) the derivative of the denominator, allowing a simple u-substitution. Partial fractions is a more general technique that works for any rational function by breaking it into simpler pieces, regardless of the numerator-denominator relationship.

Can you integrate all rational functions?

Yes. Every rational function can be integrated using a combination of polynomial long division and partial fraction decomposition. The resulting integrals always involve polynomials, logarithms, and/or arctangent functions.

What are the most common mistakes when integrating rational functions?

Common mistakes include forgetting to do long division when the fraction is improper, using the wrong partial fraction template (especially for repeated or quadratic factors), sign errors when solving for coefficients, and forgetting the absolute value in logarithm results.

About Sense of Study

Sense of Study is a concept-first learning platform that helps students build deep understanding in math, physics, chemistry, statistics, and computational thinking. Our approach maps prerequisite relationships between concepts so students master foundations before moving forward — eliminating the gaps that cause confusion later.

With 800+ interconnected concepts and mastery tracking, we help students and parents see exactly where understanding breaks down and how to fix it.

Start Your Concept Mastery Journey

Explore 800+ interconnected concepts with prerequisite maps, mastery tracking, and interaction checks that build real understanding.