//SINGULAR Mathematica for UNIX/Linux SINGULARlink[J_List,P_Integer,tord_String] := Module[ {i,vars,F,p,subst,varnames,SINGULARin,SINGULARout}, F=J; vars=Variables[F]; (* Substitution of Variable names *) varnames = Table[ ToExpression[ "x[" <> ToString[i] <> "]"], {i, 1, Length[vars]} ]; subst = Dispatch[MapThread[Rule, {vars, varnames} ]]; F = F /. subst; singF = ToString[F // InputForm]; singF = StringReplace[ singF, { "{"->"", "}"->"", ", "->",\n", "]"->")", "["->"(" } ]; If[P>0, p=P, (*Else*) p=0]; (* Prepare Singular input string *) SINGULARin = "ring R =" <> ToString[p] <> ", (" <> "x(1.." <> ToString[Length[vars]] <> ")), (" <> tord <> ");\n"; (* Define the ideal... *) SINGULARin = SINGULARin <> "ideal I =" <> singF <> " ;\n" <> "short=0;\n" <> "ideal b = std(I);\n" <> "write(\".tmp.sing.mathematica\",b );\n" <> "quit;\n"; (* Call Singular ... *) SINGULARin // OutputForm >> "!Singular -q"; SINGULARout=ReadList[".tmp.sing.mathematica",String]; >>"!rm .tmp.sing.mathematica"; SINGULARout= StringReplace[SINGULARout , { ")"->"]", "("->"[" } ]; SINGULARout= "{" <> SINGULARout <> "}"; SINGULARout= ToExpression[SINGULARout]; subst = Dispatch[MapThread[Rule, {varnames, vars} ]]; SINGULARout=SINGULARout/. subst; SINGULARout ] f=x^10+x^9*y^2; g=y^8-x^2*y^7; J=SINGULARlink[{f,g},0,"dp"]; J // InputForm