12.07.2015 Views

Sage Reference Manual: Matrices and Spaces of Matrices

Sage Reference Manual: Matrices and Spaces of Matrices

Sage Reference Manual: Matrices and Spaces of Matrices

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.2sage: B = companion_matrix(poly, format=’bottom’); B[0 1 0 0 0][0 0 1 0 0][0 0 0 1 0][0 0 0 0 1][2 3 4 5 6]sage: T = companion_matrix(poly, format=’top’); T[6 5 4 3 2][1 0 0 0 0][0 1 0 0 0][0 0 1 0 0][0 0 0 1 0]sage: perm = Permutation([5, 4, 3, 2, 1])sage: P = perm.to_matrix()sage: L == P*R*PTruesage: B == R.transpose()Truesage: T == P*R.transpose()*PTrueA polynomial may be used as input, however a symbolic expression, even if it looks like a polynomial, is notregarded as such when used as input to this routine. Obtaining the list <strong>of</strong> coefficients from a symbolic polynomialis one route to the companion matrix.sage: x = polygen(QQ, ’x’)sage: p = x^3 - 4*x^2 + 8*x - 12sage: companion_matrix(p)[ 0 0 12][ 1 0 -8][ 0 1 4]sage: y = var(’y’)sage: q = y^3 -2*y + 1sage: companion_matrix(q)Traceback (most recent call last):...TypeError: input must be a polynomial (not a symbolic expression, see docstring), or other iterasage: coeff_list = [q(y=0)] + [q.coeff(y^k) for k in range(1, q.degree(y)+1)]sage: coeff_list[1, -2, 0, 1]sage: companion_matrix(coeff_list)[ 0 0 -1][ 1 0 2][ 0 1 0]The minimal polynomial <strong>of</strong> a companion matrix is equal to the polynomial used to create it. Used in a blockdiagonal construction, they can be used to create matrices with any desired minimal polynomial, or characteristicpolynomial.sage: t = polygen(QQ, ’t’)sage: p = t^12 - 7*t^4 + 28*t^2 - 456sage: C = companion_matrix(p, format=’top’)sage: q = C.minpoly(var=t); qt^12 - 7*t^4 + 28*t^2 - 456sage: p == qTrue27

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

Saved successfully!

Ooh no, something went wrong!