<s>[INST] Integration by means of partial fraction decomposition I'm trying to solve this indefinite integral by means of partial fraction decomposition:
$\int\dfrac{x+1}{\left(x^2+4x+5\right)^2}\ dx$.
The denominator has complex (but not real) roots because $\Delta<0$; so, according with my calculus book, i try to decompose the integrand function in this form:
$\dfrac{x+1}{\left(x^2+4x+5\right)^2}=
\dfrac{Ax+B}{\left(x^2+4x+5\right)}+\dfrac{Cx+D}{\left(x^2+4x+5\right)^2}$.
I get:
$\dfrac{x+1}{\left(x^2+4x+5\right)^2}=
\dfrac{\left(Ax+B\right)\left(x^2+4x+5\right)+Cx+D}{\left(x^2+4x+5\right)^2}$.
Multiplying the right term:
$\dfrac{x+1}{\left(x^2+4x+5\right)^2}=
\dfrac{Ax^3+4Ax^2+5Ax+Bx^2+4Bx+5B+Cx+D}{\left(x^2+4x+5\right)^2}$.
Now i collect the terms with the same pwer of $x$:
$\dfrac{x+1}{\left(x^2+4x+5\right)^2}=
\dfrac{Ax^3+\left(4A+B\right)x^2+\left(5A+4B+C\right)x+D+ 5B}{\left(x^2+4x+5\right)^2}$.
Now i equate the two numerators:
$x+1=Ax^3+\left(4A+B\right)x^2+\left(5A+4B+C\right)x+D$
and equate term by term: i get:
$A=0$, $B=0$, $C=1$, $D=1$.
With these values i get a correct identity:
$\dfrac{x+1}{\left(x^2+4x+5\right)^2}=
\dfrac{x+1}{\left(x^2+4x+5\right)^2}$
but this is unuseful in order to solve the integral.
Where is my mistake ?
 [/INST] Note that we can write the partial fraction expansion of $\frac{1}{(x+4x+5)^2}$ as
$$\frac{1}{(x+4x+5)^2}=\frac{1}{(x-r)^2(x-r^*)^2}=\frac{A}{x-r}+\frac{B}{(x-r)^2}+\frac{C}{x-r^*}+\frac{D}{(x-r^*)^2}$$
where $r=-2+i$ and $r^*=-2- i$.
Multiplying by $(x-r)^2$ and letting $x\to r$ reveals that $B=\frac{1}{(r-r^*)^2}=-\frac14$.
Multiplying by $(x-r)^2$, taking a derivative with respect to $x$, and letting $x\to r$ reveals that $A=-\frac{2}{(r-r^*)^3}=-\frac{i}{4}$.
Multiplying by $(x-r^*)^2$ and letting $x\to r^*$ reveals that $D=\frac{1}{(r^*-r)^2}=-\frac14$.
Multiplying by $(x-r^*)^2$, taking a derivative with respect to $x$, and letting $x\to r^*$ reveals that $C=\frac{2}{(r-r^*)^3}=\frac{i}{4}$.

</s>