CoCalc Shared Filessupport / 2016-04-15-094245-m2.sagews
Author: William A. Stein
Description: Examples for support purposes.
R.<x,y,z> = PolynomialRing(ZZ, 3, order='lex')
I = Ideal(13*x*y*z+6*x*y+78*x*z+36*x-11*y^2*z-66*y*z,
168*x*y*z+84*x*y+1008*x*z+504*x+12*y^3-154*y^2*z+72*y^2-924*y*z,
-168*x^2*y*z^2-84*x^2*y*z-1008*x^2*z^2-504*x^2*z+x*y^3*z+6*x*y^3+154*x*y^2*z^2+6*x*y^2*z+36*x*y^2+924*x*y*z^2-11*y^4*z-66*y^3*z
);
gI  = R*( I.groebner_basis(algorithm='macaulay2') )
len(gens(gI)) # expected 3
gI

3 Ideal (x*y*z - 6*x*y + 6*x*z - 36*x - 12*y^3 + 11*y^2*z - 72*y^2 + 66*y*z, 84*x*y + 504*x + 156*y^3 - 154*y^2*z + 936*y^2 - 924*y*z, 156*y^3*z + 72*y^3 - 154*y^2*z^2 + 936*y^2*z + 432*y^2 - 924*y*z^2) of Multivariate Polynomial Ring in x, y, z over Integer Ring

this is how to use M2 in a worksheet, but don't do this...

%macaulay2
R = ZZ[x,y,z,MonomialOrder=>Lex]
I = ideal{13*x*y*z+6*x*y+78*x*z+36*x-11*y^2*z-66*y*z,
168*x*y*z+84*x*y+1008*x*z+504*x+12*y^3-154*y^2*z+72*y^2-924*y*z,
-168*x^2*y*z^2-84*x^2*y*z-1008*x^2*z^2-504*x^2*z+x*y^3*z+6*x*y^3+154*x*y^2*z^2+6*x*y^2*z+36*x*y^2+924*x*y*z^2-11*y^4*z-66*y^3*z}
gens gb I

R PolynomialRing 2 3 2 2 2 2 2 2 2 2 3 3 2 2 2 2 2 4 3 ideal (13x*y*z + 6x*y + 78x*z + 36x - 11y z - 66y*z, 168x*y*z + 84x*y + 1008x*z + 504x + 12y - 154y z + 72y - 924y*z, - 168x y*z - 84x y*z - 1008x z - 504x z + x*y z + 6x*y + 154x*y z + 6x*y z + 36x*y + 924x*y*z - 11y z - 66y z) Ideal of R | 156y3z+72y3-154y2z2+936y2z+432y2-924yz2 84xy+504x+156y3-154y2z+936y2-924yz xyz-6xy+6xz-36x-12y3+11y2z-72y2+66yz | 1 3 Matrix R <--- R
v = macaulay2('gens gb I')

str(v)

| 156y3z+72y3-154y2z2+936y2z+432y2-924yz2 84xy+504x+156y3-154y2z+936y2-924yz xyz-6xy+6xz-36x-12y3+11y2z-72y2+66yz |
v.sage_polystring()

'map((R)**1,(R)**{{-4},{-3},{-3}},{{156*y**3*z+72*y**3-154*y**2*z**2+936*y**2*z+432*y**2-924*y*z**2, 84*x*y+504*x+156*y**3-154*y**2*z+936*y**2-924*y*z, x*y*z-6*x*y+6*x*z-36*x-12*y**3+11*y**2*z-72*y**2+66*y*z}})'