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

In this example we take the symbolic answer <strong>and</strong> make it numerical at the end:<br />

sage: exp(matrix(SR, [[1.2, 5.6], [3,4]])).change_ring(RDF)<br />

[346.557487298 661.734590934]<br />

[354.500673715 677.424782765]<br />

Another example involving the reversed identity matrix, which we clumsily create:<br />

sage: m = identity_matrix(SR,4); m = matrix(list(reversed(m.rows()))) * x<br />

sage: exp(m)<br />

[1/2*(e^(2*x) + 1)*e^(-x) 0 0 1/2*(e^(2*x) - 1<br />

[ 0 1/2*(e^(2*x) + 1)*e^(-x) 1/2*(e^(2*x) - 1)*e^(-x)<br />

[ 0 1/2*(e^(2*x) - 1)*e^(-x) 1/2*(e^(2*x) + 1)*e^(-x)<br />

[1/2*(e^(2*x) - 1)*e^(-x) 0 0 1/2*(e^(2*x) + 1<br />

exp<strong>and</strong>()<br />

Operates point-wise on each element.<br />

EXAMPLES:<br />

sage: M = matrix(2, 2, range(4)) - var(’x’)<br />

sage: M*M<br />

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

[ -4*x + 6 (x - 3)^2 + 2]<br />

sage: (M*M).exp<strong>and</strong>()<br />

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

[ -4*x + 6 x^2 - 6*x + 11]<br />

factor()<br />

Operates point-wise on each element.<br />

EXAMPLES:<br />

sage: M = matrix(SR, 2, 2, x^2 - 2*x + 1); M<br />

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

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

sage: M.factor()<br />

[(x - 1)^2 0]<br />

[ 0 (x - 1)^2]<br />

fcp(var=’x’)<br />

Return the factorization <strong>of</strong> the characteristic polynomial <strong>of</strong> self.<br />

INPUT:<br />

•var - (default: ‘x’) name <strong>of</strong> variable <strong>of</strong> charpoly<br />

EXAMPLES:<br />

sage: a = matrix(SR,[[1,2],[3,4]])<br />

sage: a.fcp()<br />

x^2 - 5*x - 2<br />

sage: [i for i in a.fcp()]<br />

[(x^2 - 5*x - 2, 1)]<br />

sage: a = matrix(SR,[[1,0],[0,2]])<br />

sage: a.fcp()<br />

(x - 2) * (x - 1)<br />

sage: [i for i in a.fcp()]<br />

[(x - 2, 1), (x - 1, 1)]<br />

sage: a = matrix(SR, 5, [1..5^2])<br />

sage: a.fcp()<br />

(x^2 - 65*x - 250) * x^3<br />

309

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

Saved successfully!

Ooh no, something went wrong!