# Simple Matrix multiplication takes very long

Bug introduced in 10.1.0 and fixed in 10.3.0

I came across some strange behaviour during a computation involving matrices with symbolic values. It is reproduced below.

Multiplying a random 30x30 array with symbolic values with the identity matrix takes 4 seconds! Converting to a SparseArray seems to work, but I don't understand why it should since the matrix size is so small.

Mathematica Version is 10.1

aa = Table[RandomInteger[10] + Sqrt[RandomInteger[10]]/(1 +
Sqrt[RandomInteger[10]]), {30}, {30}];

IdentityMatrix[30].aa; // Timing


{3.95225, Null}

SparseArray[IdentityMatrix[30]].aa; // Timing


{0., Null}

• This has to be a bug ... In 10.0 it is not slow but in 10.1 it is. I can reproduce it on OS X. Can you report it to WRI? – Szabolcs Jul 9 '15 at 15:21
• already paying attention to it. I've passed it along to the appropriate tester, etc. – rcollyer Jul 9 '15 at 15:26
• Quite relevant is this prior MSE post. It seems someone here (and I mean right here) did not know to leave well enough alone (smack smack). – Daniel Lichtblau Jul 9 '15 at 15:56
• Thank you for reporting it. Makes the 3+ hours to narrow it down, worthwhile. – A. Roy Jul 9 '15 at 17:24
• Bug is still present in version 10.2, Linux – A. Roy Aug 3 '15 at 15:52

This bug has been fixed as of Mathematica 10.3.

\$Version

(* "10.3.0 for Mac OS X x86 (64-bit) (October 9, 2015)" *)

aa = Table[RandomInteger[10] +
Sqrt[RandomInteger[10]]/(1 + Sqrt[RandomInteger[10]]), {30}, {30}];

IdentityMatrix[30].aa; // Timing

(* {0.028025, Null} *)