As both sides have the same denominator we must have
$3x+1=A(x+1)+Bx$
This is an equation for $x$ so it must hold whatever value $x$ is. If we put in $x=0$ we get $A=1$ and putting $x=-1$ gives $=-B=-2$ so $B=2$ . So we see that
Rewriting the integrand as a sum of simpler fractions has allowed us to reduce the initial integral to a sum of simpler integrals. In fact this method works to integrate any rational function.
To decompose the rational function ${\frac {P(x)}{Q(x)}}$:
Step 1 Use long division (if necessary) to ensure that the degree of $P(x)$ is less than the degree of $Q(x)$ (see Breaking up a rational function in section
Step 3 Write down the correct form for the partial fraction decomposition (see below) and solve for the constants.
To factor Q(x) we have to write it as a product of linear factors (of the form $ax+b$) and irreducible quadratic factors (of the form $ax^{2}+bx+c$ with $b^{2}-4ac<0$).
Some of the factors could be repeated. For instance if $Q(x)=x^{3}-6x^{2}+9x$ we factor $Q(x)$ as
$Q(x)=x(x^{2}-6x+9)=x(x-3)(x-3)=x(x-3)^{2}$
It is important that in each quadratic factor we have $b^{2}-4ac<0$ , otherwise it is possible to factor that quadratic piece further. For example if $Q(x)=x^{3}-3x^{2}+2x$ then we can write
$Q(x)=x(x^{2}-3x+2)=x(x-1)(x-2)$
We will now show how to write ${\frac {P(x)}{Q(x)}}$ as a sum of terms of the form
${\frac {A}{(ax+b)^{k}}}$ and ${\frac {Ax+B}{(ax^{2}+bx+c)^{k}}}$
Exactly how to do this depends on the factorization of $Q(x)$ and we now give four cases that can occur.
Q(x) is a product of linear factors with no repeats[edit]
This means that $Q(x)=(a_{1}x+b_{1})(a_{2}x+b_{2})\cdots (a_{n}x+b_{n})$ where no factor is repeated and no factor is a multiple of another.
For each linear term we write down something of the form ${\frac {A}{(ax+b)}}$ , so in total we write