--------[ 3 points in P^2 ]-------- /* first we define the polynomial ring the INDETERMINATES are SINGLE LOWER-CASE letters */ Use P ::= Q[x,y,z]; -- we end each command with ";" /* now we define 3 points: the VARIABLES are strings STARTING with an UPPER-CASE letter */ Point1 := [1, 0, 0]; Point2 := [0, 1, 0]; Point3 := [1, 2, 3]; Points := [Point1, Point2, Point3]; I := IdealOfProjectivePoints(Points); I; Res(I); Hilbert(P/I); --------[ 6 points in P^3 ]-------- Use S ::= Q[x,y,z,w]; -- 6 generic points Res(IdealOfProjectivePoints(GenericPoints(6))); -- 3 on a line and 3 on another line /* a "mathematical" way to define a list: */ -- { ( 1, I^2, 0, 0 ) | I In 1..3 } L1 := [ [ 1, I^2, 0, 0 ] | I In 1..3 ]; L1; L2 := [ [ 0, 0, Rand(-10,10), Rand(-1,3) ] | I In 1..3 ]; L2; I := IdealOfProjectivePoints(Concat(L1, L2)); RES := Res(I); RES; Describe RES; --------[ 15 points in P^8 ]-------- /* we can use indexed variables */ Use P ::= Q[x[0..8]]; I := IdealOfProjectivePoints(GenericPoints(13)); I; /* this helps to read a big list */ Set Indentation; I; /* when computations get hard, we can use finite characteristic */ Use P ::= Z/(32003)[x[0..8]]; I := IdealOfProjectivePoints(GenericPoints(13)); I; /* we may want to "explore" a list instead of printing it. For example we may be interested in the degrees of the generators */ Man("degree"); ?degree G := Gens(I); For N := 1 To Len(G) Do Print Deg(G[N]), " "; EndFor; /* Or equivalently (more "mathematically") */ Foreach G In Gens(I) Do Print Deg(G), " "; EndForeach; /* a little like Pascal syntax, but never "Begin" and always "End" : If ... Then ... End; While ... Do ... End; We can define functions: (no type declaration) */ Define StrangeFunction(I) Foreach G In Gens(I) Do If Deg(G, x[1])=4 Then Return TRUE End; EndForeach; Return FALSE; EndDefine; -- StrangeFunction ----------------------------------------------------------------- -- To get a good tutorial in CoCoA ?tutorial -- Or look at its HTML version, or the help window under GUI -- http://cocoa.dima.unige.it