TExcelTAD
Home › Calculus in Depth › Partial Fractions

Partial Fractions

Every rational function, a quotient of polynomials P(x)/Q(x)P(x)/Q(x), can be integrated in elementary terms. The method is to split it into a polynomial plus a sum of simple fractions whose integrals are logarithms and arctangents. This lesson states the decomposition theorem, works through all four cases, computes coefficients by hand (including Heaviside's cover-up shortcut) and with SymPy's apart, and shows where the same algebra runs in signal processing and control code.

Step 0: make it proper

If deg⁡P≥deg⁡Q\deg P \ge \deg Q, divide first: PQ=S(x)+R(x)Q(x)\frac{P}{Q} = S(x) + \frac{R(x)}{Q(x)} with deg⁡R<deg⁡Q\deg R < \deg Q. The polynomial SS integrates directly.

x3+2xx2−1=x+3xx2−1\frac{x^3 + 2x}{x^2 - 1} = x + \frac{3x}{x^2 - 1}

The decomposition theorem

Factor QQ over the reals into linear factors (ax+b)(ax + b) and irreducible quadratics (ax2+bx+c)(ax^2 + bx + c) with b2−4ac<0b^2 - 4ac < 0 (always possible, by the Fundamental Theorem of Algebra). Then R/QR/Q is a unique sum of terms:

Factor of QQ Terms contributed
(ax+b)(ax + b) Aax+b\frac{A}{ax + b}
(ax+b)r(ax + b)^r A1ax+b+A2(ax+b)2+⋯+Ar(ax+b)r\frac{A_1}{ax + b} + \frac{A_2}{(ax + b)^2} + \cdots + \frac{A_r}{(ax + b)^r}
(ax2+bx+c)(ax^2 + bx + c) Bx+Cax2+bx+c\frac{Bx + C}{ax^2 + bx + c}
(ax2+bx+c)r(ax^2 + bx + c)^r B1x+C1ax2+bx+c+⋯+Brx+Cr(ax2+bx+c)r\frac{B_1x + C_1}{ax^2 + bx + c} + \cdots + \frac{B_rx + C_r}{(ax^2 + bx + c)^r}

The number of unknown constants always equals deg⁡Q\deg Q, and multiplying out gives a linear system with a unique solution.

Case 1: distinct linear factors, and the cover-up method

5x−4x2−x−2=5x−4(x−2)(x+1)=Ax−2+Bx+1\frac{5x - 4}{x^2 - x - 2} = \frac{5x - 4}{(x - 2)(x + 1)} = \frac{A}{x - 2} + \frac{B}{x + 1}

Multiply by (x−2)(x+1)(x - 2)(x + 1): 5x−4=A(x+1)+B(x−2)5x - 4 = A(x + 1) + B(x - 2). Setting x=2x = 2 kills the BB term: 6=3A6 = 3A, so A=2A = 2. Setting x=−1x = -1: −9=−3B-9 = -3B, so B=3B = 3.

Heaviside's cover-up rule does this in one move: to find the coefficient of 1x−r\frac{1}{x - r}, cover the factor (x−r)(x - r) in the original fraction and evaluate the rest at x=rx = r.

A=5⋅2−42+1=2,B=5⋅(−1)−4−1−2=3∫5x−4x2−x−2 dx=2ln⁡∣x−2∣+3ln⁡∣x+1∣+C\begin{aligned} &A = \frac{5 \cdot 2 - 4}{2 + 1} = 2, \qquad B = \frac{5 \cdot (-1) - 4}{-1 - 2} = 3 \\ &\int \frac{5x - 4}{x^2 - x - 2}\,dx = 2 \ln\lvert x - 2 \rvert + 3 \ln\lvert x + 1 \rvert + C \end{aligned}
python · try it yourself
import sympy as sp

x = sp.symbols('x')
f = (5*x - 4) / (x**2 - x - 2)
print("apart:", sp.apart(f))

def cover_up(num, den, r):
    """Coefficient of 1/(x - r) for a simple root r of den."""
    rest = sp.cancel(den / (x - r))
    return sp.simplify(num.subs(x, r) / rest.subs(x, r))

print("cover-up:", {r: cover_up(5*x - 4, x**2 - x - 2, r) for r in sp.roots(x**2 - x - 2)})
print("integral:", sp.integrate(f, x))
apart: 3/(x + 1) + 2/(x - 2)
cover-up: {2: 2, -1: 3}
integral: 2*log(x - 2) + 3*log(x + 1)

Case 2: repeated linear factors

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

Cover-up gives A=1/1=1A = 1/1 = 1 (at x=0x = 0) and C=2/1=2C = 2/1 = 2 (cover (x−1)2(x - 1)^2, evaluate at 1). BB needs one more equation; compare the x2x^2 coefficients: 1=A+B1 = A + B, so B=0B = 0.

∫=ln⁡∣x∣−2x−1+C\int = \ln\lvert x \rvert - \frac{2}{x - 1} + C

Cases 3 and 4: irreducible quadratics

A quadratic factor contributes a term Bx+Cx2+k2\frac{Bx + C}{x^2 + k^2}, which splits into a logarithm and an arctangent:

∫Bx+Cx2+k2 dx=B2ln⁡(x2+k2)+Cktan⁡−1xk+K\int \frac{Bx + C}{x^2 + k^2}\,dx = \frac{B}{2} \ln(x^2 + k^2) + \frac{C}{k} \tan^{-1}\frac{x}{k} + K

If the quadratic is not of the form x2+k2x^2 + k^2, complete the square first. Repeated quadratic factors lead to integrals like ∫dx(x2+1)2\int \frac{dx}{(x^2 + 1)^2}, handled with x=tan⁡θx = \tan\theta (Trigonometric Substitution).

python · try it yourself
import sympy as sp

x = sp.symbols('x')
examples = [
    (x**3 + 2*x) / (x**2 - 1),                     # improper: division first
    (x**2 + 1) / (x * (x - 1)**2),                 # repeated linear
    (2*x**2 - x + 4) / (x**3 + 4*x),               # linear × irreducible quadratic
    (x + 3) / ((x - 1) * (x**2 + 2*x + 5)),        # quadratic needing completed square
]
for f in examples:
    print("f     =", f)
    print("apart =", sp.apart(f))
    print("∫ f   =", sp.integrate(f, x))
    print()
f     = (x**3 + 2*x)/(x**2 - 1)
apart = x + 3/(2*(x + 1)) + 3/(2*(x - 1))
∫ f   = x**2/2 + 3*log(x**2 - 1)/2

f     = (x**2 + 1)/(x*(x - 1)**2)
apart = 2/(x - 1)**2 + 1/x
∫ f   = log(x) - 2/(x - 1)

f     = (2*x**2 - x + 4)/(x**3 + 4*x)
apart = (x - 1)/(x**2 + 4) + 1/x
∫ f   = log(x) + log(x**2 + 4)/2 - atan(x/2)/2

f     = (x + 3)/((x - 1)*(x**2 + 2*x + 5))
apart = -(x + 1)/(2*(x**2 + 2*x + 5)) + 1/(2*(x - 1))
∫ f   = log(x - 1)/2 - log(x**2 + 2*x + 5)/4

Every result is built from polynomials, log and atan, as the theorem promises. SymPy writes log(x - 1) where we write ln⁡∣x−1∣\ln\lvert x - 1 \rvert: it works with complex logarithms, which differ from the real ln⁡∣…∣\ln\lvert \ldots \rvert only by a constant on each interval.

Rationalising substitutions

Some non-rational integrands become rational after a substitution. For ∫x+4x dx\int \frac{\sqrt{x + 4}}{x}\,dx, set u=x+4u = \sqrt{x + 4}, so x=u2−4x = u^2 - 4 and dx=2u dudx = 2u\,du:

∫uu2−4⋅2u du=∫(2+8u2−4) du=2u+2ln⁡∣u−2u+2∣+C\int \frac{u}{u^2 - 4} \cdot 2u\,du = \int \Big(2 + \frac{8}{u^2 - 4}\Big)\,du = 2u + 2 \ln\Big\lvert \frac{u - 2}{u + 2} \Big\rvert + C

The same trick (t=tan⁡(x/2)t = \tan(x/2), the Weierstrass substitution) turns any rational function of sin⁡x\sin x and cos⁡x\cos x into a rational function of tt.

Partial fractions in signal processing

Linear filters and control systems are described by transfer functions, rational functions of ss (Laplace) or zz (digital). Their partial-fraction expansion separates the response into independent modes, one per pole. For example, H(s)=s+3s2+3s+2H(s) = \frac{s + 3}{s^2 + 3s + 2} has poles at −1 and −2, and its impulse response is the inverse Laplace transform of the expanded terms:

python · try it yourself
import sympy as sp
from scipy import signal

s, t = sp.symbols('s t')
H = (s + 3) / (s**2 + 3*s + 2)
print("expansion:", sp.apart(H, s))
print("impulse response h(t) =", sp.inverse_laplace_transform(H, s, t).subs(sp.Heaviside(t), 1))
r, p, k = signal.residue([1, 3], [1, 3, 2])
print("scipy.signal.residue: residues", [float(v.real) for v in r], "poles", [float(v.real) for v in p])
expansion: -1/(s + 2) + 2/(s + 1)
impulse response h(t) = 2*exp(-t) - exp(-2*t)
scipy.signal.residue: residues [2.0, -1.0] poles [-1.0, -2.0]

The residues are the cover-up coefficients: −1+3−1+2=2\frac{-1 + 3}{-1 + 2} = 2 at s=−1s = -1 and −2+3−2+1=−1\frac{-2 + 3}{-2 + 1} = -1 at s=−2s = -2, giving h(t)=2e−t−e−2th(t) = 2e^{-t} - e^{-2t}.

In software

  • Control and filter design. scipy.signal.residue / residuez, MATLAB's residue and every circuit simulator expand transfer functions into partial fractions to find modes, stability (all poles in the left half-plane) and time responses.
  • Logistic growth. Separating dPdt=kP(1−PM)\frac{dP}{dt} = kP\big(1 - \frac{P}{M}\big) leads to ∫dPP(M−P)\int \frac{dP}{P(M - P)}, solved by partial fractions; the result is the sigmoid (Models for Population Growth).
  • Computer algebra. The Risch–Norman and Hermite reduction algorithms that CAS systems use for rational functions are partial fractions made systematic (Integration with Tables and Computer Algebra).

Exercises

Exercise 1: Distinct linear factors

Compute ∫dxx2−9\int \frac{dx}{x^2 - 9}.

Answer

16ln⁡∣x−3x+3∣+C\frac{1}{6} \ln\Big\lvert \frac{x - 3}{x + 3} \Big\rvert + C.

Solution

Cover-up: 1(x−3)(x+3)=1/6x−3−1/6x+3\frac{1}{(x - 3)(x + 3)} = \frac{1/6}{x - 3} - \frac{1/6}{x + 3}.

Exercise 2: A repeated factor

Decompose 3x+5(x+1)2\frac{3x + 5}{(x + 1)^2} and integrate.

Answer

3x+1+2(x+1)2\frac{3}{x + 1} + \frac{2}{(x + 1)^2}; integral 3ln⁡∣x+1∣−2x+1+C3 \ln\lvert x + 1 \rvert - \frac{2}{x + 1} + C.

Solution

3x+5=3(x+1)+23x + 5 = 3(x + 1) + 2, so divide by (x+1)2(x + 1)^2.

python · try it yourself
import sympy as sp
x = sp.symbols('x')
f = (3*x + 5) / (x + 1)**2
print(sp.apart(f), "|", sp.integrate(f, x))
3/(x + 1) + 2/(x + 1)**2 | 3*log(x + 1) - 2/(x + 1)

Exercise 3: An irreducible quadratic

Compute ∫01x+2x2+1 dx\int_0^1 \frac{x + 2}{x^2 + 1}\,dx.

Answer

ln⁡22+π2≈1.9174\frac{\ln 2}{2} + \frac{\pi}{2} \approx 1.9174.

Solution

∫xx2+1=12ln⁡(x2+1)\int \frac{x}{x^2 + 1} = \frac{1}{2}\ln(x^2 + 1) and ∫2x2+1=2tan⁡−1x\int \frac{2}{x^2 + 1} = 2\tan^{-1} x. On [0,1][0, 1]: 12ln⁡2+2⋅π4\frac{1}{2} \ln 2 + 2 \cdot \frac{\pi}{4}.

Exercise 4: Count the unknowns

Write the form (without solving) of the decomposition of x4+1x2(x2+x+1)2(x−5)\frac{x^4 + 1}{x^2(x^2 + x + 1)^2(x - 5)}.

Answer

Ax+Bx2+Cx+Dx2+x+1+Ex+F(x2+x+1)2+Gx−5\frac{A}{x} + \frac{B}{x^2} + \frac{Cx + D}{x^2 + x + 1} + \frac{Ex + F}{(x^2 + x + 1)^2} + \frac{G}{x - 5}: seven constants.

Solution

deg⁡Q=2+4+1=7>4\deg Q = 2 + 4 + 1 = 7 > 4, so the fraction is proper. x2+x+1x^2 + x + 1 has discriminant −3, so it is irreducible. One term per power of each factor, as in the table.

Test yourself

What must you check before decomposing P(x)/Q(x)P(x)/Q(x)?

  1. That PP has no real roots
  2. That deg⁡P<deg⁡Q\deg P < \deg Q (otherwise divide first)
  3. That QQ is irreducible
  4. That P(0)=0P(0) = 0

Using the cover-up rule, what is AA in x+7(x−1)(x+2)=Ax−1+Bx+2\frac{x + 7}{(x - 1)(x + 2)} = \frac{A}{x - 1} + \frac{B}{x + 2}?

  1. −53-\frac{5}{3}
  2. 7
  3. 1
  4. 83\frac{8}{3}

An irreducible quadratic factor x2+4x^2 + 4 contributes which kind of term?

  1. Ax2+4\frac{A}{x^2 + 4}
  2. Ax+2+Bx−2\frac{A}{x + 2} + \frac{B}{x - 2}
  3. Bx+Cx2+4\frac{Bx + C}{x^2 + 4}
  4. Aln⁡(x2+4)A \ln(x^2 + 4)