# Revision history [back]

### How to take inverse of matrix with complex entries

I am trying to find the similarity matrix between two 18 by 18 matrices K_1 and K_2 which are cospectral. The is_similar() function takes too long to run. We can compute the similarity matrix by finding the transition matrices S and Q which diagonalize both K_1 and K_2. In other words, S^(-1)K_1S = H = Q^(-1)K_2Q, where H is a diagonal matrix. We then know that QS^(-1)K_1SQ^(-1) = K_2. My problem now though is that we can't compute Q^(-1) or S^(-1) since both Q and S have nasty complex numbers and the inverse method in Sage doesn't run fast enough. Any thoughts on how to quickly compute these inverses?

fyi, I did try using the left and right eigenmatrices to find the similarity matrix, but the eigenvectors didn't line up.

 2 None Max Alekseyev 5671 ●5 ●36 ●121

### How to take inverse of matrix with complex entries

I am trying to find the similarity matrix between two 18 by 18 matrices K_1 K_1 and K_2 K_2 which are cospectral. The is_similar() is_similar() function takes too long to run. We can compute the similarity matrix by finding the transition matrices S S and Q which diagonalize both K_1 K_1 and K_2. K_2. In other words, S^(-1)K_1S S^(-1)*K_1*S = H = Q^(-1)K_2Q, Q^(-1)*K_2*Q, where H H is a diagonal matrix. We then know that QS^(-1)K_1SQ^(-1) Q*S^(-1)*K_1*S*Q^(-1) = K_2. K_2. My problem now though is that we can't compute Q^(-1) Q^(-1) or S^(-1) S^(-1) since both Q Q and S S have nasty complex numbers and the inverse method in Sage doesn't run fast enough. Any thoughts on how to quickly compute these inverses?

fyi, I did try using the left and right eigenmatrices to find the similarity matrix, but the eigenvectors didn't line up.