To find $A$ given that $2I + A +A^2 = B$ where $B$ is given. How to find a matrix $A$ such that the following holds:
$$2I + A +A^2 = B,$$ where the matrix $B$ is given. I tried with char poly of $B$ but not getting any idea.
Note that it is also given that $B$ is invertible.
P.S. $B = \begin{pmatrix}-2&-7&-4\\ \:12&22&12\\ \:-12&-20&-10\end{pmatrix}$.

Here is an ad hoc method:
It is straightforward (if tedious) to find null spaces of
$B-2I, B-4I, (B-4I)^2$ and determine the Jordan form.
With $V=\begin{bmatrix} 3 & -1 & 1 \\ -6 & 1 & 0 \\ 6 & -1 & -1 \end{bmatrix}$ we see that
$V^{-1}BV = \begin{bmatrix} 4 & 1 & 0  \\ 0 & 4 & 0 \\ 0 & 0 & 2 \end{bmatrix}$, and since $2+0+0^2 = 2$ we can look for $A$ of the form
$A=\begin{bmatrix} \lambda & \alpha & 0  \\ 0 & \lambda & 0 \\ 0 & 0 & 0 \end{bmatrix}$.
Then from $A^2+A+2I=B$ we get $\lambda^2+\lambda +2 = 4$ and so $\lambda \in \{-2,1\}$.
Then we need $2 \alpha \lambda + \alpha = 1$ from which we get
$\alpha = {1 \over 2 \lambda +1}$.
Hence $\lambda =-2, \alpha = -{1 \over 3}$ and $\lambda =1, \alpha = {1 \over 3}$ are two solutions (or rather $V A V^{-1}$).
