Eigenvalues broken in Version 12.0
Not a solution but too big for a comment. There seems to be a catastrophic failure in Eigenvalues
happening that is not due to the matrix being crazy. As a diagnostic, let's calculate the smallest (by absolute value) eigenvalue of the upper-left $n\times n$ part of the matrix
M = mat[xlist[[3]]];
For odd $n$ the answer is zero, so let's only do this for even $n$. We do this in two ways
- Calculate all eigenvalues and pick the one with the smallest absolute value:
e1[n_?EvenQ] := M[[;; n, ;; n]] // Eigenvalues // Abs // Min
- Calculate only the smallest eigenvalue (by absolute value) with the Arnoldi algorithm:
e2[n_?EvenQ] := Eigenvalues[M[[;; n, ;; n]], 1,
Method -> {"Arnoldi", "Criteria" -> "Magnitude", "Shift" -> 0}] // First // Abs
Method (2) is very reliable, whereas method (1) breaks down for $n=358$ and above:
Considering that the Arnoldi algorithm has no problems with this matrix, there seems to be something really strange going on in method 1.
$Version
(* 12.0.0 for Mac OS X x86 (64-bit) (April 7, 2019) *)
Edit: Eigensystem fixed in 12.1 in addition to Eigenvalues
I attempted a workaround, to see if Eigensystem
had any issues also. It does. This is very unfortunate.
(Will we have to wait for 12.1 for the fix (?!))
(We waited for 12.1 for the fix (!!))
My code here:
e3[n_?EvenQ] := Eigensystem[M[[;; n, ;; n]]][[1]] // Abs // Min
Produces the following, which matches with @Roman shows:
(Apologies the colors/styles don't match with the plot from @Roman !!)
$Version
(* 12.0.0 for Microsoft Windows (64-bit) (April 6, 2019) *)
Fixed in 12.1
ClearAll[x, n];
NN = 374; R = 0.05;
t1 = -1 + Cos[x] - I Sin[x] + I R; t1p = -1 + Cos[x] + I Sin[x] + I R;
mat[x_] =
DiagonalMatrix[Table[If[EvenQ[n], t1, -1], {n, 0, 2 NN - 1 - 1}],
1] + DiagonalMatrix[
Table[If[EvenQ[n], t1p, -1], {n, 0, 2 NN - 1 - 1}], -1] +
DiagonalMatrix[Table[If[EvenQ[n], -1, 0], {n, 0, 2 NN - 1 - 3}],
3] + DiagonalMatrix[
Table[If[EvenQ[n], -1, 0], {n, 0, 2 NN - 1 - 3}], -3];
mat0 = mat[-0.2 \[Pi]];
Tr@mat0 (*0.*)
(Total@Eigenvalues@mat0) // Chop