How to take the integral? $\int \frac{x^2-3x+2}{x^2+2x+1}dx$ $$\int \frac{x^2-3x+2}{x^2+2x+1}dx$$
So after all I had
$$ \frac{-5x+1}{(x+1)^2} = \frac{A}{(x+1)} + \frac{B}{(x+1)^2}$$
and of course $$ \int xdx $$
but it is easy to solve, I do not know how to act with devided things, probably solve the system, or is there easier way to find A and B?
After all steps I finally got:
$$-5x + 1 = Ax + A + B$$
 A: \begin{align*}
\frac{x^2 - 3x + 2}{x^2 + 2x + 1} &= 1 + \frac{1-5x}{(x+1)^2} \\
&= 1 + \frac{A}{x+1} + \frac{B}{(x+1)^2} 
\end{align*}
Then
\begin{align*}
\frac{1-5x}{(x+1)^2} &= \frac{A}{x+1} + \frac{B}{(x+1)^2} \\
&= \frac{A(x+1)+B}{(x+1)^2} \\
1-5x &= Ax+(A+B)
\end{align*}
So $A = -5$ and $B=6$.
Therefore
\begin{align*}
\frac{x^2 - 3x + 2}{x^2 + 2x + 1} &= 1 - \frac{5}{x+1} + \frac{6}{(x+1)^2} \\
\int\frac{x^2 - 3x + 2}{x^2 + 2x + 1}\,dx &= \int \left( 1 - \frac{5}{x+1} + \frac{6}{(x+1)^2} \right) dx \\
&= x - 5 \ln \lvert x+1 \rvert - \frac{6}{x+1} + C 
\end{align*}
A: HINT:
For $$\dfrac{x^2-3x+2}{(x+1)^2}$$  set $x+1=y\iff x=y-1$
A: I add this answer as a kind of reference to handle any kind of partial fraction decomposition when the roots of the polynomial in the denominator are known.
This is the general algebraic solution: suppose that you have two normalized polynomials $p,q\in\Bbb C[X]$ (normalized means that the coefficient of the maximum power of each one is $1$) with $\deg(q)>\deg(p)$, then we can write
$$p=\prod(X-z_k)^{m_k},\quad\sum_k m_k=\deg(p),\quad p(z_k)=0$$
that is, the polynomial is written as the product of it roots, each one with multiplicity $m_k$. Then we want to write
$$\frac{p}{q}=\sum_{j=1}^n\sum_{k=1}^{m_j}\frac{a_{jk}}{(X-z_k)^{m_j}},\quad a_{jk}\in\Bbb C\tag{1}$$
From (1) we make the ansatz
$$\frac{p}{q}=\frac{a}{(X-z_1)^{m_1}}+\frac{p_1}{q_1}\tag{2}$$
where $a\in\Bbb C$, $p_1\in\Bbb C[X]$ and $q_1:=\frac{q}{X-z_1}$. Multiplying (2) by $q$ we get
$$p=a\prod_{j=2}^n(X-z_j)^{m_j}+(X-z_1)p_1$$
from where we get the solution
$$\bbox[2pt, border:2px yellow solid]{a=p(z_1)/\prod_{j=2}^n(z_1-z_j)^{m_j}}\tag{3}$$
Applying (3) recursively through the roots of $q$ you get the desired partial fraction expansion for $p/q$. And you knows that
$$\int\frac{1}{(X-z_j)^{m_j}}=\begin{cases}\ln|x-z_j|+c,& m_j=1\text{ and } z_j\in\Bbb R\\\ln(x-z_j)+c,&m_j=1\text{ and }z_j\in\Bbb C\setminus\Bbb R\\\frac{-1}{(m_j-1)(X-z_j)^{m_j-1}}+c, &m_j>1\end{cases}$$
A: With $$ \frac{-5x+1}{(x+1)^2} = \frac{A}{(x+1)} + \frac{B}{(x+1)^2},$$
$x=0$ tells you that
$$A+B=1$$
and $x=-2$,
$$-A+B=11.$$
Not a big deal to find $-5$ and $6$.
I chose the values of $x$ to get the simplest coefficients in the equations.

With some care, you can even use $x=-1$, giving
$$\frac A0+\frac B{0^2}=\frac6{0^2}$$ which correctly tells you that $B=6$ if you consider that $1/0$ is negligible compared to $1/0^2$.
