I'm trying to find the zeros of the eigenvalues (functions of $k_x$) of a self-adjoint $4\times4$ matrix H:
H = {{kx^2 + a kx + B, 0, I a kx,
del}, {0, -kx^2 + a kx - B, -del, -I a kx}, {-I a kx, -del,
kx^2 - a kx - B, 0}, {del, I a kx, 0, -kx^2 - a kx + B}};
B = 1;
a = 0.5;
del = 0.02;
evals = Eigenvalues[H]
solns = Table[NSolve[evals[[ii]] == 0, kx, Reals], {ii, 4}]
My eigenvalues are all real, but when mathematica calculates them, because of the complex entries in the off-diagonals, it produces a +0I inside the root on some of the coefficients. This causes a problem when I try to solve restricting the domain to the reals:
Solve::nddc: The system contains a nonreal constant 0.128451 +0. I. With the domain specified, all constants should be real.
I have tried using Re
which doesn't work, and Chop
which completely breaks the output when applied to the smaller numbers in the full code (I've tried multiplying by a constant and dividing afterwards). ToRadicals
leads to an extremely large expression which NSolve struggles to evaluate (FullSimplify
on this gives similar problems). How do I remove the +0I efficiently?
expr /. I -> 0
work? $\endgroup$H
so that we can reproduce the problem $\endgroup$