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 ?

Here is an easy way
$$\int { \frac { x+1 }{ \left( x^{ 2 }+4x+5 \right) ^{ 2 } }  } dx=\frac { 1 }{ 2 } \int { \frac { 2x+4-2 }{ \left( x^{ 2 }+4x+5 \right) ^{ 2 } }  } dx=\\ =\frac { 1 }{ 2 } \int { \frac { 2x+4 }{ \left( x^{ 2 }+4x+5 \right) ^{ 2 } } dx-\int { \frac { dx }{ \left( x^{ 2 }+4x+5 \right) ^{ 2 } }  }  } =\\ =\frac { 1 }{ 2 } \underset { { I }_{ 1 } }{ \underbrace { \int { \frac { d\left( x^{ 2 }+4x+5 \right)  }{ \left( x^{ 2 }+4x+5 \right) ^{ 2 } }  }  }  } -\underset { { I }_{ 2 } }{ \underbrace { \int { \frac { d\left( x+2 \right)  }{ { \left( { \left( x+2 \right)  }^{ 2 }+1 \right)  }^{ 2 } }  }  }  } =$$
Obviously,$$\\ { I }_{ 1 }=-\frac { 1 }{ 2\left( x^{ 2 }+4x+5 \right)  } ,$$
now,let calculate ${ I }_{ 2 }$,substitute here $x+2=\tan { z } $,so that $${ I }_{ 2 }=\int { \frac { d\tan { z }  }{ { \left( { \tan ^{ 2 }{ z }  }+1 \right)  }^{ 2 } }  } =\int { \frac { \cos ^{ 4 }{ z }  }{ \cos ^{ 2 }{ z }  }  } dz=\int { \cos ^{ 2 }{ z } =\frac { 1 }{ 2 } \int { \left( 1+\cos { 2z }  \right
) dz }  } =\frac { 1 }{ 2 } \left( z+\frac { \sin { 2z }  }{ 2 }  \right) $$
finally,

$$\int { \frac { x+1 }{ \left( x^{ 2 }+4x+5 \right) ^{ 2 } }  } dx=\frac { 1 }{ 2 } \left( -\frac { 1 }{ \left( x^{ 2 }+4x+5 \right)  } -\arctan { \left( x+2 \right) -\frac { \sin { 2\left( \arctan { \left( x+2 \right)  }  \right)  }  }{ 2 }  }  \right) +C$$

