On 8/6/10 11:56 AM, davidp wrote:
Sage has no trouble finding the eigenvectors of the 3x3 matrix below
but something is wrong in the 4x4 example.  Am I doing something
silly?

sage: version()
'Sage Version 4.3, Release Date: 2009-12-24'
sage: m=matrix(CC,[[1,0,I],[1,1,0],[I,0,1]])
sage: m.eigenvectors_right()
[(1.00000000000000 + 1.00000000000000*I, [
(1.00000000000000, -1.00000000000000*I, 1.00000000000000)
], 1), (1.00000000000000, [
(0, 1.00000000000000, 0)
], 1), (1.00000000000000 - 1.00000000000000*I, [
(1.00000000000000, 1.00000000000000*I, -1.00000000000000)
], 1)]
sage: n=matrix(CC,[[1,0,I,0],[1,1,0,I],[I,0,1,1],[0,I,0,2]])
sage: n.eigenvectors_right()
[(1.77621849241320 + 1.01489897201814*I, [

], 1), (1.77621849241320 - 1.01489897201814*I, [

], 1), (0.723781507586799 + 1.07181709265703*I, [

], 1), (0.723781507586799 - 1.07181709265703*I, [

], 1)]


Short answer: use CDF, not CC.

sage: n=matrix(CDF,[[1,0,I,0],[1,1,0,I],[I,0,1,1],[0,I,0,2]])
sage: n.eigenvectors_right()
[(0.723781507587 - 1.07181709266*I, [(-0.512558924324 - 0.132091804021*I, 0.462262927873 - 0.251444224409*I, 0.585855615051, -0.293915958782 - 0.115371137717*I)], 1), (1.77621849241 - 1.01489897202*I, [(0.340477754428 - 0.0450332871844*I, 0.598345310973, -0.38050619325 - 0.218580892372*I, -0.562226753834 - 0.123968940799*I)], 1), (0.723781507587 + 1.07181709266*I, [(0.512558924324 - 0.132091804021*I, -0.462262927873 - 0.251444224409*I, 0.585855615051, -0.293915958782 + 0.115371137717*I)], 1), (1.77621849241 + 1.01489897202*I, [(0.340477754428 + 0.0450332871844*I, 0.598345310973, 0.38050619325 - 0.218580892372*I, 0.562226753834 - 0.123968940799*I)], 1)]

That will use LAPACK under the hood (via scipy).


Medium answer: We will (very?!) soon have linear algebra over CC be very good, pending completion of ongoing work in wrapping ALGLIB in Sage.

Long answer: Our generic algorithms are woefully inadequate for multiprecision linear algebra (we just do the textbook algorithms, which can have really bad roundoff error). That is what CC employs. In fact there is an error displayed to this effect the first time you try it:

sage: n=matrix(CC,[[1,0,I,0],[1,1,0,I],[I,0,1,1],[0,I,0,2]])
sage: n.eigenvectors_right()
/Users/grout/sage/local/bin/sage-ipython:1: UserWarning: Using generic algorithm for an inexact ring, which may result in garbage from numerical precision issues.
  #!/usr/bin/env python
/Users/grout/sage/local/bin/sage-ipython:1: UserWarning: Using generic algorithm for an inexact ring, which will probably give incorrect results due to numerical precision issues.
  #!/usr/bin/env python
[(1.77621849241320 + 1.01489897201814*I, [

], 1), (1.77621849241320 - 1.01489897201814*I, [

], 1), (0.723781507586799 + 1.07181709265703*I, [

], 1), (0.723781507586799 - 1.07181709265703*I, [

], 1)]

Thanks,

Jason


--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to