Simon Rose
Simon Rose

Reputation: 421

Why am I having problems with "large" matrices in sage?

I'm trying to do some computations with a 22x22 matrix in sage. This doesn't seem like it should be that bad to do, in particular since the matrix is pretty sparse. However, when I try to do anything with the matrix I get an "IndexError: string index out of range", or nonsense computations. What gives?

Even very simply, if I try the following code:

M = matrix(ZZ,20); M

This should display a 20x20 matrix of zeros. However, it instead gives the same IndexError, where

M = matrix(ZZ,19); M

does not, and gives exactly what you expect.

The funny thing is that having inputted my matrix, any attempt to display it gives the IndexError. However, there are still a few things that I can do that give "answers", although I'm skeptical about their correctness. For example, I can do things like

M.parent()

which seems to make sense. However,

M.determinant()

spits out a number, but I'm about 99% certain that the number it gives me has little to do with the determinant of the matrix that I've put in.

So what's up? Is sage just incapable of dealing with matrices greater than size 19x19?

Edit: This is on Mac OS X 10.9.4, and my sage version is 5.10. This is after a fresh restart of sage, which gives me the same error. However, it seems that I should probably update sage and see if it keeps up with the problem....

Upvotes: 1

Views: 508

Answers (1)

Samuel Lelièvre
Samuel Lelièvre

Reputation: 3453

This is a known and fixed bug, see tickets #14785 and #14579 on Sage's trac, where we learn that the bug was in Python, see issue 17526 on Python's bug tracker, that it was resovled upstream, and that this works well in Sage since version 5.11.beta3.

I agree with John Palmieri's encouragement to update. Sage gets better and better, so it's always worth working with a recent version. Currently Sage 6.2 is out, and Sage 6.3.rc1 is out and works well, so Sage 6.3 should be released pretty soon.

Regarding the determinant, I would be very surprised if it is computed incorrectly, but why don't you check by computing it in another computer algebra system? If it is indeed incorrect, please report the bug. Search the web for 'wims determinant' for an online determinant calculator.

Edit (2014-08-10): Sage 6.3 is out!

And while I'm editing I'll link to the wims matrix tool, just for completeness. I also confess that I haven't checked who Wims and Sage call for computing such a determinant; it might end up being the same software, so that wouldn't be much of a check. It's good that you checked it another way.

Upvotes: 3

Related Questions