Ask Your Question
0

can't display the inverse of complex matrix

asked 2019-07-31 18:19:16 +0200

ortollj gravatar image

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 flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2019-08-01 08:47:31 +0200

Emmanuel Charpentier gravatar image

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,

edit flag offensive delete link more

Comments

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

sage Cell

ortollj gravatar imageortollj ( 2019-08-01 09:28:12 +0200 )edit

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

Gilbert Strang on MIT ocw

ortollj gravatar imageortollj ( 2019-08-01 09:37:13 +0200 )edit
1

answered 2019-07-31 18:47:21 +0200

nbruin gravatar image

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).

edit flag offensive delete link more

Comments

ok, thank you nbruin

ortollj gravatar imageortollj ( 2019-07-31 20:15:34 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-07-31 18:19:16 +0200

Seen: 312 times

Last updated: Aug 01 '19