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 On Mon, Feb 27, 2017 at 9:06 AM, Rishat Iskhakov <[email protected]> wrote: > 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) > > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > 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. -- 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 [email protected]. To post to this group, send email to [email protected]. 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/CAKgW%3D6%2BuQc2NgUs8MivDZEUavjYK7rKOsFTUWi8rMWbemCeLEw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
