0
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ Does expr /. I -> 0 work? $\endgroup$ – Marius Ladegård Meyer Sep 4 at 12:43
  • $\begingroup$ Provide definition of H so that we can reproduce the problem $\endgroup$ – Bob Hanlon Sep 4 at 13:24
  • $\begingroup$ @MariusLadegårdMeyer Nope $\endgroup$ – Elliott Mansfield Sep 4 at 13:28
  • $\begingroup$ @BobHanlon updated $\endgroup$ – Elliott Mansfield Sep 4 at 13:36
  • 1
    $\begingroup$ Please provide the definition in Mathematica code along with the values of the parameters that are causing the problem. $\endgroup$ – Bob Hanlon Sep 4 at 13:37
2
$\begingroup$
Clear[H, B, a, del]

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;

Use Chop in the definition of evals to eliminate the complex artifacts (0. I).

evals = Eigenvalues[H] // Chop;

solns = NSolve[# == 0, kx, Reals] & /@ evals

(* {{}, {{kx -> -1.34174}, {kx -> -0.845824}}, {{kx -> 1.34174}, {kx -> 
    0.845824}}, {}} *)

Alternatively, use exact values for the parameters

Clear[H, B, a, del]

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 = 1/2;
del = 1/50;

evals = Eigenvalues[H];

solns2 = NSolve[# == 0, kx, Reals] & /@ evals

(* {{}, {{kx -> -1.34174}, {kx -> -0.845824}}, {{kx -> 1.34174}, {kx -> 
    0.845824}}, {}} *)

solns == solns2

(* True *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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