If matrices $A,B$ similar, find nonsingular $S$ s.t.$B=S^{-1}AS$

Consider the matrices below $$A=\begin{bmatrix}9&4&5\\-4&0&-3\\-6&-4&-2\end{bmatrix}$$ and $$B=\begin{bmatrix}2&1&0\\0&2&0\\0&0&3\end{bmatrix}$$

These matrices have the same eigenvalues $\{2,2,-3\}$ and the same Jordan Canonical Form so they are similar.

In trying to find $S$ s.t. $B=S^{-1}AS$ I set $$S=\begin{bmatrix}a&b&c\\d&e&f\\g&h&k\end{bmatrix}$$ and then tried to solve the system of 9 equations with 9 unknowns $$B=S^{-1}AS\Leftrightarrow SB=AS$$ but Matlab showed it is rank deficient so it provided only the zero solution.

How can I find such matrix $S$?

Is there a systematic way to do that in the general case when both $A,B$ are $n\times n$ matrices?

• Find a basis of eigenvectors and generalized eigenvectors. – amd Mar 12 '18 at 15:07
• I think you may have made an error with "Matlab". There are certainly nonzero solutions for these linear equations, see my answer. – Dietrich Burde Mar 12 '18 at 15:58

Notice that $B$ is precisely the Jordan form of $A$, so it suffices to find a Jordan basis for $A$.

We have:

$$A - 2I =\begin{bmatrix}7&4&5\\-4&-2&-3\\-6&-4&-4\end{bmatrix},\quad (A - 2I)^2 =\begin{bmatrix}3&0&3\\-2&0&-2\\-2&0&-2\end{bmatrix}$$

so $\ker (A - 2I)^2 = \operatorname{span}\{e_1- e_3, e_2\} = \operatorname{span}\left\{\pmatrix{1 \\ 0\\ -1}, \pmatrix{0\\1\\0}\right\}$.

$$A - 3I = \begin{bmatrix}6&4&5\\-4&-1&-3\\-6&-4&-5\end{bmatrix} \implies \ker (A - 3I) = \operatorname{span}\left\{\pmatrix{-3 \\ 2 \\ 2}\right\}$$

Therefore, one Jordan basis is

$$\left\{(A - 2I)e_2, e_2, \pmatrix{-3 \\ 2 \\ 2}\right\} = \operatorname{span}\left\{\pmatrix{4 \\ -2\\ -4}, \pmatrix{0\\1\\0}, \pmatrix{-3 \\ 2 \\ 2}\right\}$$

So the similarity matrix is

$$S = \begin{bmatrix}4&0&-3\\-2&1&2\\-4&0&2\end{bmatrix}$$

• @mechanodroid Can you explain how you replaced vector $[1\ 0\ -1]^T$ you found in the basis of $\ker (A - 2I)^2$ with $(A - 2I)e_2=[4\ -2\ -4]^T$ ? – mgus Mar 12 '18 at 16:55
• @mgus In this case, the Jordan basis for the generalized eigenspace $\ker (A - 2I)^2$ can be found by picking a vector $v \in \ker (A - 2I)^2$ which is not in $\ker (A - 2I)$. Then the basis will be $\{(A - 2I)v, v\}$. I picked $v = e_2$. – mechanodroid Mar 12 '18 at 17:06

Yes, there is a systematic way. It works as you said. Writing $AS=SB$ as a system of equations in the $n^2$ variables of $S$, we just solve this system of linear equations. In general, there will be several solutions, including $S=0$ of course. But then we impose the condition $\det(S)\neq 0$, which is a polynomial inequality on the variables of $S$. Then we obtain all possible invertible $S$ with $AS=SB$. Again, there are many such $S$ in general.

So, explicitly, solving the linear equations, we obtain $$S=\begin{pmatrix} s_1 & s_4 & s_7 \cr -\frac{s_1}{2} & \frac{s_1-2s_4}{4} & -\frac{2s_7}{3} \cr -s_1 & -s_4 & -\frac{2s_7}{3} \end{pmatrix}$$ for arbitary parameters $s_1,s_4,s_7$. However, $$\det(S)=\frac{s_1^2s_7}{12},$$ so that we can take all such $S$ with $s_1s_7\neq 0$.

Since $A$ and $B$ have the same Jordan normal form $J$, there exist invertible matrices $P$ and $Q$ such that $$P^{-1}AP=J=Q^{-1}BQ\text{.}$$ Then $$B=(PQ^{-1})^{-1}APQ^{-1}\text{.}$$

Let $v_1=(-2,1,2)$, $v_2=(-1,0,1)$, and $v_3=(-3,2,2)$. Then $A.v_1=2v_1$, $A.v_2=2v_2+v_1$, and $A.v_3=3v_3$. Therefore, if$$M=\begin{pmatrix}-2&-1&-3\\1&0&2\\2&1&2\end{pmatrix},$$then$$M^{-1}.A.M=\begin{pmatrix}2&1&0\\0&2&0\\0&0&3\end{pmatrix}=B.$$

• Can you explain you found $\mathbf{v}_2$ since it's not an eigenvector? I also found $\mathbf{v}_1$ and $\mathbf{v}_3$ for eigenvalues 2 and 3, respectively but I am not sure where the $\mathbf{v}_2$ comes from. – mgus Mar 12 '18 at 15:19
• @mgus In order to find $v_2$, after finding $v_1$ I solved the equation $A.v=2v+v_1$ and took one of the solutions. – José Carlos Santos Mar 12 '18 at 15:21
• But, what is the intuition behind it? I mean which equation should I solve in the general case if I have many eigenvalues with algebraic multiplicity larger than 1? – mgus Mar 12 '18 at 15:24
• @mgus The intuition come from the Jordan normal form, with all those $1$'s right above the main diagonal. In this case, if the multiplicity of $1$ was $3$ and if I knew that the Jordan normal form had a block like$$\begin{pmatrix}2&1&0\\0&2&1\\0&0&2\end{pmatrix},$$then I would go after a vector $v_3$ that would be a solution of the equation $A.v=2v+v_2$. And so on. – José Carlos Santos Mar 12 '18 at 15:55