First time here? Check out the FAQ!

Ask Your Question
1

weighted univariate polynomials

asked 5 years ago

heluani gravatar image

updated 2 years ago

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.

Preview: (hide)

Comments

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

John Palmieri gravatar imageJohn Palmieri ( 5 years ago )

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 ( 5 years ago )

1 Answer

Sort by » oldest newest most voted
3

answered 5 years ago

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.

Preview: (hide)
link

Comments

A ticket ?

tmonteil gravatar imagetmonteil ( 5 years ago )

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

heluani gravatar imageheluani ( 5 years ago )

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

B r u n o gravatar imageB r u n o ( 5 years ago )

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

tmonteil gravatar imagetmonteil ( 5 years ago )

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 ( 5 years ago )

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: 5 years ago

Seen: 461 times

Last updated: Aug 28 '19