ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 29 Jan 2024 19:11:05 +0100How to take inverse of matrix with complex entrieshttps://ask.sagemath.org/question/75698/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_1*S = H = Q^(-1)*K_2*Q`, where `H` is a diagonal matrix. We then know that `Q*S^(-1)*K_1*S*Q^(-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.luke_mattgreenMon, 29 Jan 2024 19:11:05 +0100https://ask.sagemath.org/question/75698/Issue with inversion of complex symbolic array initialized with numpyhttps://ask.sagemath.org/question/56850/issue-with-inversion-of-complex-symbolic-array-initialized-with-numpy/Hello!
I am trying to invert a symbolic matrix that is initialized with a combination of numpy arrays and I get an error. Below i present a simple code that gives the error.
import numpy as np
a = np.zeros((5,5) , dtype = 'complex')
np.fill_diagonal(a,1)
b = var('x')*a
c = matrix(b)
c.inverse()
Gives the error:
> ECL says: THROW: The catch
> MACSYMA-QUIT is undefined.
What I have noticed up until now is that the issue stems from the data type. When I try casting the numpy array to float before turning it into a matrix, it works. However, my actual code makes use of complex coefficients. I believe it might have to do with how the imaginary part is represented in SageMath in comparison to numpy. ( `j` vs `I` )
When I manually create the symbolic array with `I` for the imaginary part, the `.inverse()` has no issue.yorgos_sotWed, 28 Apr 2021 13:31:54 +0200https://ask.sagemath.org/question/56850/can't display the inverse of complex matrixhttps://ask.sagemath.org/question/47326/cant-display-the-inverse-of-complex-matrix/ Hi
it seems that Sagemath is able to calculate this matrix inverse, but it is unable to display it.
Maybe someone will explain me why ? it is not easy to find what I do wrong because there is no error message for n=8
an it's ok for n=4
#FFT
w=var('w')
n=8
FFT=matrix(SR,n,n)
#show (FFT)
for i in (0..n-1):
for j in (0..n-1):
FFT[i,j]=w^(i*j)
FFTc=1/sqrt(n) *FFT.subs(w=e^(2*I*pi/n))
#show(" FFTc : ",FFTc)
FFTc.change_ring(CC)
show(" FFTc.right_kernel().matrix() : ",FFTc.right_kernel().matrix())
show (" FFTc.determinant() for n =",str(n),": ",FFTc.determinant())
FFTcI=copy(FFTc).inverse()
#show (" FFT w :",FFT)
show (" FFTc with w=e^(2*I*pi/",str(n),") : ",FFTc)
show (" FFTc inverse with w=e^(2*I*pi/",str(n),") : ",FFTcI)
ortolljWed, 31 Jul 2019 18:19:16 +0200https://ask.sagemath.org/question/47326/