Ask Your Question

# How to implement the multivariable division algorithm without passing to Grobner bases?

Hi, I'm new to Sage, and I'm wondering how to implement the multivariable division algorithm in Sage. I pulled up the "Multivariate Polynomials via libSINGULAR" page of the Sage Reference Manual v7.1, but it wasn't helpful. What I'm wanting is a generalization of the quo_rem command that can take in more than one argument on the right and follows the division algorithm with respect to a fixed monomial ordering and the order that the polynomials are entered in. Is there any set of commands that does that for me? If so, would you please include the code, say for the following example?

Divide the polynomial yx^2 + xy^2 + y^2 by xy-1 and y2 -1 (in that order) using the lexicographic ordering with x>y. I would like to process more complicated examples, perhaps with that order and dividing by 8 things at once rather than 2.

I've learned about the p.mod(I) and p.reduce(I) commands where p is a polynomial and I is an ideal. The problem with those is that they seem to pass to a Grobner basis for I to get a "canonical" remainder rather than the remainder we'd get from the given order of the polynomials, as I tested switching the order of the polynomials in defining an ideal I and it did not change my answer for p.mod(I) or p.reduce(I).

Thanks!

edit retag close merge delete

## 1 answer

Sort by » oldest newest most voted

It seems that there is no method readily available for what you want. Though, it is not too hard to write it. For instance, if you simply want the remainder in this long division, you can act as follows where you see that the order matters:

sage: R.<x,y> = PolynomialRing(QQ, order="lex")
sage: p = x*y^2+x*x*y+y**2
sage: q = x*y-1
sage: r = y^2-1
sage: p % q % r
x + y + 1
sage: p % r % q
2*x + 1


Now if you want a more general function, you can implement it as follows:

sage: def remainder(p, L):
....:     r = p
....:     for q in L:
....:         r = r % q
....:     return r
....:
sage: remainder(p, [q, r])
x + y + 1
sage: remainder(p, [r, q])
2*x + 1


You may also want to keep the quotients:

sage: def list_quo_rem(p, L):
....:     r = p
....:     quo = []
....:     for q in L:
....:         Q, R = r.quo_rem(q)
....:         quo.append(Q)
....:         r = R
....:     return (quo, r)
....:
sage: list_quo_rem(p, [q, r])
([x + y, 1], x + y + 1)
sage: list_quo_rem(p, [r, q])
([x + 1, x], 2*x + 1)

more

## Comments

Thank you so much! I wish I could at least award you karma for this, but it seems I can't since I don't have enough myself.

One more question: How are we defining the object L? Is it the ideal generated by the pair q and r, is it an ordered list, or is it something else?

Thanks again!

The object L in my code is any iterable, a list for instance. If you work with an ideal I, I.gens() is such an iterable so you can call remainder(p, I.gens()) for instance.

As a corollary question: would you happen to know how I could get all possible remainders from all possible orders with one command? If I'm dividing 5 or 6 things at once, iterating the program you've written to get all possible remainders isn't very practical to type out. It looks like I might need to do that to test the examples I've come up with to test my conjecture. Thanks!

You can use the permutation groups. Suppose you have a list L of polynomials (which can be I.gens() for some ideal), then you can do the following:

sage: S = SymmetricGroup(len(L))
sage: for s in S: # = for each permutation of the elements
....:     print list_quo_rem(p, s(L))


## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2016-03-31 14:00:13 -0500

Seen: 949 times

Last updated: Apr 01 '16