# Undesired complex number in the square root

I am trying to solve the eigenvalues of a hamiltonian The code I used is typed below.

t = 0.1;
h = {{0, (-t)*(1 + Exp[(-I)*ky]), 0}, {0, 0, (-t)*(1 + Exp[I*kx])}, {0, 0, 0}};
ham = h + Assuming[{Element[kx, Reals], Element[ky, Reals]}, Refine[ConjugateTranspose[h]]];
FullSimplify[Eigenvalues[ham], Assumptions -> Element[{kx, ky}, Reals]]


The Eigenvalues gives an undesired complex number (which should be elminated inside and outside the square root) How can I elminate the undesired complex number?

• Try PowerExpand to simplify your last result. – Ulrich Neumann Apr 20 at 9:30
• Thanks! It works for me. – Rosetta Apr 20 at 9:31
• Fine, you're welcome. – Ulrich Neumann Apr 20 at 9:32

Since symbolic calculations are better done with exact, rather than floating-point, numbers, the following was done with t = 1/10:

Eigenvalues[ham // ExpToTrig]
(*
{ 0,
-Sqrt[2 + Cos[kx] + Cos[ky]]/(5 Sqrt),
Sqrt[2 + Cos[kx] + Cos[ky]]/(5 Sqrt)}
*)


Note: It will "work" with t = 0.1 but the factor in the denominator gets incorporated as Real coefficients in the square root:

(*
{ 0,
-Sqrt[0.04 + 0.02 Cos[kx] + 0.02 Cos[ky]],
Sqrt[0.04 + 0.02 Cos[kx] + 0.02 Cos[ky]]}
*)


Thus rationalizing 0.1 is not necessary, but one should be aware that round-off error often leads to problems in symbolic manipulation.

At least for this case, one can take an indirect route through CharacteristicPolynomial[]:

ham = Simplify[(# + ConjugateTranspose[#]) &[{{0, (-t)*(1 + Exp[(-I)*ky]), 0},
{0, 0, (-t)*(1 + Exp[I*kx])},
{0, 0, 0}}], {t, kx, ky} ∈ Reals]
{{0, -(1 + E^(-I ky)) t, 0}, {-(1 + E^(I ky)) t, 0, -(1 + E^(I kx)) t},
{0, -(1 + E^(-I kx)) t, 0}}

cp = FullSimplify[CharacteristicPolynomial[ham, λ], {t, kx, ky} ∈ Reals]
λ (4 t^2 - λ^2 + 2 t^2 (Cos[kx] + Cos[ky]))

λ /. Solve[cp == 0, λ]
{0, -Sqrt t Sqrt[2 + Cos[kx] + Cos[ky]], Sqrt t Sqrt[2 + Cos[kx] + Cos[ky]]}