08.02.2015 Views

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Matrices</strong> <strong>and</strong> <strong>Spaces</strong> <strong>of</strong> <strong>Matrices</strong>, Release 6.1.1<br />

sage: es = A.eigenspaces_right(format=’galois’); es<br />

[<br />

(0, Vector space <strong>of</strong> degree 3 <strong>and</strong> dimension 1 over Rational Field<br />

User basis matrix:<br />

[ 1 -2 1]),<br />

(a1, Vector space <strong>of</strong> degree 3 <strong>and</strong> dimension 1 over Number Field in a1 with defining polynomi<br />

User basis matrix:<br />

[ 1 1/5*a1 + 2/5 2/5*a1 - 1/5])<br />

]<br />

sage: es = A.eigenspaces_right(format=’galois’, algebraic_multiplicity=True); es<br />

[<br />

(0, Vector space <strong>of</strong> degree 3 <strong>and</strong> dimension 1 over Rational Field<br />

User basis matrix:<br />

[ 1 -2 1], 1),<br />

(a1, Vector space <strong>of</strong> degree 3 <strong>and</strong> dimension 1 over Number Field in a1 with defining polynomi<br />

User basis matrix:<br />

[ 1 1/5*a1 + 2/5 2/5*a1 - 1/5], 1)<br />

]<br />

sage: e, v, n = es[0]; v = v.basis()[0]<br />

sage: delta = v*e - A*v<br />

sage: abs(abs(delta)) < 1e-10<br />

True<br />

The same computation, but with implicit base change to a field:<br />

sage: A = matrix(ZZ, 3, range(9)); A<br />

[0 1 2]<br />

[3 4 5]<br />

[6 7 8]<br />

sage: A.eigenspaces_right(format=’galois’)<br />

[<br />

(0, Vector space <strong>of</strong> degree 3 <strong>and</strong> dimension 1 over Rational Field<br />

User basis matrix:<br />

[ 1 -2 1]),<br />

(a1, Vector space <strong>of</strong> degree 3 <strong>and</strong> dimension 1 over Number Field in a1 with defining polynomi<br />

User basis matrix:<br />

[ 1 1/5*a1 + 2/5 2/5*a1 - 1/5])<br />

]<br />

This method is only applicable to exact matrices. The “eigenmatrix” routines for matrices with doubleprecision<br />

floating-point entries (RDF, CDF) are the best alternative. (Since some platforms return eigenvectors<br />

that are the negatives <strong>of</strong> those given here, this one example is not tested here.) There are also<br />

“eigenmatrix” routines for matrices with symbolic entries.<br />

sage: B = matrix(RR, 3, 3, range(9))<br />

sage: B.eigenspaces_right()<br />

Traceback (most recent call last):<br />

...<br />

NotImplementedError: eigenspaces cannot be computed reliably for inexact rings such as Real<br />

consult numerical or symbolic matrix classes for other options<br />

sage: em = B.change_ring(RDF).eigenmatrix_right()<br />

sage: eigenvalues = em[0]; eigenvalues.dense_matrix().zero_at(1e-15)<br />

[ 13.3484692283 0.0 0.0]<br />

[ 0.0 -1.34846922835 0.0]<br />

[ 0.0 0.0 0.0]<br />

sage: eigenvectors = em[1]; eigenvectors # not tested<br />

[ 0.164763817... 0.799699663... 0.408248290...]<br />

[ 0.505774475... 0.104205787... -0.816496580...]<br />

234 Chapter 7. Base class for matrices, part 2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!