ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 07 Nov 2013 03:15:26 +0100Smith-McMillan Form of a polynomial matrixhttps://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 09:24:44 +0100https://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>
https://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 10:11:52 +0100https://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/?answer=15665#post-id-15665Comment 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>
https://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 12:29:23 +0100https://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/?comment=16775#post-id-16775Comment 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>
https://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.Thu, 07 Nov 2013 03:15:26 +0100https://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/?comment=16767#post-id-16767Comment 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>
https://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 17:28:34 +0100https://ask.sagemath.org/question/10705/smith-mcmillan-form-of-a-polynomial-matrix/?comment=16773#post-id-16773