3

I encountered a problem. I have a eigenvector eigvsI[1]

eigvsI[1]={0.0161028 - 0.0119647 I, 0.111551 - 0.0828846 I, 0.20484 - 0.1522 I, 
0.249467 - 0.185359 I, 0.28268 - 0.210037 I, 
0.301895 - 0.224314 I, -0.190871 + 0.141821 I, -0.271275 + 
0.201562 I, -0.244686 + 0.181807 I, -0.204743 + 
0.152128 I, -0.148422 + 0.11028 I, -0.0281275 + 0.0208993 I}

and a hermite matrix hI[1]

    hI[1]={{0, Sqrt[5]/2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {Sqrt[5]/2, 0, Sqrt[2],
0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, Sqrt[2], 0, 3/2, 0, 0, 0, 0, 0, 0, 
0, 0}, {0, 0, 3/2, 0, Sqrt[2], 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, Sqrt[
2], 0, Sqrt[5]/2, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, Sqrt[5]/2, 0, 0, 
0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, Sqrt[5]/2, 0, 0, 0, 0}, {0, 0,
0, 0, 0, 0, Sqrt[5]/2, 0, Sqrt[2], 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 
Sqrt[2], 0, 3/2, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 3/2, 0, Sqrt[2], 
0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, Sqrt[2], 0, Sqrt[5]/2}, {0, 0, 0, 0,
0, 0, 0, 0, 0, 0, Sqrt[5]/2, 0}}

theoretically

Conjugate[eigvsI[1]].hI[1].eigvsI[1]

should be Real number. But MMA gives

-0.253172 - 8.00544*10^-18 I

where does this small imaginary part come from?

On the other hand,

Conjugate[eigvsI[1]].eigvsI[1]

gives perfect zero imaginary part

0.811081 + 0. I
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
matheorem
  • 17,132
  • 8
  • 45
  • 115
  • Calculating eigenvalues involves factoring a large polynomial (the characteristic polynomial) and routines for factoring often "miss" by small amounts, causing small imaginary parts. I would just use Chop to remove the bear-zero parts. – bill s May 07 '13 at 04:57
  • @bills it's not the problem of calculating eigenvalues. – matheorem May 07 '13 at 04:58
  • See this for a discussion of machine precision arithmetic in Mathematica: http://reference.wolfram.com/mathematica/tutorial/MachinePrecisionNumbers.html – bill s May 07 '13 at 05:08
  • @bills thank you bill s. OK, I understand. – matheorem May 07 '13 at 05:20

1 Answers1

9

The numbers you have, like 0.0161028 - 0.0119647 I are floating point (machine precision) numbers. Whenever you do calculations with floating point numbers, you will get roundoff errors. Note that you appear to have 7 or 8 digits of accuracy in the numbers. The "error" in the imaginary part is in the 18th decimal place. This is roundoff error. See this for a discussion of machine precision arithmetic in Mathematica. The simplest way to remove such round-off errors is to use Chop, which replaces approximate real numbers that are close to zero with the exact number 0. This effectively removes the imaginary part from a number like -0.253172 - 8.00544*10^-18 I.

bill s
  • 68,936
  • 4
  • 101
  • 191