# Integrals Involving Rational Functions

## Related Calculator: Integral (Antiderivative) Calculator with Steps

Consider integral int (4x-6)/(x^2-3x+2)dx.

This integral can be easily evaluated using substitution u=x^2-3x+2.

Indeed, du=(2x-3)dx. So, integral becoms 2 int (du)/u=2ln|u|+C=2ln|x^2-3x+2|+C.

This integral is easy, because in numerator there is exact derivative of denominator (or a constant multiply). But in many cases there is no derivative in numerator. For example, how to integrate int 1/(x^2-3x+2)dx?

Example 1. Integrate int (dx)/(x^2-3x+2).

Note, that (x^2-3x+2)=(x-2)(x-1).

So, 1/(x^2-3x+2)=1/((x-2)(x-1)).

Now, suppose you can decompose it as A/(x-2)+B/(x-1) . We need to determine constants A and B.

So, A/(x-2)+B/(x-1)=(A(x-1)+B(x-2))/((x-2)(x-1)).

And this must be equal for any x to 1/((x-2)(x-1)). Denominators are equal, so we require equality of numerators:

Thus, A(x-1)+B(x-2)=1.

At this point we have one of two ways to proceed. One way will always work, but is often requires more work. The other, while it won’t always work, is often quicker when it does work.

First way that always works. We can rewrite equation as (A+B)x+(-A-2B)=0*x+1.

Equating coefficients near like terms gives:

{(A+B=0),(-A-2B=1):} .

Adding two equations gives that -B=1 or B=-1 . From first equation A=-B=-(-1)=1.

Second way that will not always work. Note that A(x-1)+B(x-2)=1 must hold for any x. Therefore, choosing appropriate x's we got the unknown constants to quickly drop out.

If x=1 then x-1=0 and A*(1-1)+B(1-2)=1 ,so B=-1.

If x=2 then x-2=0 and A*(2-1)+B(2-2)=1, so A=1.

Therefore 1/((x-2)(x-1))=1/(x-2)-1/(x-1).

Finally, int (dx)/(x^2-3x+2)dx=int (1/(x-2)-1/(x-1))dx=ln|x-2|-ln|x-1|+C.

The process described in example 1 is called partial fraction decomposition.

Definition. Partial Fraction Decomposition is a process of taking a rational expression and decomposing it into simpler rational expressions that we can add or subtract to get the original rational expression. Many integrals are solved quickly with performing partial fraction decomposition.

Partial fractions can only be done if the degree of the numerator is strictly less than the degree of the denominator. If this doesn't hold, we first need to perform long division.

Example 2. Evaluate int (x^3-3x^2+2x+4)/(x^2-3x+2)dx .

Here degree of numerator is greater than degree of denominator, so perform long division first:

int (x^3-3x^2+2x+4)/(x^2-3x+2)dx=int (x(x^2-3x+2)+4)/(x^2-3x+2)dx=int (x+4 1/(x^2-3x+2))dx=

=int (x+4/(x-2)-4/(x-1))dx=1/2x^2+4ln|x-2|-4ln|x-1|+C .

In general if you have in denominator (a_nx^n+a_(n-1)x^(n-1)+...+a_0)^k then corresponding term in partial fraction decomposition is (A_(n-1)x^(n-1)+A_(n-2)x^(n-2)+...+A_0)/(a_nx^n+a_(n-1)x^(n-1)+...+a_0)+(A_(n-1)x^(n-1)+A_(n-2)x^(n-2)+...+A_0)/(a_nx^n+a_(n-1)x^(n-1)+...+a_0)^2+...+

+(A_(n-1)x^(n-1)+A_(n-2)x^(n-2)+...+A_0)/(a_nx^n+a_(n-1)x^(n-1)+...+a_0)^k.

In particular,

1. ax+b->A/(ax+b)
2. ax^2+bx+c->(Ax+B)/(ax^2+bx+c)
3. (ax+b)^2->A/(ax+b)+B/(ax+b)^2
4. (ax^2+bx+c)^2->(Ax+B)/(ax^2+bx+c)+(Cx+D)/(ax^2+bx+c)^2 .

Often there are quadratic terms that can't be reduced (discriminant is negative). In this case you should complete a square.

Example 3. Find int 1/(x^2-6x+10)dx.

x^2-6x+10 cannot be factored, so complete a square: x^2-6x+10=x^2-6x+9+1=(x-3)^2+1.

int 1/((x-3)^2+1)dx=arctan(x-3)+C .

In general you will need following integrals:

1. int 1/(ax+b)dx=1/a ln|ax+b|+C
2. int x/(x^2+-a)dx=1/2ln|x^2+-a|+C
3. int 1/((x+a)^2+b^2)dx=1/b tan^(-1)((x+a)/b)+C
4. int 1/(ax+b)^2dx=-1/a 1/(ax+b)+C

Example 4. Integrate int (2x^2-x+4)/(x^3+4x)dx

Since x^3+4x=x(x^2+4) then partial fraction decomposition is (2x^2-x+4)/(x(x^2+4))=A/x+(Bx+C)/(x^2+4).

Multiplying by x(x^2+4) we have that (2x^2-x+4)=A(x^2+4)+x(Bx+C)=(A+B)x^2+Cx+4A.

Equating coefficients near like terms yields A+B=2 , C=-1 and 4A=4.

Thus, A=1 , B=1 , C=-1 .

int (2x^2-x+4)/(x^3+4x)dx=int (1/x+(x-1)/(x^2+4))dx=int (1/x+x/(x^2+4)-1/(x^2+4))dx=

=ln|x|+1/2ln|x^2+4|-1/2tan^(-1)(x/2)+C.

Example 5. Evaluate int (2x^3-11x^2-2x+2)/(2x^2+x-1)dx .

Degree of numerator is greater than degree of denominator, so we must first perform long division.

(2x^3-11x^2-2x+2)/(2x^2+x-1)=x-6+(5x-4)/(2x^2+x-2)=x-6+(5x-4)/((2x-1)(x+1)).

Partial fraction decomposition is (5x-4)/((2x-1)(x+1))=A/(2x-1)+B/(x+1).

Multiplying by (2x-1)(x+1) gives the following: 5x-4=A(x+1)+B(2x-1).

If x=-1 then 5*(-1)-4=A(-1+1)+B(2*(-1)-1) or B=3.

If x=1/2 then 5*1/2-4=A(1/2+1)+B(2*1/2-1) or A=-1.

So, (5x-4)/((2x-1)(x+1))=-1/(2x-1)+3/(x+1).

Finally, int (2x^3-11x^2-2x+2)/(2x^2+x-1)dx=int (x-6-1/(2x-1)+3/(x+1))dx=

=1/2 x^2-6x-1/2 ln|2x-1|+3ln|x+1|+C.

Example 6. Evaluate int (15x^2-29x+15)/(x(x-3)(4x-5))dx.

Partial fraction decomposition is (15x^2-29x+15)/(x(x-3)(4x-5))=A/x+B/(x-3)+C/(4x-5) .

Multiplying by x(x-3)(4x-5) yields 15x^2-29x+15=A(x-3)(4x-5)+Bx(4x-5)+Cx(x-3).

If x=0 then 15*0^2-29*0+15=A(0-3)(4*0-5)+B*0*(4*0-5)+C*0*(0-3) or A=1.

If x=3 then 15*3^2-29*3+15=A(3-3)(4*3-5)+B*3*(4*3-5)+C*3*(3-3) or B=3.

If x=5/4 then 15*(5/4)^2-29*(5/4)+15=

=A((5/4)-3)(4*(5/4)-5)+B*(5/4)*(4*(5/4)-5)+C*(5/4)*((5/4)-3) or C=-1.

So, (15x^2-29+15)/(x(x-3)(4x-5))=1/x+3/(x-3)-1/(4x-5) .

Thus, required integral is int (1/x+3/(x-3)+1/(4x-5))dx=ln|x|+ln|x-3|+1/4ln|4x-5|+C.

Example 7. Integrate int x/((x+2)^2(x-1)dx .

Partial fraction decomposition is x/((x+2)^2(x-1))=A/(x+2)+B/(x+2)^2+C/(x-1).

Multiplying both by denominator gives x=A(x+2)(x-1)+B(x-1)+C(x+2)^2.

If x=1 then 1=A(1+2)(1-1)+B(1-1)+C(1+2)^2 or C=1/9.

If x=-2 then -2=A(-2+2)(-2-1)+B(-2-1)+C(-2+2)^2 or B=2/3.

To find constant A we can't use second method anymore, so we rewrite x=A(x+2)(x-1)+B(x-1)+C(x+2)^2 as

x=(A+C)x^2+(A+B+4C)x+(-2A-B+4C) .

From this we have that A+C=0. We've already found that C=1/9, so A=-1/9.

Therefore, x/((x+2)^2(x-1))=-1/9 1/(x+2)+2/3 1/(x+2)^2+1/9 1/(x-1).

Thus, required integral is int (-1/9 1/(x+2)+1/3 1/(x+2)^2+1/9 1/(x-1))dx=

=-1/9ln|x+2|-2/3 1/(x+2)+1/9ln|x-1|+C.

Example 8. Find int x^2/(x^2-1)dx.

First perform long division: (x^2)/(x^2-1)=1+1/(x^2-1).

Partial fraction decomposition is 1/(x^2-1)=1/2 1/(x-1)-1/2 1/(x+1).

Therefore, int (x^2)/(x^2-1)dx=int (1+1/2 1/(x-1)- 1/2 1/(x+1))dx=x+1/2 ln|x-1|-1/2 ln|x+1|+C.

Some integral with roots can be expressed as integral of rational function.

Example 9. int 1/(x-sqrt(x+2))dx .

Let u=sqrt(x+2) then du=1/2 1/(sqrt(x+2))dx or dx=2sqrt(x+2)du=2udu.

Also since u=sqrt(x+2) then x=u^2-2.

So, int 1/(x-sqrt(x+2))dx=int (2u)/(u^2-u-2)du.

Since u^2-u-2=(u-2)(u+1) then partial fraction decomposition is (2u)/((u-2)(u+1))=A/(u-2)+B/(u+1).

Multiplying by (u-2)(u+1) yields 2u=A(u+1)+B(u-2).

If u=-1 then 2*(-1)=A(-1+1)+B(-1-2) or B=2/3.

If u=2 then 2*2=A(2+1)+B(2-2) or A=4/3.

So, int (2u)/(u^2-u-2)du=int (4/3 1/(u-2)+2/3 1/(u+1))du=4/3ln|u-2|+2/3ln|u+1|+C=

=4/3ln|sqrt(x+2)-2|+2/3ln|sqrt(x+2)+1|+C .

Example 10. Find int (3x+5)/(x^2+10x+34)dx .

Factor in denominator is irreducible, so complete the square: x^2+10x+34=x^2+10x+25+9=(x+5)^2+9.

Now make substitution u=x+5 then du=dx and x=u-5.

Thus, int (3x+5)/(x^2+10x+34)dx=int (3(u-5)+5)/(u^2+9)du=3 int u/(u^2+9)du-10int 1/(u^2+9)du=

=3/2ln|u^2+9|-10/3arctan(u/3)+C=3/2ln((x+5)^2+9)-10/3arctan((x+5)/3)+C.

Now, let's see how to handle integrals where irreducible factor is raised to some power.

Example 11. Evaluate int 1/(x^2+4x+13)^3 dx.

We first complete the square: x^2+4x+13=x^2+4x+4+9=(x+2)^2+9.

Now, make substitution u=x+2 then du=dx.

int 1/((x+2)^2+9)^3dx=int 1/(u^2+9)^3 du.

We will need trig substitution here.

Let u=3tan(t) then u^2+9=9tan^2(t)+9=9sec^2(t) and du=3sec^2(t)dt.

So, int 1/(u^2+9)^3du=int (3sec^2(t))/(9sec^2(t))dt=1/243 int 1/(sec^4(t))dt.

To find this integral we need to use techniques from Integrals Involving Trig Functions note.

1/243 int 1/(sec^4(t))dt=1/243 int cos^4(t)dt=1/243 int (cos^2(t))^2dt=1/243 int (1/2 (1+cos(2t)))^2dt=

=1/972 int (1+2cos(2t)+cos^2(2t))dt=1/972 int (1+2cos(2t)+1/2(1+cos(4t)))dt=

=1/972 (3/2 t+sin(2t)+1/8sin(4t))+C.

Since u=3tan(t) and u=(x+2) then t=arctan((x+2)/3).

So, int 1/(x^2+4x+13)^3dx=

=1/972(3/2 arctan((x+2)/3)+sin(2arctan((x+2)/3))+1/8sin(4arctan((x+2)/3)))+C.