Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sorted variables in multivariate polynomial ring wrong order #17550

Closed
dkrenn opened this issue Dec 26, 2014 · 11 comments
Closed

sorted variables in multivariate polynomial ring wrong order #17550

dkrenn opened this issue Dec 26, 2014 · 11 comments

Comments

@dkrenn
Copy link
Contributor

dkrenn commented Dec 26, 2014

We have

sage: R.<a,b> = QQ[]
sage: sorted([a,b])
[b, a]

which looks weird to me and is not what one would expect.

This is also inconsistent with

sage: var('a, b')
(a, b)
sage: sorted([a,b])
[a, b]

(but in this case the ordering seems always to be alphabetically.)

However, in the multivariate polynomial ring this ordering depends on the definition:

sage: R.<b,a> = QQ[]
sage: sorted([a,b])
[a, b]

Component: algebra

Issue created by migration from https://trac.sagemath.org/ticket/17550

@dkrenn dkrenn added this to the sage-6.5 milestone Dec 26, 2014
@dkrenn
Copy link
Contributor Author

dkrenn commented Apr 16, 2015

comment:1

Still there in 6.6

@nbruin
Copy link
Contributor

nbruin commented Apr 16, 2015

comment:2

Polynomial rings have a monomial order which should affect how monomials (and hence terms) compare:

sage: A.<a,b>=PolynomialRing(Rationals(),order="lex")
sage: sorted([a^i*b^j for i in [0..2] for j in [0..2]])
[1, b, b^2, a, a*b, a*b^2, a^2, a^2*b, a^2*b^2]
sage: A.<a,b>=PolynomialRing(Rationals(),order="deglex")
sage: sorted([a^i*b^j for i in [0..2] for j in [0..2]])
[1, b, a, b^2, a*b, a^2, a*b^2, a^2*b, a^2*b^2]
sage: A.<a,b>=PolynomialRing(Rationals(),order="degrevlex")
sage: sorted([a^i*b^j for i in [0..2] for j in [0..2]])
[1, b, a, b^2, a*b, a^2, a*b^2, a^2*b, a^2*b^2]

@lftabera
Copy link
Contributor

lftabera commented Jun 5, 2015

comment:3

By default sage uses 'degrevlex' for term orders. This is somehow standard in multivariate polynomial rings. I would not change this default. If you want a>b I suggest you to use 'deglex' term order instead.

I propose to resolve the ticket as wontfix.

@lftabera lftabera removed this from the sage-6.5 milestone Jun 5, 2015
@bgrenet
Copy link

bgrenet commented Jun 5, 2015

comment:4

Replying to @lftabera:

By default sage uses 'degrevlex' for term orders. This is somehow standard in multivariate polynomial rings. I would not change this default. If you want a>b I suggest you to use 'deglex' term order instead.

I propose to resolve the ticket as wontfix.

I agree with you that this is related to the term orders. Yet, the order on the variables themselves doesn't change between "degrevlex" and "deglex". This is due to the fact that there are two distinct changes between these two orders.

@dkrenn
Copy link
Contributor Author

dkrenn commented Jun 6, 2015

comment:5

Replying to @nbruin:

Polynomial rings have a monomial order which should affect how monomials (and hence terms) compare:

sage: A.<a,b>=PolynomialRing(Rationals(),order="lex")
sage: sorted([a^i*b^j for i in [0..2] for j in [0..2]])
[1, b, b^2, a, a*b, a*b^2, a^2, a^2*b, a^2*b^2]
sage: A.<a,b>=PolynomialRing(Rationals(),order="deglex")
sage: sorted([a^i*b^j for i in [0..2] for j in [0..2]])
[1, b, a, b^2, a*b, a^2, a*b^2, a^2*b, a^2*b^2]
sage: A.<a,b>=PolynomialRing(Rationals(),order="degrevlex")
sage: sorted([a^i*b^j for i in [0..2] for j in [0..2]])
[1, b, a, b^2, a*b, a^2, a*b^2, a^2*b, a^2*b^2]

I understand that the original posted "problem" is not one, since we use "degrevlex", but using "lex" or "deglex" the output of the lines above should definitely start with [1, a, ...].

@dkrenn
Copy link
Contributor Author

dkrenn commented Jun 6, 2015

comment:6

Replying to @lftabera:

By default sage uses 'degrevlex' for term orders. This is somehow standard in multivariate polynomial rings. I would not change this default. If you want a>b I suggest you to use 'deglex' term order instead.

Understood.

I propose to resolve the ticket as wontfix.

To get something out of it, e should at least mention this in the docstrings more explicitly.

@dkrenn
Copy link
Contributor Author

dkrenn commented Jun 6, 2015

Work Issues: document this better

@dkrenn
Copy link
Contributor Author

dkrenn commented Jun 6, 2015

comment:7

Replying to @bgrenet:

[...] Yet, the order on the variables themselves doesn't change between "degrevlex" and "deglex". This is due to the fact that there are two distinct changes between these two orders.

What do you mean by this? This should (IMHO) change...

@bgrenet
Copy link

bgrenet commented Jun 8, 2015

comment:8

Replying to @dkrenn:

Replying to @bgrenet:

[...] Yet, the order on the variables themselves doesn't change between "degrevlex" and "deglex". This is due to the fact that there are two distinct changes between these two orders.

What do you mean by this? This should (IMHO) change...

This is described in the reference manual http://doc.sagemath.org/html/en/reference/polynomial_rings/sage/rings/polynomial/term_order.html. The "two changes" I mentioned are the fact that in "degrevlex" one considers the last variable whose exponent is larger while in "deglex" one considers the first variable whose exponent is smaller. Thus, if you have as first variable a and second variable b, the comparison between the two monomials a and b is:

  • degrevlex: a > b since both monomials have degree 1 and b is the last variable whose exponent is smaller in the monomial a (0) than in the monomial b (1);
  • deglex: a > b since both monomials have degree 1 and a is the first variable whose exponent is larger in the monomial a (1) than in the monomial b (0).

Note that, unless I make a mistake, all orders defined in SageMath satisfy a > b.

I do not understand what you mean by "This should change". The way the orders are defined in SageMath seems consistent with the literature and the other softwares.

@fchapoton
Copy link
Contributor

comment:9

Let us close this as invalid.

@fchapoton
Copy link
Contributor

Changed work issues from document this better to none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants