# 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

Answering the unanswered before it gets too old to be pushed to the front page. One possible answer is already given by Arturo Magidin in the comment.

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
@J.M. Feel free to edit my answers whenever you think something is missing or you simply have additional content :) – user13838 Nov 6 '11 at 1:43
Naw, I'm fine with it as a comment. :) (The first upvote's mine.) – J. M. Nov 6 '11 at 1:50