[sage-devel] Re: Bug in groebner_basis()?

2017-07-15 Thread Johannes Schwab
Oh, thank you! Sometimes it's a good idea to have a look at the 
documentation of ALL used functions...
Sorry for the trouble.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: Bug in groebner_basis()?

2017-07-14 Thread Simon King
Hi Daniel,

On 2017-07-14, Daniel Krenn  wrote:
>>> R. = PolynomialRing(QQ, 'lex')
>> That's not what you want.
>> [...]
>> Instead you have to do
>>   sage: R. = PolynomialRing(QQ, order='lex')
>> (i.e., specify what parameter is 'lex' being assigned to)
>
> What does the polynomial ring constructor do with the 'lex' in the first
> example? Why is no error raised?

The preparser translates it into
  R = PolynomialRing(QQ, 'lex', names=('x', 'y',)); (x, y,) = R._first_ngens(2)

And we have the following function head:
def PolynomialRing(base_ring, arg1=None, arg2=None,
   sparse=False, order='degrevlex',
   names=None, name=None,
   var_array=None,
   implementation=None):

So, "lex" ends up in "arg1". Unfortunately, the documentation of
the PolynomialRing constructor is not very clear about what happens
with arg1. But in the source code, I find that arg1 is used to override the
parameter `name` (not `names`). However it seems that if both `name` and `names`
is present then the value of `name` has no effect. Let's try:

  sage: PolynomialRing(QQ, name='lex', names=('x','y'))
  Multivariate Polynomial Ring in x, y over Rational Field
  sage: _.term_order()
  Degree reverse lexicographic term order

Cheers,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] Re: Bug in groebner_basis()?

2017-07-14 Thread Daniel Krenn
On 2017-07-14 16:41, Simon King wrote:
> On 2017-07-14, Johannes Schwab  wrote:
>> Here is the code:
>> R. = PolynomialRing(QQ, 'lex')
> That's not what you want.
> [...]
> Instead you have to do
>   sage: R. = PolynomialRing(QQ, order='lex')
> (i.e., specify what parameter is 'lex' being assigned to)

What does the polynomial ring constructor do with the 'lex' in the first
example? Why is no error raised?

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: Bug in groebner_basis()?

2017-07-14 Thread Simon King
Hi Johannes,

On 2017-07-14, Johannes Schwab  wrote:
> Here is the code:
> R. = PolynomialRing(QQ, 'lex')

That's not what you want.
  sage: R.term_order()
  Degree reverse lexicographic term order

Instead you have to do
  sage: R. = PolynomialRing(QQ, order='lex')
(i.e., specify what parameter is 'lex' being assigned to)

And then you'll get the correct result:
  sage: f = x^2 + 2*y
  sage: g = x*y - y^2 + 1
  sage: I = [f,g]*R
  sage: I.groebner_basis()
  [x - y^3 - 2*y^2 + y, y^4 + 2*y^3 - 2*y^2 + 1]

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.