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

$$A=SJS^{-1},\\ 2I+A+A^2=S(2I+J+J^2)S^{-1}=B\\
2I+J+J^2=S^{-1}BS$$
So incorporating (yeah, stealing) the idea of the Mostafa Ayaz's answer we get $$\left(J+\frac{1}{2}I\right)^2=S^{-1}BS-\frac{7}{4}I$$
Letting, for a second, that $S$ is the same for $$B=S\begin{pmatrix}2&0&0\\0&4&1\\0&0&4\end{pmatrix}S^{-1}$$
we feed this thing to wolframalpha obtaining 
$$J+\frac{1}{2}I=\pm_{\small{1}}\begin{pmatrix}\frac12&0&0\\0&\pm_{\small{2}}\frac32&\pm_{\small{2}}\frac13
\\0&0&\pm_{\small{2}}\frac32\end{pmatrix}$$ and hence $A$. Can test here
