22
$\begingroup$

Bug introduced in 11.1.0 and fixed in 11.3.0


The code

M = Flatten[Table[Flatten[Transpose[{{1, a, a, -1}[[i]] 
            UnitVector[4, i]}].{{1, a, a, -1}[[j]]
            UnitVector[4, j]}],   {i, 1, 4}, {j, 1, 4}], 1]

creates the diagonal matrix with diagonal

{1,a,a,-1,a,a^2,a^2,-a,a,a^2,a^2,-a,-1,-a,-a,1}

However, in Mathematica 11.2, Eigenvalues[M] returns me

{-1,-a,-a,-1,-a,-a,a,a,a,a,a,a,a,a^2,a^2,a}

Is this only me or is it a bug? In Mathematica 11.0.x, it works fine.

$\endgroup$
10
  • $\begingroup$ It looks like a bug to me ... did you report it to Wolfram? $\endgroup$
    – Szabolcs
    Feb 7, 2018 at 13:13
  • 9
    $\begingroup$ If you don't report it, don't expect it to get fixed ... $\endgroup$
    – Szabolcs
    Feb 7, 2018 at 13:26
  • 7
    $\begingroup$ The bug is under investigation; thanks for the example. $\endgroup$
    – ilian
    Feb 7, 2018 at 16:13
  • 1
    $\begingroup$ The fix will be available in the next release. $\endgroup$
    – ilian
    Feb 7, 2018 at 18:28
  • 2
    $\begingroup$ The workaround is to unpack, as in the answer. $\endgroup$
    – ilian
    Feb 7, 2018 at 19:07

1 Answer 1

21
$\begingroup$

This is a bug.

The problem seems to be related to the fact that some rows of your matrix are packed arrays and some are not.

Developer`PackedArrayQ /@ M
(* {True, False, False, True, False, False, False, False, False, False, False, False, True, False, False, True} *)

Unpacking seems to avoid the problem.

Eigenvalues@Developer`FromPackedArray[M]
(* {-1, -1, 1, 1, -a, -a, -a, -a, a, a, a, a, a^2, a^2, a^2, a^2} *)
$\endgroup$
6
  • $\begingroup$ By any chance, do you know a way to disable packed arrays as a workaround? $\endgroup$
    – Matthias
    Feb 7, 2018 at 13:46
  • 14
    $\begingroup$ @Matthias I do not think packed arrays can be disabled. Please do report it to WRI for the sake of everyone who may be affected by it. $\endgroup$
    – Szabolcs
    Feb 7, 2018 at 13:57
  • 1
    $\begingroup$ This answer really doesn't deserve upvotes ... it was just an observation that it is a bug. $\endgroup$
    – Szabolcs
    Feb 7, 2018 at 17:50
  • $\begingroup$ @Szabolcs - it deserves upvotes because it identifies the cause of the problem and provides a workaround. $\endgroup$
    – Bob Hanlon
    Feb 7, 2018 at 19:07
  • 2
    $\begingroup$ "Use every man after his desert, and who should 'scape whipping? Use them after your own honor and dignity. The less they deserve, the more merit is in your bounty." (Hamlet II.ii) -- Good luck getting SE voting to correspond to the degree of deserving. $\endgroup$
    – Michael E2
    Feb 8, 2018 at 3:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.