L11-intTechRational.mws
Calculus II
Lesson 11: Integration of Rational Functions
Introduction
You know from the Fundamental Theorem of Calculus that every continuous function has an anti-derivative. Specifically, if
is continuous on an interval
, then
is differentiable on the open interval (
), and
on this interval, so
is an anti-derivative for
.
On the other hand, not every (continuous) function has an
elementary
anti-derivative, which we could define loosely as an anti-derivative built up from functions discussed in first semester of Calculus. We have seen some examples already.
>
int(exp(-x^2), x);
>
int(sqrt(x^3 + 1), x);
The functions
erf
and
EllipticF
appearing in these anti-derivatives are not familiar to us: they do not appear in Stewart, and are not considered elementary.
It is therefore of some interest to know which functions
do
have elementary anti-derivatives. This worksheet will show you that every rational function does, by explicitly showing how, in principle, such a function may be anti-differentiated. (Recall that a
rational function
is a function of the form
, where
and
are polynomials.) The idea is to show first that any rational function can be written as a sum of certain special types of rational functions, then show how to find anti-derivatives for each of the special types. The special types are called
partial fractions
, and we will begin by looking at the types of partial fraction that are needed.
Partial Fractions
Suppose we are given a rational expression, for example
>
f := (x^7 + 6*x^5 - 3*x^2 + 7) /
(2*x^5 + 21*x^4 + 44*x^3 - 24*x^2 + 144*x - 432);
We will want to refer to the numerator and denominator of this expression separately, and we can extract them with the
numer
and
denom
commands:
>
P := numer(f);
>
Q := denom(f);
(Of course, we could equally well start with
and
and define
to be their quotient.)
In this example, the degree of the numerator of
is greater than or equal to the degree of the denominator, so we can divide
by
, obtaining a quotient
and a remainder
, such that
, where the degree of
is less than the degree of
. We then rewrite the expression
in this form, denoting it by
.
>
q := quo(P, Q, x);
>
r := rem(P, Q, x);
>
f1 := q + r/Q;
We can easily check that the expression
is equal to
:
>
simplify(f1);
Since the polynomial
can easily be anti-differentiated, the remaining problem is to see how to
anti-differentiate the
proper
rational function
. We will call this expression
:
>
f2 := r/Q;
The next step is always possible
in principle
, although it may be impossible to carry out in practice: we
factor the denominator into linear and irreducible quadratic factors.
>
factor(Q);
With the factorisation completed, we can write
as a sum of partial fractions:
>
f3 := convert(f2, parfrac, x);
It should now be clear that if we can anti-differentiate each term in this sum, we can anti-differentiate the original expression
. In later sections of the worksheet, we will see how to anti-differentiate any type of partial fraction, but first you should see what kinds of partial fraction can arise, and how they relate to the factorisation of the denominator.
Two observations:
1. The
convert
command is able to do the initial polynomial division as well as the subsequent decomposition. For example, using our original
,
>
convert(f, parfrac, x);
2.
The factorisation step is the biggest hurdle in the whole partial fraction method:
every other step is automatic (although the whole procedure can become extremely long and tedious), but there is no systematic method for finding the factorisation of a polynomial, although there is a theorem which guarantees that the factorisation exists.
Question 1
Here are some rational expressions. Use the
convert
command to write them in partial fractions, and observe the types of terms which can occur. Try to find a rule which relates the types of partial fraction which occur in a given decomposition to the factorisation of the numerator. Test your rule by making up other examples and seeing if you can predict the types of partial fractions you get.
Solutions.
>
g1 := 1/(x^2 - 9);
>
convert(g1,parfrac,x);
>
g2 := (3*x + 5)/(x^2 - 9);
>
convert(g2,parfrac,x);
>
g3 := (3*x + 5)/(x^2 - 9)^2;
>
convert(g3,parfrac,x);
>
g4 := (2*x^3 + x)/(x^2 - 9)^2;
>
convert(g4,parfrac,x);
>
g5 := (x^3 - 2*x^2 + 3)/(x^2 - 9)^3;
>
convert(g5,parfrac,x);
>
g6 := x/(x^2 + 9);
>
convert(g6,parfrac,x);
>
g7 := (x^7 - 1)/(x^2 + 5)^4;
>
convert(g7,parfrac,x);
>
g8 := 1/(x^10 - 3*x^8 + 8*x^7 - 18*x^6 + 24*x^5 - 26*x^4 + 24*x^3 - 15*x^2 + 8*x - 3);
>
factor(denom(g8));
>
convert(g8,parfrac,x);
>
g9 := (x^7 + x^5 + x^3 + 1) /
(x^10 - 3*x^8 + 8*x^7 - 18*x^6 + 24*x^5 - 26*x^4 + 24*x^3 - 15*x^2 + 8*x - 3);
>
factor(denom(g9));
>
convert(g9,parfrac,x);
The denominators of the partial fractions are factors (or powers of factors) of the denominator of the original fraction. If a factor appears only once in the denominator, there is a single partial fraction with that factor as its denominator; if a factor is repeated, there will be partial fractions with that power
and all lower powers
of that factor in their denominators.
As for the numerators of the partial fractions: any partial fraction coming from a linear factor has a constant in its numerator (
Maple
writes this constant in front of the fraction, leaving a numerator of 1); any partial fraction coming from an irreducible quadratic factor has at most a linear polynomial in the numerator.
Terms arising from Linear Factors
After doing Question 1 in the last section, you should be convinced that (apart from a possible polynomial) only two types of partial fraction show up in the decomposition of a rational function. If the denominator of the original rational function has a linear factor
, possibly repeated, there will be
partial fractions of the form
in the decomposition; if the original denominator has an irreducible quadratic factor
, possibly repeated, there will be partial fractions of the form
. In each case, the highest value of
which appears is the number of times the corresponding factor is repeated in the original denominator. It follows that if we can find anti-derivatives for each of these expressions, we can anti-differentiate any rational function.
It is easy to find anti-derivatives for the partial fractions arising from linear factors: just substitute
. Here are two worked examples, using
changevar
from the
student
package.
>
with(student):
>
p1 := Int(1/(2*x - 3), x);
>
p2 := changevar(u=2*x - 3, p1, u);
>
p3 := simplify(p2);
>
p4 := value(p3);
>
p5 := subs(u = 2*x - 3, p4);
>
p1 = p5 + C;
>
q1 := Int(1/(4*x + 17)^6, x);
>
q2 := changevar(u = 4*x + 17, q1, u);
>
q3 := simplify(q2);
>
q4 := value(q3);
>
q5 := subs(u = 4*x + 17, q4);
>
q1 = q5 + C;
After the suggested substitution, the problem reduces to finding
. If
we get a logarithm term; otherwise the anti-derivative is a rational function again.
Question 2
Use the method shown above to find the following anti-derivatives:
(a)
Solution.
>
p1 := Int(1/(4*x + 5)^3, x);
>
p2 := changevar(u = 4*x + 5, p1, u);
>
p3 := simplify(p2);
>
p4 := value(p3);
>
p5 := subs(u = 4*x + 5, p4);
>
p1 = p5 + C;
>
(b)
Solution.
>
q1 := Int(1/(sqrt(2)*x - 1), x);
>
q2 := changevar(u = sqrt(2)*x - 1, q1, u);
>
q3 := simplify(q2);
>
q4 := value(q3);
>
q5 := subs(u = sqrt(2)*x - 1, q4);
>
q1 = q5 + C;
>
(c)
Solution.
>
r1 := Int(5/(x + 2), x);
>
r2 := changevar(u = x+2, r1, u);
>
r3 := simplify(r2);
>
r4 := value(r3);
>
r5 := subs(u = x+2, r4);
>
r1 = r5 + C;
Terms arising from Quadratic Factors
In this section, we will see how to anti-differentiate the second type of partial fraction: one of the
form
arising from an irreducible quadratic factor
in the original denominator.
We will begin by looking at two special cases. The general case can then be handled by cleverly combining these two.
CASE 1:
.
In this case, our partial fraction looks like
. The constant
in the numerator can be pulled through the anti-derivative sign, so we may as well assume
. We can also factor the coefficient
out of the denominator (it will become
when we pull it through the
-th power) and pull it through the anti-derivative sign, so we may as well assume
also. We are now reduced to finding
, where
is irreducible.
To solve this problem, we re-write
by completing the square, and make a tangent substitution. Needless to say,
Maple
has a command
completesquare
. This command resides in the
student
package, so you should load that package now if you have not already done so.
Here are two worked examples of case 1:
>
p1 := Int(1/(x^2 - 6*x + 18), x);
>
den1 := x^2 - 6*x + 18;
>
den2 := completesquare(den1, x);
>
p2 := subs(den1=den2, p1);
>
p3 := changevar(x-3 = 3*tan(u), p2, u);
>
p4 := simplify(p3);
>
p5 := value(p4);
>
p6 := subs(u = arctan((x-3)/3), p5);
>
p1 = p6 + C;
>
q1 := Int(1/(x^2 - 6*x + 18)^3, x);
>
q2 := subs(den1 = den2, q1);
>
q3 := changevar(x-3 = 3*tan(u), q2, u);
>
q4 := simplify(q3);
Maple
seems unwilling to make the next simplification, so we will have to force it.
>
q5 := subs(1 + tan(u)^2 = sec(u)^2, q4);
>
q6 := simplify(q5);
This is now do-able: we have a reduction formula for powers of cosine. Rather than grind out the calculation, we will allow
Maple
to evaluate this anti-derivative.
>
q7 := value(q6);
>
q8 := subs(u = arctan((x-3)/3), q7);
>
q9 := simplify(q8);
>
Question 3
Use the method above to find these anti-derivatives:
(a)
Solution.
>
expr := 1/(x^2 + 2*x + 11);
>
p1 := Int(expr, x);
>
den1 := denom(expr);
>
den2 := completesquare(den1);
>
p2 := subs(den1 = den2, p1);
>
p3 := changevar(x+1 = sqrt(10)*tan(u), p2, u);
>
p4 := simplify(p3);
>
p5 := value(p4);
>
p6 := subs(u = arctan((x+1)/sqrt(10)), p5);
>
p1 = p6 + C;
As always, it is easy to check this answer. (I usually don't do the checks in my solutions, but you should!)
>
check := diff(p6, x);
>
simplify(check);
>
(b)
Solution.
>
expr := 1/(x^2 + 6*x + 11);
>
q1 := Int(expr, x);
>
den1 := denom(expr);
>
den2 := completesquare(den1);
>
q2 := subs(den1 = den2, q1);
>
q3 := changevar(x + 3 = sqrt(2)*tan(u), q2, u);
>
q4 := simplify(q3);
>
q5 := value(q4);
>
q6 := subs(u = arctan((x+3)/sqrt(2)), q5);
>
q1 = q6 + C;
>
(c)
Solution.
>
expr := 1/(2*x^2 - 4*x + 10);
>
r1 := Int(expr^2, x);
>
den1 := denom(expr);
>
den2 := completesquare(den1);
>
r2 := subs(den1 = den2, r1);
>
r3 := changevar(x-1 = 2*tan(u), r2, u);
>
r4 := simplify(r3);
>
r5 := subs(1 + tan(u)^2 = sec(u)^2, r4);
>
r6 := simplify(r5);
>
r7 := value(r6);
>
r8 := subs(u = arctan((x-1)/2), r7);
>
r9 := simplify(r8);
>
r1 = r9 + C;
Since this is the most complicated example we have worked out so far, we might check it:
>
check := diff(r9, x);
>
simplify(check);
This is the original rational function, though written in a slightly different form.
>
>
CASE 2:
.
In this case, the numerator is exactly the derivative of the irreducible polynomial
. If this remarkable coincidence occurs, the substitution
does the job.
>
p1 := Int((2*x + 2)/(x^2 + 2*x + 11), x);
>
p2 := changevar(u = x^2 + 2*x + 11, p1, u);
>
p3 := value(p2);
>
p4 := subs(u = x^2 + 2*x + 11, p3);
>
p1 = p4 + C;
>
q1 := Int((6*x + 30)/(3*x^2 + 30*x + 33)^7, x);
>
q2 := changevar(u = 3*x^2 + 30*x + 33, q1, u);
>
q3 := value(q2);
>
q4 := subs(u = 3*x^2 + 30*x + 33, q3);
>
q1 = q4 + C;
Case 2 may appear to be very special, but at least it is very easy.
THE GENERAL CASE.
As mentioned above, the general case can be written as a combination of the two special cases. This is done by re-writing the numerator
as
(
)
+ (
) . This formula may not be too illuminating: the point is that we write the derivative of
in the numerator, so that we can use Case 2, and then we adjust constants so that we have the correct numerator. If you think about it, this is the same as dividing
by
, so we can use
Maple
's
rem
and
quo
commands to do the algebra. For example:
>
expr1 := (5*x - 3)/(x^2 + 2*x + 11);
We find the derivative of the denominator, and find the quotient and remainder when it is divided into the numerator.
>
d := diff(denom(expr1), x);
>
q := quo(numer(expr1), d, x);
>
r := rem(numer(expr1), d, x);
>
expr2 := q*d/denom(expr1);
>
expr3 := r/denom(expr1);
We can easily check that our original expression is the sum of these two:
>
simplify(expr2 + expr3);
Since
expr2
is an example of Case 2 (apart from the factor of 5/2, which causes no difficulty), and
expr3
is an example of Case 1, we can find anti-derivatives for each of them, and hence for the original expression. In exactly the same way, if we had started with a power of
in the denominator, for example
>
expr4 := (5*x - 3)/(x^2 + 2*x + 11)^3;
we would re-write it as the sum of the two expressions
>
expr5 := q*d/denom(expr1)^3;
and
>
expr6 := r/denom(expr1)^3;
Check:
>
simplify(expr5 + expr6);
In conclusion, we can now anti-differentiate any partial fraction coming from an irreducible quadratic factor, and hence any rational function.
>
Question 4
Re-write each of the following expressions as a sum of an expression that falls into Case 1 and one that falls into Case 2.
>
p1 := (3*x + 4)/(x^2 + x + 1);
Solution.
(To be honest, this procedure is probably done more easily by hand, but here are
Maple
solutions, following the method indicated above.)
>
den := denom(p1);
>
d := diff(den, x);
>
q := quo(numer(p1), d, x);
>
r := rem(numer(p1), d, x);
>
p2 := q*d/den + r/den;
>
>
q1 := (6*x + 5)/(x^2 + 4*x + 13)^2;
Solution.
>
quad := x^2 + 4*x + 13;
>
d := diff(quad, x);
>
q := quo(numer(q1), d, x);
>
r := rem(numer(q1), d, x);
>
q2 := (q*d)/quad^2 + r/quad^2;
>
>
Question 5
Work through the complete procedure we have outlined, and find anti-derivatives for the following expressions: first use
convert
to find the partial-fraction decomposition, then find anti-derivatives for each of the partial fractions.
>
p1 := 1/((x-1)*(x+1)^2);
Solution.
>
p2 := convert(p1, parfrac, x);
>
p3 := Int(1/(4*(x-1)), x);
>
p4 := changevar(u=x-1, p3, u);
>
p5 := simplify(p4);
>
p6 := value(p5);
>
p7 := subs(u=x-1, p6);
Since the next two partial fractions involve the same substitution, we will do them together.
>
p8 := op(2, p2) + op(3, p2);
>
p9 := Int(p8, x);
>
p10 := changevar(u=x+1, p9, u);
>
p11 := value(p10);
>
p12 := subs(u=x+1, p11);
>
p13 := p7 + p12;
>
Int(p1, x) = p13 + C;
>
>
q1 := (3*x + 4)/(x^2 + x + 1);
Solution.
Since the denominator is irreducible (as will become apparent when we complete the square), this expression is already in partial-fraction form. We proceed as in Question 4.
>
den := denom(q1);
>
d := diff(den, x);
>
q := quo(numer(q1), d, x);
>
r := rem(numer(q1), d, x);
>
q2 := q*d/den;
>
q3 := r/den;
The expression
has been split into expressions that fall into case 1 and case 2, so we can proceed to find anti-derivatives for each of them. We start with
.
>
q4 := Int(q2, x);
>
q5 := changevar(u = x^2 + x + 1, q4, u);
>
q6 := value(q5);
>
q7 := subs(u = x^2 + x + 1, q6);
Now for
.
>
q8 := Int(q3, x);
>
den1 := completesquare(den);
>
q9 := subs(den=den1, q8);
>
q10 := changevar(x + 1/2 = sqrt(3/4)*tan(u), q9, u);
>
q11 := simplify(q10);
>
q12 := value(q11);
>
q13 := subs(u = arctan((x + 1/2)/sqrt(3/4)), q12);
Now we put the two parts together.
>
q14 := q7 + q13;
>
Int(q1, x) = q14 + C;
This was a long calculation, so let's check:
>
check := diff(q14, x);
>
simplify(check);
>
>
r1 := 1/(x^3 - 1);
Solution.
>
r2 := convert(r1, parfrac, x);
Now anti-differentiate the partial fractions, one by one.
>
r3 := op(1, r2);
>
r4 := Int(r3, x);
>
r5 := changevar(u = x-1, r4, u);
>
r6 := value(r5);
>
r7 := subs(u = x-1, r6);
The first partial fraction is done, so we move to the second. This must first be broken into case 1 and case 2 fractions (
and
below).
>
r8 := op(2, r2);
>
den := denom(r8);
>
d := diff(den, x);
>
q := quo(numer(r8), d, x);
>
r := rem(numer(r8), d, x);
>
r9 := q*d/den;
>
r10 := r/den;
Anti-differentiate
:
>
r11 := Int(r9, x);
>
r12 := changevar(u = 3*x^2 + 3*x + 3, r11, u);
>
r13 := value(r12);
>
r14 := subs(u = 3*x^2 + 3*x + 3, r13);
Anti-differentiate
:
>
r15 := Int(r10, x);
>
den1 := completesquare(den);
>
r16 := subs(den = den1, r15);
>
r17 := changevar(x + 1/2 = sqrt(3/4)*tan(u), r16, u);
>
r18 := simplify(r17);
>
r19 := value(r18);
>
r20 := subs(u = arctan((x + 1/2)/sqrt(3/4)), r19);
Put everything together:
>
r21 := r7 + r14 + r20;
>
Int(r1, x) := r21 + C;
Check:
>
check := diff(r21, x);
>
simplify(check);
This is the original rational function, as you can see by multiplying out the denominator.