# best way to retrieve similarity $L$ matrix

given the similarity relation between $A$ and $B$ matrices;

$$A = L^{-1} B L$$

if $A$ and $B$ are given, what is the best way to compute the similarity transformation matrix $L$?

-
The matrix $L$ need not be unique. One method is to find a "canonical form" for $A$ and $B$, which should be equal up to some easy permutation of blocks (e.g., the rational canonical form). If $R_A = R_B$, and $\beta$ is a rational canonical basis for $A$, $\gamma$ a rational canonical basis for $B$, then letting $P$ be the change-of-basis matrix for $\beta$ and $Q$ the change-of-basis matrix for $\gamma$, you get $Q^{-1}AQ = P^{-1}BP$, from whence you get $A = (QP^{-1})B(QP^{-1})^{-1}$. – Arturo Magidin Oct 26 '11 at 20:23

If $A$ and $B$ are similar then they are also similar to a canonical form (typically the Jordan form). Thus, one way to find the similarity matrix is to reach to the canonical form, say $J$, from both matrices via $$Q^{-1}AQ = J = P^{-1}BP$$
Then, one can use either $A = (QP^{-1})B(QP^{-1})^{-1}$ or $B = (PQ^{-1})A(PQ^{-1})^{-1}$
If $A$ and $B$ are matrices with inexact numbers, replace "Jordan" with "Schur" in this answer. – J. M. Nov 6 '11 at 1:06