1

I want to compute remainders in Python for multivariate polynomials and I found that div() from sympy should do the trick (I also need sympy for Gröbner computations). But the problem I keep finding is that it seems that div() only checks the leading term for division because

q, r = div(x**2 + y, 2*x)

gives r=y, while

q, r = div(x**2 + y, 2*y) 

gives r=x**2+y.

I want to do things like Ideal Membership, hence finding the remainder of some polynomial f on division by G={g_1,...,g_s}, where by above I now cannot rely upon div().

Whilst working with Sage I don't get this problem (using (x^2+y)%y gives x^2), but I'm more familier with Python and prefer to do this via Python.

Can someone please tell me if I'm doing something wrong? Or does someone know a better function to use for remainders?

Andreas K.
  • 9,282
  • 3
  • 40
  • 45
Robert
  • 43
  • 4
  • There are Groebner basis methods, such as `groebner([g]).reduce(f)` and `groebner([g]).contains(f)`, but I couldn't make them work on your example. –  Feb 11 '18 at 18:33
  • Thank you for your very quick respond. I feel bad for not answering earlier, but I finally found a good alternative: reduced(x^2+y,[2*y]) gives the desired ([1/2], x^2) – Robert Apr 17 '18 at 08:19
  • Post it as an answer, please. –  Apr 17 '18 at 10:54

1 Answers1

1

I found a good alternative: reduced(x**2+y, [2*y]) gives the desired ([1/2], x^2).

Andreas K.
  • 9,282
  • 3
  • 40
  • 45
Robert
  • 43
  • 4