Does Eigensystem[]
produce incorrect output for symmetric matrices with integer components?
The following eigensystem decomposition of a 12x12 matrix and its subsequent reconstruction depends on whether the matrix components are integer or real values:
dim=12;
m = {{12, 0, 0, -4, 0, 0, -4, 0, 0, -4, 0, 0},
{0, 12, 0, 0, -4, 0, 0, -4, 0, 0, -4, 0},
{0, 0, 12, 0, 0, -4, 0, 0, -4, 0, 0, -4},
{-4, 0, 0, 12, 0, 0, -4, 0, 0, -4, 0, 0},
{0, -4, 0, 0, 12, 0, 0, -4, 0, 0, -4, 0},
{0, 0, -4, 0, 0, 12, 0, 0, -4, 0, 0, -4},
{-4, 0, 0, -4, 0, 0, 12, 0, 0, -4, 0, 0},
{0, -4, 0, 0, -4, 0, 0, 12, 0, 0, -4, 0},
{0, 0, -4, 0, 0, -4, 0, 0, 12, 0, 0, -4},
{-4, 0, 0, -4, 0, 0, -4, 0, 0, 12, 0, 0},
{0, -4, 0, 0, -4, 0, 0, -4, 0, 0, 12, 0},
{0, 0, -4, 0, 0, -4, 0, 0, -4, 0, 0, 12}};
es = Eigensystem[m];
eveks = Table[Normalize[es[[2, i]]], {i, 1, dim}];
Print["Check eigenvector orthogonality"]
Table[eveks[[i]] . eveks[[j]], {i, 1, dim}, {j, 1, dim}] // Chop // MatrixForm
Print["Check reconstruction of matrix from eigensystem"]
(Sum[es[[1, i]] Outer[Times, eveks[[i]], eveks[[i]]], {i, 1, dim}] - m) // Chop
In MMA 13.2 the above produces the eigenvector metric
{{1, 0, 0, 1/2, 0, 0, 1/2, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 1/2, 0, 0, 1/2, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 1/2, 0, 0, 1/2, 0, 0, 0},
{1/2, 0, 0, 1, 0, 0, 1/2, 0, 0, 0, 0, 0},
{0, 1/2, 0, 0, 1, 0, 0, 1/2, 0, 0, 0, 0},
{0, 0, 1/2, 0, 0, 1, 0, 0, 1/2, 0, 0, 0},
{1/2, 0, 0, 1/2, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 1/2, 0, 0, 1/2, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 1/2, 0, 0, 1/2, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}
and the difference between the matrix and its reconstruction in spectral form is
{{12, 0, 0, -4, 0, 0, -4, 0, 0, -4, 0, 0},
{0, 12, 0, 0, -4, 0, 0, -4, 0, 0, -4, 0},
{0, 0, 12, 0, 0, -4, 0, 0, -4, 0, 0, -4},
{-4, 0, 0, -4, 0, 0, 4, 0, 0, 4, 0, 0},
{0, -4, 0, 0, -4, 0, 0, 4, 0, 0, 4, 0},
{0, 0, -4, 0, 0, -4, 0, 0, 4, 0, 0, 4},
{-4, 0, 0, 4, 0, 0, -4, 0, 0, 4, 0, 0},
{0, -4, 0, 0, 4, 0, 0, -4, 0, 0, 4, 0},
{0, 0, -4, 0, 0, 4, 0, 0, -4, 0, 0, 4},
{-4, 0, 0, 4, 0, 0, 4, 0, 0, -4, 0, 0},
{0, -4, 0, 0, 4, 0, 0, 4, 0, 0, -4, 0},
{0, 0, -4, 0, 0, 4, 0, 0, 4, 0, 0, -4}}
Clearly, the eigenvectors are not orthogonal and the reconstruction fails.
If I convert the matrix components to floats, e.g. by changing the Eigensystem argument to es = Eigensystem[N[m]]
, everything works as expected.