proc displayHilbPoly(ideal G) "USAGE: displayHilbPoly(G), G of type ideal ASSUME: G must be a homogeneous Groebner basis for an ideal of the active ring in the SINGULAR session; say, G generates the homogeneous ideal I of R. RETURN: None. NOTE: Displays the Hilbert polynomial of R/I. " { int d = dim(G)-1; // degree of Hibert polynomial intvec co = hilb(G,2); // representation II of Hilbert series int s = size(co)-1; // s = deg(Q_M) +1 ring Qt = 0, t, dp; // change active ring to Q[t] poly QM = 0; for (int i=1; i<=s; i=i+1) { QM = QM+co[i]*t^(i-1); } poly QMi = QM; // the polynomial Q_M(t) int ifac = 1; list a; for (i=1; i<=d+1; i=i+1) { a = insert(a, subst(QMi,t,1)/ifac, i-1); QMi = diff((QMi),t); ifac = ifac*i; } poly PM = (-1)^(d)*a[d+1]; poly bin = 1; for (i=1; i<=d; i=i+1) { bin = bin*(t+i)/i; // compute binomial coeff. by recursion PM = PM+(-1)^(d-i)*a[d+1-i]*bin; } print(PM); }