Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following Matrix represents my Hamiltonian.

m = {{ B/2 - d - j/2 + a, (Sqrt[2]*j)/2, M}, {(Sqrt[2]*j)/2, B/2 + a, 0}, {M, 0, (-3*B)/2 - d + j/2 + a}

How can I define the variables used in matrix such that the Mathematica assumes as they are real. because with this matrix, mathematica gives complex eigenvalues but my eigenvalues are supposed to be real.

share|improve this question
The matrix you give is a symbolic one, and Eigenvalues returns symbolic Root objects. How did you arrive to complex eigenvalues? The matrix is symmetric, so they are always supposed to be real. Finding the eigenvalues of this matrix symbolically or with exact numbers amounts to solving a cubic equation. The solutions of some cubic equations can't be written in an explicit form (in terms of radicals) without using the imaginary unit, but this does not mean that they are not real. It is possible that this is what happened when you substituted in numbers. – Szabolcs Feb 11 '14 at 15:58

The matrix

m = {{B/2 - d - j/2 + a, (Sqrt[2]*j)/2, M}, {(Sqrt[2]*j)/2, B/2 + a, 
    0}, {M, 0, (-3*B)/2 - d + j/2 + a}};

has eigenvalues determined by the characteristic polynomial of (maximal) degree 3. In the absence of any other information, we get three Root objects as the eigenvalues, which is Mathematica's way of preserving all the information necessary to provide an arbitrarily precise answer to the question what the roots of the characteristic polynomial of m are.

By itself, m is not guaranteed to have real eigenvalues unless you specify some additional properties of the variables. In particular, if you choose them to be real then m is real-symmetric and therefore has real eigenvalues. This doesn't affect the form of the Root solutions, but it may be important for other test that may be performed in your calculations.

For example, if you ask whether m is hermitian,


(* ==> False *)

which means the hermiticity is not recognized because it is not explicit in the form of the components of m. To maintain the symbolic form of the matrix and still have this last test yield True, you can do this:

m1 = m /. Map[(# -> Re[#]) &, Variables[m]]

==> {{Re[a] + Re[B]/2 - Re[d] - Re[j]/2, Re[j]/Sqrt[2], 
  Re[M]}, {Re[j]/Sqrt[2], Re[a] + Re[B]/2, 0}, {Re[M], 0, 
  Re[a] - (3 Re[B])/2 - Re[d] + Re[j]/2}}


(* ==> True *)

The test HermitianMatrixQ, and (to my knowledge) all test functions ending in Q, inspect the explicit form of the argument, and by giving all variables the Head Re I make sure this is recognized.

This also allows you to get the expected answer from

Simplify[ConjugateTranspose[m1] == m1]

(* ==> True *)

whereas this is not true for m.

There are in fact algorithms that can find the roots of a cubic polynomial without using complex numbers, assuming that three real roots are known to exist. This is based on trigonometric identities. This is where it may be useful to have specified symbolically that the matrix has only real entries, as I did above.

share|improve this answer

I think you may be misinterpreting the answer you see. Let's define a function:

e[{a_, d_, B_, M_, j_}] := 
 Eigenvalues[{{a + B/2 - d - j/2, j/Sqrt[2], M}, {j/Sqrt[2], a + B/2, 
    0}, {M, 0, a - (3 B)/2 - d + j/2}}]

This will gives the eigenvalues for any set of parameters a,d,B,M,j. For instance,

e[{1, 2, 3, 4, 5}]
{1/4 (-15 - Sqrt[185]), 5, 1/4 (-15 + Sqrt[185])}

For arbitrary values:

e[RandomReal[{-1, 1}, 5]] // N
{-1.19836, -0.203181, 0.13574}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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