Apart function (issue #12177) - DMP, converting Ring to a Field for multivariate polynomial

34 views
Skip to first unread message

Rishat Iskhakov

unread,
Feb 27, 2017, 9:33:37 AM2/27/17
to sympy

I've already been working on the issue for several days. I've created my own example:


In [9]: apart((x+y)/(2*x-y), x)
Out[9]: 0

The problem is that a domain of a fraction is identified as a ZZ[y] in this example. However it has to be QQ[y] for an apart to happen.


Generally, the division for polynomials is done using a DMP and this seems to work absolutely correct, however when the result is converted to a polynomial, non-integers (e.g. 1/2 and 3/2) are considered to be 0.


def to_field(f):


    """Make the ground domain a field. """


    return f.convert(f.dom.get_field())


I'm trying to compare two different expressions: (x+1)/(2*x-4) and (x+y)/(2*x-y) and apart them on x. The differences appear while converting a Ring to a Field: `get_field(self)` is different for each class.

It simply returns QQ for the IntegerRing, which is correct, while for PolynomialRing the code is more complicated. It initializes a new PolyRing class, which preprocesses domain according to it’s options and returns a new class: Rational function field in y over ZZ with lex order. So the Ring ZZ[x] is converted to a ZZ(x) field. But this way the division will never happen correctly, if I'm right.


If I manually change the automatically detected domain to a QQ[y], apart functions works fine, however I do not pass some tests, e.g.

assert ZZ[x].get_field() == ZZ.frac_field(x)


Aaron Meurer

unread,
Feb 27, 2017, 2:09:11 PM2/27/17
to sy...@googlegroups.com
ZZ[x] -> ZZ(x) is correct for get_field.

There are likely some calls to quo(), or maybe some other algorithm,
which need to be passed field=True to get the right behavior in
apart().

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/7710087e-23a1-4218-90df-e3f4811e6f58%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages