Skip to first unread message

Andrew

unread,
Jun 21, 2018, 4:43:56 AM6/21/18
to sage-support
I am using sage to find some basis elements in a CombinatorialFreeModule that have some nice properties. To do this I work in a large polynomial ring and solve a corresponding system of equations. The algebra that I am working in is itself defined over a polynomial ring, say ZZ[h, q, ,q^-1, u0, u1] and I am getting solutions to my matrix equations that look like:

[[(-h)/(-h), 0, h/(-h),0],
[0, ((-h*q^-1 + h*q)*u0 + (-h*q^-1 + h*q)*u1)/((-h*q^-1 + h*q)*u0 + (-h*q^-1 + h*q)*u1), 0, 0],                                                               [0, 0, 0, h^2*u0*u1/(h^2*u0*u1)]]
 

These coefficients simplify quite drastically to:

[[1, 0, 1, 0],
[0, 1, 0, 0],
[0, 0, 0, 1]]

Is there a way to make sage do this reduction? Everything that I have tried so far as failed. If I take the (1,1) entry above to be a then it's parent is

sage: a.parent()
Fraction Field of Multivariate Polynomial Ring in c0, c1, c2, c3 over Multivariate Laurent Polynomial Ring in u0, u1 over Univariate Laurent Polynomial Ring in q over Univariate Laurent Polynomial Ring in h over Integer Ring

So I get errors when I try things like:

sage: a.reduce()
---------------------------------------------------------------------------
ArithmeticError                           Traceback (most recent call last)
...
ArithmeticError: unable to reduce because gcd algorithm not implemented on input



Andrew

slelievre

unread,
Jun 21, 2018, 9:51:31 AM6/21/18
to sage-support
Have you tried defining

    sage: R.<c0, c1, c2, c3, u0, u1, q, h> = LaurentPolynomialRing(QQ)

and maping everything to R so it gets simplified?

Andrew

unread,
Jun 21, 2018, 6:26:37 PM6/21/18
to sage-support
If by mapping to R you mean applying

sage: R( f )

then, no, this doesn't work. I'll see if I can post an example to make this more concrete.

Andrew

Dima Pasechnik

unread,
Jun 21, 2018, 7:47:27 PM6/21/18
to sage-support


On Thursday, June 21, 2018 at 11:26:37 PM UTC+1, Andrew wrote:
If by mapping to R you mean applying

sage: R( f )

then, no, this doesn't work. I'll see if I can post an example to make this more concrete.

Perhaps 

f.change_ring(R)

would work (this is what you do if f is a polynomial)

slelievre

unread,
Jun 22, 2018, 5:49:15 AM6/22/18
to sage-support
Yes, a reproducible example of input would help explore this.

Andrew

unread,
Jun 22, 2018, 7:01:00 AM6/22/18
to sage-support
Under the hood these are the sort of calculations that my code is doing:
{{{
sage: Rq.<q> = LaurentPolynomialRing(ZZ,'q')
sage: Ruq.<u> = PolynomialRing(Rq,'u')
sage: mat = matrix([[q-q,u-q],[1,1]])
Under the hood these are the sort of calculations that my code is doing:

sage: Rq.<q> = LaurentPolynomialRing(ZZ,'q')
sage
: Ruq.<u> = PolynomialRing(Rq,'u')
sage
: mat = matrix([[q-q,u-q],[1,1]])
sage
: mat.rref()
[              1               0]
[              0 (u - q)/(u - q)]
sage
: c = _[1][1]; c; c.parent()
(u - q)/(u - q)
Fraction Field of Univariate Polynomial Ring in u over Univariate Laurent Polynomial Ring in q over Integer Ring
sage
: c==1
True
sage
: c.reduce()
-------------------------------------  ------------------------------
ArithmeticError                           Traceback

...
ArithmeticError: unable to reduce because gcd algorithm not implemented on input

It may be an issue with LaurentPolynomial because the following works as expected:

sage: Rq.<q> = PolynomialRing(ZZ,'q')
sage
: Ruq.<u> = PolynomialRing(Rq,'u')
sage
: mat = matrix([[q-u,u-q],[1,1]])
sage
: mat.rref()
[1 0]
[0 1]



Andrew

unread,
Jun 22, 2018, 8:32:21 AM6/22/18
to sage-support
OK, it seems that it is the nesting of LaurentPolynomial rings that causes the problems. it is slightly cumbersome in my real application but work I can solve my problem by creating my creating my coefficient rings only once, without nesting them.

Andrew
Reply all
Reply to author
Forward
0 new messages