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

sage: a.r<strong>and</strong>omize(0.5)<br />

sage: a<br />

[ 1/2*x^2 - x - 12 1/2*x^2 - 1/95*x - 1/2 0]<br />

[-5/2*x^2 + 2/3*x - 1/4 0 0]<br />

[ -x^2 + 2/3*x 0 0]<br />

Now we r<strong>and</strong>omize all the entries <strong>of</strong> the resulting matrix:<br />

sage: a.r<strong>and</strong>omize()<br />

sage: a<br />

[ 1/3*x^2 - x + 1 -x^2 + 1 x^2 - x]<br />

[ -1/14*x^2 - x - 1/4 -4*x - 1/5 -1/4*x^2 - 1/2*x + 4]<br />

[ 1/9*x^2 + 5/2*x - 3 -x^2 + 3/2*x + 1 -2/7*x^2 - x - 1/2]<br />

We create the zero matrix over the integers:<br />

sage: a = matrix(ZZ, 2); a<br />

[0 0]<br />

[0 0]<br />

Then we r<strong>and</strong>omize it; the x <strong>and</strong> y parameters, which determine the size <strong>of</strong> the r<strong>and</strong>om elements, are<br />

passed onto the ZZ r<strong>and</strong>om_element method.<br />

sage: a.r<strong>and</strong>omize(x=-2^64, y=2^64)<br />

sage: a<br />

[-12401200298100116246 1709403521783430739]<br />

[ -4417091203680573707 17094769731745295000]<br />

rational_form(format=’right’, subdivide=True)<br />

Returns the rational canonical form, also known as Frobenius form.<br />

INPUT:<br />

•self - a square matrix with entries from an exact field.<br />

•format - default: ‘right’ - one <strong>of</strong> ‘right’, ‘bottom’, ‘left’, ‘top’ or ‘invariants’. The first four will<br />

cause a matrix to be returned with companion matrices dictated by the keyword. The value ‘invariants’<br />

will cause a list <strong>of</strong> lists to be returned, where each list contains coefficients <strong>of</strong> a polynomial associated<br />

with a companion matrix.<br />

•subdivide - default: ‘True’ - if ‘True’ <strong>and</strong> a matrix is returned, then it contains subdivisions delineating<br />

the companion matrices along the diagonal.<br />

OUTPUT:<br />

The rational form <strong>of</strong> a matrix is a similar matrix composed <strong>of</strong> submatrices (“blocks”) placed on the main<br />

diagonal. Each block is a companion matrix. Associated with each companion matrix is a polynomial.<br />

In rational form, the polynomial <strong>of</strong> one block will divide the polynomial <strong>of</strong> the next block (<strong>and</strong> thus, the<br />

polynomials <strong>of</strong> all subsequent blocks).<br />

Rational form, also known as Frobenius form, is a canonical form. In other words, two matrices are similar<br />

if <strong>and</strong> only if their rational canonical forms are equal. The algorithm used does not provide the similarity<br />

transformation matrix (also known as the change-<strong>of</strong>-basis matrix).<br />

Companion matrices may be written in one <strong>of</strong> four styles, <strong>and</strong> any such style may<br />

be selected with the format keyword. See the companion matrix constructor,<br />

sage.matrix.constructor.companion_matrix(), for more information about companion<br />

matrices.<br />

If the ‘invariants’ value is used for the format keyword, then the return value is a list <strong>of</strong> lists, where each<br />

list is the coefficients <strong>of</strong> the polynomial associated with one <strong>of</strong> the companion matrices on the diagonal.<br />

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