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 />

[0.0 1.0]<br />

[1.1 3.0]<br />

sage: m.is_symmetric()<br />

False<br />

The tolerance inequality is strict: sage: m.is_symmetric(tol=0.1) False sage: m.is_symmetric(tol=0.11)<br />

True<br />

is_unitary(tol=1e-12, algorithm=’orthonormal’)<br />

Returns True if the columns <strong>of</strong> the matrix are an orthonormal basis.<br />

For a matrix with real entries this determines if a matrix is “orthogonal” <strong>and</strong> for a matrix with complex<br />

entries this determines if the matrix is “unitary.”<br />

INPUT:<br />

•tol - default: 1e-12 - the largest value <strong>of</strong> the absolute value <strong>of</strong> the difference between two matrix<br />

entries for which they will still be considered equal.<br />

•algorithm - default: ‘orthonormal’ - set to ‘orthonormal’ for a stable procedure <strong>and</strong> set to ‘naive’<br />

for a fast procedure.<br />

OUTPUT:<br />

True if the matrix is square <strong>and</strong> its conjugate-transpose is its inverse, <strong>and</strong> False otherwise. In other<br />

words, a matrix is orthogonal or unitary if the product <strong>of</strong> its conjugate-transpose times the matrix is the<br />

identity matrix.<br />

The tolerance parameter is used to allow for numerical values to be equal if there is a slight difference due<br />

to round-<strong>of</strong>f <strong>and</strong> other imprecisions.<br />

The result is cached, on a per-tolerance <strong>and</strong> per-algorithm basis.<br />

ALGORITHMS:<br />

The naive algorithm simply computes the product <strong>of</strong> the conjugate-transpose with the matrix <strong>and</strong> compares<br />

the entries to the identity matrix, with equality controlled by the tolerance parameter.<br />

The orthonormal algorithm first computes a Schur decomposition (via the schur() method) <strong>and</strong> checks<br />

that the result is a diagonal matrix with entries <strong>of</strong> modulus 1, which is equivalent to being unitary.<br />

So the naive algorithm might finish fairly quickly for a matrix that is not unitary, once the product has<br />

been computed. However, the orthonormal algorithm will compute a Schur decomposition before going<br />

through a similar check <strong>of</strong> a matrix entry-by-entry.<br />

EXAMPLES:<br />

A matrix that is far from unitary.<br />

sage: A = matrix(RDF, 4, range(16))<br />

sage: A.conjugate().transpose()*A<br />

[224.0 248.0 272.0 296.0]<br />

[248.0 276.0 304.0 332.0]<br />

[272.0 304.0 336.0 368.0]<br />

[296.0 332.0 368.0 404.0]<br />

sage: A.is_unitary()<br />

False<br />

sage: A.is_unitary(algorithm=’naive’)<br />

False<br />

sage: A.is_unitary(algorithm=’orthonormal’)<br />

False<br />

374 Chapter 19. Dense matrices using a NumPy backend.

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

Saved successfully!

Ooh no, something went wrong!