Ask Your Question

Revision history [back]

You 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]
)