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

My problem is that I have a matrix A and the computer says is not Hermitian (self-adjoint). Then I check which elements make A be not Hermitian by calculating:


In case A is Hermitian, this difference should be zero. What I get is that A is not Hermitian, but the terms I get in matrix B all are smaller than 10^(-15).

So how can I fix it at the beggining of the code, Mathematica to consider two numbers equal, up to 10^(-10) precision for example, that is it to consider:

0.00000000010 = 0.00000000012

or saying it in an alternative way, I want Mathematica to consider the following matrix Hermitian:


throughout the whole code.

share|improve this question
You can force it to consider c Hermetian by instead using cHerm=1/2(c + ConjugateTranspose[c]) – bill s Oct 30 '13 at 18:00
up vote 4 down vote accepted

You can check to see if the difference is less than the desired amount, and if so, to force it to be symmetric:

c = {{0, I 1.1*10^(-10)}, {-I 1.2*10^(-10), 0}}; 
cOut = If[Abs[Total[c - ConjugateTranspose[c], 2]] < 10^(-10), 
           1/2 (c + ConjugateTranspose[c]),c]

This returns cOut which is a symmetrized version of c if c is close to Hermetian and returns c otherwise (i..e, if it really isn't Hermetian).

share|improve this answer

There are two undocumented functions which control the tolerance of Equal and SameQ: Internal`$EqualTolerance and Internal`$SameQTolerance. I refer you to this answer of mine for further information.

share|improve this answer
Accidentally hit touch-screen and downvoted. Will reverse when timeout happens. Sorry. – ciao Apr 6 '15 at 8:58
@rasher Moderators cannot change votes. You can make a dummy edit, reverse your vote and then undo the edit within the minute. (there will be a note in the history that you edited the post, but the contents will remain the same) – R. M. Apr 6 '15 at 12:59

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.