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$$

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}$$
