ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 06 Nov 2013 20:15:26 -0600Smith-McMillan Form of a polynomial matrixhttp://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/ sage: s = var('s')
sage: G = matrix([[1,-1],[s^2+s-4,2*s^2-s-8],[s^2-4, 2*s^2-8]])
`G` is a symbolic matrix, each entry of which is a polynomial of variable `s`.
# How can we calculate the Smith McMillan Form of the matrix G?
*NOTE: `G.smith_form()` doesn't work.*
Thanks in advance!
Wed, 06 Nov 2013 02:24:44 -0600http://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/Answer by tmonteil for <pre><code>sage: s = var('s')
sage: G = matrix([[1,-1],[s^2+s-4,2*s^2-s-8],[s^2-4, 2*s^2-8]])
</code></pre>
<p><code>G</code> is a symbolic matrix, each entry of which is a polynomial of variable <code>s</code>.</p>
<h1>How can we calculate the Smith McMillan Form of the matrix G?</h1>
<p><em>NOTE: <code>G.smith_form()</code> doesn't work.</em></p>
<p>Thanks in advance!</p>
http://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/?answer=15665#post-id-15665You should avoid symbolic expressions as possible and work with genuine polynomials instead:
sage: R.<s> = PolynomialRing(QQ) ; R
Univariate Polynomial Ring in s over Rational Field
sage: G = matrix([[1,-1],[s^2+s-4,2*s^2-s-8],[s^2-4, 2*s^2-8]])
sage: G.parent()
Full MatrixSpace of 3 by 2 dense matrices over Univariate Polynomial Ring in s over Rational Field
sage: G.smith_form()
(
[ 1 0] [ 1 0 0]
[ 0 3*s^2 - 12] [-s^2 - s + 4 1 0]
[ 0 0], [ s -1 1],
[1 1]
[0 1]
)
Wed, 06 Nov 2013 03:11:52 -0600http://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/?answer=15665#post-id-15665Comment by tmonteil for <p>You should avoid symbolic expressions as possible and work with genuine polynomials instead:</p>
<pre><code>sage: R.<s> = PolynomialRing(QQ) ; R
Univariate Polynomial Ring in s over Rational Field
sage: G = matrix([[1,-1],[s^2+s-4,2*s^2-s-8],[s^2-4, 2*s^2-8]])
sage: G.parent()
Full MatrixSpace of 3 by 2 dense matrices over Univariate Polynomial Ring in s over Rational Field
sage: G.smith_form()
(
[ 1 0] [ 1 0 0]
[ 0 3*s^2 - 12] [-s^2 - s + 4 1 0]
[ 0 0], [ s -1 1],
[1 1]
[0 1]
)
</code></pre>
http://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/?comment=16773#post-id-16773As explained in the error message, you need to use an exact ring, not a numerical ring, probably because of uncontrolled roundings in such a case. What you can do is to use `QQbar`, the field of (complex) algebraic numbers. It is exact and quite huge.Wed, 06 Nov 2013 10:28:34 -0600http://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/?comment=16773#post-id-16773Comment by gundamlh for <p>You should avoid symbolic expressions as possible and work with genuine polynomials instead:</p>
<pre><code>sage: R.<s> = PolynomialRing(QQ) ; R
Univariate Polynomial Ring in s over Rational Field
sage: G = matrix([[1,-1],[s^2+s-4,2*s^2-s-8],[s^2-4, 2*s^2-8]])
sage: G.parent()
Full MatrixSpace of 3 by 2 dense matrices over Univariate Polynomial Ring in s over Rational Field
sage: G.smith_form()
(
[ 1 0] [ 1 0 0]
[ 0 3*s^2 - 12] [-s^2 - s + 4 1 0]
[ 0 0], [ s -1 1],
[1 1]
[0 1]
)
</code></pre>
http://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/?comment=16767#post-id-16767Thanks a lot! I should read a lecture book about basic computer/abstract algebra.Wed, 06 Nov 2013 20:15:26 -0600http://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/?comment=16767#post-id-16767Comment by gundamlh for <p>You should avoid symbolic expressions as possible and work with genuine polynomials instead:</p>
<pre><code>sage: R.<s> = PolynomialRing(QQ) ; R
Univariate Polynomial Ring in s over Rational Field
sage: G = matrix([[1,-1],[s^2+s-4,2*s^2-s-8],[s^2-4, 2*s^2-8]])
sage: G.parent()
Full MatrixSpace of 3 by 2 dense matrices over Univariate Polynomial Ring in s over Rational Field
sage: G.smith_form()
(
[ 1 0] [ 1 0 0]
[ 0 3*s^2 - 12] [-s^2 - s + 4 1 0]
[ 0 0], [ s -1 1],
[1 1]
[0 1]
)
</code></pre>
http://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/?comment=16775#post-id-16775Thanks! I haven't taken a math course like "computer algebra" or "abstract algebra". Can I extend the smith_form() to "basic ring := Complex Field", i.e., R.<s> = PolynomialRing(CC), G = the same expression, G.smith_form() (it doesn't work)... ERROR: NotImplementedError: Smith form over non-exact rings not implemented at presentWed, 06 Nov 2013 05:29:23 -0600http://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/?comment=16775#post-id-16775