# can't 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)

edit retag close merge delete

Sort by » oldest newest most voted

AFAICT, the computations go just fine. One can print any element of the inverse matrix (a very large SR expression).

However, the resultant expressions are way to large for Mathjax (or even for \LaTeX) to cope. Therefore, show (or view) fails spectacularly.

One possible solution is to change ring to QQbar (which is still an exact field). That way, you still can do exact computations and print your results.

Another could be to change ring to a suitably choose cyclotomic field (left as an exercise to the reader...).

HTH,

more

but the simplest way is : as FFTc is orthogonal , I just have to get Hermitian FFTc for the inverse !

sage Cell

( 2019-08-01 02:28:12 -0500 )edit

But it is also ok when changing ring in QQbar, thank Emmanuel. reference doc

Gilbert Strang on MIT ocw

( 2019-08-01 02:37:13 -0500 )edit

I think the problem is that you compute with symbolic matrices. Computations there can easily blow up horribly and I expect that is what's happening. The line:

FFTc.change_ring(CC)


produces a new matrix with complex-float entries, but since you don't assign it to anything, the resulting matrix just gets lost. You continue working with the symbolic matrix after that, and I think that just grinds to a halt due to explosion of intermediate expressions. Perhaps you meant to compute with a float approximation to the matrix instead?

Note that computing a "kernel" of a float matrix generally doesn't work, because numerically matrices of non-maximal rank aren't really distinguishable from maximal rank ones. Also computing the "inverse" numerically is generally tricky and requires special measures to get a bit of numerical stability. Sage unfortunately doesn't do that by default (in part because you're probably doing something wrong if you're computing an inverse numerically).

more

ok, thank you nbruin

( 2019-07-31 13:15:34 -0500 )edit