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

EXAMPLES:<br />

– "hessenberg" - Use the Hessenberg form <strong>of</strong> the matrix<br />

sage: A = MatrixSpace(Integers(8),3)([1,7,3, 1,1,1, 3,4,5])<br />

sage: A.determinant()<br />

6<br />

sage: A.determinant() is A.determinant()<br />

True<br />

sage: A[0,0] = 10<br />

sage: A.determinant()<br />

7<br />

We compute the determinant <strong>of</strong> the arbitrary 3x3 matrix:<br />

sage: R = PolynomialRing(QQ,9,’x’)<br />

sage: A = matrix(R,3,R.gens())<br />

sage: A<br />

[x0 x1 x2]<br />

[x3 x4 x5]<br />

[x6 x7 x8]<br />

sage: A.determinant()<br />

-x2*x4*x6 + x1*x5*x6 + x2*x3*x7 - x0*x5*x7 - x1*x3*x8 + x0*x4*x8<br />

We create a matrix over Z[x, y] <strong>and</strong> compute its determinant.<br />

sage: R. = PolynomialRing(IntegerRing(),2)<br />

sage: A = MatrixSpace(R,2)([x, y, x**2, y**2])<br />

sage: A.determinant()<br />

-x^2*y + x*y^2<br />

TESTS:<br />

sage: A = matrix(5, 5, [next_prime(i^2) for i in range(25)])<br />

sage: B = MatrixSpace(ZZ[’x’], 5, 5)(A)<br />

sage: A.det() - B.det()<br />

0<br />

We verify that trac ticket #5569 is resolved (otherwise the following would hang for hours):<br />

sage: d = r<strong>and</strong>om_matrix(GF(next_prime(10^20)),50).det()<br />

sage: d = r<strong>and</strong>om_matrix(Integers(10^50),50).det()<br />

We verify that trac 7704 is resolved:<br />

sage: matrix(ZZ, {(0,0):1,(1,1):2,(2,2):3,(3,3):4}).det()<br />

24<br />

sage: matrix(QQ, {(0,0):1,(1,1):2,(2,2):3,(3,3):4}).det()<br />

24<br />

We verify that trac 10063 is resolved:<br />

sage: A = GF(2)[’x,y,z’]<br />

sage: A.inject_variables()<br />

Defining x, y, z<br />

sage: R = A.quotient(x^2 + 1).quotient(y^2 + 1).quotient(z^2 + 1)<br />

sage: R.inject_variables()<br />

Defining xbarbarbar, ybarbarbar, zbarbarbar<br />

sage: M = matrix([[1,1,1,1],[xbarbarbar,ybarbarbar,1,1],[0,1,zbarbarbar,1],[xbarbarbar,zbarb<br />

sage: M.determinant()<br />

xbarbarbar*ybarbarbar*zbarbarbar + xbarbarbar*ybarbarbar + xbarbarbar*zbarbarbar + ybarbarba<br />

151

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

Saved successfully!

Ooh no, something went wrong!