Given a module over a local ring, a parameter ideal, and an integer, this method computes the Hilbert-Samuel function for the module. If parameter ideal is not given, the maximal ideal is assumed.
Note: If computing at index n is fast but slows down at n+1, try computing at range (n, n+1). On the other hand, if computing at range (n, n+m) is slow, try breaking up the range.
To learn more read Eisenbud, Commutative Algebra, Chapter 12.
Here is an example from Computations in Algebraic Geometry with Macaulay2, pp. 61:
i1 : R = QQ[x,y,z]; |
i2 : RP = localRing(R, ideal gens R); |
i3 : I = ideal"x5+y3+z3,x3+y5+z3,x3+y3+z5" 5 3 3 5 3 3 5 3 3 o3 = ideal (x + y + z , y + x + z , z + x + y ) o3 : Ideal of RP |
i4 : M = RP^1/I o4 = cokernel | x5+y3+z3 y5+x3+z3 z5+x3+y3 | 1 o4 : RP-module, quotient of (localRing (R, ideal (x, y, z))) |
i5 : elapsedTime length M -- 0.55 seconds -- 1.32431 seconds elapsed o5 = 27 |
i6 : elapsedTime hilbertSamuelFunction(M, 0, 6) -- 0.55 seconds -- 1.29899 seconds elapsed o6 = {1, 3, 6, 7, 6, 3, 1} o6 : List |
i7 : oo//sum o7 = 27 |
An example of using a parameter ideal:
i8 : R = ZZ/32003[x,y]; |
i9 : RP = localRing(R, ideal gens R); |
i10 : N = RP^1 1 o10 = (localRing (R, ideal (x, y))) o10 : RP-module, free |
i11 : q = ideal"x2,y3" 2 3 o11 = ideal (x , y ) o11 : Ideal of RP |
i12 : elapsedTime hilbertSamuelFunction(N, 0, 5) -- n+1 -- 0.02 seconds -- 0.0639001 seconds elapsed o12 = {1, 2, 3, 4, 5, 6} o12 : List |
i13 : elapsedTime hilbertSamuelFunction(q, N, 0, 5) -- 6(n+1) -- 0.32 seconds -- 0.629965 seconds elapsed o13 = {6, 12, 18, 24, 30, 36} o13 : List |
Hilbert-Samuel function with respect to a parameter ideal other than the maximal ideal can be slower.