Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Bug introduced in 7.0 or earlier and fixed in 9.0.1 or earlier

Why does the following simple code never come to an end (at least with version 8)

n = 5;
mat = SparseArray[{i_, i_} -> 1, {n, n}, -1/(n - 1)];

when the following clearly doesn't cause any problem?

n = 5;
mat = Normal@SparseArray[{i_, i_} -> 1, {n, n}, -1/(n - 1)];

The same issue appears to exist with Det instead of MatrixRank.

share|improve this question
The problem does not seem to exist on newer versions, I'd suggest upgrading. – rcollyer Aug 5 '13 at 17:12
On V8.0.4 (Mac) it more or less immediately crashes the kernel. The problem seems to be mixing Integer and Rational -- obviously a bug. Here's a workaround: mat = SparseArray[{i_, i_} -> 1/2, {n, n}, -1/(2 (n - 1))]. Then MatrixRank[mat] and Det[mat] return values. You would have to multiply the determinant by 2^n, but it returns zero. – Michael E2 Aug 5 '13 at 18:20
The question code also crashes v7, and the workaround from @Michael works there too. – Mr.Wizard Aug 5 '13 at 20:04
@MichaelE2 Are you able to check this in version 9? – Mr.Wizard Jul 30 '15 at 0:07
@Mr.Wizard It's fixed in V9.0.1. I'll update the notice. Can't check 9.0.0. – Michael E2 Jul 30 '15 at 0:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.