Partial Fractions: How to Integrate Rational Functions

A rational function is a ratio of two polynomials, for example \frac{5x+7}{(x-1)(x+3)}. No single integration rule fits such a fraction directly. The method of partial fractions splits it into simpler pieces, and each piece integrates with a logarithm, an arctangent, or the power rule.

You can check every example below in the integral calculator, which shows the solution step by step. Partial fractions is one of the main techniques covered in How to Solve Integrals Step by Step, and it works best together with the other methods described there.

Step 0: Proper and Improper Fractions

A fraction \frac{P(x)}{Q(x)} is proper if the degree of P is less than the degree of Q. Otherwise it is improper.

Partial fractions only works on proper fractions. If the fraction is improper, divide first. Polynomial long division gives

\frac{P(x)}{Q(x)} = S(x) + \frac{R(x)}{Q(x)},

where S(x) is a polynomial and the remainder R(x) has a smaller degree than Q(x). The polynomial part is easy to integrate. Only the remainder fraction needs partial fractions.

Example. Find \int \frac{x^2+1}{x-1}\,dx.

The numerator has degree 2 and the denominator has degree 1, so the fraction is improper. Dividing gives

x^2 + 1 = (x-1)(x+1) + 2,

so

\frac{x^2+1}{x-1} = x + 1 + \frac{2}{x-1}.

Now integrate term by term:

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

Check by differentiating: x + 1 + \frac{2}{x-1} = \frac{(x+1)(x-1)+2}{x-1} = \frac{x^2+1}{x-1}. ✓

Types of Denominator Factors

Factor the denominator Q(x) completely into linear factors and irreducible quadratic factors. A quadratic ax^2+bx+c is irreducible when b^2-4ac<0, which means it has no real roots. For example, x^2+4 is irreducible, while x^2-4=(x-2)(x+2) is not.

Each factor produces a specific form of terms in the decomposition:

Factor in the denominator Terms in the decomposition
Simple linear: (x-a) \frac{A}{x-a}
Repeated linear: (x-a)^k \frac{A_1}{x-a}+\frac{A_2}{(x-a)^2}+\dots+\frac{A_k}{(x-a)^k}
Irreducible quadratic: ax^2+bx+c \frac{Bx+C}{ax^2+bx+c}
Repeated quadratic: (ax^2+bx+c)^k \frac{B_1x+C_1}{ax^2+bx+c}+\dots+\frac{B_kx+C_k}{(ax^2+bx+c)^k}

Two rules matter here. A repeated factor needs a term for every power from 1 up to k. A quadratic factor needs a linear numerator Bx+C, not just a constant.

Finding the Coefficients

After writing the form of the decomposition, multiply both sides by the denominator Q(x). This leaves a polynomial identity that must hold for all x. There are two ways to find the unknown coefficients, and they are often combined.

Method 1: Substituting Roots

Substitute the roots of the denominator into the identity. Each root makes most terms vanish and leaves one unknown.

For \frac{1}{(x-1)(x+2)} = \frac{A}{x-1} + \frac{B}{x+2} we get 1 = A(x+2) + B(x-1). Setting x=1 gives 1 = 3A, so A=\frac13. Setting x=-2 gives 1 = -3B, so B=-\frac13.

This is the fastest method for simple linear factors.

Method 2: Comparing Coefficients

Expand the right side and equate the coefficients of equal powers of x. This gives a system of linear equations.

Take \frac{1}{x^2(x+1)}. The denominator has a repeated factor x^2, so

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

Multiplying through gives

1 = A\,x(x+1) + B(x+1) + C\,x^2.

Substituting roots gives two coefficients: x=0 gives B=1, and x=-1 gives C=1. There are no more roots to use, so compare the x^2 coefficients: 0 = A + C, which gives A=-1. The x coefficients confirm this, since 0 = A + B = -1 + 1. ✓

So

\frac{1}{x^2(x+1)} = -\frac1x + \frac1{x^2} + \frac1{x+1}.

In practice, use root substitution for as many coefficients as it can give, then comparing coefficients for the rest.

Example 1: Distinct Linear Factors

Find \int \frac{5x+7}{(x-1)(x+3)}\,dx.

Step 1. The fraction is proper (degree 1 over degree 2), and the denominator already has two distinct linear factors:

\frac{5x+7}{(x-1)(x+3)} = \frac{A}{x-1} + \frac{B}{x+3}.

Step 2. Multiply by the denominator:

5x+7 = A(x+3) + B(x-1).

Step 3. Substitute the roots. For x=1: 12 = 4A, so A=3. For x=-3: -8 = -4B, so B=2.

Step 4. Integrate each term:

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

Check. Differentiating gives \frac{3}{x-1}+\frac{2}{x+3} = \frac{3(x+3)+2(x-1)}{(x-1)(x+3)} = \frac{5x+7}{(x-1)(x+3)}. ✓

You can check this step by step in the integral calculator by entering (5*x+7)/((x-1)*(x+3)).

Example 2: A Linear and an Irreducible Quadratic Factor

Find \int \frac{3x^2+2x+5}{(x-1)(x^2+4)}\,dx.

Step 1. The fraction is proper. The factor x^2+4 has b^2-4ac = -16 < 0, so it is irreducible and needs a linear numerator:

\frac{3x^2+2x+5}{(x-1)(x^2+4)} = \frac{A}{x-1} + \frac{Bx+C}{x^2+4}.

Step 2. Multiply by the denominator and expand:

3x^2+2x+5 = A(x^2+4) + (Bx+C)(x-1) = (A+B)x^2 + (C-B)x + (4A-C).

Step 3. Find A by setting x=1: 10 = 5A, so A=2. Then compare coefficients:

Therefore

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

Step 4. Split the second fraction and integrate each part:

\int \frac{x+3}{x^2+4}\,dx = \int \frac{x}{x^2+4}\,dx + 3\int \frac{dx}{x^2+4} = \frac12\ln(x^2+4) + \frac32\arctan\frac{x}{2} + C.

The full answer is

\int \frac{3x^2+2x+5}{(x-1)(x^2+4)}\,dx = 2\ln|x-1| + \frac12\ln(x^2+4) + \frac32\arctan\frac{x}{2} + C.

Check. The derivative is \frac{2}{x-1} + \frac{x}{x^2+4} + \frac32\cdot\frac{2}{x^2+4} = \frac{2}{x-1} + \frac{x+3}{x^2+4}, which matches the decomposition. ✓

To see the same solution worked out by the calculator, open this example in the integral calculator with the expression (3*x^2+2*x+5)/((x-1)*(x^2+4)).

Integrating the Result

After decomposition, every term falls into one of a few standard types:

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

\int \frac{A}{(x-a)^k}\,dx = -\frac{A}{(k-1)(x-a)^{k-1}} + C \quad (k \ge 2)

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

\int \frac{dx}{x^2+a^2} = \frac1a\arctan\frac{x}{a} + C

The third formula is a quick substitution u = x^2+a^2, as described in Integration by Substitution. The fourth comes from the substitution x = a\tan\theta, which is explained in Trigonometric Substitution.

If the quadratic is not of the form x^2+a^2, complete the square first. For example,

\int \frac{dx}{x^2+2x+5} = \int \frac{dx}{(x+1)^2+4} = \frac12\arctan\frac{x+1}{2} + C.

Common Mistakes

Summary

To integrate a rational function, check that the fraction is proper (divide if it is not), factor the denominator, write the decomposition form for each factor, find the coefficients, and integrate term by term. Differentiating the result confirms the answer. For more on choosing between methods, see How to Solve Integrals Step by Step.