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

For a matrix A the routine returns a lower triangular matrix L such that,<br />

A = LL ∗<br />

where L ∗ is the conjugate-transpose in the complex case, <strong>and</strong> just the transpose in the real case. If the<br />

matrix fails to be positive definite (perhaps because it is not symmetric or Hermitian), then a ValueError<br />

results.<br />

ALGORITHM:<br />

Whether or not the matrix is positive definite is checked first in every case. This is accomplished with<br />

an indefinite factorization (see indefinite_factorization()) which caches its result. This algorithm<br />

is <strong>of</strong> an order n 3 /3. If the matrix is positive definite, this computation always succeeds, using just<br />

field operations. The transistion to a Cholesky decomposition “only” requires computing square roots <strong>of</strong><br />

the positive (real) entries <strong>of</strong> the diagonal matrix produced in the indefinite factorization. Hence, there is no<br />

real penalty in the positive definite check (here, or prior to calling this routine), but a field extension with<br />

square roots may not be implemented in all reasonable cases.<br />

EXAMPLES:<br />

This simple example has a result with entries that remain in the field <strong>of</strong> rational numbers.<br />

sage: A = matrix(QQ, [[ 4, -2, 4, 2],<br />

... [-2, 10, -2, -7],<br />

... [ 4, -2, 8, 4],<br />

... [ 2, -7, 4, 7]])<br />

sage: A.is_symmetric()<br />

True<br />

sage: L = A.cholesky()<br />

sage: L<br />

[ 2 0 0 0]<br />

[-1 3 0 0]<br />

[ 2 0 2 0]<br />

[ 1 -2 1 1]<br />

sage: L.parent()<br />

Full MatrixSpace <strong>of</strong> 4 by 4 dense matrices over Rational Field<br />

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

True<br />

This seemingly simple example requires first moving to the rational numbers for field operations, <strong>and</strong> then<br />

square roots necessitate that the result has entries in the field <strong>of</strong> algebraic numbers.<br />

sage: A = matrix(ZZ, [[ 78, -30, -37, -2],<br />

... [-30, 102, 179, -18],<br />

... [-37, 179, 326, -38],<br />

... [ -2, -18, -38, 15]])<br />

sage: A.is_symmetric()<br />

True<br />

sage: L = A.cholesky()<br />

sage: L<br />

[ 8.83176086632785 0 0 0]<br />

[ -3.396831102433787 9.51112708681461 0 0]<br />

[ -4.189425026335004 17.32383862241232 2.886751345948129 0]<br />

[-0.2264554068289192 -1.973397116652010 -1.649572197684645 2.886751345948129]<br />

sage: L.parent()<br />

Full MatrixSpace <strong>of</strong> 4 by 4 dense matrices over Algebraic Field<br />

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

True<br />

135

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

Saved successfully!

Ooh no, something went wrong!