Shared09 - Partial Fractions Assignment / Partial Fractions Notes.sagewsOpen in CoCalc
This material was developed by Aaron Tresham at the University of Hawaii at Hilo and is Creative Commons License
licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Prerequisites:

  • Intro to Sage
  • Symbolic Integration

Partial Fractions

Partial fraction decomposition is a tool to help us integrate rational functions (quotients of polynomials). It allows us to "decompose" a complicated rational function into a sum of simpler rational functions.

It is the reverse of fraction addition. For example, consider this addition:

1x+1+1x+3=2(x+3)(x+1)\frac{1}{x+1}+\frac{-1}{x+3}=\frac{2}{(x+3)(x+1)}

Partial fraction decomposition undoes the addition.

So if you wanted to find the antiderivative of 2(x+3)(x+1)\displaystyle\frac{2}{(x+3)(x+1)}, you could find the antiderivatives of 1x+1\displaystyle\frac{1}{x+1} and 1x+3\displaystyle\frac{-1}{x+3} and add them together.

Of course, in terms of practice, it is silly to use the computer to do partial fraction decomposition in order to integrate, since the computer can already integrate the original rational function. So the goal of this lab is to explore the different kinds of decompositions and the kind of antiderivatives you get out of the process.

Example 1

Here is an example of computing a partial fraction decomposition in Sage:

f(x)=2/(x^2 + 4*x + 3)
f(x).partial_fraction()
show(_)
-1/(x + 3) + 1/(x + 1)
1x+3+1x+1\displaystyle -\frac{1}{x + 3} + \frac{1}{x + 1}

Example 2

Find the antiderivative of f(x)=xx2+4x+3\displaystyle f(x)=\frac{x}{x^2+4x+3}.

First, we'll integrate with Sage, then we'll find the partial fraction decomposition and integrate term by term.

f(x)=x/(x^2+4*x+3)
integral(f(x),x)
show(_)
3/2*log(x + 3) - 1/2*log(x + 1)
32log(x+3)12log(x+1)\displaystyle \frac{3}{2} \, \log\left(x + 3\right) - \frac{1}{2} \, \log\left(x + 1\right)

Note: We would normally write this as follows: xx2+4x+3dx=32ln(x+3)12ln(x+1)+C\int\frac{x}{x^2+4x+3}\, dx=\frac{3}{2}\ln(|x+3|)-\frac{1}{2}\ln(|x+1|)+C

(notice the absolute values and the +C+C).

Now let's try partial fractions:

f(x).partial_fraction()
show(_)
3/2/(x + 3) - 1/2/(x + 1)
32(x+3)12(x+1)\displaystyle \frac{3}{2 \, {\left(x + 3\right)}} - \frac{1}{2 \, {\left(x + 1\right)}}

So xx2+4x+3=3/2x+3+1/2x+1\frac{x}{x^2+4x+3}=\frac{3/2}{x+3}+\frac{-1/2}{x+1}

This means xx2+4x+3dx=3/2x+3+1/2x+1dx=321x+3dx121x+1dx\int\frac{x}{x^2+4x+3}\, dx=\int\frac{3/2}{x+3}+\frac{-1/2}{x+1}\, dx=\frac{3}{2}\int\frac{1}{x+3}\, dx-\frac{1}{2}\int\frac{1}{x+1}\, dx

integral(3/2/(x + 3),x)
integral(- 1/2/(x + 1),x)
3/2*log(x + 3) -1/2*log(x + 1)

Non-repeated Linear Factors

In general, a rational function whose denominator has distinct linear factors will decompose similar to the last example.

Suppose R(x)R(x) is a rational function which may be written as R(x)=P(x)(xr1)(xr2)(xrn)R(x)=\frac{P(x)}{(x-r_1)(x-r_2)\cdots(x-r_n)}

where P(x)P(x) is a polynomial of degree less than nn and all the rir_i are distinct (note: nn is the degree of the denominator).

Then there exists constants aia_i (i.e., real numbers) such that:

R(x)=a1xr1+a2xr2++anxrnR(x)=\frac{a_1}{x-r_1}+\frac{a_2}{x-r_2}+\cdots+\frac{a_n}{x-r_n}

Then R(x)dx=a11xr1dx+a21xr2dx++an1xrndx\int R(x)\, dx=a_1\int\frac{1}{x-r_1}\, dx+a_2\int\frac{1}{x-r_2}\, dx+\cdots+a_n\int\frac{1}{x-r_n}\, dx

=a1ln(xr1)+a2ln(xr2)++anln(xrn)+C=a_1\ln(|x-r_1|)+a_2\ln(|x-r_2|)+\cdots+a_n\ln(|x-r_n|)+C

Example 3

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

Again, we'll use Sage to compute the integral directly, and then we'll compare the partial fraction approach.

f(x)=(2*x^2+4*x+3)/((x+3)*(x+2)*(x-1))
#Make sure you have parentheses around the top and the entire bottom. You must put * between factors.
integral(f(x),x)
show(_)
9/4*log(x + 3) - log(x + 2) + 3/4*log(x - 1)
94log(x+3)log(x+2)+34log(x1)\displaystyle \frac{9}{4} \, \log\left(x + 3\right) - \log\left(x + 2\right) + \frac{3}{4} \, \log\left(x - 1\right)
f(x).partial_fraction()
show(_)
9/4/(x + 3) - 1/(x + 2) + 3/4/(x - 1)
94(x+3)1x+2+34(x1)\displaystyle \frac{9}{4 \, {\left(x + 3\right)}} - \frac{1}{x + 2} + \frac{3}{4 \, {\left(x - 1\right)}}
integral(9/4/(x + 3),x)
integral(- 1/(x + 2),x)
integral(3/4/(x - 1),x)
9/4*log(x + 3) -log(x + 2) 3/4*log(x - 1)

So 2x2+4x+3x3+4x2+x6dx=941x+3dx+(1)1x+2dx+341x1dx\int\frac{2x^2+4x+3}{x^3+4x^2+x-6}\,dx=\frac{9}{4}\int\frac{1}{x+3}\, dx+(-1)\int\frac{1}{x+2}\, dx+\frac{3}{4}\int\frac{1}{x-1}\,dx

=94ln(x+3)ln(x+2)+34ln(x1)+C=\frac{9}{4}\ln(|x+3|)-\ln(|x+2|)+\frac{3}{4}\ln(|x-1|)+C

Note: To perform the partial fraction decomposition by hand, you have to first factor the denominator (another example where finding roots of polynomials is important), and then you set up a system of equations to solve for the constants (the aia_i). I'll leave the details to your lecture professor. It's a lot of work, but it's the only way to deal with rational functions by hand.

Repeated Linear Factors

Let's start with a rational function with only one root with multiplicity greater than 1.

Suppose a rational function R(x)R(x) may be written R(x)=P(x)(xr)nR(x)=\frac{P(x)}{(x-r)^n}

where P(x)P(x) is a polynomial of degree less than nn (the degree of the denominator).

Then there exist constants aia_i such that R(x)=a1xr+a2(xr)2++an(xr)nR(x)=\frac{a_1}{x-r}+\frac{a_2}{(x-r)^2}+\cdots+\frac{a_n}{(x-r)^n}

Integrating each of these terms is fairly simple.

R(x)dx=a11xrdx+a21(xr)2dx++an1(xr)ndx\int R(x)\, dx=a_1\int\frac{1}{x-r}\,dx+a_2\int\frac{1}{(x-r)^2}\,dx+\cdots+a_n\int\frac{1}{(x-r)^n}\,dx

=a1ln(xr)+a2111xr+a3121(xr)2++an1n+11(xr)n1+C=a_1\ln(|x-r|)+a_2\frac{1}{-1}\frac{1}{x-r}+a_3\frac{1}{-2}\frac{1}{(x-r)^2}+\cdots+a_n\frac{1}{-n+1}\frac{1}{(x-r)^{n-1}}+C

Recall, 1xdx=ln(x)+C\displaystyle\int\frac{1}{x}\,dx=\ln(|x|)+C, and for n1n\ne 1, 1xndx=xndx=1n+1xn+1+C=1n+11xn1+C\displaystyle\int\frac{1}{x^n}\,dx=\int x^{-n}\,dx=\frac{1}{-n+1}x^{-n+1}+C=\frac{1}{-n+1}\frac{1}{x^{n-1}}+C.

Example 4

Find x22(x1)3dx\displaystyle\int\frac{x^2-2}{(x-1)^3}\,dx.

f(x)=(x^2-2)/(x-1)^3
integral(f(x),x)
show(_)
-1/2*(4*x - 5)/(x^2 - 2*x + 1) + log(x - 1)
4x52(x22x+1)+log(x1)\displaystyle -\frac{4 \, x - 5}{2 \, {\left(x^{2} - 2 \, x + 1\right)}} + \log\left(x - 1\right)
f(x).partial_fraction()
show(_)
1/(x - 1) + 2/(x - 1)^2 - 1/(x - 1)^3
1x1+2(x1)21(x1)3\displaystyle \frac{1}{x - 1} + \frac{2}{{\left(x - 1\right)}^{2}} - \frac{1}{{\left(x - 1\right)}^{3}}
show(integral(1/(x - 1),x))
show(integral(2/(x - 1)^2,x))
show(integral(-1/(x - 1)^3,x))
log(x1)\displaystyle \log\left(x - 1\right)
2x1\displaystyle -\frac{2}{x - 1}
12(x1)2\displaystyle \frac{1}{2 \, {\left(x - 1\right)}^{2}}

Our answers look different, but they are the same. In the first integral, Sage has combined the rational pieces into one. In the partial fraction approach we can see the two rational pieces separately. In other words, 124x5x22x+1=2x1+1/2(x1)2\displaystyle-\frac{1}{2}\cdot\frac{4x-5}{x^2-2x+1}=\frac{-2}{x-1}+\frac{1/2}{(x-1)^2}

Here's an example with more than one repeated linear factor.

Example 5

Find 2x1(x+2)2(x3)4\displaystyle\int\frac{2x-1}{(x+2)^2(x-3)^4}.

f(x)=(2*x-1)/((x+2)^2*(x-3)^4) #Careful with parentheses and multiplication.
integral(f(x),x)
show(_)
1/375*(6*x^3 - 39*x^2 + 47*x - 77)/(x^4 - 7*x^3 + 9*x^2 + 27*x - 54) - 2/625*log(x + 2) + 2/625*log(x - 3)
6x339x2+47x77375(x47x3+9x2+27x54)2625log(x+2)+2625log(x3)\displaystyle \frac{6 \, x^{3} - 39 \, x^{2} + 47 \, x - 77}{375 \, {\left(x^{4} - 7 \, x^{3} + 9 \, x^{2} + 27 \, x - 54\right)}} - \frac{2}{625} \, \log\left(x + 2\right) + \frac{2}{625} \, \log\left(x - 3\right)
f(x).partial_fraction()
show(_)
-2/625/(x + 2) + 2/625/(x - 3) - 1/125/(x + 2)^2 - 1/125/(x - 3)^2 + 1/5/(x - 3)^4
2625(x+2)+2625(x3)1125(x+2)21125(x3)2+15(x3)4\displaystyle -\frac{2}{625 \, {\left(x + 2\right)}} + \frac{2}{625 \, {\left(x - 3\right)}} - \frac{1}{125 \, {\left(x + 2\right)}^{2}} - \frac{1}{125 \, {\left(x - 3\right)}^{2}} + \frac{1}{5 \, {\left(x - 3\right)}^{4}}
show(integral(-2/625/(x + 2),x))
show(integral(2/625/(x - 3),x))
show(integral(-1/125/(x + 2)^2,x))
show(integral(-1/125/(x - 3)^2,x))
show(integral(1/5/(x - 3)^4,x))
2625log(x+2)\displaystyle -\frac{2}{625} \, \log\left(x + 2\right)
2625log(x3)\displaystyle \frac{2}{625} \, \log\left(x - 3\right)
1125(x+2)\displaystyle \frac{1}{125 \, {\left(x + 2\right)}}
1125(x3)\displaystyle \frac{1}{125 \, {\left(x - 3\right)}}
115(x3)3\displaystyle -\frac{1}{15 \, {\left(x - 3\right)}^{3}}

So our integral is 2625ln(x+2)+2625ln(x3)+11251x+2+11251x31151(x3)3+C\displaystyle-\frac{2}{625}\ln(|x+2|)+\frac{2}{625}\ln(|x-3|)+\frac{1}{125}\cdot\frac{1}{x+2}+\frac{1}{125}\cdot\frac{1}{x-3}-\frac{1}{15}\frac{1}{(x-3)^3}+C.

Non-repeated Irreducible Quadratics

We know that some polyomials do not have real roots. Such polynomials cannot be factored into (real) linear factors. However, any polynomial can be factored into linear factors and irreducible quadratic factors (in this context, irreducible means these quadratic functions have no real roots - you may recall that such functions have two complex roots, which are complex conjugates).

We now consider partial fraction decomposition for rational functions that have irreducible quadratic factors in the denominator.

Suppose R(x)R(x) is a rational function which may be written

R(x)=P(x)(a1x2+b1x+c1)(a2x2+b2x+c2)(anx2+bnx+cn)R(x)=\frac{P(x)}{(a_1x^2+b_1x+c_1)(a_2x^2+b_2x+c_2)\cdots(a_nx^2+b_nx+c_n)}

where all the quadratics factors in the denominator are distinct, and the degree of P(x)P(x) is less than 2n2n (the degree of the denominator).

Then there exist constants did_i and eie_i such that

R(x)=d1x+e1a1x2+b1x+c1+d2x+e2a2x2+b2x+c2++dnx+enanx2+bnx+cnR(x)=\frac{d_1x+e_1}{a_1x^2+b_1x+c_1}+\frac{d_2x+e_2}{a_2x^2+b_2x+c_2}+\cdots+\frac{d_nx+e_n}{a_nx^2+b_nx+c_n}

Integrating this is usually a pain. If you're lucky, some of these terms may be fairly simple substitution problems (when the numerator is a constant multiple of the derivative of the denominator). When you integrate, your answer involves a natural logarithm (ln).

If you're not so lucky, then you have to do some algebra, including completing the square. After integrating, the result may involve a natural logarithm and/or an inverse tangent (arctan).

If that sounds bad, that's because it is!

Example 6

Find 3x3+4x1(x2+1)(x2+x+2)\displaystyle\int\frac{3x^3+4x-1}{(x^2+1)(x^2+x+2)}.

Note: the quadratics in the denominator are irreducible.

f(x)=(3*x^3+4*x-1)/((x^2+1)*(x^2+x+2))  #Don't forget the () around the bottom and the * between factors.
integral(f(x),x)
show(_)
-4/7*sqrt(7)*arctan(1/7*sqrt(7)*(2*x + 1)) + log(x^2 + x + 2) + 1/2*log(x^2 + 1)
477arctan(177(2x+1))+log(x2+x+2)+12log(x2+1)\displaystyle -\frac{4}{7} \, \sqrt{7} \arctan\left(\frac{1}{7} \, \sqrt{7} {\left(2 \, x + 1\right)}\right) + \log\left(x^{2} + x + 2\right) + \frac{1}{2} \, \log\left(x^{2} + 1\right)

Our answer involves three terms: two natural logs and one arctan. Let's use partial fractions to see where these come from.

f(x).partial_fraction()
show(_)
(2*x - 1)/(x^2 + x + 2) + x/(x^2 + 1)
2x1x2+x+2+xx2+1\displaystyle \frac{2 \, x - 1}{x^{2} + x + 2} + \frac{x}{x^{2} + 1}

Integrating the first term gives the arctan and one log:

integral((2*x - 1)/(x^2 + x + 2),x)
show(_)
-4/7*sqrt(7)*arctan(1/7*sqrt(7)*(2*x + 1)) + log(x^2 + x + 2)
477arctan(177(2x+1))+log(x2+x+2)\displaystyle -\frac{4}{7} \, \sqrt{7} \arctan\left(\frac{1}{7} \, \sqrt{7} {\left(2 \, x + 1\right)}\right) + \log\left(x^{2} + x + 2\right)

Integrating the second terms gives the other log:

integral(x/(x^2 + 1),x)
show(_)
1/2*log(x^2 + 1)
12log(x2+1)\displaystyle \frac{1}{2} \, \log\left(x^{2} + 1\right)

The last piece is a simple substitution. Let u=x2+1u=x^2+1. Then du=2xdxdu=2x\, dx, so xx2+1dx=121udu=12ln(u)+C=12ln(x2+1)+C\int\frac{x}{x^2+1}\,dx=\int\frac{1}{2}\cdot\frac{1}{u}\,du=\frac{1}{2}\ln(|u|)+C=\frac{1}{2}\ln(x^2+1)+C

(Note: x2+1x^2+1 is positive, so you don't need the absolute value.)

The first piece is more complicated (as you can see by the result).

Notice, if you tried to substitute u=x2+x+2u=x^2+x+2, then you get du=2x+1dxdu=2x+1\, dx, which is not what you have in the numerator. But we can force it into the numerator and then adjust by adding another term:

2x1x2+x+2=2x+1x2+x+2+2x2+x+2\frac{2x-1}{x^2+x+2}=\frac{2x+1}{x^2+x+2}+\frac{-2}{x^2+x+2}

When you integrate the first term, you get ln(x2+x+2)\ln(x^2+x+2).

The second term is where the arctan comes from, but the algebra is messy. First, you complete the square in the denominator.

2x2+x+2=2(x+12)2+74\frac{-2}{x^2+x+2}=\frac{-2}{\left(x+\frac{1}{2}\right)^2+\frac{7}{4}}

Now you have to factor 7/47/4 out of the denominator.

2(x+12)2+74=274[(27x+17)2+1]=871(27x+17)2+1\frac{-2}{\left(x+\frac{1}{2}\right)^2+\frac{7}{4}}=\frac{-2}{\frac{7}{4}\left[\left(\frac{2}{\sqrt{7}}x+\frac{1}{\sqrt{7}}\right)^2+1\right]}=\frac{-8}{7}\cdot\frac{1}{\left(\frac{2}{\sqrt{7}}x+\frac{1}{\sqrt{7}}\right)^2+1}

Now substitute u=27x+17u=\frac{2}{\sqrt{7}}x+\frac{1}{\sqrt{7}} to get

871(27x+17)2+1dx=4771u2+1du=477arctan(u)+C=477arctan(27x+17)+C\int\frac{-8}{7}\cdot\frac{1}{\left(\frac{2}{\sqrt{7}}x+\frac{1}{\sqrt{7}}\right)^2+1}\,dx=\frac{-4\sqrt{7}}{7}\int\frac{1}{u^2+1}\,du=\frac{-4\sqrt{7}}{7}\arctan(u)+C=\frac{-4\sqrt{7}}{7}\arctan\left(\frac{2}{\sqrt{7}}x+\frac{1}{\sqrt{7}}\right)+C

Aren't you glad to have Sage?

Repeated Irreducible Quadratics

If the irreducible quadratic factors are repeated, you get something similar to what happened with the repeated linear factors.

Suppose R(x)R(x) is a rational function which may be written

R(x)=P(x)(ax2+bx+c)nR(x)=\frac{P(x)}{(ax^2+bx+c)^n}

where the quadratic is irreducible, and the degree of P(x)P(x) is less than 2n2n (the degree of the denominator).

Then there exist constants did_i and eie_i such that

R(x)=d1x+e1ax2+bx+c+d2x+e2(ax2+bx+c)2++dnx+en(ax2+bx+c)nR(x)=\frac{d_1x+e_1}{ax^2+bx+c}+\frac{d_2x+e_2}{(ax^2+bx+c)^2}+\cdots+\frac{d_nx+e_n}{(ax^2+bx+c)^n}

Example 7

Find x3+2(x2+1)2\displaystyle\int\frac{x^3+2}{(x^2+1)^2}.

f(x)=(x^3+2)/(x^2+1)^2
integral(f(x),x)
show(_)
1/2*(2*x + 1)/(x^2 + 1) + arctan(x) + 1/2*log(x^2 + 1)
2x+12(x2+1)+arctan(x)+12log(x2+1)\displaystyle \frac{2 \, x + 1}{2 \, {\left(x^{2} + 1\right)}} + \arctan\left(x\right) + \frac{1}{2} \, \log\left(x^{2} + 1\right)
f(x).partial_fraction()
show(_)
x/(x^2 + 1) - (x - 2)/(x^2 + 1)^2
xx2+1x2(x2+1)2\displaystyle \frac{x}{x^{2} + 1} - \frac{x - 2}{{\left(x^{2} + 1\right)}^{2}}
integral(x/(x^2 + 1),x)
show(_)
1/2*log(x^2 + 1)
12log(x2+1)\displaystyle \frac{1}{2} \, \log\left(x^{2} + 1\right)
integral(-(x - 2)/(x^2 + 1)^2,x)
show(_)
1/2*(2*x + 1)/(x^2 + 1) + arctan(x)
2x+12(x2+1)+arctan(x)\displaystyle \frac{2 \, x + 1}{2 \, {\left(x^{2} + 1\right)}} + \arctan\left(x\right)

This last integral can be computed using trig substitution. I'll spare you the gory details.

What if the degree of the denominator is not greater than the degree of the numerator?

We have only considered examples where the degree of the numerator is less than the degree of the denominator. If this is not the case, then you must first use long division of polynomials to rewrite your rational function as a polynomial plus a new rational function for which the degree of the numerator is smaller.

In general, if R(x)=P(x)Q(x)R(x)=\frac{P(x)}{Q(x)} and the degree of PP \ge degree of QQ, then there exist polynomials SS and TT, with degree of TT < degree of QQ, such that R(x)=S(x)+T(x)Q(x)R(x)=S(x)+\frac{T(x)}{Q(x)}

Integrating S(x)S(x) is easy (it's a polynomial), and integrating T(x)Q(x)\frac{T(x)}{Q(x)} is accomplished as above.

Example 8

Find x3+x+1x2dx\displaystyle\int\frac{x^3+x+1}{x-2}\,dx.

First, we divide to find that x3+x+1x2=x2+2x+5+11x2\frac{x^3+x+1}{x-2}=x^2+2x+5+\frac{11}{x-2}

Thus, x3+x+1x2dx=x2+2x+5+11x2dx=13x3+x2+5x+11ln(x2)+C\int\frac{x^3+x+1}{x-2}\,dx=\int x^2+2x+5+\frac{11}{x-2}\,dx=\frac{1}{3}x^3+x^2+5x+11\ln(|x-2|)+C

There is a command in Sage to find the quotient and remainder from polynomial long division, but it's somewhat cumbersome to use. Fortunately, we don't have to worry about this, since the partial_fraction command will deal with this situation with no problems.

f(x)=(x^3+x+1)/(x-2)
f(x).partial_fraction()
show(_)
x^2 + 2*x + 11/(x - 2) + 5
x2+2x+11x2+5\displaystyle x^{2} + 2 \, x + \frac{11}{x - 2} + 5
integral(x^2 + 2*x + 5,x)
integral(11/(x - 2),x)
1/3*x^3 + x^2 + 5*x 11*log(x - 2)