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

Division of polynomials produces errors when using local orderings #17638

Closed
enriqueartal opened this issue Jan 15, 2015 · 36 comments
Closed

Division of polynomials produces errors when using local orderings #17638

enriqueartal opened this issue Jan 15, 2015 · 36 comments

Comments

@enriqueartal
Copy link
Contributor

Consider two polynomials f,g in a ring define using a local ordering, e.g.,

R.<x,y>=PolynomialRing(QQ,order='neglex')

If the leading monomial of g is 1 then f/g will produces a wrong result, namely f divided by the independent coefficient of g. Note that in that case g.is_unit() yields True, since for Singular R is not Q[x,y] but the ordering localization (i.e., one can divide by the polynomials whose leading monomial is 1).

PS: It is my first ticket, I apologize for the mistakes.

CC: @simon-king-jena @sagetrac-jakobkroeker @slel

Component: commutative algebra

Keywords: Singular, days94

Author: Mckenzie West

Branch/Commit: 8dd8ebe

Reviewer: Luis Felipe Tabera Alonso, Thierry Monteil

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

@simon-king-jena
Copy link
Member

comment:2

Example:

sage: R.<x,y>=PolynomialRing(QQ,order='neglex')
sage: f = 1+y
sage: g = 1+x
sage: f/g
1 + y
sage: _*g==f
False

@enriqueartal
Copy link
Contributor Author

comment:3

As far as I remember, in the definition of the division of two polynomials, it checks first if the denominator is a unit. If it is, it divides each monomial by the indepent coefficient of the polynomial. There may be two possible solutions. The simple one would be to change this behavior for the division. A more permanent one, which was discussed in this thread proposes to create a new class of localized rings.

@simon-king-jena
Copy link
Member

comment:4

Note that this is the code of "div" for multivariate polynomial rings:

        cdef poly *p
        cdef MPolynomial_libsingular right = <MPolynomial_libsingular>right_ringelement
        cdef bint is_field = left._parent._base.is_field()
        if p_IsConstant(right._poly, right._parent_ring):
            if is_field:
                singular_polynomial_div_coeff(&p, left._poly, right._poly, right._parent_ring)
                return new_MP(left._parent, p)
            else:
                return left.change_ring(left.base_ring().fraction_field())/right_ringelement
        else:
            return (left._parent).fraction_field()(left,right_ringelement)

So, it is tested with the libsingular function !p_IsConstant whether the divisor is constant, hence, we can divide by the leading coefficient. I bet !p_IsConstant assumes a positive ordering and just tests whether the leading monomial is of degree zero.

@sagetrac-jakobkroeker
Copy link
Mannequin

sagetrac-jakobkroeker mannequin commented Mar 4, 2017

Changed keywords from none to Singular

@mckenziewest
Copy link

comment:7

I checked the example again and it now works, is this fixed?

sage: R.<x,y>=PolynomialRing(QQ,order='neglex')
sage: f = 1+y
sage: g = 1+x
sage: f/g
(y + 1)/(x + 1)

@sagetrac-tmonteil
Copy link
Mannequin

sagetrac-tmonteil mannequin commented Jun 29, 2018

comment:8

Replying to @mckenziewest:

I checked the example again and it now works, is this fixed?

In any case, it deserves a dedicated doctest to prevent future regression.

@mckenziewest
Copy link

@mckenziewest
Copy link

Changed keywords from Singular to Singular, days94

@mckenziewest
Copy link

Commit: 989c4fc

@mckenziewest
Copy link

New commits:

989c4fcAdded test to verify division works

@lftabera
Copy link
Contributor

comment:12

This looks good to me. Note that the _div_ has not chaged.

Just one question, would it better if the test appears in src/sage/rings/polynomial/multi_polynomial_element.py? This is where the code in question is executed...

@lftabera
Copy link
Contributor

Author: Mckenzie West

@lftabera lftabera modified the milestones: sage-6.5, sage-8.3 Jun 30, 2018
@mckenziewest
Copy link

comment:13

I added the test to the definition of __div__ in src/sage/rings/polynomial/multi_polynomial_element.py
are you thinking somewhere else?

@lftabera
Copy link
Contributor

comment:14

yes, sorry, I was thinking of the method _div_ in
src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
which is where the actual _div_ is performed for this ring.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 2, 2018

Changed commit from 989c4fc to b958f36

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 2, 2018

Branch pushed to git repo; I updated commit sha1. New commits:

b958f36properly formated ::

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 2, 2018

Branch pushed to git repo; I updated commit sha1. New commits:

703ad58Removed print function from test

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 2, 2018

Changed commit from b958f36 to 703ad58

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 2, 2018

Changed commit from 703ad58 to c2c1e9e

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 2, 2018

Branch pushed to git repo; I updated commit sha1. New commits:

c2c1e9eremoved spacing for assignment within function

@sagetrac-tmonteil
Copy link
Mannequin

sagetrac-tmonteil mannequin commented Jul 2, 2018

comment:18

For reference, there is some documentation about formatting on the developer guide, see http://doc.sagemath.org/html/en/developer/coding_basics.html#python-code-style

In particular, you can add spacing between QQ, and order="neglex", and perhaps between the + (though the current code is already readable).

About the ::, just to make things clearer than our previous discussion:

blah

::

it the secure way to write blah followed by a block of code,

blah ::

is equivalent to the previous one.

However,

blah::

is equivalent to

blah:

::

which is therefore equivalent to:

blah: ::

[My personal preference goes to first and third, but it is up to you]

What was wrong in the commit 989c4fc (comment 10) was

Ensure that :trac:`17638` is fixed.::

wich will print both a dot and a column, but i fear that now you removed both, while it might be good to keep a column.

@slel

This comment has been minimized.

@slel
Copy link
Member

slel commented Apr 9, 2020

comment:24

Discussed on sage-devel at:

@slel slel modified the milestones: sage-8.4, sage-9.2 Apr 9, 2020
@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Sep 5, 2020
@mkoeppe
Copy link
Member

mkoeppe commented Feb 13, 2021

comment:26

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Feb 13, 2021
@mkoeppe
Copy link
Member

mkoeppe commented Jul 19, 2021

comment:27

Setting a new milestone for this ticket based on a cursory review.

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 May 3, 2022
@mkoeppe
Copy link
Member

mkoeppe commented May 4, 2022

comment:30

Replying to @vbraun:

Merge conflict

The merge conflict has magically healed by itself.

@vbraun
Copy link
Member

vbraun commented May 15, 2022

comment:32

Merge failure on top of:

341d434082 Trac #33834: Fix map_reduce doctest

40dfa7a1a3 Trac #33828: Fix conda workflow

b90120d1cf Trac #33761: OpenSSL 3.0.3 security update

bdcb741 Trac #33700: Developer's guide: Expand on GitHub accounts and SSH keys

bf6aeb9 Updated SageMath version to 9.6

reviewer u'\u200bLuis Felipe Tabera Alonso, Thierry Monteil' does not look right

@mkoeppe
Copy link
Member

mkoeppe commented May 15, 2022

Changed reviewer from ​Luis Felipe Tabera Alonso, Thierry Monteil to Luis Felipe Tabera Alonso, Thierry Monteil

@mkoeppe
Copy link
Member

mkoeppe commented May 15, 2022

comment:34

removed the offending character

@vbraun
Copy link
Member

vbraun commented May 17, 2022

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

8 participants