//SINGULAR ExampleA.8.12
LIB"random.lib";
int r = 5;
ring R = 0,x(0..r),dp;
ring S = 0,(s,t),dp;
ideal I = maxideal(r); //s^r, s^(r-1)*t,..., s*t^(r-1), t^r
ideal zero;
map phi = R,I; //R --> S, x(i) --> s^(r-i)*t^i
setring R;
ideal I = preimage(S,phi,zero); //kernel of map phi R --> S
I = std(I); //ideal of rational normal curve C
dim(I); //dimension of affine cone over C
degree(I);
ideal L = sparsepoly(1,1,0,10); //a general linear form
//?sparsepoly; explains the syntax
ideal CL = std(I+L+(x(0)-1)); //ideal of intersection of C
//with L=0
//in affine chart x(0)=1
vdim(CL); //number of intersection points is 5
LIB"primdec.lib";
vdim(std(radical(CL)));