-- This is code related to HW 3 for Math 615, Winter 2013 -- By: Daniel Erman -- Exercise 2 -- Here is how to use Macaulay2 to compute the hilbert polynomial in one of the examples. S = QQ[x,y,z,w] I = ideal(y*z-x*w,z^3-y*w^2,x*z^2-y^2*w,y^3-x^2*z) -- Rather than computing the Hilbert function of I, let's work with the initial ideal of I. leadTerm I -- leadTerm(I) computes a grobner basis for I and then returns the generators as a matrix -- So if you want the initial ideal, you should type "J = ideal leadTerm I" J = ideal leadTerm I hilbertPolynomial(J) -- The default output of the command "hilbertPolynomial" is a bit funny. -- In particular, it writes the Hilbert polynomial with respect to the basis -- of binomial coefficients. So P_e denotes the function P_e(i) = \binom{e+i}{i} in QQ[i]. -- If you set the option "Projective" to "false", then you can get the Hilbert polynomial -- written as a polynomial in QQ[i] in the natural way. hilbertPolynomial(J,Projective => false) viewHelp hilbertPolynomial -- One important caveat: basically whenever you ask M2 to compute something for an ideal J, -- it actually computes that value for the quotient ring S/J. -- Thus, for instance hilbertPolynomial(J) == hilbertPolynomial(S/J) -- This is an abuse of notation on M2's part, so be careful. -- For the Hilbert function, you can get individual values by, for example: hilbertFunction(3,J) -- We'll also discuss the Hilbert series in an upcoming lecture, and this can be computed by hilbertSeries(J) -- Exercise 5 -- The key thing to remember in this Exercise is how to change the monomial order in a ring. -- Remember that GRevLex is the default order. Here is the syntax for part (a) of this problem. -- I think that it is useful to do track the time it takes in each case, as well. -- Tacking on "time" in front of a command will return the computation time as well. S = QQ[x,y,z]; I = ideal(x^5+y^4+z^3-1, x^3+y^2+z^2-1) time gens gb I S = QQ[x,y,z, MonomialOrder => Lex]; I = ideal(x^5+y^4+z^3-1, x^3+y^2+z^2-1) time gens gb I -- Actually displaying the generators of the Grobner basis is a bit unwieldy. But -- if you want to see the degree of the entries in the Grobner basis, you can type degrees ideal gens gb I