Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Inverse of real sparse matrix

Dear sagemath community,

I'm a bit surprised in the result that I obtain when I compute the inverse of a real, sparse matrix. The problem occurs in Sagemath 8.7, (on windows).

In my case the matrix is B=matrix(RR, [[1/6, -1/24, -1/30, 1/120,1/12, 0, 0, 0, 0], [-1/24,1/60,1/60, 1/420, -1/24, 0, 0, 0, 0], [-1/30,1/60, 2/105, 1/140, -1/20, 0, 0, 0, 0], [1/120, 1/420, 1/140, 13/1260, -1/40, 0, 0, 0, 0], [1/12, -1/24, -1/20, -1/40, 1/3, -1/24, -1/30, 1/120,1/12], [0, 0, 0, 0, -1/24,1/60,1/60, 1/420, -1/24], [0, 0, 0, 0, -1/30,1/60, 2/105, 1/140, -1/20], [0, 0, 0, 0, 1/120, 1/420, 1/140, 13/1260, -1/40], [0, 0, 0, 0,1/12, -1/24, -1/20, -1/40, 1/6]],sparse=true) (B.inverse()*B).norm(1)

The result is 138.4999999999923, which is very far from the expected value: 1. If one replaces sparse=true by sparse=false, the result becomes reasonable.The problem also does not occur when I replace RR by QQ.

I suspect that this will not happen in all versions of Sagemath, since I stumbled upon this strange behaviour when I was executing a code that used to work fine years ago. Sadly I do not recall which version I used to have back then. I wanted to ask: what is currently the right way to compute the inverse of a sparse real matrix?

cheers,

IV

Inverse of real sparse matrix

Dear sagemath community,

I'm a bit surprised in the result that I obtain when I compute the inverse of a real, sparse matrix. The problem occurs in Sagemath 8.7, (on windows).

In my case the matrix is B=matrix(RR, [[1/6, -1/24, -1/30, 1/120,1/12, 0, 0, 0, 0], [-1/24,1/60,1/60, 1/420, -1/24, 0, 0, 0, 0], [-1/30,1/60, 2/105, 1/140, -1/20, 0, 0, 0, 0], [1/120, 1/420, 1/140, 13/1260, -1/40, 0, 0, 0, 0], [1/12, -1/24, -1/20, -1/40, 1/3, -1/24, -1/30, 1/120,1/12], [0, 0, 0, 0, -1/24,1/60,1/60, 1/420, -1/24], [0, 0, 0, 0, -1/30,1/60, 2/105, 1/140, -1/20], [0, 0, 0, 0, 1/120, 1/420, 1/140, 13/1260, -1/40], [0, 0, 0, 0,1/12, -1/24, -1/20, -1/40, 1/6]],sparse=true) (B.inverse()*B).norm(1)

The result is 138.4999999999923, which is very far from the expected value: 1. If one replaces sparse=true by sparse=false, the result becomes reasonable.The problem also does not occur when I replace RR by QQ.

I suspect that this will not happen in all versions of Sagemath, since I stumbled upon this strange behaviour when I was executing a code that used to work fine years ago. Sadly I do not recall which version I used to have back then. I wanted to ask: what is currently the right way to compute the inverse of a sparse real matrix?

cheers,

IV

click to hide/show revision 3
None

Inverse of real sparse matrix

Dear sagemath community,

I'm a bit surprised in the result that I obtain when I compute the inverse of a real, sparse matrix. The problem occurs in Sagemath 8.7, (on windows).

In my case the matrix is

B=matrix(RR, [[1/6, -1/24, -1/30, 1/120,1/12, 0, 0, 0, 0],
[-1/24,1/60,1/60, 1/420, -1/24, 0, 0, 0, 0],
[-1/30,1/60, 2/105, 1/140, -1/20, 0, 0, 0, 0],
[1/120, 1/420, 1/140, 13/1260, -1/40, 0, 0, 0, 0],
[1/12, -1/24, -1/20, -1/40, 1/3, -1/24, -1/30, 1/120,1/12],
[0, 0, 0, 0, -1/24,1/60,1/60, 1/420, -1/24],
[0, 0, 0, 0, -1/30,1/60, 2/105, 1/140, -1/20],
[0, 0, 0, 0, 1/120, 1/420, 1/140, 13/1260, -1/40],
[0, 0, 0, 0,1/12, -1/24, -1/20, -1/40, 1/6]],sparse=true)
(B.inverse()*B).norm(1)

(B.inverse()*B).norm(1)

The result is 138.4999999999923, which is very far from the expected value: 1. If one replaces sparse=true by sparse=false, the result becomes reasonable.The problem also does not occur when I replace RR by QQ.

I suspect that this will not happen in all versions of Sagemath, since I stumbled upon this strange behaviour when I was executing a code that used to work fine years ago. Sadly I do not recall which version I used to have back then. I wanted to ask: what is currently the right way to compute the inverse of a sparse real matrix?

cheers,

IV