We want to evaluate the integral
$$\int \frac{-x^2+x+4}{(1-x)^2(3x+1)} dx$$
What I have troubles with, is to understand the principle of partial fraction decomposition.
For instance, here we'd have
$$\frac{-x^2+x+4}{(1-x)^2 (3x+1)} = \frac{c_1}{(1-x)} + \frac{c_2}{(1-x)^2} + \frac{c_3}{(3x+1)}$$
Sure, we could say
$$ c_3 = \bigg(\frac{-x^2+x+4}{(1-x)^2 (3x+1)} - \frac{c_1}{(1-x)} - \frac{c_2}{(1-x)^2} \bigg) \cdot (3x+1)$$
but how does that help us?
How do we find out that
$c_3 = 2$, $c_2 = 1$ and $c_1 = 1$?
A simple and efficient way of doing this is as follows:
When you have $$\frac{-x^2+x+4}{(1-x)^2(3x+1)}=\frac{c_1}{1-x}+\frac{c_2}{(1-x)^2}+\frac{c_3}{3x+1}$$ Start by combining the RHS into one fraction with the same denominator as the LHS, and then just write out the numerators, i.e. $$-x^2+x+4\equiv c_1(1-x)(3x+1)+c_2(3x+1)+c_3(1-x)^2$$
Note that the $\equiv$ sign indicates that this is an identity and must be true for any value of $x$. Therefore choose values of $x$ which make brackets zero (to avoid a simultaneous equation).
When $x=1$, we have $4=0+c_2(4)+0\implies c_2=1$
When $x=-\frac13$, we have $\frac{32}{9}=0+0+c_3(\frac43)^2\implies c_3=2$
Now that we have run out of convenient values of $x$, we can just choose any other value, such as zero. Or, more conveniently, compare coefficients such as the $x^2$ term, which gives
$-1=-3c_1+c_3\implies c_1=1$
I hope this helps.