These are chat archives for symengine/symengine

14th
Jun 2016
Srajan Garg
@srajangarg
Jun 14 2016 05:31
Still not clear as to why SymPy chose to return 0. I'll ask on the the SymPy gitter
Isuru Fernando
@isuruf
Jun 14 2016 05:31
What do you mean sympy returns 0?
Srajan Garg
@srajangarg
Jun 14 2016 05:32
5x**2 / 2x
quotient is zero, while remainder is 5x**2
Isuru Fernando
@isuruf
Jun 14 2016 05:32
Can you give the full code?
Srajan Garg
@srajangarg
Jun 14 2016 05:32
I have pasted above
Isuru Fernando
@isuruf
Jun 14 2016 05:34
What do you expect as the solution?
Srajan Garg
@srajangarg
Jun 14 2016 05:35
I expect
Out[16]: (Poly(2*x, x, domain='ZZ'), Poly(x**2, x, domain='ZZ'))
That's what Flint outputs too
Isuru Fernando
@isuruf
Jun 14 2016 05:35
Remainder should have degree less than the divisor right?
Srajan Garg
@srajangarg
Jun 14 2016 05:36
No, this division is not euclidean anymore (as we force it into intger ring) , so we can't promise that http://docs.sympy.org/0.6.7/modules/polynomials.html
In any case, expected and sympy remainder have same degree
Isuru Fernando
@isuruf
Jun 14 2016 05:37
Then what's the point of a remainder?
sympy remainder is 0
Srajan Garg
@srajangarg
Jun 14 2016 05:37
No
It's 5*x**2
Isuru Fernando
@isuruf
Jun 14 2016 05:38
ah okay. I thought it was the other way around
Srajan Garg
@srajangarg
Jun 14 2016 05:40
So sympy says 5x**2 = (0 * 2x) + 5x**2, while I feel expected should be 5x**2 = (2x * 2x) + x**2
Isuru Fernando
@isuruf
Jun 14 2016 05:41
Okay. Can you ask on sympy?
Srajan Garg
@srajangarg
Jun 14 2016 05:41
Yes, will do
Srajan Garg
@srajangarg
Jun 14 2016 07:02
@isuruf Can you see what sage does?
Isuru Fernando
@isuruf
Jun 14 2016 07:05
@srajangarg, you can use https://cloud.sagemath.com/
Srajan Garg
@srajangarg
Jun 14 2016 07:07
thanks
Srajan Garg
@srajangarg
Jun 14 2016 07:30
Sage returns same as flint, which is expected
sage: R, t = ZZ['t'].objgen()
sage: p = 5*t**2
sage: q = 2*t
sage: p.quo_rem(q)
(2*t, t^2)
Srajan Garg
@srajangarg
Jun 14 2016 11:45
@isuruf what do you think? sage and flint show something else, while sympy sticks to something else. Do you know who I can ask about this in sympy? someone who has contributed to the poly module there
Sumith Kulal
@Sumith1896
Jun 14 2016 11:49
It's Mateusz's work
We can ask him if this is blocking
Kalevi Suominen
@jksuom
Jun 14 2016 14:00
The operation quo_rem is mathematically well defined only in so-called Euclidean domains. They are principal ideal domains (PIDs) equipped with a 'Euclidean function. ZZ[t] is not a PID, so there is no universal agreement on how quo_rem should be defined. I think that there are some appealing features in the way it is defined in sage, but one cannot say that SymPy's way would be wrong, either.
Kalevi Suominen
@jksuom
Jun 14 2016 14:54
It seems that the main (only?) practical use of quo_rem in non-Euclidean domains is for testing if an element is divisible by another. That happens when the remainder vanishes. Both ways of defining quo_rem in ZZ[t] can be used to decide this.
Srajan Garg
@srajangarg
Jun 14 2016 15:27
That makes a lot of sense. Considering the only practical use of quo_rem is as you mentioned, testing divisibility, it does not make a difference. But the problem for SymEngine is that, we have two types of Polynomial classes UIntPoly (symengine's implementation) and UIntPolyFlint (the flint poly wrapper). When calling quo_rem on two (same) polys of both types, a user should get the same answer (and he would be expecting the same too). As a library I feel there must be this consistency.
@isuruf if the main purpose of quo_rem is as above, can we just skip upoly_div? Piranha also doesn't give an answer to it.
Isuru Fernando
@isuruf
Jun 14 2016 15:37
we can revisit when gcd is done. sage has fraction fields. http://combinat.sagemath.org/doc/reference/rings/sage/rings/fraction_field_element.html