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 ?

As suggested in the comment directly use Trigonometric substitution
As $x^2+4x+5=(x+2)^2+1^2,$ let $\arctan(x+2)=y\implies x+2=\tan y$
$$2I\int\dfrac{x+1}{(x^2+4x+5)^2}dx=\int(\tan y-1)\cos^2y\ dy$$
$$4I=2\int(\sin2y-1-\cos2y)dy=-\sin2y-2y-\cos2y+K$$
Now $\sin2y=\dfrac{2\tan y}{1+\tan^2y}=\cdots$
and $\cos2y=\dfrac{1-\tan^2y}{1+\tan^2y}=\dfrac2{1+\tan^2y}-1=\cdots$
