Eigenvectors are complex but only for large matrices
What you are seeing appears to be fairly normal roundoff error. This is an unfortunate result of storing floating point numbers with a finite precision. It naturally gets relatively worse for large problems. Here is a plot of the real vs. imaginary components of the eigenvalues:
You can see that the imaginary numbers are effectively noise. This is not to say that they are not important. Here is a plot of the imaginary vs. real part, showing that the ratio can get as large as 0.06 in the worst case:
This ratio changes with respect to the absolute and relative quantities la
and mi
. If you multiply both by 10, you get
If you keep la = 0.02
and set mi = 0.8
, you get a smaller imaginary part:
Things get really weird when you do the opposite, and increase la
by a factor of 10, keeping mi
as-is:
The relative precision of the calculation decreases for smaller eigenvalues, so this is not too surprising.
Given the relatively small magnitudes of the imaginary parts (at least for the important eigenvalues), you can either take the magnitude or the real part of the result since you know that all the eigenvalues are real.