40  Partial Fractions

using CalculusWithJulia
using SymPy

Integration is facilitated when an antiderivative for \(f\) can be found, as then definite integrals can be evaluated through the fundamental theorem of calculus.

However, despite differentiation being an algorithmic procedure, integration is not. There are “tricks” to try, such as substitution and integration by parts. These work in some cases. However, there are classes of functions for which algorithms exist. For example, the SymPy integrate function mostly implements an algorithm that decides if an elementary function has an antiderivative. The elementary functions include exponentials, their inverses (logarithms), trigonometric functions, their inverses, and powers, including \(n\)th roots. Not every elementary function will have an antiderivative comprised of (finite) combinations of elementary functions. The typical example is \(e^{x^2}\), which has no simple antiderivative, despite its ubiquitousness.

There are classes of functions where an (elementary) antiderivative can always be found. Polynomials provide a case. More surprisingly, so do their ratios, rational functions.

40.1 Partial fraction decomposition

Let \(f(x) = p(x)/q(x)\), where \(p\) and \(q\) are polynomial functions with real coefficients. Further, we assume without comment that \(p\) and \(q\) have no common factors. (If they did, we can divide them out, an act which has no effect on the integrability of \(f(x)\).

The function \(q(x)\) will factor over the real numbers. The fundamental theorem of algebra can be applied to say that \(q(x)=q_1(x)^{n_1} \cdots q_k(x)^{n_k}\) where \(q_i(x)\) is a linear or quadratic polynomial and \(n_k\) a positive integer.

Partial Fraction Decomposition: There are unique polynomials \(a_{ij}\) with degree \(a_{ij} <\) degree \(q_i\) such that

\[ \frac{p(x)}{q(x)} = a(x) + \sum_{i=1}^k \sum_{j=1}^{n_i} \frac{a_{ij}(x)}{q_i(x)^j}. \]

The method is attributed to John Bernoulli, one of the prolific Bernoulli brothers who put a stamp on several areas of math. This Bernoulli was a mentor to Euler.

This basically says that each factor \(q_i(x)^{n_i}\) contributes a term like:

\[ \frac{a_{i1}(x)}{q_i(x)^1} + \frac{a_{i2}(x)}{q_i(x)^2} + \cdots + \frac{a_{in_i}(x)}{q_i(x)^{n_i}}, \]

where each \(a_{ij}(x)\) has degree less than the degree of \(q_i(x)\).

The value of this decomposition is that the terms \(a_{ij}(x)/q_i(x)^j\) each have an antiderivative, and so the sum of them will also have an antiderivative.

Note

Many calculus texts will give some examples for finding a partial fraction decomposition. We push that work off to SymPy, as for all but the easiest cases - a few are in the problems - it can be a bit tedious.

In SymPy, the apart function will find the partial fraction decomposition when a factorization is available. For example, here we see \(n_i\) terms for each power of \(q_i\)

@syms a::real b::real c::real A::real B::real x::real
(a, b, c, A, B, x)
apart((x-2)*(x-3) / (x*(x-1)^2*(x^2 + 2)^3))
\[ - \frac{8 x - 13}{9 \left(x^{2} + 2\right)^{3}} - \frac{35 x - 34}{54 \left(x^{2} + 2\right)^{2}} - \frac{45 x - 28}{108 \left(x^{2} + 2\right)} - \frac{1}{3 \left(x - 1\right)} + \frac{2}{27 \left(x - 1\right)^{2}} + \frac{3}{4 x} \]

40.1.1 Sketch of proof

A standard proof uses two facts of number systems: the division algorithm and a representation of the greatest common divisor in terms of sums, extended to polynomials. Our sketch shows how these are used.

Take one of the factors of the denominators, and consider this representation of the rational function \(P(x)/(q(x)^k Q(x))\) where there are no common factors to any of the three polynomials.

Since \(q(x)\) and \(Q(x)\) share no factors, Bezout’s identity says there exists polynomials \(a(x)\) and \(b(x)\) with:

\[ a(x) Q(x) + b(x) q(x) = 1. \]

Then dividing by \(q(x)^kQ(x)\) gives the decomposition

\[ \frac{1}{q(x)^k Q(x)} = \frac{a(x)}{q(x)^k} + \frac{b(x)}{q(x)^{k-1}Q(x)}. \]

So we get by multiplying the \(P(x)\):

\[ \frac{P(x)}{q(x)^k Q(x)} = \frac{A(x)}{q(x)^k} + \frac{B(x)}{q(x)^{k-1}Q(x)}. \]

This may look more complicated, but what it does is peel off one term (The first) and leave something which is smaller, in this case by a factor of \(q(x)\). This process can be repeated pulling off a power of a factor at a time until nothing is left to do.

What remains is to establish that we can take \(A(x) = a(x)\cdot P(x)\) with a degree less than that of \(q(x)\).

In Proposition 3.8 of Bradley and Cook we can see how. Recall the division algorithm, for example, says there are \(q_k\) and \(r_k\) with \(A=q\cdot q_k + r_k\) where the degree of \(r_k\) is less than that of \(q\), which is linear or quadratic. This is repeatedly applied below:

\[\begin{align*} \frac{A}{q^k} &= \frac{q\cdot q_k + r_k}{q^k}\\ &= \frac{r_k}{q^k} + \frac{q_k}{q^{k-1}}\\ &= \frac{r_k}{q^k} + \frac{q \cdot q_{k-1} + r_{k-1}}{q^{k-1}}\\ &= \frac{r_k}{q^k} + \frac{r_{k-1}}{q^{k-1}} + \frac{q_{k-1}}{q^{k-2}}\\ &= \frac{r_k}{q^k} + \frac{r_{k-1}}{q^{k-1}} + \frac{q\cdot q_{k-2} + r_{k-2}}{q^{k-2}}\\ &= \cdots\\ &= \frac{r_k}{q^k} + \frac{r_{k-1}}{q^{k-1}} + \cdots + q_1. \end{align*}\]

So the term \(A(x)/q(x)^k\) can be expressed in terms of a sum where the numerators or each term have degree less than \(q(x)\), as expected by the statement of the theorem.

40.2 Integrating the terms in a partial fraction decomposition

We discuss, by example, how each type of possible term in a partial fraction decomposition has an antiderivative. Hence, rational functions will always have an antiderivative that can be computed.

40.2.1 Linear factors

For \(j=1\), if \(q_i\) is linear, then \(a_{ij}/q_i^j\) must look like a constant over a linear term, or something like:

p = a/(x-c)
\[ \frac{a}{- c + x} \]

This has a logarithmic antiderivative:

integrate(p, x)
\[ a \log{\left(- c + x \right)} \]

For \(j > 1\), we have powers.

@syms j::positive
integrate(a/(x-c)^j, x)
\[ a \left(\begin{cases} \frac{\left(- c + x\right)^{1 - j}}{1 - j} & \text{for}\: j \neq 1 \\\log{\left(- c + x \right)} & \text{otherwise} \end{cases}\right) \]

40.2.2 Quadratic factors

When \(q_i\) is quadratic, it looks like \(ax^2 + bx + c\). Then \(a_{ij}\) can be a constant or a linear polynomial. The latter can be written as \(Ax + B\).

The integral of the following general form is presented below:

\[ \frac{Ax +B }{(ax^2 + bx + c)^j}, \]

With SymPy, we consider a few cases of the following form, which results from a shift of x

\[ \frac{Ax + B}{((ax)^2 \pm 1)^j} \]

This can be done by finding a \(d\) so that \(a(x-d)^2 + b(x-d) + c = dx^2 + e = e((\sqrt{d/e}x)^2 \pm 1)\).

The integrals of the type \(Ax/((ax)^2 \pm 1)\) can completed by \(u\)-substitution, with \(u=(ax)^2 \pm 1\).

For example,

integrate(A*x/((a*x)^2 + 1)^4, x)
\[ - \frac{A}{6 a^{8} x^{6} + 18 a^{6} x^{4} + 18 a^{4} x^{2} + 6 a^{2}} \]

The integrals of the type \(B/((ax)^2\pm 1)\) are completed by trigonometric substitution and various reduction formulas. They can get involved, but are tractable. For example:

integrate(B/((a*x)^2 + 1)^4, x)
\[ B \left(\frac{15 a^{4} x^{5} + 40 a^{2} x^{3} + 33 x}{48 a^{6} x^{6} + 144 a^{4} x^{4} + 144 a^{2} x^{2} + 48} + \frac{5 \operatorname{atan}{\left(a x \right)}}{16 a}\right) \]

and

integrate(B/((a*x)^2 - 1)^4, x)
\[ B \left(\frac{- 15 a^{4} x^{5} + 40 a^{2} x^{3} - 33 x}{48 a^{6} x^{6} - 144 a^{4} x^{4} + 144 a^{2} x^{2} - 48} - \frac{5 \log{\left(x - \frac{1}{a} \right)}}{32 a} + \frac{5 \log{\left(x + \frac{1}{a} \right)}}{32 a}\right) \]

In Bronstein this characterization can be found - “This method, which dates back to Newton, Leibniz and Bernoulli, should not be used in practice, yet it remains the method found in most calculus texts and is often taught. Its major drawback is the factorization of the denominator of the integrand over the real or complex numbers.” We can also find the following formulas which formalize the above exploratory calculations (\(j>1\) and \(b^2 - 4c < 0\) below):

\[\begin{align*} \int \frac{A}{(x-a)^j} &= \frac{A}{1-j}\frac{1}{(x-a)^{j-1}}\\ \int \frac{A}{x-a} &= A\log(x-a)\\ \int \frac{Bx+C}{x^2 + bx + c} &= \frac{B}{2} \log(x^2 + bx + c) + \frac{2C-bB}{\sqrt{4c-b^2}}\cdot \arctan\left(\frac{2x+b}{\sqrt{4c-b^2}}\right)\\ \int \frac{Bx+C}{(x^2 + bx + c)^j} &= \frac{B' x + C'}{(x^2 + bx + c)^{j-1}} + \int \frac{C''}{(x^2 + bx + c)^{j-1}} \end{align*}\]

The first returns a rational function; the second yields a logarithm term; the third yields a logarithm and an arctangent term; while the last, which has explicit constants available, provides a reduction that can be recursively applied;

That is integrating \(f(x)/g(x)\), a rational function, will yield an output that looks like the following, where the functions are polynomials:

\[ \int f(x)/g(x) = P(x) + \frac{C(x)}{D{x}} + \sum v_i \log(V_i(x)) + \sum w_j \arctan(W_j(x)) \]

(Bronstein also sketches the modern method which is to use a Hermite reduction to express \(\int (f/g) dx = p/q + \int (g/h) dx\), where \(h\) is square free (the “j” are all \(1\)). The latter can be written over the complex numbers as logarithmic terms of the form \(\log(x-a)\), the “as”found following a method due to Trager and Lazard, and Rioboo, which is mentioned in the SymPy documentation as the method used.)

Examples

Find an antiderivative for \(1/(x\cdot(x^2+1)^2)\).

We have a partial fraction decomposition is:

q = (x * (x^2 + 1)^2)
apart(1/q)
\[ - \frac{x}{x^{2} + 1} - \frac{x}{\left(x^{2} + 1\right)^{2}} + \frac{1}{x} \]

We see three terms. The first and second will be done by \(u\)-substitution, the third by a logarithm:

integrate(1/q, x)
\[ \log{\left(x \right)} - \frac{\log{\left(x^{2} + 1 \right)}}{2} + \frac{1}{2 x^{2} + 2} \]

Find an antiderivative of \(1/(x^2 - 2x-3)\).

We again just let SymPy do the work. A partial fraction decomposition is given by:

q =  (x^2 - 2x - 3)
apart(1/q)
\[ - \frac{1}{4 \left(x + 1\right)} + \frac{1}{4 \left(x - 3\right)} \]

We see what should yield two logarithmic terms:

integrate(1/q, x)
\[ \frac{\log{\left(x - 3 \right)}}{4} - \frac{\log{\left(x + 1 \right)}}{4} \]
Note

SymPy will find \(\log(x)\) as an antiderivative for \(1/x\), but more generally, \(\log(\lvert x\rvert)\) is one.

Example

The answers found can become quite involved. Corless, Moir, Maza, and Xie use this example which at first glance seems tame enough:

ex = (x^2 - 1) / (x^4 + 5x^2 + 7)
\[ \frac{x^{2} - 1}{x^{4} + 5 x^{2} + 7} \]

But the integral is something best suited to a computer algebra system:

integrate(ex, x)
\[ \sqrt{\frac{17}{84} + \frac{13 \sqrt{7}}{168}} \log{\left(x^{2} + x \left(- \frac{38 \sqrt{6} \sqrt{34 + 13 \sqrt{7}}}{9} - \frac{1301 \sqrt{42} \sqrt{34 + 13 \sqrt{7}}}{1638} + \frac{19 \sqrt{42} \sqrt{34 + 13 \sqrt{7}} \sqrt{884 \sqrt{7} + 2339}}{546}\right) - \frac{2124092 \sqrt{884 \sqrt{7} + 2339}}{31941} - \frac{9481 \sqrt{7} \sqrt{884 \sqrt{7} + 2339}}{378} + \frac{290246555}{63882} + \frac{4221850 \sqrt{7}}{2457} \right)} - \sqrt{\frac{17}{84} + \frac{13 \sqrt{7}}{168}} \log{\left(x^{2} + x \left(- \frac{19 \sqrt{42} \sqrt{34 + 13 \sqrt{7}} \sqrt{884 \sqrt{7} + 2339}}{546} + \frac{1301 \sqrt{42} \sqrt{34 + 13 \sqrt{7}}}{1638} + \frac{38 \sqrt{6} \sqrt{34 + 13 \sqrt{7}}}{9}\right) - \frac{2124092 \sqrt{884 \sqrt{7} + 2339}}{31941} - \frac{9481 \sqrt{7} \sqrt{884 \sqrt{7} + 2339}}{378} + \frac{290246555}{63882} + \frac{4221850 \sqrt{7}}{2457} \right)} + 2 \sqrt{- \frac{\sqrt{884 \sqrt{7} + 2339}}{84} + \frac{17}{84} + \frac{13 \sqrt{7}}{56}} \operatorname{atan}{\left(\frac{78 \sqrt{42} x}{- 9 \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}} + 19 \sqrt{884 \sqrt{7} + 2339} \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}}} - \frac{988 \sqrt{7} \sqrt{34 + 13 \sqrt{7}}}{- 9 \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}} + 19 \sqrt{884 \sqrt{7} + 2339} \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}}} - \frac{1301 \sqrt{34 + 13 \sqrt{7}}}{- 9 \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}} + 19 \sqrt{884 \sqrt{7} + 2339} \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}}} + \frac{57 \sqrt{34 + 13 \sqrt{7}} \sqrt{884 \sqrt{7} + 2339}}{- 9 \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}} + 19 \sqrt{884 \sqrt{7} + 2339} \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}}} \right)} + 2 \sqrt{- \frac{\sqrt{884 \sqrt{7} + 2339}}{84} + \frac{17}{84} + \frac{13 \sqrt{7}}{56}} \operatorname{atan}{\left(\frac{78 \sqrt{42} x}{- 9 \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}} + 19 \sqrt{884 \sqrt{7} + 2339} \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}}} - \frac{57 \sqrt{34 + 13 \sqrt{7}} \sqrt{884 \sqrt{7} + 2339}}{- 9 \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}} + 19 \sqrt{884 \sqrt{7} + 2339} \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}}} + \frac{1301 \sqrt{34 + 13 \sqrt{7}}}{- 9 \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}} + 19 \sqrt{884 \sqrt{7} + 2339} \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}}} + \frac{988 \sqrt{7} \sqrt{34 + 13 \sqrt{7}}}{- 9 \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}} + 19 \sqrt{884 \sqrt{7} + 2339} \sqrt{- 2 \sqrt{884 \sqrt{7} + 2339} + 34 + 39 \sqrt{7}}} \right)} \]

40.3 Questions

Question

The partial fraction decomposition of \(1/(x(x-1))\) must be of the form \(A/x + B/(x-1)\).

What is \(A\)? (Use SymPy or just put the sum over a common denominator and solve for \(A\) and \(B\).)


What is \(B\)?


Question

The following gives the partial fraction decomposition for a rational expression:

\[ \frac{3x+5}{(1-2x)^2} = \frac{A}{1-2x} + \frac{B}{(1-2x)^2}. \]

Find \(A\) (being careful with the sign):


Find \(B\):


Question

The following specifies the general partial fraction decomposition for a rational expression:

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

Find \(A\):


Find \(B\):


Find \(C\):


Question

Compute the following exactly:

\[ \int_0^1 \frac{(x-2)(x-3)}{(x-4)^2\cdot(x-5)} dx \]

Is \(-6\log(5) - 5\log(3) - 1/6 + 11\log(4)\) the answer?

Select an item
Question

In the assumptions for the partial fraction decomposition is the fact that \(p(x)\) and \(q(x)\) share no common factors. Suppose, this isn’t the case and in fact we have:

\[ \frac{p(x)}{q(x)} = \frac{(x-c)^m s(x)}{(x-c)^n t(x)}. \]

Here \(s\) and \(t\) are polynomials such that \(s(c)\) and \(t(c)\) are non-zero.

If \(m > n\), then why can we cancel out the \((x-c)^n\) and not have a concern?

Select an item

If \(m = n\), then why can we cancel out the \((x-c)^n\) and not have a concern?

Select an item

If \(m < n\), then why can we cancel out the \((x-c)^n\) and not have a concern?

Select an item
Question

The partial fraction decomposition, as presented, factors the denominator polynomial into linear and quadratic factors over the real numbers. Alternatively, factoring over the complex numbers is possible, resulting in terms like:

\[ \frac{a + ib}{x - (\alpha + i \beta)} + \frac{a - ib}{x - (\alpha - i \beta)} \]

How to see that these give rise to real answers on integration is the point of this question.

Breaking the terms up over \(a\) and \(b\) we have:

\[\begin{align*} I &= \frac{a}{x - (\alpha + i \beta)} + \frac{a}{x - (\alpha - i \beta)} \\ II &= i\frac{b}{x - (\alpha + i \beta)} - i\frac{b}{x - (\alpha - i \beta)} \end{align*}\]

Integrating \(I\) leads to two logarithmic terms, which are combined to give:

\[ \int I dx = a\cdot \log((x-(\alpha+i\beta)) \cdot (x - (\alpha-i\beta))) \]

This involves no complex numbers, as:

Select an item

The term \(II\) benefits from this computation (attributed to Rioboo by Corless et. al)

\[ \frac{d}{dx} i \log(\frac{X+iY}{X-iY}) = 2\frac{d}{dx}\arctan(\frac{X}{Y}) \]

Applying this with \(X=x - \alpha\) and \(Y=-\beta\) shows that \(\int II dx\) will be

Select an item