Chapter VI · Derivatives and integrals

Integrating rational functions

§§133–134 40 min

Partial fractions reduce every real rational function to pieces we can integrate, and the answer is always a rational function plus logarithms plus inverse tangents, provided we can factor the denominator.

Why this matters

After polynomials come rational functions R(x)=P(x)/Q(x)R(x) = P(x)/Q(x). Here Hardy proves something remarkable: there is a complete method. Every real rational function can be integrated, and the answer is always built from just three kinds of function: rational functions, logarithms and inverse tangents. The method is partial fractions, the same decomposition that made rational functions easy to differentiate in §118. Its one weak point, Hardy notes in §134, is that it needs the roots of the denominator.

The idea

A rational function such as 1x2−1\dfrac{1}{x^2 - 1} has no standard form of its own. But it is the sum of two simple fractions,

1x2−1=1/2x−1−1/2x+1,\frac{1}{x^2-1} = \frac{1/2}{x-1} - \frac{1/2}{x+1},

and each of those is a standard form: ∫dx/(x−α)=log⁡∣x−α∣\int dx/(x - \alpha) = \log|x - \alpha|. So the plan is: split RR into pieces with one factor of the denominator each, integrate each piece, and add.

Why must such a splitting exist? Near each root α\alpha of QQ, the function RR blows up like a multiple of 1/(x−α)p1/(x-\alpha)^p; each piece of the decomposition captures exactly the misbehaviour at one root, and what is left over is a polynomial. The widget lets you see this.

Explore Split a rational function into partial fractions

Try this. Step through the method with Next step. Then, with all the pieces switched on, the dashed curve lies on top of RR. Switch one piece off at a time and watch where the dashed curve parts company from RR. Try the example “a repeated root” and “divide first” too.

R(x)=1x2−1R(x) = \dfrac{1}{x^2-1}
  1. Factor the denominator
    x2−1=(x−1)(x+1)x^2 - 1 = (x-1)(x+1)
Step 1 of 4
xy
  • R(x)
  • sum of the pieces switched on
  • poles
All pieces are on: their sum is R itself, so the sum of their integrals (right of each arrow) is an integral of R.
What to notice

Switching off a piece with denominator x−αx - \alpha or (x−α)2(x-\alpha)^2 spoils the curve near the pole at α\alpha and hardly anywhere else: each pole has its own pieces. In “divide first”, switching off the polynomial piece xx spoils the curve far away instead: the polynomial part is what RR looks like for large ∣x∣|x|. A quadratic factor such as x2+1x^2 + 1, with no real root, causes no pole but gives an arctan in the integral.

Precise statements

From §118, every rational function can be written as a polynomial Π(x)\Pi(x) plus a finite sum of terms

A(x−α)p,p≥1,\frac{A}{(x-\alpha)^p}, \qquad p \ge 1,

where α\alpha runs through the roots of Q(x)=0Q(x) = 0, possibly complex. The polynomial part is found by long division when deg⁡P≥deg⁡Q\deg P \ge \deg Q.

The polynomial is integrated by §132, and when p≥2p \ge 2,

∫A dx(x−α)p=−Ap−1 1(x−α)p−1,\int \frac{A\,dx}{(x-\alpha)^p} = -\frac{A}{p-1}\,\frac{1}{(x-\alpha)^{p-1}},

which holds whether α\alpha is real or complex. The terms with p=1p = 1 need a new rule, which is the chain rule read backwards.

Theorem The chain rule backwards Hardy: §133 (3), (5)

If FF is differentiable and ff is differentiable, then

∫F′{f(x)} f′(x) dx=F{f(x)},in particular∫f′(x)f(x) dx=log⁡∣f(x)∣.\int F'\{f(x)\}\,f'(x)\,dx = F\{f(x)\}, \qquad\text{in particular}\qquad \int \frac{f'(x)}{f(x)}\,dx = \log|f(x)| .

With f(x)=x−αf(x) = x - \alpha and α\alpha real, this gives ∫dx/(x−α)=log⁡∣x−α∣\int dx/(x - \alpha) = \log|x - \alpha|. That leaves the terms with p=1p = 1 and α\alpha complex. Here Hardy assumes, as we do from now on, that RR has real coefficients. Then complex roots come in conjugate pairs γ±δi\gamma \pm \delta i, and the corresponding partial fractions have conjugate numerators, so they combine into one real fraction

Ax+Bax2+2bx+c,b2<ac.\frac{Ax + B}{ax^2 + 2bx + c}, \qquad b^2 < ac .

Completing the square, ax2+2bx+c=a{(x−λ)2+μ2}ax^2 + 2bx + c = a\{(x - \lambda)^2 + \mu^2\} with λ=−b/a\lambda = -b/a and μ2=(ac−b2)/a2>0\mu^2 = (ac - b^2)/a^2 > 0. Then we split the numerator as a multiple of the derivative of the denominator plus a constant, and use

∫2(x−λ)(x−λ)2+μ2 dx=log⁡{(x−λ)2+μ2},∫dx(x−λ)2+μ2=1μarctan⁡x−λμ.\int \frac{2(x-\lambda)}{(x-\lambda)^2 + \mu^2}\,dx = \log\{(x-\lambda)^2 + \mu^2\}, \qquad \int \frac{dx}{(x-\lambda)^2 + \mu^2} = \frac1\mu\arctan\frac{x - \lambda}{\mu} .

The first is the f′/ff'/f rule; the second is the standard form ∫dx/(1+u2)=arctan⁡u\int dx/(1+u^2) = \arctan u with u=(x−λ)/μu = (x-\lambda)/\mu and the linear change of variable.

Theorem What the integral of a rational function looks like Hardy: §133

Let RR be a rational function with real coefficients, and suppose the roots of its denominator are known. Then ∫R(x) dx\int R(x)\,dx is the sum of a polynomial, finitely many rational functions of the form −Ap−11(x−α)p−1-\dfrac{A}{p-1}\dfrac{1}{(x-\alpha)^{p-1}} (complex ones occurring in conjugate pairs, whose sums are real), finitely many logarithms and finitely many inverse tangents.

One worked case is worth having as a formula. Put X=ax2+2bx+cX = ax^2 + 2bx + c, Δ=ac−b2\Delta = ac - b^2 and D=aB−bAD = aB - bA. Then for Δ>0\Delta > 0 (no real roots)

∫Ax+BX dx=A2alog⁡∣X∣+DaΔarctan⁡ax+bΔ.\int \frac{Ax + B}{X}\,dx = \frac{A}{2a}\log|X| + \frac{D}{a\sqrt{\Delta}}\arctan\frac{ax + b}{\sqrt{\Delta}} .

Proofs

Proof The chain rule backwards
Strategy

Differentiate the right-hand side.

Chain rule

By §114, ddxF{f(x)}=F′{f(x)} f′(x)\dfrac{d}{dx}F\{f(x)\} = F'\{f(x)\}\,f'(x), which is the integrand.

The logarithmic case

Take F(u)=log⁡∣u∣F(u) = \log|u|, so F′(u)=1/uF'(u) = 1/u for u≠0u \ne 0. Then ddxlog⁡∣f(x)∣=f′(x)/f(x)\dfrac{d}{dx}\log|f(x)| = f'(x)/f(x) wherever f(x)≠0f(x) \ne 0.

Proof What the integral of a rational function looks like
Strategy

Decompose into partial fractions and show that each kind of term has an integral of one of the listed kinds. The only real work is the pair of terms coming from a pair of conjugate complex roots with p=1p = 1.

Polynomial part and the terms with p≥2p \ge 2

The polynomial integrates to a polynomial. A term A/(x−α)pA/(x-\alpha)^p with p≥2p \ge 2 integrates to −A/{(p−1)(x−α)p−1}-A/\{(p-1)(x-\alpha)^{p-1}\}: differentiate to check. For complex α\alpha these occur with their conjugates, and a sum w+wˉw + \bar w is real.

Terms with p=1p = 1 and α\alpha real

∫A dx/(x−α)=Alog⁡∣x−α∣\int A\,dx/(x-\alpha) = A\log|x - \alpha|, by the chain rule backwards.

Terms with p=1p = 1 and α=γ+δi\alpha = \gamma + \delta i complex

The conjugate term is present too. Adding (λ+μi)/(x−γ−δi)(\lambda + \mu i)/(x - \gamma - \delta i) and (λ−μi)/(x−γ+δi)(\lambda - \mu i)/(x - \gamma + \delta i) gives the real fraction 2{λ(x−γ)−μδ}(x−γ)2+δ2\dfrac{2\{\lambda(x - \gamma) - \mu\delta\}}{(x-\gamma)^2 + \delta^2}.

Integrate that fraction

Its first part is λ\lambda times 2(x−γ)/{(x−γ)2+δ2}2(x - \gamma)/\{(x-\gamma)^2 + \delta^2\}, with integral λlog⁡{(x−γ)2+δ2}\lambda\log\{(x-\gamma)^2 + \delta^2\}. Its second part is the constant −2μδ-2\mu\delta over (x−γ)2+δ2(x-\gamma)^2+\delta^2, with integral −2μarctan⁡{(x−γ)/δ}-2\mu\arctan\{(x - \gamma)/\delta\}.

Add up

Every piece is a polynomial, a rational function, a logarithm or an inverse tangent, and so is their sum.

The proof is constructive, which is the point: it is also the algorithm. Its first step (§134) is to solve Q(x)=0Q(x) = 0. For Q(x)=x5+x+3Q(x) = x^5 + x + 3 we cannot do that by a formula, and the method stalls, although the integral certainly exists.

Worked examples and exercises

Exercise The quadratic denominator, in general ●●○ Hardy: Examples XLVIII, 1

With X=ax2+2bx+cX = ax^2 + 2bx + c, Δ=ac−b2>0\Delta = ac - b^2 > 0 and D=aB−bAD = aB - bA, prove that

∫Ax+BX dx=A2alog⁡∣X∣+DaΔarctan⁡ax+bΔ.\int \frac{Ax + B}{X}\,dx = \frac{A}{2a}\log|X| + \frac{D}{a\sqrt\Delta}\arctan\frac{ax+b}{\sqrt\Delta}.
Hint
Write Ax+B=A2a(2ax+2b)+(B−Aba)Ax + B = \dfrac{A}{2a}(2ax + 2b) + \left(B - \dfrac{Ab}{a}\right). The first part is a multiple of X′X'.
Hint
For the rest, aX=(ax+b)2+ΔaX = (ax + b)^2 + \Delta.
Solution

Since X′=2ax+2bX' = 2ax + 2b, we have Ax+B=A2aX′+DaAx + B = \dfrac{A}{2a}X' + \dfrac{D}{a}. So

∫Ax+BX dx=A2alog⁡∣X∣+Da∫dxX.\int \frac{Ax+B}{X}\,dx = \frac{A}{2a}\log|X| + \frac{D}{a}\int\frac{dx}{X}.

Now aX=(ax+b)2+ΔaX = (ax+b)^2 + \Delta, so 1X=a(ax+b)2+Δ\dfrac1X = \dfrac{a}{(ax+b)^2 + \Delta}. Put u=ax+bu = ax + b: by the linear change of variable and ∫du/(u2+Δ)=Δ−1/2arctan⁡(u/Δ)\int du/(u^2 + \Delta) = \Delta^{-1/2}\arctan(u/\sqrt\Delta),

∫dxX=1a⋅a⋅1Δarctan⁡ax+bΔ=1Δarctan⁡ax+bΔ.\int \frac{dx}{X} = \frac{1}{a}\cdot a\cdot\frac{1}{\sqrt\Delta}\arctan\frac{ax+b}{\sqrt\Delta} = \frac{1}{\sqrt\Delta}\arctan\frac{ax+b}{\sqrt\Delta}.

Multiplying by D/aD/a gives the formula. (For Δ<0\Delta < 0 the same split works, but XX now factors over the reals and the second integral is a logarithm: Hardy gives D2a−Δlog⁡∣ax+b−−Δax+b+−Δ∣\dfrac{D}{2a\sqrt{-\Delta}}\log\left|\dfrac{ax + b - \sqrt{-\Delta}}{ax + b + \sqrt{-\Delta}}\right|.)

Exercise Distinct real roots: a formula for the coefficients ●●○ Hardy: Examples XLVIII, 3

Let the roots of Q(x)=0Q(x) = 0 be real and distinct, and deg⁡P<deg⁡Q\deg P < \deg Q. Show that

∫P(x)Q(x) dx=∑αP(α)Q′(α)log⁡∣x−α∣,\int \frac{P(x)}{Q(x)}\,dx = \sum_\alpha \frac{P(\alpha)}{Q'(\alpha)}\log|x - \alpha|,

the sum over the roots α\alpha of QQ.

Hint
Write P/Q=∑Aα/(x−α)P/Q = \sum A_\alpha/(x - \alpha). Multiply by x−αx - \alpha and let x→αx \to \alpha.
Hint
Q(x)/(x−α)→Q′(α)Q(x)/(x - \alpha) \to Q'(\alpha) as x→αx \to \alpha, since Q(α)=0Q(\alpha) = 0.

Solution

Since deg⁡P<deg⁡Q\deg P < \deg Q and the roots are simple, P(x)/Q(x)=∑βAβ/(x−β)P(x)/Q(x) = \sum_\beta A_\beta/(x - \beta). Multiply by x−αx - \alpha:

(x−α)P(x)Q(x)=Aα+(x−α)∑β≠αAβx−β.\frac{(x - \alpha)P(x)}{Q(x)} = A_\alpha + (x - \alpha)\sum_{\beta \ne \alpha}\frac{A_\beta}{x - \beta}.

As x→αx \to \alpha the right side tends to AαA_\alpha. On the left, Q(x)x−α=Q(x)−Q(α)x−α→Q′(α)\dfrac{Q(x)}{x - \alpha} = \dfrac{Q(x) - Q(\alpha)}{x - \alpha} \to Q'(\alpha), which is not 00 because α\alpha is a simple root. So Aα=P(α)/Q′(α)A_\alpha = P(\alpha)/Q'(\alpha), and integrating each term gives the formula. This is the “cover-up rule” used in the widget: P(α)/Q′(α)P(\alpha)/Q'(\alpha) is what you get by deleting the factor x−αx - \alpha from QQ and putting x=αx = \alpha.

Exercise Three distinct linear factors ●○○ Hardy: Examples XLVIII, 6

Integrate x(x−a)(x−b)(x−c)\dfrac{x}{(x-a)(x-b)(x-c)}, where a,b,ca, b, c are distinct.

Hint
Use the previous exercise, or cover up each factor in turn.

Solution

Covering up x−ax - a and putting x=ax = a gives the coefficient a(a−b)(a−c)\dfrac{a}{(a-b)(a-c)}, and similarly for bb and cc. So

∫x dx(x−a)(x−b)(x−c)=alog⁡∣x−a∣(a−b)(a−c)+blog⁡∣x−b∣(b−c)(b−a)+clog⁡∣x−c∣(c−a)(c−b).\int \frac{x\,dx}{(x-a)(x-b)(x-c)} = \frac{a\log|x-a|}{(a-b)(a-c)} + \frac{b\log|x-b|}{(b-c)(b-a)} + \frac{c\log|x-c|}{(c-a)(c-b)} .
Exercise A cubic denominator ●●○ Hardy: Examples XLVIII, 7

Integrate x1+x3\dfrac{x}{1+x^3}.

Hint
1+x3=(1+x)(1−x+x2)1 + x^3 = (1+x)(1 - x + x^2), and the quadratic has no real roots. The widget’s example 1/(x3+1)1/(x^3+1) uses the same factorisation.
Hint
Template: A1+x+Bx+Cx2−x+1\dfrac{A}{1+x} + \dfrac{Bx + C}{x^2 - x + 1}. Cover-up gives AA; compare coefficients for BB, CC.

Solution

Cover-up at x=−1x = -1: A=−11+1+1=−13A = \dfrac{-1}{1 + 1 + 1} = -\tfrac13. Then x=A(x2−x+1)+(Bx+C)(x+1)x = A(x^2 - x + 1) + (Bx + C)(x + 1); the x2x^2 terms give B=13B = \tfrac13, the constants give C=13C = \tfrac13. So

x1+x3=−13(x+1)+13 x+1x2−x+1=−13(x+1)+16 2x−1x2−x+1+12 1(x−12)2+34.\frac{x}{1+x^3} = -\frac{1}{3(x+1)} + \frac13\,\frac{x + 1}{x^2 - x + 1} = -\frac{1}{3(x+1)} + \frac16\,\frac{2x-1}{x^2-x+1} + \frac12\,\frac{1}{(x-\frac12)^2 + \frac34}.

Integrating,

∫x dx1+x3=−13log⁡∣x+1∣+16log⁡(x2−x+1)+13arctan⁡2x−13.\int\frac{x\,dx}{1+x^3} = -\tfrac13\log|x+1| + \tfrac16\log(x^2 - x + 1) + \tfrac{1}{\sqrt3}\arctan\frac{2x-1}{\sqrt3}.

Check by differentiating: the three derivatives add to −13(x+1)+2x−16(x2−x+1)+12{(x−12)2+34}-\dfrac{1}{3(x+1)} + \dfrac{2x-1}{6(x^2-x+1)} + \dfrac{1}{2\{(x-\frac12)^2+\frac34\}}, which is the decomposition above.

Exercise Hardy’s worked example ●●○ Hardy: Examples XLVIII, 5

Calculate ∫dx{(x−1)(x2+1)}2\displaystyle\int \frac{dx}{\{(x-1)(x^2+1)\}^2}. (Choose Hardy’s example in the widget to step through it after trying.)

Hint
The template has four pieces: A(x−1)2+Bx−1+Cx+D(x2+1)2+Ex+Fx2+1\dfrac{A}{(x-1)^2} + \dfrac{B}{x-1} + \dfrac{Cx + D}{(x^2+1)^2} + \dfrac{Ex + F}{x^2+1}.
Hint
AA comes from cover-up at x=1x = 1: A=1/(1+1)2A = 1/(1+1)^2. For the others, clear denominators and compare coefficients, or use x=ix = i.

Solution

The decomposition is

14(x−1)2−12(x−1)+x2(x2+1)2+2x+14(x2+1),\frac{1}{4(x-1)^2} - \frac{1}{2(x-1)} + \frac{x}{2(x^2+1)^2} + \frac{2x + 1}{4(x^2+1)} ,

which you can confirm by putting it over the common denominator. Integrating term by term (with ∫x dx/(x2+1)2=−1/{2(x2+1)}\int x\,dx/(x^2+1)^2 = -1/\{2(x^2+1)\} by the chain rule backwards):

−14(x−1)−14(x2+1)−12log⁡∣x−1∣+14log⁡(x2+1)+14arctan⁡x.-\frac{1}{4(x-1)} - \frac{1}{4(x^2+1)} - \frac12\log|x-1| + \frac14\log(x^2+1) + \frac14\arctan x .

This is Hardy’s answer. Hardy reaches the same decomposition through complex partial fractions with denominators (x∓i)(x \mp i) and (x∓i)2(x \mp i)^2; pairing conjugates gives the real form.

Check yourself

Check yourself Choose one

Which is the correct template for x+1x2(x2+4)\dfrac{x+1}{x^2(x^2+4)}?

Why

A repeated factor x2x^2 needs one term for each power, A/x+B/x2A/x + B/x^2; an irreducible quadratic needs a linear numerator Cx+DCx + D. The last option factors x2+4x^2 + 4 as if it were x2−4x^2 - 4. (In fact A=B=14A = B = \tfrac14, C=D=−14C = D = -\tfrac14.)

Check yourself Enter a number

In 1(x−2)(x+3)=Ax−2+Bx+3\dfrac{1}{(x-2)(x+3)} = \dfrac{A}{x-2} + \dfrac{B}{x+3}, what is AA?

Why

Cover up x−2x - 2 and put x=2x = 2: A=1/(2+3)=15A = 1/(2 + 3) = \tfrac15. Similarly B=1/(−3−2)=−15B = 1/(-3-2) = -\tfrac15.

Check yourself True or false?

The integral of a rational function is always a rational function.

Why

False. ∫dx/x=log⁡∣x∣\int dx/x = \log|x| and ∫dx/(1+x2)=arctan⁡x\int dx/(1+x^2) = \arctan x are not rational, and §131 showed 1/x1/x is not the derivative of any rational function. The integral is rational exactly when no terms with p=1p = 1 survive in the partial fractions.

Check yourself Choose one

∫3x2+1x3+x+5 dx=\displaystyle\int \frac{3x^2 + 1}{x^3 + x + 5}\,dx = {}

Why

The numerator is exactly the derivative of the denominator, so the f′/ff'/f rule applies directly, with no need for the roots. Hardy’s warning in §134 is about the general method; look for f′/ff'/f before reaching for partial fractions.

Hardy’s language

In more complicated cases the labour involved is sometimes prohibitive, and other devices have to be used.

— G. H. Hardy, §134

Summary

Summary
  • Divide first if the numerator has degree at least that of the denominator; then split the proper part into partial fractions.
  • ∫A/(x−α)p\int A/(x-\alpha)^p is −A/{(p−1)(x−α)p−1}-A/\{(p-1)(x-\alpha)^{p-1}\} for p≥2p \ge 2 and Alog⁡∣x−α∣A\log|x-\alpha| for p=1p = 1.
  • An irreducible quadratic factor gives a fraction (Ax+B)/(ax2+2bx+c)(Ax+B)/(ax^2+2bx+c): split off a multiple of the derivative (a log) and complete the square (an arctan).
  • The chain rule backwards, ∫F′(f) f′=F(f)\int F'(f)\,f' = F(f), and its special case ∫f′/f=log⁡∣f∣\int f'/f = \log|f| are worth looking for first.
  • The integral of a real rational function is always polynomial + rational + logs + arctans; the obstacle in practice is finding the roots of the denominator.