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

•dimensions - the list <strong>of</strong> dimensions corresponding to each eigenspace (default=None).<br />

OUTPUT:<br />

A square, diagonalizable, matrix with only integer entries. The eigenspaces <strong>of</strong> this matrix, if computed by h<strong>and</strong>,<br />

give basis vectors with only integer entries.<br />

Note: It is easiest to use this function via a call to the r<strong>and</strong>om_matrix() function with the<br />

algorithm=’diagonalizable’ keyword. We provide one example accessing this function directly,<br />

while the remainder will use this more general function.<br />

EXAMPLES:<br />

A diagonalizable matrix, size 5.<br />

sage: from sage.matrix.constructor import r<strong>and</strong>om_diagonalizable_matrix<br />

sage: matrix_space = sage.matrix.matrix_space.MatrixSpace(QQ, 5)<br />

sage: A=r<strong>and</strong>om_diagonalizable_matrix(matrix_space); A # r<strong>and</strong>om<br />

[ 10 18 8 4 -18]<br />

[ 20 10 8 4 -16]<br />

[-60 -54 -22 -12 18]<br />

[-60 -54 -24 -6 6]<br />

[-20 -18 -8 -4 8]<br />

sage: A.eigenvalues() # r<strong>and</strong>om<br />

[10,6,2,-8,-10]<br />

sage: S=A.right_eigenmatrix()[1]; S # r<strong>and</strong>om<br />

[ 1 1 1 1 0]<br />

[ 1 1 1 0 1]<br />

[-3 -3 -4 -3 -3]<br />

[-3 -4 -3 -3 -3]<br />

[-1 -1 -1 -1 -1]<br />

sage: S_inverse=S.inverse(); S_inverse # r<strong>and</strong>om<br />

[ 1 1 1 1 -5]<br />

[ 0 0 0 -1 3]<br />

[ 0 0 -1 0 3]<br />

[ 0 -1 0 0 -1]<br />

[-1 0 0 0 -1]<br />

sage: S_inverse*A*S # r<strong>and</strong>om<br />

[ 10 0 0 0 0]<br />

[ 0 6 0 0 0]<br />

[ 0 0 2 0 0]<br />

[ 0 0 0 -8 0]<br />

[ 0 0 0 0 -10]<br />

A diagonalizable matrix with eigenvalues <strong>and</strong> dimensions designated, with a check that if eigenvectors were<br />

calculated by h<strong>and</strong> entries would all be integers.<br />

sage: B=r<strong>and</strong>om_matrix(QQ, 6, algorithm=’diagonalizable’, eigenvalues=[-12,4,6],dimensions=[2,3,1<br />

[ -52 32 240 -464 -96 -520]<br />

[ 6 4 -48 72 36 90]<br />

[ 46 -32 -108 296 -12 274]<br />

[ 24 -16 -64 164 0 152]<br />

[ 18 -16 0 72 -48 30]<br />

[ 2 0 -16 24 12 34]<br />

sage: all([x in ZZ for x in (B-(-12*identity_matrix(6))).rref().list()])<br />

True<br />

sage: all([x in ZZ for x in (B-(4*identity_matrix(6))).rref().list()])<br />

True<br />

sage: all([x in ZZ for x in (B-(6*identity_matrix(6))).rref().list()])<br />

42 Chapter 2. Matrix Constructor

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

Saved successfully!

Ooh no, something went wrong!