Ask Your Question
1

Hi, there: I am computing the eigenvalues and eigenvectors of the following complex matrix. It looks that Sage does not give the right answer?

asked 2017-10-10 21:17:11 +0100

wang gravatar image

Here is the matrix that I use

B = matrix(CDF, [ [-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]])

edit retag flag offensive close merge delete

Comments

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?

jipilab gravatar imagejipilab ( 2017-10-11 08:47:59 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-10-11 09:06:00 +0100

jipilab gravatar image

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 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]
edit flag offensive delete link more

Comments

are there cases where one would prefer QQbar over NumberField, or vice-versa?

mforets gravatar imagemforets ( 2017-10-11 10:25:26 +0100 )edit

QQbar is slower but more flexible (e.g. you can take square roots).

vdelecroix gravatar imagevdelecroix ( 2017-10-12 08:49:30 +0100 )edit

ok, merci :)

mforets gravatar imagemforets ( 2017-10-12 10:19:57 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2017-10-10 21:17:11 +0100

Seen: 264 times

Last updated: Oct 11 '17