Simple integral: $\int \frac {1+r}{-r^2+r-1} dr$. I was solving a much longer exercise, and while solving an ODE, I got this integral $$\int \frac {1+r}{-r^2+r-1} dr$$
I think this must be pretty simple, but  I couldn't solve it, my substitutions didn't work and the polynomial in the denumerator does not have real roots, so partial frac. decomp. looks quite messy.
How are do you solve the general integral:
$$
\int \frac {r+a}{dr^2+er+f}dr
$$
When the denumerator has no real roots?
 A: Notice,  let $1+r=A\frac{d}{dr}(-r^2+r-1)+B=A(-2r+1)+B$
By comparing the corresponding coefficients, we get $A=-\frac{1}{2}$ & $B=\frac{3}{2}$ 
$$\int \frac{1+r}{-r^2+r-1}\ dr$$ $$=\int \frac{\frac{3}{2}-\frac{1}{2}(-2r+1)}{-r^2+r-1}\ dr$$
$$=\frac{3}{2}\int \frac{1}{-r^2+r-1}\ dr-\frac{1}{2}\int \frac{-2r+1}{-r^2+r-1}\ dr$$
$$=\frac{3}{2}\int \frac{1}{-\left(r-\frac{1}{2}\right)^2-\frac{3}{4}}\ dr-\frac{1}{2}\int \frac{d(-r^2+r-1)}{-r^2+r-1}$$
A: Hint Write the denominator as $$-(r^2 - r + 1) = -\left(r - \frac{1}{2}\right)^2 + \frac{3}{4} .$$ This suggests splitting up the integral as
$$- \int \frac{r - \frac{1}{2}}{\left(r - \frac{1}{2}\right)^2 + \frac{3}{4}} dr - \frac{3}{2} \int \frac{dr}{\left(r - \frac{1}{2}\right)^2 + \frac{3}{4}} .$$ (If this sort of decomposition seems unmotivated or unfamiliar first substitute $u = r - \frac{1}{2}$, which gives
$$-\int \frac{u + \frac{3}{2}}{u^2 + \frac{3}{4}} du .)$$ In any case, one can then handle the two integrals using more primitive techniques.
A: $r^2-r+1 = \frac{r^3+1}{r+1}$, hence $r^2-r+1=(r-\omega)(r-\omega^2)$, with $\omega=\exp\left(\frac{2\pi i}{6}\right)$.
By the residue theorem:
$$ \text{Res}\left(\frac{r+1}{r^2-r+1},r=\omega\right) = \frac{\omega+1}{2\omega},$$
$$ \text{Res}\left(\frac{r+1}{r^2-r+1},r=-\omega\right) = \frac{-\omega+1}{-2\omega},$$
hence the partial fraction decomposition is given by:
$$ \frac{r+1}{r^2-r+1} = \frac{1+\omega}{2\omega}\cdot\frac{1}{r-\omega}-\frac{1-\omega}{2\omega}\cdot\frac{1}{r+\omega}. $$
We may compute the primitive through the previous line, or through the trick:
$$ \frac{4r+4}{4r^2-4r+4} = \frac{1}{2}\frac{2r-1}{r^2-r+1}+\frac{2}{1+\frac{1}{3}(2r-1)^2}$$
that gives:
$$ \int \frac{r+1}{r^2-r+1}\,dr = \frac{1}{2}\log(r^2-r+1)+\sqrt{3}\arctan\left(\frac{2r-1}{\sqrt{3}}\right)+C.$$
