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

•other - a matrix, which should be square, <strong>and</strong> <strong>of</strong> the same size as self, where the entries <strong>of</strong> the<br />

matrix have a fraction field equal to that <strong>of</strong> self. Inexact rings are not supported.<br />

•transformation - default: False - if True, the output will include the change-<strong>of</strong>-basis matrix.<br />

See below for an exact description.<br />

OUTPUT:<br />

Two matrices, A <strong>and</strong> B are similar if there is an invertible matrix S such that A = S −1 BS. S can be<br />

interpreted as a change-<strong>of</strong>-basis matrix if A <strong>and</strong> B are viewed as matrix representations <strong>of</strong> the same linear<br />

transformation.<br />

When transformation=False this method will return True if such a matrix S exists, otherwise it<br />

will return False. When transformation=True the method returns a pair. The first part <strong>of</strong> the pair<br />

is True or False depending on if the matrices are similar <strong>and</strong> the second part is the change-<strong>of</strong>-basis<br />

matrix, or None should it not exist.<br />

When the transformation matrix is requested, it will satisfy self = S.inverse()*other*S.<br />

If the base rings for any <strong>of</strong> the matrices is the integers, the rationals, or the field <strong>of</strong> algebraic numbers<br />

(QQbar), then the matrices are converted to have QQbar as their base ring prior to checking the equality<br />

<strong>of</strong> the base rings.<br />

It is possible for this routine to fail over most fields, even when the matrices are similar. However, since<br />

the field <strong>of</strong> algebraic numbers is algebraically closed, the routine will always produce a result for matrices<br />

with rational entries.<br />

EXAMPLES:<br />

The two matrices in this example were constructed to be similar. The computations happen in the field <strong>of</strong><br />

algebraic numbers, but we are able to convert the change-<strong>of</strong>-basis matrix back to the rationals (which may<br />

not always be possible).<br />

sage: A = matrix(ZZ, [[-5, 2, -11],<br />

... [-6, 7, -42],<br />

... [0, 1, -6]])<br />

sage: B = matrix(ZZ, [[ 1, 12, 3],<br />

... [-1, -6, -1],<br />

... [ 0, 6, 1]])<br />

sage: A.is_similar(B)<br />

True<br />

sage: _, T = A.is_similar(B, transformation=True)<br />

sage: T<br />

[ 1.0000000000000 + 0.e-13*I 0.e-13 + 0.e-13*I 0.e-13 + 0.e-13*I]<br />

[-0.6666666666667 + 0.e-13*I 0.16666666666667 + 0.e-14*I -0.8333333333334 + 0.e-13*I]<br />

[ 0.6666666666667 + 0.e-13*I 0.e-13 + 0.e-13*I -0.333333333334 + 0.e-13*I]<br />

sage: T.change_ring(QQ)<br />

[ 1 0 0]<br />

[-2/3 1/6 -5/6]<br />

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

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

True<br />

Other exact fields are supported.<br />

sage: F. = FiniteField(7^2)<br />

sage: A = matrix(F,[[2*a + 5, 6*a + 6, a + 3],<br />

... [ a + 3, 2*a + 2, 4*a + 2],<br />

... [2*a + 6, 5*a + 5, 3*a]])<br />

sage: B = matrix(F,[[5*a + 5, 6*a + 4, a + 1],<br />

... [ a + 5, 4*a + 3, 3*a + 3],<br />

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