Opened 5 years ago
Closed 2 years ago
#17550 closed defect (wontfix)
sorted variables in multivariate polynomial ring wrong order
Reported by: | dkrenn | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | algebra | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
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]
Change History (10)
comment:1 Changed 5 years ago by
comment:2 follow-up: ↓ 5 Changed 5 years ago by
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]
comment:3 follow-ups: ↓ 4 ↓ 6 Changed 5 years ago by
- Milestone changed from sage-6.5 to sage-duplicate/invalid/wontfix
- Status changed from new to needs_review
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.
comment:4 in reply to: ↑ 3 ; follow-up: ↓ 7 Changed 5 years ago by
- Status changed from needs_review to positive_review
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.
comment:5 in reply to: ↑ 2 Changed 5 years ago by
- Status changed from positive_review to needs_info
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, ...]
.
comment:6 in reply to: ↑ 3 Changed 5 years ago by
- Work issues set to document this better
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.
comment:7 in reply to: ↑ 4 ; follow-up: ↓ 8 Changed 5 years ago by
Replying to bruno:
[...] 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...
comment:8 in reply to: ↑ 7 Changed 5 years ago by
Replying to dkrenn:
Replying to bruno:
[...] 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 degree1
andb
is the last variable whose exponent is smaller in the monomiala
(0) than in the monomialb
(1); - deglex:
a > b
since both monomials have degree1
anda
is the first variable whose exponent is larger in the monomiala
(1) than in the monomialb
(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.
comment:9 Changed 3 years ago by
- Status changed from needs_info to positive_review
- Work issues document this better deleted
Let us close this as invalid.
comment:10 Changed 2 years ago by
- Resolution set to wontfix
- Status changed from positive_review to closed
Still there in 6.6