-- This is code related to lectures from Feb 1
-- Math 615, Winter 2013
-- By: Daniel Erman
-- Basics
-- If you ask M2 to compute a Grobner basis, it will automatically compute the reduced GB,
-- and sort the basis elements by their leading terms
R = QQ[x,y, MonomialOrder => Lex]
viewHelp MonomialOrder
I = ideal(x^3,x^2*y+y^3)
gb I
-- The command "gb" will compute and store the Grobner basis, but it will not display it!
-- To see the actual Grobner basis, try:
gens gb I
-- Reduced GB Example from lecture
R = QQ[x,y]
-- Not specifying a monomial order means we use GRevLex
I = ideal(x^3+x*y^2, x*y+y^2)
gens gb I
-- Ideal membership example
-- we continue with the above notation.
f = x^2*y^3
f % I
-- this means that there has to be a way to write f = a*x^3+b*(x^2*y+y^3). What are a & b?
f // gens I
-- So this matrix provides a "witness" to the fact that f lies in I, namely:
M = f // gens I;
(gens I)*M == f
-- Elimination of variables examples
R = QQ[x,a,b,c, MonomialOrder => Lex]
f = a*x^2+b*x+c;
I=ideal(f,diff(x,f))
gens gb I
R = QQ[x,y,a,b, MonomialOrder => Lex]
f = y^2-x^3-a*x-b;
I=ideal(f,diff(y,f),diff(x,f))
gens gb I
-- Here is an example that I didn't do in class. This involves projecting an elliptic
-- curve V(I) in PP^3 down to PP^2 via the map [x:y:z:w] --> [y:z:w].
R = QQ[x,y,z,w, MonomialOrder=> Lex]
I = ideal(x*w-y*z,x*y+z^2+w^2)
dim (minors(2,jacobian I) + I)
degree I
gens gb I
-- the first entry of the above matrix is the defining equation of the curve inside of PP^2.
(gens gb I)_(0,0)
-- Solving polynomial equations
R = QQ[x,y, MonomialOrder=> Lex]
I = ideal(x^2+2*y^2-3,x^2+x*y+y^2-3)
degree I
gens gb I
-- so y^3-y=0. Thus y=0,1, or -1.
-- Now substituting these values for y and solving yields the remaining solutions.
-- Implicitization
-- This is the implicitization example from class, where we compute the image of a
-- map AA^2-->AA^3.
R = QQ[s,t,x,y,z, MonomialOrder=> Lex]
I = ideal(x-s^2-t^2,y-s^3-t^3,z-s*t)
(gens gb I)_(0,0)
-- Radical membership
-- Here is a radical membership example
R = QQ[x,y]
I = ideal(x^3-x^2*y, x*y^2+y^3)
-- Let's show that x belongs to the radical of I.
S = R[t]
J = I+ideal(1-t*x)
gens gb J
-- By Rabinovitch's trick, we see that x lies in the radical of I.