I am given the system $\dot{x}(t)=Ax(t) + Bu(t)$ where $$A = \left( \begin{matrix} -1 & 0& 2\\ 0 & -3 & 0 \\ 1&0&0 \end{matrix} \right), \quad B = \left( \begin{matrix} 1\\1\\0 \end{matrix} \right)$$ Now this system is not stable as $A$ has eigenvalues $-3,-2$ and $1$, the characteristic polynomial of $A$ is $\lambda ^3 + 4 \lambda^2 +\lambda -6$. It is stabilizable though. Now I need to put it into controller form, that is find an invertible $S$ such that $\bar{A} =S^{-1}AS$ and $\bar{B} = S^{-1}B$ where $$\bar{A} = \left( \begin{matrix} 0 & 1& 0\\ 0 & 0 & 1 \\ 6&-1&-4 \end{matrix} \right),\quad \bar{B} = \left( \begin{matrix} 0\\0\\1 \end{matrix} \right)$$ Where the third row of $\bar{A}$ is given by the coefficients of the characteristic polynomial of $A$.
Now I have tried for hours now to find $S$ using the algorithm I am given but I can't get the right matrix $S$. I keep checking $AS = S\bar{A}$ but every time this doesn't work out. If anyone can show me their workings and method of how to find $S$ I would be very happy and thankful! Thank you.
Also, it is possible of course I made a mistake somewhere along the road, if so please point it out and I will see if I can finally figure this problem out. Thanks :)