<s>[INST] Integrate $\int \frac{(1-x)^2 \cdot e^x}{(1+x^2)^2}dx$ Integrate using integrating by parts : 

$$\int \frac{(1-x)^2 \cdot e^x}{(1+x^2)^2}dx$$

My attempt  :
$$I=\int \frac{(1-x)^2 \cdot e^x}{(1+x^2)^2}dx$$
$$I=\int \frac{e^x}{(1+x^2)^2}\cdot(1-x)^2dx$$
$$I=\frac{e^x}{(1+x^2)^2}\cdot\frac{(1-x)^3}{-3}-\int \frac{(1-x)^3}{-3}\cdot\frac{(1+x^2)^2e^x-e^x\cdot2(1+x^2)\cdot2x}{(1+x^2)^4}dx$$
Now it is little bit confusing. How can I simplify this ? Is there another method to do it differently ?
 [/INST] $$\int  \frac { (1-x)^{ 2 }\cdot e^{ x } }{ (1+x^{ 2 })^{ 2 } } dx=\int { \frac { { e }^{ x } }{ (1+x^{ 2 }) } dx-2\int { \frac { x{ e }^{ x } }{ (1+x^{ 2 })^{ 2 } } dx= }  } \\ =\int { \frac { d{ e }^{ x } }{ 1+x^{ 2 } }  } -2\int { \frac { x{ e }^{ x } }{ (1+x^{ 2 })^{ 2 } } dx= } \left( \frac { { e }^{ x } }{ 1+x^{ 2 } } +2\int { \frac { { xe }^{ x } }{ { \left( 1+x^{ 2 } \right)  }^{ 2 } } dx }  \right) -\\-2\int { \frac { x{ e }^{ x } }{ (1+x^{ 2 })^{ 2 } } dx=\frac { { e }^{ x } }{ 1+x^{ 2 } } +C } $$
</s>