First time here? Check out the FAQ!

Ask Your Question
0

can't display the inverse of complex matrix

asked 5 years ago

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)
Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 5 years ago

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,

Preview: (hide)
link

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 ( 5 years ago )

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

Gilbert Strang on MIT ocw

ortollj gravatar imageortollj ( 5 years ago )
1

answered 5 years ago

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

Preview: (hide)
link

Comments

ok, thank you nbruin

ortollj gravatar imageortollj ( 5 years ago )

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: 5 years ago

Seen: 464 times

Last updated: Aug 01 '19