Multivariate polynomial division using // operator

63 views
Skip to first unread message

Jaya Kediya

unread,
Jan 24, 2024, 1:42:42 AMJan 24
to Macaulay2
Hi, I'm trying to perform multivariate polynomial division where remainder is either 0 or a linear combination of leading terms of the divisors. One such example is shown in the picture below
 div2.2 (1).png
I have tried doing the same with the // operator by putting divisors in a matrix but that seems to give a different output as shown

CODE :
R=QQ[x,y,z,MonomialOrder=>Lex];
g1=x*y-1;
g2=y^2-1;
g3=x^2*y+y^2*x+y^2;
I= ideal((g2),(g1))

(g3)//gens I

g3% gens I

OUTPUT:
      Screenshot 2024-01-24 121053.png

Please help me spot the problem here thank you!

Doug Torrance

unread,
Jan 24, 2024, 6:02:02 AMJan 24
to Macaulay2
There's no problem with the answer, as it's also correct:

i8 : A = g3 // gens I

o8 = {2} | -x2y-2xy2+2y+1 |
     {2} | xy2+2y3        |

             2      1
o8 : Matrix R  <-- R

i9 : f = g3 % gens I

o9 = 2y + 1

o9 : R

i10 : gens I * A + f

o10 = | x2y+xy2+y2 |

              1      1
o10 : Matrix R  <-- R

i11 : oo_(0, 0) == g3

o11 = true

The problem is that, in general, multivariate polynomial division does not give a unique answer.  (That's one of the reasons for Groebner bases!)  In this example, g1 and g2 do *not* form a Groebner basis for I, so it's not surprising that we might get different results if we use slightly different algorithms (e.g., changing the order of the generators of the ideal).

This looks like one of the multivariate polynomial division examples from Cox, Little, and O'Shea, and here's some code implementing their division algorithm from Section 2.3:

polynomialDivision = (f, F) -> (
    s := #F;
    q := new MutableList from s:0;
    r := 0;
    p := f;
    while p != 0 do (
i := 0;
divisionOccurred := false;
while i < s and not divisionOccurred do (
    if leadTerm p % leadTerm F#i == 0 then (
q#i = q#i + leadTerm p // leadTerm F#i;
p = p - (leadTerm p // leadTerm F#i) * F#i;
divisionOccurred = true)
    else i = i + 1);
if not divisionOccurred then (
    r = r + leadTerm p;
    p = p - leadTerm p));
    (toList q, r))

This gives the same answer as in the book:

i14 : polynomialDivision(g3, {g2, g1})

o14 = ({x + 1, x}, 2x + 1)

Jaya Kediya

unread,
Jan 25, 2024, 3:30:40 AMJan 25
to maca...@googlegroups.com
This is very helpful, thank you!! 

--
You received this message because you are subscribed to the Google Groups "Macaulay2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to macaulay2+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/macaulay2/3f5c8548-020d-464c-be0a-76af5f354d4fn%40googlegroups.com.

Adam Boocher

unread,
Jun 7, 2024, 12:15:14 PMJun 7
to Macaulay2
Dear Doug, thank you very much for this!  I'm helping my students learn M2 and they are reading CLO.  This provides a great way to help them do Exercise 2.3.3 without having to code the algorithm by hand.  
Reply all
Reply to author
Forward
0 new messages