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

OUTPUT:<br />

True if the matrix is square <strong>and</strong> equal to the transpose with every entry conjugated, <strong>and</strong> False otherwise.<br />

Note that if conjugation has no effect on elements <strong>of</strong> the base ring (such as for integers), then the<br />

is_symmetric() method is equivalent <strong>and</strong> faster.<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 compares corresponing entries on either side <strong>of</strong> the diagonal (<strong>and</strong> on the<br />

diagonal itself) to see if they are conjugates, 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 real entries.<br />

So the naive algorithm can finish quickly for a matrix that is not Hermitian, while the orthonormal algorithm<br />

will always compute a Schur decomposition before going through a similar check <strong>of</strong> the matrix<br />

entry-by-entry.<br />

EXAMPLES:<br />

sage: A = matrix(CDF, [[ 1 + I, 1 - 6*I, -1 - I],<br />

... [-3 - I, -4*I, -2],<br />

... [-1 + I, -2 - 8*I, 2 + I]])<br />

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

False<br />

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

False<br />

sage: B = A*A.conjugate_transpose()<br />

sage: B.is_hermitian(algorithm=’orthonormal’)<br />

True<br />

sage: B.is_hermitian(algorithm=’naive’)<br />

True<br />

A matrix that is nearly Hermitian, but for one non-real diagonal entry.<br />

sage: A = matrix(CDF, [[ 2, 2-I, 1+4*I],<br />

... [ 2+I, 3+I, 2-6*I],<br />

... [1-4*I, 2+6*I, 5]])<br />

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

False<br />

sage: A[1,1] = 132<br />

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

True<br />

We get a unitary matrix from the SVD routine <strong>and</strong> use this numerical matrix to create a matrix that should<br />

be Hermitian (indeed it should be the identity matrix), but with some imprecision. We use this to illustrate<br />

that if the tolerance is set too small, then we can be too strict about the equality <strong>of</strong> entries <strong>and</strong> may achieve<br />

the wrong result (depending on the system):<br />

sage: A = matrix(CDF, [[ 1 + I, 1 - 6*I, -1 - I],<br />

... [-3 - I, -4*I, -2],<br />

... [-1 + I, -2 - 8*I, 2 + I]])<br />

sage: U, _, _ = A.SVD()<br />

sage: B=U*U.conjugate_transpose()<br />

sage: B.is_hermitian(algorithm=’naive’)<br />

True<br />

368 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!