# Revision history [back]

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/constructions/linear_algebra.html#eigenvectors-and-eigenvalues). 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 QQusing 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]