120 CHAPTER 4. ALGORITHMS FOR STABLE IDEALSThe advantage <strong>of</strong> the above algorithm is that it can be used to compute single valuesh R/I (i) <strong>of</strong> a Hilbert function for large i ∈ N efficiently. The algorithm stated in Remark4.25 would have to compute h R/I (j) for all j < i to obtain h R/I (i), whereas the abovealgorithm can be implemented in so far that it first checks whether the value <strong>of</strong> i is largerthan the integer k <strong>of</strong> Lemma 4.26. If this is the case, there is no need to compute all valuesh R/I (j) for j < i. It suffices to compute the Hilbert polynomial, from which one obtainsh R/I (i). Next we give the source code <strong>of</strong> a possible implementation <strong>of</strong> the above algorithmin MuPAD.MuPAD Source Code 4.28. Let H = H(t) be the numerator <strong>of</strong> a reduced Hilbert series<strong>of</strong> R/I for I ⊂ R a saturated stable ideal. Let d be the exponent <strong>of</strong> (1 − t) in the denominator<strong>of</strong> H and n the index <strong>of</strong> the last variable in R. The procedure below computes thevalues <strong>of</strong> the corresponding Hilbert function up to an upper bound, which has to be givenas the third argument for the procedure.Input for the procedure compute Hilbert function.◦ H — the numerator <strong>of</strong> a reduced Hilbert series◦ d — the power <strong>of</strong> (1 − t) in the denominator <strong>of</strong> the Hilbert series◦ upper bound — the value, i.e. the upper bound, up to which the values <strong>of</strong> the Hilbertfunction (associated to the given Hilbert series) should be computed◦ n — the index <strong>of</strong> the last variable <strong>of</strong> the polynomial ring ROutput <strong>of</strong> the procedure compute Hilbert function.◦ values — a list containing the values <strong>of</strong> the Hilbert functioncompute_Hilbert_function:= proc(H, d, upper_bound, n)local coeffs, values, i, j, p, L_p, lastMon, G_bound;begincoeffs:= [coeff(poly(expand(1-t)^d, [t]))]:values:= [0 $ upper_bound + 1]:values[1]:= 1:p:= compute_Hilbert_polynomial2(H, d):L_p:= compute_L_p(p, n):lastMon:= L_p[nops(L_p)]:G_bound:= _plus(lastMon[i] $ i = 1..n+1):for i from 2 to d+1 dovalues[i]:= coeff(H,i-1):for j from 1 to i-1 dovalues[i]:= values[i] - (values[i-j] * coeffs[d+1-j])
4.7. COMPUTING ALL HILBERT FUNCTIONS TO A HILBERT POLYNOMIAL 121end_for:end_for:for i from d+2 to G_bound - 1 dovalues[i]:= coeff(H,i-1):for j from 1 to d dovalues[i]:= values[i] - (values[i-j] * coeffs[d+1-j])end_for:end_for:/* Now compute the Hilbert function with the Hilbert polynomial. */for i from G_bound to upper_bound+1 dovalues[i]:= p(i-1):end_for:return(values);end_proc:Example 4.29. We determine the values <strong>of</strong> the Hilbert functions associated to the Hilbertseries computed in Example 4.24.MuPAD>> compute_Hilbert_function(poly(-t^7+t^4+t^3+t^2+t+1,[t]),2,10,4);>> compute_Hilbert_function(poly(-t^4+t^3+t^2+2*t+1,[t]),2,10,4);>> compute_Hilbert_function(poly(-2*t^6+t^5+t^4+t^3+t^2+t+1,[t]),2,10,4);>> compute_Hilbert_function(poly(-t^3+2*t^2+2*t+1,[t]),2,10,4);>> compute_Hilbert_function(poly(-t^6+t^4+t^3+2*t+1,[t]),2,10,4);>> compute_Hilbert_function(poly(-t^5+t^4+t^3-t^2+3*t+1,[t]),2,10,4);>> compute_Hilbert_function(poly(3*t+1,[t]),2,10,4);>> compute_Hilbert_function(poly(-t^5+t^4+t^2+2*t+1,[t]),2,10,4);Output[1, 3, 6, 10, 15, 20, 25, 29, 33, 37, 41][1, 4, 8, 13, 17, 21, 25, 29, 33, 37, 41][1, 3, 6, 10, 15, 21, 25, 29, 33, 37, 41][1, 4, 9, 13, 17, 21, 25, 29, 33, 37, 41][1, 4, 7, 11, 16, 21, 25, 29, 33, 37, 41][1, 5, 8, 12, 17, 21, 25, 29, 33, 37, 41][1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41][1, 4, 8, 12, 17, 21, 25, 29, 33, 37, 41]