Partial fractions

1. Dec 12, 2005

StatusX

So, what I'm going to do in this thread is show a general method for finding the antiderivative (ie, indefinite integral) of any rational function. Here, a rational function is a function of the form P(x)/Q(x), where P(x) and Q(x) are polynomials, and the antiderivative of a function f(x) is the function F(x) such that d(F(x))/dx=f(x), where F(x) is unique up to an additive constant (which will be suppressed in this thread).

I'll break the thread up into 4 sections. The first half will be concerned with complex polynomials (ie, the coefficients and variable may be complex), and the second will be restricted to real numbers. Each half will be broken up into a section describing how to transform the rational function into an integrable form, and a section on how to integrate it. Here we go.

We'll start with complex polynomials, because they're actually a little simpler. Let A(z) and B(z) be two polynomials, where A has order n and B has order m, and let r(z)=A(z)/B(z). Here z is a complex variable. By the fundamental theorem of algebra, B has exactly m roots (counting multiple roots multiple times), and so we may factor it into m monomials as follows:

$$B(z) = b_0 (z-b'_1)(z-b'_2)...(z-b'_m)$$

Where b0 is the coefficient of the leading order term in B. We can absorb this into A, so it will be ignored from here on. Now, let's be more explicit about the multiple roots. Let there be p distinct roots, and let bi have multiplicity ki, so that m is the product of all the ki's. Then:

$$B(z)=(z-b_1)^{k_1}(z-b_2)^{k_2}...(z-b_p)^{k_p}$$

We will write A in the ordinary way. Then:

$$r(z)=\frac{a_0 + a_1 z + ... + a_n z^n}{(z-b_1)^{k_1}(z-b_2)^{k_2}...(z-b_p)^{k_p}}$$

It's not immediately obvious how to integrate this function. But there are some special cases we can integrate. For example, when b is constant, r(z) is just a normal polynomial, which is easily integrated. When a is constant and b has only one distinct root, r(z) looks like 1/(z-b)k for some natural number k, which is also easily integrated, using the natural log if k=1. Also, note that if we can integrate any two functions, the integral of the sum of the two functions is just the sum of the integrals of the individual functions, which is just to say that integration is a linear operation. So if we can get r(z) into a form where it is the sum of these functions we know how to integrate, we can do r(z) with no problem.

So how do we do this? There are two seperate cases we need to consider: n<m and n≥m. First, assume n<m. Then the rational function is "bottom-heavy", and we would expect its partial fraction expansion to be all denominator. This isn't a rigorous argument, but it does turn out to be true, and it helps you remember what to do in each case. The partial fraction expansion will consist of a linear combination of the recipricals of all the monomials making up B. In the case of multiple roots, all powers of the reciprical up to the multiplicity of the root are included in the sum. In other words, we set:

$$r(z)=\frac{c_{1,1}}{(z-b_1)} + \frac{c_{1,2}}{(z-b_1)^2} + ... +\frac{c_{1,k_1}}{(z-b_1)^{k_1}} + \frac{c_{2,1}}{(z-b_2)} + ... +\frac{c_{p,k_p}}{(z-b_p)^{k_p}}$$

and then solve for all the ci,j. At this point, the notation is getting cumbersome, so I'm going to proceed with a specific example. It should be clear how the general argument would run. I'll start off with an easy example with all real coefficients, but don't forget that this applies equally well to complex numbers, as I'll show in the second example.

Let:

$$r(z)=\frac{3z^2-2z+1}{z^3-2z^2-7z-4}$$

Then we can factor the denominator as:

$$r(z)=\frac{3z^2-2z+1}{(z+1)^2(z-4)}$$

And so the partial fraction expansion will have the form:

$$r(z)=\frac{c_{1,1}}{(z+1)}+\frac{c_{1,2}}{(z+1)^2}+\frac{c_{2,1}}{(z-4)}$$

Now, to solve for these coefficients, we multiply through by B, in this case, (z+1)2(z-4):

$$r(z)(z+1)^2(z-4) = 3z^2-2z+1 = c_{1,1}(z+1)(z-4) + c_{1,2}(z-4) + c_{2,1}(z+1)^2$$

Now, if you like, you can expand the right side, collect terms, and equate like powers of z. You then have m linear equations for m unknowns. (note: in this case, all powers of z on the right side have non-zero coefficients on the left side. This won't be the case if n<m-1, but in that case, you would just set the coefficient on the right side to zero). That should assure you that the solution exists in all cases, but there is an easier way to do it in practice. Note that the equality must hold at all z, and so in particular at z=-1 and z=4. Plugging in the roots of B simplifes things a lot:

z=-1:

$$3(-1)^2-2(-1)+1 = c_{1,1}(0) + c_{1,2}(-1-4) + c_{2,1}(0)^2$$

$$6 = c_{1,2}(-5)$$

$$c_{1,2} = -6/5$$

z=4:

$$3(4)^2-2(4)+1 = c_{1,1}(0) + (-6/5)(0) + c_{2,1}(4+1)^2$$

$$41 = 25c_{2,1}$$

$$c_{2,1} = 41/25$$

For terms which have a monomial for each distinct root, this trick won't work, but you can still plug in a convenient value of z:

z=0:

$$3(0)^2-2(0)+1 = c_{1,1}(1)(-4) + (-6/5)(-4) + (41/25)(1)^2$$

$$1=-4c_{1,1} +24/5 +41/25$$

$$4c_{1,1}=(-25/25+120/25+41/25)=136/25$$

$$c_{1,1}=34/25$$

So we are left with the result:

$$r(z)=\frac{3z^2-2z+1}{z^3-2z^2-7z-4}=\frac{34/25}{(z+1)} - \frac{6/5}{(z+1)^2}+\frac{41/25}{(z-4)}$$

I'm sure you can all integrate this, but I'll still go over it in the next section. Also, in the case of real numbers, the integration step is more difficult, so I think it deserves its own section.

Now, the case n≥m is a simple extension of this. In addition to all the fractional terms included above, we add a polynomial of order n-m:

$$r(x)= ... + d_0 + d_1 z + ... + d_{n-m} z^{n-m}$$

(Note that if n=m, this is just an extra constant.) In other words, the rational functon is now top heavy, with the top outweighing the bottom by n-m, so you would expect partial fraction expansion to include terms up to zn-m. Now, proceeding as before, multiply both sides by B(z). Remember that there were m coefficients to solve for in the previous case, so now there are an additional n-m+1, or n+1 total. So, equating like powers as before, we now have n+1 equations for n+1 unknowns (since a0,...,anzn constitute n+1 terms), and again a unique solution will exist. The same trick helps here too, since plugging in any root of B will cause all the dk terms to be suppressed.

As an example, consider the following rational function:

$$r(z)=\frac{(1+i)z^4+(-2+4i)z^3+3iz-2}{z^2(z+2i)}$$

Since n-m=4-3=1, we want to expand this as:

$$r(z)=\frac{c_{1,1}}{z} +\frac{c_{1,2}}{z^2}+\frac{c_{2,1}}{(z+2i)} +d_0 +d_1 z$$

Multiplying through by B(z):

$$(1+i)z^4+(-2+4i)z^3+3iz-2 = c_{1,1} z(z+2i) +c_{1,2}(z+2i) +c_{2,1}z^2 + (d_0 + d_1 z)z^2(z+2i)$$

Plugging in z=0:

$$-2=c_{1,1} (0) +c_{1,2}(2i) +c_{2,1}(0)^2 + (d_0 + d_1 (0))(0)$$

$$c_{1,2}=i$$

z=-2i:

$$(1+i)(-2i)^4+(-2+4i)(-2i)^3+3i(-2i)-2 = c_{1,1} (0) +c_{1,2}(0) +c_{2,1}(-2i)^2 + (d_0 + d_1 (-2i))(0)$$

$$16(1+i)+8i(-2+4i)+6-2=-12= -4c_{2,1}$$

$$c_{2,1}=3$$

To get the last 3 coefficients, you can't avoid doing a little algebra. Plugging in still helps though:

z=1:

$$(1+i)(1)^4+(-2+4i)(1)^3+3i(1)-2 = c_{1,1}(1)(1+2i) +i(1+2i) +3(1)^2 + (d_0 + d_1 (1))((1)^2(1+2i))$$

$$1+i-2+4i+3i-2=-3+8i=c_{1,1}(1+2i)+i-2+3+(1+2i)d_0+(1+2i)d_1$$

$$c_{1,1}+d_0+d_1=\frac{-4+7i}{1+2i}=2+3i$$ (*)

z=i:

$$(1+i)(i)^4+(-2+4i)(i)^3+3i(i)-2 = c_{1,1}(i)(i+2i) +i(i+2i) +3(i)^2 + (d_0 + d_1 (i))((i)^2(i+2i))$$

$$1+i+2i+4-3-2=-3c{1,1}-3-3-3id_0+3d_1$$

$$c_{1,1}+id_0-d_1=-2-i$$ (*)

z=-i
$$(1+i)(-i)^4+(-2+4i)(-i)^3+3i(-i)-2 = c_{1,1}(-i)(-i+2i) +i(-i+2i) +3(-i)^2 + (d_0 + d_1 (-i))((-i)^2(-i+2i))$$

$$(1+i)-2i-4+3-2=c_{1,1}-1-3-id_0-d_1$$

$$c_{1,1}-id_0-d_1=2-i$$ (*)

The (*) equations can be solved using linear algebra or any method you like, but I'll just tell you that in this example the solutions are:

$$c_{1,1}=1$$

$$d_0=2i$$

$$d_1=1+i$$

So that:

$$r(z)=\frac{(1+i)z^4+(-2+4i)z^3+3iz-2}{z^2(z+2i)}=\frac{1}{z}+\frac{i}{z^2}+\frac{3}{z+2i}+2i+(1+i)z$$

That's all there is to it. In the next section I'll briefly go over how to integrate the functions once they're in this form, and then I'll move on to real numbers. (Also, if anyone has any other information on the topic, or sees any errors I may have made, please share it here).

Last edited: Dec 12, 2005
2. Dec 12, 2005

StatusX

This will be by far the shortest section. We've now expressed the rational function r(z) as the sum of functions which we can integrate. So all that's left to do is integrate them:

$$r(z)=\frac{c_{1,1}}{(z-b_1)}+\frac{c_{1,2}}{(z-b_1)^2}+...+\frac{c_{p,k_p}}{(z-b_p)^{k_p}}+d_0+d_1 z +...+d_{n-m} z^{n-m}$$

(where the dk will all be zero if n<m)

Then, defining:

$$R(z)=\int r(z) dz$$

We have:

$$R(z)=c_{1,1}\mbox{ln}(z-b_1)+\frac{(-1)c_{1,2}}{(z-b_1)^1}+...+\frac{\frac{-1}{k_p-1}c_{p,k_p}}{(z-b_p)^{k_p-1}}+d_0 z+\frac{1}{2}d_1 z^2 +...+\frac{1}{n-m+1}d_{n-m} z^{n-m+1}$$

So in the two examples from the last section, we get:

$$\int \frac{3z^2-2z+1}{z^3-2z^2-7z-4} dz=\int\left[ \frac{34/25}{z+1}-\frac{6/5}{(z+1)^2}+\frac{41/25}{z-4}\right] dz$$

$$=\frac{34}{25}\mbox{ln}(z+1) +\frac{6/5}{z+1}+\frac{41}{25}\mbox{ln}(z-4)$$

and:

$$\int\frac{(1+i)z^4+(-2+4i)z^3+3iz-2}{z^2(z+2i)} dz=\int\left[ \frac{1}{z}+\frac{i}{z^2}+\frac{3}{z+2i}+2i+(1+i)z\right] dz$$

$$=\mbox{ln}(z) -\frac{i}{z}+3\mbox{ln}(z+2i)+2iz+\frac{1+i}{2}z^2$$

as you can verify by differentiating these two functions to get back to the rational functions we started with. That's the story for complex numbers, which is made simpler by the fact that every polynomial with complex coefficients has roots in the complex numbers. In the next section, we will work exclusively with real numbers, and so we'll need to find a way to carry this over that deals with the complex roots of B(x).

Last edited: Dec 12, 2005
3. Dec 12, 2005

StatusX

(Note: This method goes out of its way to ensure real numbers are used the whole way (except the very beginning, where I use complex numbers just to show that the expansion we'll use is in fact valid, but this step can be skipped). If all you're interested in is a real final answer, there is a shortcut that uses complex numbers in the intermediate steps. This will be shown in a later post).

The procedure for real numbers is basically the same, with the caveat that the partial fraction expansion will now include the recipricals of quadratic polynomials, and powers thereof. These are integrated by substitution and using the inverse tan function, as will be discussed in the next section. For now, let's examine why we can expand a real rational function this way, and how it's done.

The key thing to note for real polynomials is that whenever there is a complex root, its complex conjugate is also a root. To see this, assume that some complex number z is a root of a polynomial B(x). Then:

$$B(z)=b_0+b_1 z +...+b_nz^n=0$$

Then taking the complex conjugate of both sides:

$$(b_0)^*+(b_1)^* z^* +...+(b_n)^*(z^*)^n=0$$

But since all the bk are real, bk*=bk, so this is just:

$$b_0+b_1 z^* +...+b_n(z^*)^n=B(z^*)=0$$

And so the complex conjugate of z is also a root. Thus if we were to expand B into a product of monomials, it would look something like this:

$$B(x)=(x-r_1)(x-r_2)...(x-r_p)(x-z_1)(x-z_1^*)...(x-z_q)(x-z_q^*)$$

Where the rk are real, the zk are complex (which we'll take to mean that they have a non-zero imaginary part), so that there are p real roots and 2q complex ones. Now, we've decided we don't want any complex numbers in our expansion, so we need to get rid of the zk somehow. The trick is that if we multiply the pairs of monomials with conjugate roots, we get quadratic terms with real coefficients. This is because:

$$(x-z)(x-z^*)=(x-(a+bi))(x-(a-bi))=x^2-(a+bi)x-(a-bi)x+(a+bi)(a-bi)$$

$$=x^2-2ax+a^2-b^2$$

where a and b are real numbers, and i is the square root of -1, and we have let z=a+bi, as we can do for any complex number. Thus the expansion of B turns into:

$$B(x)=(x-r_1)(x-r_2)...(x-r_p)(x^2+s_1x+t_1)...(x^2+s_qx+t_q)$$

Where all the coefficients are now real. Now we can proceed as before. Again, there may be multiple copies of the same binomial, but these are treated the same way. So, defining r(x)=A(x)/B(x), where A(x) and B(x) are polynomials of degree n and m respectively, and B(x) is factored as above, we write:

$$r(x)=\frac{a_0 + a_1 x+...+a_n x^n}{(x-r_1)^{k_1}(x-r_2)^{k_2}...(x-r_p)^{k_p}(x^2+s_1x+t_1)^{j_1}...(x^2+s_qx+t_q)^{j_q}}$$

And we set this equal to:

$$r(x)=\frac{c_{1,1}}{(x-r_1)}+\frac{c_{1,2}}{(x-r_1)^2}+...+\frac{c_{p,k_p}}{(x-r_p)^{k_p}} +\frac{d_{1,1} x +e_{1,1}}{(x^2+s_1x+t_1)}+\frac{d_{1,2} x +e_{1,2}}{(x^2+s_1x+t_1)^2}+...+\frac{d_{q,j_q} x +e_{q,j_q}}{(x^2+s_qx+t_q)^{j_q}}$$

With a polynomial of order n-m tagged on the end if n≥m, as before. Again, it is easiest to show this with an example. Define:

$$r(x)=\frac{5x^4+30x^3+115x^2+212x+247}{x^5+7x^4+29x^3+65x^2+91x+49}$$

It can be shown that the denominator factors as:

$$x^5+7x^4+29x^3+65x^2+91x+49=(x+1)(x^2+3x+7)^2$$

(I may go over a rough sketch of how to find something like this later). So we want our expansion to look like: (using a,b,c,d,e as the unknown coefficients)

$$r(x)=\frac{a}{x+1}+\frac{bx+c}{x^2+3x+7}+\frac{dx+e}{(x^2+3x+7)^2}$$

Multiplying through by the denominator:

$$r(x)(x+1)(x^2+3x+7)^2=5x^4+30x^3+115x^2+212x+247$$

$$=a(x^2+3x+7)^2+(bx+c)(x+1)(x^2+3x+7)+(dx+e)(x+1)$$

Again, plugging in the roots helps somewhat, but if we want to stay in the reals, there is only one root at x=-1:

$$5(-1)^4+30(-1)^3+115(-1)^2+212(-1)+247=125=a((-1)^2+3(-1)+7)^2$$

$$25a=125$$

$$a=5$$

Now, it is probably easier in cases like this to actually expand the right side and equate like terms:

$$5(x^2+3x+7)^2+(bx+c)(x+1)(x^2+3x+7)+(dx+e)(x+1)$$

$$=5(x^4+6x^3+23x^2+42x+49)+(bx+c)(x^3+4x^2+10x+7)+(dx^2+ex+dx+e)$$

$$x^4(5+b)+x^3(30+4b+c)+x^2(115+10b+4c+d)+x(210+7b+10c+d+e)+(245+7c+e)$$

Which yields the equations:

$$5+b=5$$

$$30+4b+c=30$$

$$115+10b+4c+d=115$$

$$210+7b+10c+d+e=212$$

$$245+7c+e=247$$

Which, in this contrived example, has the solution (b,c,d,e)=(0,0,0,2) (note it may seem like there are more equations than unknowns, but remember that we already solved for a. We could have done this instead using these same equations with a put back in as an unknown). Thus we get the partial fraction expansion:

$$r(x)=\frac{5x^4+30x^3+115x^2+212x+247}{x^5+7x^4+29x^3+65x^2+91x+49}=\frac{5}{x+1}+\frac{2}{(x^2+3x+7)^2}$$

The reason we do it this way is because we can't reduce polynomials over the reals to any better than a product of binomials and monomials, ie, we can't factor the binomials any further. However, we can integrate expressions like:

$$\frac{ax+b}{(x^2+cx+d)^k}$$

as I'll show in the next section. The reason we use two unknowns in the form ax+b in the numerator instead of just a single constant like before is (1) so that we get the right number of unknowns (2) so that each power of x appears on the right side, with some linear combination of unknowns as its coefficient, so that we're guaranteed to get a solution. For example, say you had the rational function:

$$\frac{3x^2+x+1}{x^2+4}$$

And you tried to expand it as:

$$\frac{ax^2+b}{x^2+4}+c$$

So that you have the right number of unknowns, but they're not in the form used above. Then when you multiply across by the denominator, you get:

$$3x^2+x+1=ax^2+b+c(x^2+4)$$

And there is no way to get the correct coefficient of x. I might give a more rigorous argument that the form I've given will actually always ensure there's a solution, but this thread is long enough for now.

So in the next section, I'll show how to integrate the function once it's in this form.

Last edited: Dec 12, 2005
4. Dec 12, 2005

StatusX

OK, so now we have our real rational function as a sum of the following four types of terms:

1. $$\frac{a}{x+b}$$

2. $$\frac{a}{(x+b)^p}$$

3. $$\frac{ax+b}{x^2+cx+d}$$

4. $$\frac{ax+b}{(x^2+cx+d)^p}$$

As I mentioned before, if you can integrate all of these, the integral of the sum is the sum of the integrals, and so you know how to integrate the whole expansion. I've already gone over how to do cases (1) and (2) in the second section. For case (3), there are two steps. First, use substitution. Define u=x2+cx+d, so that du=(2x+c)dx. We don't have this in the numerator, and so this won't finish the job, but we can use this it to eliminate the x term in the numerator:

$$\int \frac{ax+b}{x^2+cx+d}dx=\int\left[\frac{a}{2}\frac{2x+c}{x^2+cx+d}+\frac{b-ca/2}{x^2+cx+d}\right]dx$$

$$=\frac{a}{2}\int\frac{du}{u}+\int\frac{e}{x^2+cx+d}dx$$

$$=\frac{a}{2}\mbox{ln}(x^2+cx+d)+\int\frac{e}{x^2+cx+d}dx$$

Where we have defined e =b-ca/2. Then we have only to integrate the second term. Here's where arctan comes in. We know that the function:

$$\frac{1}{1+x^2}$$

has arctan as its antiderivative. Our function isn't quite in this form, but we can get it there by completing the square. Again, the notation will get tiring if I continue abstractly, so I'll use an example. Say we want to integrate:

$$\frac{10}{x^2+4x+29}$$

We complete the square in the denominator by noting that:

$$x^2+4x+4=(x+2)^2$$

So that:

$$x^2+4x+29=(x+2)^2+25$$

(If you aren't familiar with this procedure of completing the square, just remember that you always put half the linear coefficient, 4 in this case, as the number added to x inside the square, so that x2+2ax+b=(x+a)2+(b-a2).)

Now we're getting closer. Use the substitution u=(x+2)/5, du=dx/5, to give:

$$\int \frac{10dx}{(x+2)^2+25}=\int \frac{50du}{(5u)^2+25}$$

$$=\int \frac{50du}{25(u^2+1)} = 2\int\frac{du}{u^2+1}=2\mbox{tan}^{-1}(u)$$

$$=2\mbox{tan}^{-1}\left(\frac{x+2}{5}\right)$$

This should make it clear why we divided by 5 in defining u, but if you didn't catch on, you divide by the square root of the constant term in the denominator, 25 in this case. Note that this constant term must be positive, because if we had something like (x+a)2-b2, this would have the real roots ±b-a, and so could be factored further into monomials. So that completes case (3).

For case (4), the first step is the same as before, and we will get a term like:

$$\int\frac{(a/2) du}{u^p} = \frac{\frac{-a}{2(p-1)}}{(x+cx+d)^{p-1}}$$

Again, this can be done in such a way as to eliminate the x term in the numerator of the remaining term. So we'll be left with something like:

$$\frac{e}{(x+cx+d)^{p}}$$

which we need to integrate. Using essentially the same method as before, we can get this into the form:

$$\frac{1}{(u^2+1)^{p}}$$

Unfortunately, at this point we are reduced to integrating by parts.

(If you like, you may make the trigonometric substitution u=tanθ, du=sec2θ dθ, which will leave you with the integral of some even power of cos θ, which can then be reduced to an integral of cos(kθ) using the half angle formula repeatedly. But then you are left with a bunch of terms that look like sin(k tan-1(u)), which I don't like).

I'll briefly present a recursive method for doing this integral. First, rewrite the integral as:

$$\frac{1}{(u^2+1)^{p}}=\frac{u^2+1}{(u^2+1)^{p}}-\frac{u^2}{(u^2+1)^{p}}$$

$$= \frac{1}{(u^2+1)^{p-1}}-\frac{u^2}{(u^2+1)^{p}}$$

Then the second term can be integrated by parts, by taking:

$$a=u/2$$ $$db=\frac{2udu}{(u^2+1)^p}$$

$$da=du/2$$ $$b=\frac{\frac{-1}{p-1}}{(u^2+1)^{p-1}}$$

$$\int\frac{u^2}{(u^2+1)^{p}}du = \frac{\frac{-u}{2(p-1)}}{(u^2+1)^{p-1}} - \int \frac{\frac{-du}{2(p-1)}}{(u^2+1)^{p-1}}$$

So that:

$$\int \frac{1}{(u^2+1)^{p}}=\frac{\frac{u}{2(p-1)}}{(u^2+1)^{p-1}}+ (1-\frac{1}{2(p-1)})\int \frac{du}{(u^2+1)^{p-1}}$$

Then we can repeat this process for p-1, and so on, until we are reduced to an integral which gives us the arctan function, at which point we're done.

Now we have a method for integrating all possible terms. The discussion may have been somewhat abstract, so here is an example, continuing the example from the last section, slightly modified so as to be more instructive. We have:

$$r(x)=\frac{5}{x+1}+\frac{x+2}{(x^2+3x+7)^2}$$

The first term is easily integrated, so we'll ignore that for now. As for the second, first we use the substitution u=x2+3x+7, du=(2x+3)dx. To use this, we need to expand the term into:

$$\frac{x+2}{(x^2+3x+7)^2}=\frac{1}{2}\frac{2x+3}{(x^2+3x+7)^2}+\frac{1}{2}\frac{1}{(x^2+3x+7)^2}$$

The first term is integrated to yield:

$$\int\frac{1}{2}\frac{2x+3}{(x^2+3x+7)^2}dx = \frac{1}{2}\int\frac{du}{u^2}=\frac{-1}{2}\frac{1}{x^2+3x+7}$$

For the second term, we complete the square to get:

$$\frac{1}{2}\frac{1}{(x^2+3x+7)^2}=\frac{1}{2}\frac{1}{((x+3/2)^2+19/4)^2}$$

$$=\frac{1}{2}\frac{1}{(19/4)^2((\frac{x+3/2}{\sqrt{19/4}})^2+1)^2}$$

Then let $u=(x+3/2)/\sqrt{19/4}$, $du=dx/\sqrt{19/4}$, so that:

$$\int\frac{1}{2(19/4)^2}\frac{dx}{((\frac{x+3/2}{\sqrt{19/4}})^2+1)^2}=\int\frac{1}{2(19/4)^2}\frac{\sqrt(19/4)du}{(u^2+1)^2}$$

or:

$$\int\frac{1}{2}\frac{dx}{(x^2+3x+7)^2}=\frac{1}{2(19/4)^{3/2}}\int\frac{du}{(u^2+1)^2}$$

Now, applying the method described above:

$$\int \frac{du}{(1+u^2)^2} = \int \left[ \frac{1+u^2}{(1+u^2)^2} -\frac{u^2}{(1+u^2)^2} \right]du$$

$$=\int\frac{du}{1+u^2} - \frac{1}{2}\left[ \frac{-u}{1+u^2}-\int \frac{-du}{1+u^2}\right]$$

$$=\frac{1}{2}\mbox{tan}^{-1} u+\frac{1}{2}\frac{u}{1+u^2}$$

$$=\frac{1}{2}\mbox{tan}^{-1}\left(\frac{x+3/2}{\sqrt{19/4}}\right)+\frac{1}{2}\frac{\frac{x+3/2}{\sqrt{19/4}}}{1+\frac{(x+3/2)^2}{19/4}}$$

And so our final answer is:

$$\int \left(\frac{5}{x+1}+\frac{x+2}{(x^2+3x+7)^2}\right) = 5\mbox{ln}(x+1)-\frac{1}{2}\frac{1}{x^2+3x+7}+\frac{1}{4(19/4)^{3/2}}\mbox{tan}^{-1}\left(\frac{x+3/2}{\sqrt{19/4}}\right)+\frac{1}{4(19/4)^{2}}\frac{x+3/2}{1+\frac{(x+3/2)^2}{19/4}}$$

$$=5\mbox{ln}(x+1)-\frac{1}{2}\frac{1}{x^2+3x+7}+\frac{1}{4(19/4)^{3/2}}\mbox{tan}^{-1}\left(\frac{2x+3}{\sqrt{19}}\right)+\frac{1}{19}\frac{x+3/2}{x^2+3x+7}$$

And now you see why calculators can be useful sometimes... That's it for now. Sometime soon I'll explain the easier method to get these answers using complex numbers, and maybe give a proof of some things I handwavingly claimed. This thread helped me realize I need to get a life, but I hope it was helpful to some of you with partial fractions. See ya.

Last edited: Dec 13, 2005
5. Dec 20, 2005

StatusX

In this post, I'll go over an alternative method for computing the antiderivative of real rational functions that uses complex numbers in the intermediate steps, but leaves a real final answer. It turns out to be much quicker than the previous method for most functions, and should probably be used if you're comfortable with complex numbers, and unless the function is in a form particularly conducive to the previous method.

Ok, so we now have two methods for computing the integrals of partial fractions. One is for real numbers and one is for complex numbers. You might have wondered what would happen if you applied the complex method to a real rational function. As should be pretty clear from the above (and from the example in the first post where we did just this), the methods will give the same answer if all the roots of the denominator are real. But what about something like this:

$$r(x)=\frac{1}{1+x^2}$$

If we use the real method, we're already at the last step, and the integral is:

$$R(x)=\mbox{tan}^{-1} x$$

If we use the complex method, we first need to factor the denominator:

$$r(x)=\frac{1}{(x-i)(x+i)}$$

And then we set:

$$r(x)=\frac{A}{x-i}+\frac{B}{x+i}$$

Solving for A and B, we end up with:

$$r(x)=\frac{1}{2i}\left(\frac{1}{x-i}-\frac{1}{x+i}\right)$$

Which has the integral:

$$R(x)=\frac{1}{2i}(\mbox{ln}(x-i)-\mbox{ln}(x+i))$$

$$= \frac{1}{2i}\mbox{ln}\left(\frac{x-i}{x+i}\right)$$

At this point, I should point out something I didn't make clear in the last sections. When integrating a function like:

$$\frac{1}{x-a}$$

I've only mentioned the solution:

$$\mbox{ln}(x-a)$$

But the following is also a solution, as you can verify yourself by differentiating:

$$\mbox{ln}(-(x-a))$$

This isn't very suprising when you consider the complex valued natural log function, because then this function only differs from the previous one by a constant term $\pi i$. However, it is also true for real numbers, in which case the first solution is valid for x>a and the second for x<a. This is usually succinctly expressed by:

$$\int \frac{dx}{x-a} = \mbox{ln}|x-a|$$

Although it must be kept in mind that this solution is not valid at x=a, and is really only valid for either x<a or x>a, depending on where the bounds of the integral lie.

The reason I bring this up now is because we need to realize that, in addition to:

$$\frac{1}{2i}\mbox{ln}\left(\frac{x-i}{x+i}\right)$$

The following is also an indefinite integral of the original function:

$$\frac{1}{2i}\mbox{ln}\left(\frac{i-x}{x+i}\right)$$

It will turn out that it is this second function gives us back the arctan function, while the first gives the negative of the arccot function. These differ by a constant (depending on which branch of each multivalued function you take), as we would expect, but we'll use the arctan function here since it's a little more familiar.

We can prove the second function is identical with the arctan function using Euler's formula:

$$e^{ix}=\mbox{cos }x+i\mbox{sin }x$$

Which gives us:

$$\mbox{cos }x=\frac{1}{2}(e^{ix}+e^{-ix})$$

and:

$$\mbox{sin }x=\frac{1}{2i}(e^{ix}-e^{-ix})$$

and so:

$$\mbox{tan }x=-i\frac{e^{ix}-e^{-ix}}{e^{ix}+e^{-ix}}$$

Now we can invert this to get a definition of arctan involving natural logs:

$$y=\mbox{tan}^{-1} x$$

$$x = \mbox{tan } y = -i\frac{e^{iy}-e^{-iy}}{e^{iy}+e^{-iy}}$$

$$x(e^{iy}+e^{-iy})=-i(e^{iy}-e^{-iy})$$

$$x(e^{2iy}+1)=-i(e^{2iy}-1)$$

$$e^{2iy}(x+i)=-x+i$$

$$2iy=\mbox{ln}\left(\frac{i-x}{x+i}\right)$$

$$y=\mbox{tan}^{-1} x =\frac{1}{2i}\mbox{ln}\left(\frac{i-x}{x+i}\right)$$

Which matches what we found above for the second function. However, we know that the first function is equal to second up to a constant, so we can freely substitute arctan in for it in an indefinite integral. So, in general, we get (by substitution) (and up to a constant):

$$\mbox{tan}^{-1} (ax+b) = \frac{1}{2i}\mbox{ln}\left(\frac{ax+b-i}{ax+b+i}\right)$$

$$= \frac{1}{2i}\mbox{ln}\left(\frac{x+b/a-i/a}{x+b/a+i/a}\right)$$

Note that the numerator and denominator of the argument of the log are conjugates. So, working backwards, we now know that, given a function like:

$$\frac{A}{2i}\mbox{ln}\left(\frac{x-(c+di)}{x-(c-di)}\right)$$

noting that if we take a=1/d and b=-ac=-c/d, we get that this is equal to:

$$A \mbox{ tan}^{-1} \left(\frac{x-c}{d}\right)$$

So now we have a link between the two methods. But how do we start from a general expression containing complex arguments of natural logs to one with just real arguments of arctan?

The key is to remember that when we start with a real rational function, we always have a symmetry under the complex conjugate operation. That is, at every step along the way, we must have an expression that will evaluate to a real number, and so taking the complex conjugate of the expression should leave it unchanged. For example, if, in our expansion, we have terms like:

$$r(x) = ... + \frac{A}{x-(a+bi)} + \frac{B}{x-(a-bi)} + ...$$

it must be the case that A is the complex conjugate of B. So, in the integral we get using the complex method, we'll get the following two types of terms (always occuring in pairs as shown):

1) $$(c+di) \mbox{ ln} (x-(a+bi))+(c-di) \mbox{ ln} (x-(a-bi))$$

2) $$\frac{c+di}{(x-(a+bi))^p} + \frac{c-di}{(x-(a-bi))^p}$$

Where a, b, c, and d are all real. For case (1), we start by grouping the terms as follows:

$$c\left(\mbox{ln}(x-(a+bi)) + \mbox{ln}(x-(a+bi)) \right)+ di\left(\mbox{ln}(x-(a+bi) - \mbox{ln}(x-(a+bi)) \right)$$

$$=c\mbox{ ln}[(x-(a+bi))(x-(a-bi))] + di\mbox{ ln}\left(\frac{x-(a+bi)}{x-(a-bi)}\right)$$

$$=c\mbox{ ln}(x^2-2ax-a^2+b^2)+\frac{-2d}{2i}\mbox{ ln}\left(\frac{x-(a+bi)}{x-(a-bi)}\right)$$

and from the above expression for arctan:

$$=c\mbox{ ln}(x^2-2ax-a^2+b^2)-2d \mbox{ tan}^{-1}\left(\frac{x-a}{b}\right)$$

For case (2), we do the same type of grouping:

$$\frac{c+di}{(x-(a+bi))^p} + \frac{c-di}{(x-(a-bi))^p}$$

$$= c\left(\frac{1}{(x-(a+bi))^p} + \frac{1}{(x-(a-bi))^p} \right)+ di\left(\frac{1}{(x-(a+bi))^p} - \frac{1}{(x-(a-bi))^p} \right)$$

$$= c\left(\frac{(x-(a-bi))^p+(x-(a+bi))^p}{(x-(a+bi))^p(x-(a-bi))^p} \right)+ di\left(\frac{(x-(a-bi))^p-(x-(a+bi))^p}{(x-(a+bi))^p(x-(a-bi))^p}\right)$$

$$= \frac{R+S}{(x^2-2ax-a^2+b^2)^p}$$

where:

$$R=c((x-(a-bi))^p+(x-(a+bi))^p)$$

which is real, since it is a real number times the sum of complex conjugates, which is real, and:

$$S=di((x-(a-bi))^p-(x-(a+bi))^p)$$

which is real, since it is an imaginary number times the difference of complex conjugates, which is imaginary, and the product of two imaginary numbers is real. So now we have an expression with no imaginary numbers in it (assuming you expand the polynomials in the denominator and cancel off the appropriate terms), which is what we wanted.

So we have managed to turn all of the terms containing complex numbers into terms containing only real numbers, higher degree polynomials in the denominator and log argument, and arctan functions. These are the kinds of things we would have gotten using the real method, but here we have achieved it much more easily using complex numbers in the intermediate steps.

Here's an example. Define:

$$r(x)=\frac{3x^5+6x^4+8x^3+15x^2+13x+5}{x^4+2x^3+2x^2+2x+1}$$

We can factor the denominator as:

$$x^4+2x^3+2x^2+2x+1=(x+1)^2(x+i)(x-i)$$

Which means, given the denominator has a degree 1 greater than the numerator, the expansion will look like:

$$r(x)=\frac{A}{x+1}+\frac{B}{(x+1)^2}+\frac{C}{x+i}+\frac{D}{x-i}+E+Fx$$

which gives:

$$3x^5+6x^4+8x^3+15x^2+13x+5 = A(x+1)(x+i)(x-i)+B(x+i)(x-i)+C(x+1)^2(x-i)+D(x+1)^2(x+i)+(E+Fx)(x+1)^2(x+i)(x-i)$$

Plugging in -1, i, and -i allows you to solve for B, C, and D, and then the other coefficients can be solved for by plugging in some other values and solving the three resulting coupled linear equations. I won't go through that again here, but the result is:

$$(A,B,C,D,E,F)=(0,1,1+2i,1-2i,0,3)$$

So that:

$$r(x)=\frac{1}{(1+x)^2}+\frac{1+2i}{x+i}+\frac{1-2i}{x-i}+3x$$

which can be easily integrated to yield:

$$R(x)=\frac{-1}{1+x}+(1+2i)\mbox{ ln}(x+i)+(1-2i)\mbox{ ln}(x-i)+\frac{3}{2}x^2$$

We can use the technique from above to eliminate the complex numbers in the second and third terms:

$$(1+2i)\mbox{ ln}(x+i)+(1-2i)\mbox{ ln}(x-i)=\mbox{ ln}(x+i)+\mbox{ ln}(x-i)+2i(\mbox{ ln}(x+i)-\mbox{ ln}(x-i))$$

$$=\mbox{ ln}(x^2+1)+\frac{4}{2i}\mbox{ ln}\left(\frac{x-i}{x+i}\right)$$

$$=\mbox{ ln}(x^2+1)+4\mbox{ tan}^{-1}x$$

So that:

$$R(x)=\frac{-1}{1+x}+\mbox{ln}(x^2+1)+4\mbox{tan}^{-1}x+\frac{3}{2}x^2$$

Go ahead and try to do this using the purely real method. You'll see it's much harder, and this is a relatively simple example. If you're at all comfortable with complex numbers, I'd recommend doing it this way instead. But it's nice to know that there's a way to do it with just real numbers. I'll do one more post in the next day or so summarizing all I've talked about.

Last edited: Dec 20, 2005
6. Dec 21, 2005

misogynisticfeminist

hey, thanks alot for the contribution, i havent started really reading it yet. but gonna get around it soon.

7. Dec 21, 2005

VietDao29

Hmm,... there's a little mistake here:
$$\tan x = -i \frac{e ^ {ix} - e ^ {-ix}}{e ^ {ix} + e ^ {-ix}}$$
The numerator should read:
-i (eix - e-ix) not -i (eix - eix) = 0.
And some of the following lines are also wrong because of this.
Also, don't forget the constant of integration!
--------------
By the way, you can LaTeX tangent function (or most functions by putting '\' in front of the function's name) , e.g: \tan instead of \mbox{tan}
Regards,
Anyway, this is a good tutorial.
Thanks,

Last edited: Dec 21, 2005
8. Dec 21, 2005

StatusX

Thanks for the comments and corrections. I fixed the mistake you mentioned, VietDao, and I'm sure there's more mistakes like that. I'll go over everything again once I'm done. And, as I mentioned in the first post, I'm suppressing all the constants of integration. I've even (maybe misleadingly) said two expressions are equal when they differ by a constant, but I hope it was clear where and why I did this.

Last edited: Dec 21, 2005
9. Dec 21, 2005

StatusX

So now I'll summarize everything I've gone over in this thread. The idea is that you could learn all the core concepts in this post, and then refer to the above for more details and examples.

Complex Rational Functions

These are functions of the form:

$$r(z)=\frac{a'_0 + a'_1 z + ... + a'_n z^n}{b'_0+b'_1 z+...+b'_m z^m}$$

Where the a'k, b'k, and z are all complex. Here's how you integrate them:

1. Factor the denominator:

$$b'_0+b'_1 z+...+b'_m z^m = b'_m (z-b_1)(z-b_2)...(z-b_m)$$

Where we may have multiple roots (ie, bi may equal bj for i≠j). We can absorb the factor of b'm into the numerator, and we'll be left with:

$$r(z) = \frac{a_0 + a_1 z + ... + a_n z^n}{(z-b_1)(z-b_2)...(z-b_m)}$$

Where the ak and bk are also complex, and are not, in general, equal to their primed counterparts. Hopefully the function is given to you in this form. If not, you'll need to find the roots of the denominator, either by guessing, a calculator, the quadratic, cubic, or quartic formulas, etc.

2. Expand the rational function as the linear combination of integrable functions:

By "integrable functions," I mean either polynomials or reciprocals of monomials to some power, all of which we know how to integrate. There are two cases:

a) n<m: If there are no repeated roots, we set:

$$r(z)=\frac{c_1}{z-b_1} + \frac{c_2}{z-b_2} + ... + \frac{c_m}{z-b_m}$$

If, for example, b1 is repeated p times, then we set:

$$r(z)=\frac{c_{11}}{z-b_1} + \frac{c_{12}}{(z-b_1)^2}+ ...+\frac{c_{1p}}{(z-b_1)^p} + \frac{c_2}{z-b_2} + ...$$

That is, we include a power of 1/(z-b1) for every integer up to the multiplicity of the root (see 1st post for more details). Note that this means there will be m terms in the expansion.

b) n≥m: Same as above, but we also include an unknown polynomial of degree n-m:

$$r(z)=\frac{c_1}{z-b_1} + \frac{c_2}{z-b_2} + ... + \frac{c_2}{z-b_2}+d_0 + d_1 z + ... +d_{n-m} z^{n-m}$$

The trick for remembering what to do in each case is (as I mentioned before): If the rational function is "bottom-heavy", ie, if the polynomial in the denominator is of a higher degree than the one in the numerator, the expansion will be all reciprocals. If, on the other hand, the function is "top-heavy," with the top outweighing the bottom by n-m, the expansion includes (in addition to the reciprocals) powers of z up to zn-m.

3. Solve for the unknown coefficients:

First, multiply both sides by the denominator of the rational function (we assume no repeated roots and n<m here for simplicity, but the extension should be clear):

$$(z-b_1)(z-b_2)...(z-b_m)r(z)=(z-b_1)(z-b_2)...(z-b_m) \left( \frac{c_1}{z-b_1} + \frac{c_2}{z-b_2} + ... + \frac{c_m}{z-b_m} \right)$$

$$a_0 + a_1 z + ... + a_n z^n = (z-b_2)(z-b_3)...(z-b_m)c_{1} + ... +(z-b_1)(z-b_2)...(z-b_{m-1})c_{m}$$

Then we need to solve for the ck. This is most easily done by plugging in the roots of the denominator and solving the resulting equations. If there are no repeated roots, this gets the job done, but otherwise you need to plug in other values of x and solve the coupled linear equations that result for the remaining constants.

4. Integrate:

Once it's in this form (see step 2), integration is pretty easy. In fact, it's easy enough that I won't go over it again. If you want the details, refer to post 2.

Real Rational Functions - Method 1

These are the same types of functions as before, but this time with all real coefficients, and over the real variable x:

$$r(x)=\frac{a'_0 + a'_1 x + ... + a'_n x^n}{b'_0+b'_1 x+...+b'_m x^m}$$

1. Factor the denominator:

Again, we need to factor the polynomial in the denominator. But now, if we want to stay in the real numbers, we don't necessarily have enough roots to factor the polynomial into monomials as before. Luckily, we can still factor it into monomials and binomials as follows:

$$b'_0+b'_1 x+...+b'_m x^m = b'_m (x+b_1)...(x+b_p)(x^2+c_1 x+d_1)...(x^2+c_q x+d_q)$$

Where again, we may have repeated monomials, and even repeated binomials. For the rest of the method to work, these binomials must not have any real roots. If they do, we can always factor them further into two real monomials.

Again, this leaves:

$$r(x)=\frac{a_0 + a_1 x + ... + a_n x^n}{(x+b_1)...(x+b_p)(x^2+c_1 x+d_1)...(x^2+c_q x+d_q)}$$

2. Expand the rational function as the linear combination of integrable functions:

This works exactly the same as last time, except now we have recipricals of binomials. These are included in the expansion as:

$$r(x) = ...+ \frac{e_k x + f_k}{x^2+c_k x +d_k} +...$$

Again, when there are multiple copies of a monomial or binomial, each power is included in the expansion. For example, if the above binomial was included twice in the factorization of the denominator, we would also include the following term in the expansion of the rational function:

$$\frac{e_{k2} x + f_{k2}}{(x^2+c_k x +d_k)^2}$$

Also, as before, if the polynomial in the numerator is of a higher degree than that in the denominator, an appropriate polynomial is added at the end of the expansion.

3. Solve for the unknown coefficients:

This works exactly as before. First multiply across by the denominator polynomial, then plug in roots, etc.

4. Integrate:

This is significantly more complicated than last time. The reciprocal monomials and the polynomial at the end are integrated straightforwardly as before, but the reciprical binomials present a problem. This is sufficiently complicated that I'll refer you to the fourth post of this thread, where I go over this about as briefly as can properly be done.

Real Rational Functions - Method 2

This method is somewhat easier than the first, but uses complex numbers in the intermediate steps. The idea is to use the complex method, and then convert the final answer into one involving only real numbers. So, this picks up after step 4 of the complex method.

5. Convert to an expression containing only real numbers:

We now have terms like:

1) $$A_k \mbox{ ln}(x-b_k) + A_k^* \mbox{ ln}(x-b_k^*)$$

2) $$\frac{B_k}{(x-b_k)^p} + \frac{B_k^*}{(x-b_k^*)^p}$$

Where, eg, Ak, Ak*, are complex conjugates, for reasons discussed in the fifth post. By seperating the coefficients into their real and imaginary parts and grouping these terms, we can convert (1) into the log of a real binomial and the arctan of a real monomial, using:

$$\frac{A}{2i}\mbox{ln}\left(\frac{x-(c+di)}{x-(c-di)}\right)=A\mbox{ tan}^{-1} \left(\frac{x-c}{d}\right)$$

Where this "equality" really only holds up to an additive constant, so the two terms aren't really equal (although their derivatives are), but they may be freely interchanged in an antiderivative. And (2) can be turned into a real rational function. This is discussed in more detail in the fifth post.

So, that's all. If anyone wants, I can go into more detail, clarify parts that were unclear, or give more rigorous proofs of things I've said. Hope you enjoyed it.

Last edited: Dec 21, 2005