newPackage( "Sept19", Version => "1.0", Date => "Sept 19, 2016", Authors => {Name => "Martin Helmer"}, Headline => "Examples for Class Sept 19", DebuggingMode => false, Reload => true ); export{"Spoly" } Spoly = method(TypicalValue=>RingElement) Spoly(RingElement,RingElement) := (f,g) -> ( LcM:=lcm(leadMonomial f,leadMonomial g); Spol:=(LcM//leadTerm(f))*f-(LcM//leadTerm(g))*g; return Spol; ) TEST /// {* restart needsPackage "Sept19" *} R=QQ[x,y,MonomialOrder=>GLex] I=ideal(x^3-2*x*y,x^2*y-2*y^2+x) J=ideal groebnerBasis I --Now do Buchberger's algorithm F={I_0,I_1} f3=Spoly(I_0,I_1) --Append the new poly to our list F F=append(F,f3) f4=Spoly(f3,I_0) F=append(F,f4) --would still get non-zero remainder --add another f5=Spoly(f3,I_1) F=append(F,f5) --Now we finally get zero remainder J --Note that the last 3 we computed are infact enough... J==ideal(F) /// TEST /// {* restart --reduction with respect to a GB *} R=QQ[x,y,z] f=z^2-x^4*y I=ideal(-x^3+z,-x^2+y) --does reduction with respect to a GB of I, even if you haven't given it one. f%I --how to find a GB in M2 I=ideal groebnerBasis I f%I ///