Ask Your Question
1

weighted univariate polynomials

asked 2019-08-27 20:55:48 +0100

heluani gravatar image

updated 2023-01-09 23:59:51 +0100

tmonteil gravatar image

I have a polynomial algebra in n variables k[x_1,...,x_n]. I know how assign different degrees to each of the generators as in

sage: P = PolynomialRing(QQ, 'x,y,z', order = TermOrder('wdegrevlex', (2,3,4)))
sage: P.inject_variables()
Defining x, y, z
sage: z.degree()
sage:
4

However if I want to do this with only one variable this does not work

sage: P = PolynomialRing(QQ, 'x', order = TermOrder('wdegrevlex', (2)))
sage: P.inject_variables()
Defining x
sage: x.degree()
1

I wander if I can do this in an uniform way cause I need to use a class that takes an arbitrary number of variables.

edit retag flag offensive close merge delete

Comments

You can use GradedCommutativeAlgebra, as I suggested in my answer to another of your questions.

John Palmieri gravatar imageJohn Palmieri ( 2019-08-27 22:13:43 +0100 )edit

That doesn't work for a number of other reasons, I have a particular derivation of degree 1 and doubling the degrees is not an option. I need a number of methods from PolynomialRings and Groebner bases that I cannot coalesce to GradedCommutativeAlgebra and a few more. But still it's striking why that example as in my question is implemented the way it is

heluani gravatar imageheluani ( 2019-08-28 14:03:57 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2019-08-28 16:49:39 +0100

B r u n o gravatar image

This (mainly) comes from the construction of your univariate polynomial ring. Compare

sage: R1 = PolynomialRing(QQ, 'x'); R1
Univariate Polynomial Ring in x over Rational Field
sage: R2 = PolynomialRing(QQ, 1, 'x'); R2
Multivariate Polynomial Ring in x over Rational Field

This means that if you explicitly give the number of variables, the polynomial ring is considered as a multivariate one (in this case a "one-variable multivariate polynomial ring") while if you don't, it is considered a univariate polynomial ring. As a consequence, R1 and R2 in my example use two completely distinct implementations.

Now you can do what you need:

sage: P = PolynomialRing(QQ, 1, 'x', order = TermOrder('wdegrevlex', (2,)))
sage: P.inject_variables()
Defining x
sage: x.degree()
2

Note the two changes: 1. add the number of variables ; 2. change (2) into (2,). The second change is due to the fact that TermOrder needs a tuple, and (2) is an integer for Python while (2,) is a 1-tuple containing an integer.

It is a pity that you did not get any warning: In my sense, you should have been told that order = ... has no effect for a univariate polynomial ring, and that TermOrder(...) requires a tuple rather than an integer.

edit flag offensive delete link more

Comments

A ticket ?

tmonteil gravatar imagetmonteil ( 2019-08-28 16:56:58 +0100 )edit

Thanks a lot this is precisely what I needed. I had tried (2,) before but not explicitly adding the ,1,

heluani gravatar imageheluani ( 2019-08-28 17:46:02 +0100 )edit

@Thierry: I'll open one (or two for the two silent behaviors), soon ;-).

B r u n o gravatar imageB r u n o ( 2019-08-28 18:56:40 +0100 )edit

These are now trac ticket 28420 and trac ticket 28421, thanks !

tmonteil gravatar imagetmonteil ( 2019-08-30 09:57:27 +0100 )edit

I need advice on 28420 which happens to be more complicated than I thought!

B r u n o gravatar imageB r u n o ( 2019-08-30 17:41:00 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-08-27 20:55:48 +0100

Seen: 442 times

Last updated: Aug 28 '19