A rational function

, where
P(x) and
Q(x)
are both polynomials, can be integrated in four steps:
- Reduce the fraction if it is improper (i.e. degree of P(x) is greater than degree of Q(x));
- Factor Q(x) into linear and/or quadratic (irreducible) factors;
- Decompose the fraction into a sum of partial fractions;
- Calculate integrals of each partial fraction.
Consider the specified steps in more details.
Step 1. Reducing an improper fraction
If the fraction is improper (i.e. degree of
P(x) is greater than degree of
Q(x)),
divide the numerator
P(x) by the denominator
Q(x) to obtain
where

is a proper fraction.
Step 2. Factoring Q(x) into linear and/or quadratic factors
Write the denominator
Q(x) as
where quadratic functions are irreducible, i.e. do not have real roots.
Step 3. Decomposing the rational fraction into a sum of partial fractions.
Write the function as follows:
The total number of undetermined coefficients
Ai , Bi , Ki , Li , Mi , Ni , ...
must be equal to the degree of the denominator
Q(x).
Then equate the coefficients of equal powers of
x by multiplying both sides of the latter expression by
Q(x) and write the system of linear equations in
Ai , Bi , Ki , Li , Mi , Ni , ....
The resulting system must always have a unique solution.
Step 4. Integrating partial fractions.
Use the following 6 formulas to evaluate integrals of partial fractions with linear and quadratic denominators:
For fractions with quadratic denominators, first complete the square:
where

Then use the formulas:
The integral

can be calculated in
k steps using the reduction formula: