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: a=matrix([(1, 9, -1, -1), (-2, 0, -10, 2), (-1, 0, 15, -2), (0, 1, 0, -1)])<br />

sage: a.eigenvalues()<br />

[-0.9386318578049146, 15.50655435353258, 0.2160387521361705 - 4.713151979747493*I, 0.216<br />

A symmetric matrix a+a.transpose() should have real eigenvalues<br />

sage: b=a+a.transpose()<br />

sage: ev = b.eigenvalues(); ev<br />

[-8.35066086057957, -1.107247901349379, 5.718651326708515, 33.73925743522043]<br />

The eigenvalues are elements <strong>of</strong> QQbar, so they really represent exact roots <strong>of</strong> polynomials, not just approximations.<br />

sage: e = ev[0]; e<br />

-8.35066086057957<br />

sage: p = e.minpoly(); p<br />

x^4 - 30*x^3 - 171*x^2 + 1460*x + 1784<br />

sage: p(e) == 0<br />

True<br />

To perform computations on the eigenvalue as an element <strong>of</strong> a number field, you can always convert back<br />

to a number field element.<br />

sage: e.as_number_field_element()<br />

(Number Field in a with defining polynomial y^4 - 2*y^3 - 507*y^2 - 3972*y - 4264,<br />

a + 7,<br />

Ring morphism:<br />

From: Number Field in a with defining polynomial y^4 - 2*y^3 - 507*y^2 - 3972*y - 4264<br />

To: Algebraic Real Field<br />

Defn: a |--> -15.35066086057957)<br />

Notice the effect <strong>of</strong> the extend option.<br />

sage: M=matrix(QQ,[[0,-1,0],[1,0,0],[0,0,2]])<br />

sage: M.eigenvalues()<br />

[2, -1*I, 1*I]<br />

sage: M.eigenvalues(extend=False)<br />

[2]<br />

eigenvectors_left(extend=True)<br />

Compute the left eigenvectors <strong>of</strong> a matrix.<br />

For each distinct eigenvalue, returns a list <strong>of</strong> the form (e,V,n) where e is the eigenvalue, V is a list <strong>of</strong><br />

eigenvectors forming a basis for the corresponding left eigenspace, <strong>and</strong> n is the algebraic multiplicity <strong>of</strong><br />

the eigenvalue.<br />

If the option extend is set to False, then only the eigenvalues that live in the base ring are considered.<br />

EXAMPLES: We compute the left eigenvectors <strong>of</strong> a 3 × 3 rational matrix.<br />

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

[0 1 2]<br />

[3 4 5]<br />

[6 7 8]<br />

sage: es = A.eigenvectors_left(); es<br />

[(0, [<br />

(1, -2, 1)<br />

], 1),<br />

(-1.348469228349535, [(1, 0.3101020514433644, -0.3797958971132713)], 1),<br />

(13.34846922834954, [(1, 1.289897948556636, 1.579795897113272)], 1)]<br />

165

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

Saved successfully!

Ooh no, something went wrong!