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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

INPUT:<br />

Any matrix over RDF or CDF.<br />

OUTPUT:<br />

True if <strong>and</strong> only if the matrix is square, Hermitian, <strong>and</strong> meets the condition above on the quadratic form.<br />

The result is cached.<br />

IMPLEMENTATION:<br />

The existence <strong>of</strong> a Cholesky decomposition <strong>and</strong> the positive definite property are equivalent. So this<br />

method <strong>and</strong> the cholesky() method compute <strong>and</strong> cache both the Cholesky decomposition <strong>and</strong> the<br />

positive-definiteness. So the is_positive_definite() method or catching a ValueError from<br />

the cholesky() method are equally expensive computationally <strong>and</strong> if the decomposition exists, it is<br />

cached as a side-effect <strong>of</strong> either routine.<br />

EXAMPLES:<br />

A matrix over RDF that is positive definite.<br />

sage: M = matrix(RDF,[[ 1, 1, 1, 1, 1],<br />

... [ 1, 5, 31, 121, 341],<br />

... [ 1, 31, 341, 1555, 4681],<br />

... [ 1,121, 1555, 7381, 22621],<br />

... [ 1,341, 4681, 22621, 69905]])<br />

sage: M.is_symmetric()<br />

True<br />

sage: M.eigenvalues()<br />

[77547.66..., 82.44..., 2.41..., 0.46..., 0.011...]<br />

sage: [round(M[:i,:i].determinant()) for i in range(1, M.nrows()+1)]<br />

[1, 4, 460, 27936, 82944]<br />

sage: M.is_positive_definite()<br />

True<br />

A matrix over CDF that is positive definite.<br />

sage: C = matrix(CDF, [[ 23, 17*I + 3, 24*I + 25, 21*I],<br />

... [ -17*I + 3, 38, -69*I + 89, 7*I + 15],<br />

... [-24*I + 25, 69*I + 89, 976, 24*I + 6],<br />

... [ -21*I, -7*I + 15, -24*I + 6, 28]])<br />

sage: C.is_hermitian()<br />

True<br />

sage: [x.real() for x in C.eigenvalues()]<br />

[991.46..., 55.96..., 3.69..., 13.87...]<br />

sage: [round(C[:i,:i].determinant().real()) for i in range(1, C.nrows()+1)]<br />

[23, 576, 359540, 2842600]<br />

sage: C.is_positive_definite()<br />

True<br />

A matrix over RDF that is not positive definite.<br />

sage: A = matrix(RDF, [[ 3, -6, 9, 6, -9],<br />

... [-6, 11, -16, -11, 17],<br />

... [ 9, -16, 28, 16, -40],<br />

... [ 6, -11, 16, 9, -19],<br />

... [-9, 17, -40, -19, 68]])<br />

sage: A.is_symmetric()<br />

True<br />

sage: A.eigenvalues()<br />

[108.07..., 13.02..., -0.02..., -0.70..., -1.37...]<br />

sage: [round(A[:i,:i].determinant()) for i in range(1, A.nrows()+1)]<br />

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