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.6063218341690895 0.5289635311888953 0.5937772444966257]<br />

[ 0.5252981913594170 0.2941669871612735 -0.798453250866314]<br />

sage: M<br />

[ 10.04987562112089 0 0]<br />

[ 1.890570661398980 4.735582601355131 0]<br />

[ 1.492555785314984 7.006153332071100 1.638930357041381]<br />

[ 2.885607851608969 1.804330147889395 7.963520581008761]<br />

[ 7.064764050490923 5.626248468100069 -1.197679876299471]<br />

sage: M*G-A<br />

[0 0 0]<br />

[0 0 0]<br />

[0 0 0]<br />

[0 0 0]<br />

[0 0 0]<br />

sage: (G*G.transpose()-identity_matrix(3)).norm() < 10^-10<br />

True<br />

sage: G.row_space() == A.row_space()<br />

True<br />

After trac ticket #14047, the matrix can also be over the algebraic reals AA:<br />

sage: A = matrix(AA, [[6, -8, 1],<br />

... [4, 1, 3],<br />

... [6, 3, 3],<br />

... [7, 1, -5],<br />

... [7, -3, 5]])<br />

sage: G, M = A.gram_schmidt(orthonormal=True)<br />

sage: G<br />

[ 0.5970223141259934 -0.7960297521679913 0.09950371902099891]<br />

[ 0.6063218341690895 0.5289635311888953 0.5937772444966257]<br />

[ 0.5252981913594170 0.2941669871612735 -0.798453250866314]<br />

sage: M<br />

[ 10.04987562112089 0 0]<br />

[ 1.890570661398980 4.735582601355131 0]<br />

[ 1.492555785314984 7.006153332071100 1.638930357041381]<br />

[ 2.885607851608969 1.804330147889395 7.963520581008761]<br />

[ 7.064764050490923 5.626248468100069 -1.197679876299471]<br />

Starting with complex numbers with rational real <strong>and</strong> imaginary parts. Note the use <strong>of</strong> the conjugatetranspose<br />

when checking the orthonormality.<br />

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

... [-4*I, -2*I + 17, 0, 9*I + 1],<br />

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

sage: G, M = A.gram_schmidt(orthonormal=True)<br />

sage: (M*G-A).norm() < 10^-10<br />

True<br />

sage: id3 = G*G.conjugate().transpose()<br />

sage: (id3 - identity_matrix(3)).norm() < 10^-10<br />

True<br />

sage: G.row_space() == A.row_space() # long time<br />

True<br />

A square matrix with small rank. The zero vectors produced as a result <strong>of</strong> linear dependence get eliminated,<br />

so the rows <strong>of</strong> G are a basis for the row space <strong>of</strong> A.<br />

sage: A = matrix(QQbar, [[2, -6, 3, 8],<br />

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

... [0, 0, 2, 4],<br />

176 Chapter 7. Base class for matrices, part 2

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

Saved successfully!

Ooh no, something went wrong!