The ring of complex floats CDF
is not an exact ring:
sage: CDF.is_exact()
False
So while doing computation in floating point entries (i.e. in RDF
or CDF
) some errors may occur (see http://doc.sagemath.org/html/en/const...). You can change the base ring to the algebraic field QQbar
:
sage: B = matrix(QQbar, [ [-1, 0, 1, 0, 0, 0, 1, I, -1 ], [0, 0, 0, -I, 1, I, 1, I, 0], [-1, -I, 1, -I, 1, 0, 1, 0, I], [0, 0, 0, 0, 1, I, 1, I, -1], [0, -I, 1, -I, 1, I, 1, I, 0], [-1, -I, 1, -I, 1, 0, 0, 0, 0], [-1, 0, 1, 0, 1, I, 1, I, -1], [0, -I, 1, -I, 1, I, 0, 0, 0], [-1, -I, 1, 0, 0, 0, 1, 0, -1]])
sage: B.eigenvalues()
[3.917412364954442? + 0.05429188890228639?*I, 0.6516886324409428? + 0.2353750083092179?*I, 0.3580569417083658? - 0.08398467888210074?*I, -0.1167390153623098? + 0.6697900534213050?*I, -0.1742956154446435? - 0.5989951966469979?*I, -0.7276189211835305? + 0.3726506970413855?*I, -0.8274431770819343? + 1.205961277873422?*I, -0.9961206931117568? - 1.191900422440107?*I, -1.084940516919576? - 0.6631886275784114?*I]
An alternative is to use an algebraic extension of QQ
using NumberField
:
sage: K.<a> = NumberField(x^2 + 1)
sage: K.is_exact()
True
sage: B = matrix(K, [ [-1, 0, 1, 0, 0, 0, 1, a, -1 ], [0, 0, 0, -a, 1, a, 1, a, 0], [-1, -a, 1, -a, 1, 0, 1, 0, a], [0, 0, 0, 0, 1, a, 1, a, -1], [0, -a, 1, -a, 1, a, 1, a, 0], [-1,-a, 1, -a, 1, 0, 0, 0, 0], [-1, 0, 1, 0, 1, a, 1, a, -1], [0, -a, 1, -a, 1, a, 0, 0, 0], [-1, -a, 1, 0, 0, 0, 1, 0, -1]])
sage: B.eigenvalues()
[-1.084940516919576? - 0.6631886275784114?*I, -0.9961206931117568? - 1.191900422440107?*I, -0.8274431770819343? + 1.205961277873422?*I, -0.7276189211835305? + 0.3726506970413855?*I, -0.1742956154446435? - 0.5989951966469979?*I, -0.1167390153623098? + 0.6697900534213050?*I, 0.3580569417083658? - 0.08398467888210074?*I, 0.6516886324409428? + 0.2353750083092179?*I, 3.917412364954442? + 0.05429188890228639?*I]
Could you add the values that you obtain and perhaps the version of Sage that you are using? What are the expected eigenvalues? In Sage version 8.1beta7 I get
sage: B.eigenvalues() [3.917412364954441 + 0.054291888902286756I, -0.9961206931117547 - 1.1919004224401037I, -0.8274431770819329 + 1.205961277873422I, -1.0849405169195765 - 0.6631886275784113I, -0.7276189211835324 + 0.3726506970413847I, -0.1167390153623094 + 0.6697900534213056I, 0.6516886324409439 + 0.23537500830921726I, 0.3580569417083653 - 0.08398467888210029I, -0.174295615444644 - 0.598995196646998*I]
Is that correct?