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(CDF, 2, 2, [[2+I, -1+3*I], [5-4*I, 2-7*I]])<br />

sage: A.schur(base_ring=RDF)<br />

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

...<br />

TypeError: unable to convert input matrix over CDF to a matrix over RDF<br />

If theory predicts your matrix is real, but it contains some very small imaginary parts, you can specify the<br />

cut<strong>of</strong>f for “small” imaginary parts, then request the output as real matrices, <strong>and</strong> let the routine do the rest.<br />

sage: A = matrix(RDF, 2, 2, [1, 1, -1, 0]) + matrix(CDF, 2, 2, [1.0e-14*I]*4)<br />

sage: B = A.zero_at(1.0e-12)<br />

sage: B.parent()<br />

Full MatrixSpace <strong>of</strong> 2 by 2 dense matrices over Complex Double Field<br />

sage: Q, T = B.schur(RDF)<br />

sage: Q.parent()<br />

Full MatrixSpace <strong>of</strong> 2 by 2 dense matrices over Real Double Field<br />

sage: T.parent()<br />

Full MatrixSpace <strong>of</strong> 2 by 2 dense matrices over Real Double Field<br />

sage: Q.round(6)<br />

[ 0.707107 0.707107]<br />

[-0.707107 0.707107]<br />

sage: T.round(6)<br />

[ 0.5 1.5]<br />

[-0.5 0.5]<br />

sage: (Q*T*Q.conjugate().transpose()-B).zero_at(1.0e-11)<br />

[0.0 0.0]<br />

[0.0 0.0]<br />

A Hermitian matrix has real eigenvalues, so the similar matrix will be upper-triangular. Furthermore, a<br />

Hermitian matrix is diagonalizable with respect to an orthonormal basis, composed <strong>of</strong> eigenvectors <strong>of</strong> the<br />

matrix. Here that basis is the set <strong>of</strong> columns <strong>of</strong> the unitary matrix.<br />

sage: A = matrix(CDF, [[ 52, -9*I - 8, 6*I - 187, -188*I + 2],<br />

... [ 9*I - 8, 12, -58*I + 59, 30*I + 42],<br />

... [-6*I - 187, 58*I + 59, 2677, 2264*I + 65],<br />

... [ 188*I + 2, -30*I + 42, -2264*I + 65, 2080]])<br />

sage: Q, T = A.schur()<br />

sage: T = T.zero_at(1.0e-12).change_ring(RDF)<br />

sage: T.round(6)<br />

[4680.13301 0.0 0.0 0.0]<br />

[ 0.0 102.715967 0.0 0.0]<br />

[ 0.0 0.0 35.039344 0.0]<br />

[ 0.0 0.0 0.0 3.11168]<br />

sage: (Q*Q.conjugate().transpose()).zero_at(1.0e-12)<br />

[1.0 0.0 0.0 0.0]<br />

[0.0 1.0 0.0 0.0]<br />

[0.0 0.0 1.0 0.0]<br />

[0.0 0.0 0.0 1.0]<br />

sage: (Q*T*Q.conjugate().transpose()-A).zero_at(1.0e-11)<br />

[0.0 0.0 0.0 0.0]<br />

[0.0 0.0 0.0 0.0]<br />

[0.0 0.0 0.0 0.0]<br />

[0.0 0.0 0.0 0.0]<br />

Similarly, a real symmetric matrix has only real eigenvalues, <strong>and</strong> there is an orthonormal basis composed<br />

<strong>of</strong> eigenvectors <strong>of</strong> the matrix.<br />

sage: A = matrix(RDF, [[ 1, -2, 5, -3],<br />

... [-2, 9, 1, 5],<br />

385

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

Saved successfully!

Ooh no, something went wrong!