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

sage: A = matrix(GF(9,’c’), 4, [1, 1, 0,0, 0,1,0,0, 0,0,5,0, 0,0,0,5])<br />

sage: factor(A.minpoly())<br />

(x + 1) * (x + 2)^2<br />

sage: A.minpoly()(A) == 0<br />

True<br />

sage: factor(A.charpoly())<br />

(x + 1)^2 * (x + 2)^2<br />

The default variable name is x, but you can specify another name:<br />

sage: factor(A.minpoly(’y’))<br />

(y + 1) * (y + 2)^2<br />

We can take the minimal polynomial <strong>of</strong> symbolic matrices:<br />

sage: t = var(’t’)<br />

sage: m = matrix(2,[1,2,4,t])<br />

sage: m.minimal_polynomial()<br />

x^2 + (-t - 1)*x + t - 8<br />

n(prec=None, digits=None)<br />

Return a numerical approximation <strong>of</strong> self as either a real or complex number with at least the requested<br />

number <strong>of</strong> bits or digits <strong>of</strong> precision.<br />

INPUT:<br />

•prec - an integer: the number <strong>of</strong> bits <strong>of</strong> precision<br />

•digits - an integer: digits <strong>of</strong> precision<br />

OUTPUT: A matrix coerced to a real or complex field with prec bits <strong>of</strong> precision.<br />

EXAMPLES:<br />

sage: d = matrix([[3, 0],[0,sqrt(2)]]) ;<br />

sage: b = matrix([[1, -1], [2, 2]]) ; e = b * d * b.inverse();e<br />

[ 1/2*sqrt(2) + 3/2 -1/4*sqrt(2) + 3/4]<br />

[ -sqrt(2) + 3 1/2*sqrt(2) + 3/2]<br />

sage: e.numerical_approx(53)<br />

[ 2.20710678118655 0.396446609406726]<br />

[ 1.58578643762690 2.20710678118655]<br />

sage: e.numerical_approx(20)<br />

[ 2.2071 0.39645]<br />

[ 1.5858 2.2071]<br />

sage: (e-I).numerical_approx(20)<br />

[2.2071 - 1.0000*I 0.39645]<br />

[ 1.5858 2.2071 - 1.0000*I]<br />

sage: M=matrix(QQ,4,[i/(i+1) for i in range(12)]);M<br />

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

[ 3/4 4/5 5/6]<br />

[ 6/7 7/8 8/9]<br />

[ 9/10 10/11 11/12]<br />

sage: M.numerical_approx()<br />

[0.000000000000000 0.500000000000000 0.666666666666667]<br />

215

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

Saved successfully!

Ooh no, something went wrong!