source: git/Tst/BuchDL/Sol_Exe_1.tst @ c2400ce

spielwiese
Last change on this file since c2400ce was 9558c5f, checked in by Hans Schönemann <hannes@…>, 19 years ago
*hannes/lossen: very long examples from DL-Book git-svn-id: file:///usr/local/Singular/svn/trunk@8762 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.9 KB
Line 
1LIB "tst.lib";
2tst_init();
3
4
5//======================  Exercise 1.1 =============================
6ring R;
7R;
8poly f = x^4+x^3*z+x^2*y^2+y*z^4+z^5;
9f;
10ring S = 32003, (x,y,z), lp;
11poly g = fetch(R,f);
12g;
13
14
15kill R,S;
16//======================  Exercise 1.2 =============================
17ring R = 32003, x(1..5), lp;
18int d = 5;
19ideal MId = maxideal(d);
20int s = size(MId);
21int i,j;
22ideal I;
23for (i=1; i<=10; i++)
24{
25  poly f(i);
26  for (j=1; j<=s; j++)
27  {
28    f(i) = f(i)+random(0,32002)*MId[j];
29  }
30  I = I, f(i);
31}
32
33// -------------Alternatively--------------
34kill I;
35if (not(defined(randomid))) { LIB "random.lib"; }
36ideal I = randomid(maxideal(d),10,32002);
37// ----------------------------------------
38
39int aa = timer;
40ideal II = groebner(I);
41size(II);
42II;
43deg(II[1]);
44deg(II[size(II)]);
45write (":w lexGB.out",II);
46ring R1 = 32003, x(1..5), dp;
47ideal I = imap(R,I);
48aa = timer;
49ideal II = std(I);
50size(II);
51II;
52deg(II[1]);
53deg(II[size(II)]);
54write (":w dpGB.out",II);
55
56
57kill R,R1,aa,i,j,s,d;
58//======================  Exercise 1.3 =============================
59ring R = 0, x(0..4), dp;
60matrix M[2][4] = x(0),x(1),x(2),x(3),
61                 x(1),x(2),x(3),x(4);
62ideal I = minor(M,2);
63resolution rI = mres(I,0);
64print(betti(rI),"betti");
65for (int i=1; i<=3; i++)
66{
67  i,"th syzygy matrix: ";   
68  "--------------------- ";   
69  print(rI[i]);
70  "";   
71  "has data type : ", typeof(rI[i]);   
72  "";
73}
74ideal GI = groebner(I);
75hilb(GI);
76matrix JM = jacob(I);
77int codimI = nvars(R) - dim(GI);
78ideal singI = minor(JM,codimI) + I;
79nvars(R) - dim(groebner(singI));
80//-> 5
81
82// -------------Alternatively--------------
83if (not(defined(slocus))){ LIB "sing.lib"; }
84nvars(R) - dim(groebner(slocus(I)));
85//-> 5
86// ----------------------------------------
87
88
89kill R,i,codimI;
90//======================  Exercise 1.4 =============================
91proc maximaldegree (ideal I)
92"USAGE:  maximaldegree(I);   I=ideal
93RETURN: integer; the maximum degree of the given
94                 generators for I
95NOTE:   return value is -1 if I=0
96"
97{
98  if (size(I)>0)
99  {
100    int i,dd;
101    int d = deg(I[1]);
102    for (i=2; i<=size(I); i++)
103    {
104      dd = deg(I[i]);
105      if (dd>d) { d = dd; }
106    }
107    return(d);
108  }
109  else
110  {
111    return(-1);
112  }
113}
114
115ring R = 32003, x(1..5), lp;
116string xxx = "ideal II="+read("lexGB.out")+";";
117execute(xxx);
118maximaldegree(II);
119xxx = "ideal JJ="+read("dpGB.out")+";";
120execute(xxx);
121maximaldegree(JJ);
122
123
124kill R,xxx;
125//======================  Exercise 1.5 =============================
126ring P2 = 0, (u,v,w), dp;
127ideal emb = u2, v2, w2, uv, uw, vw;
128ideal I0 = ideal(0);
129ring P5 = 0, x(0..5), dp;
130ideal VP5 = preimage(P2, emb, I0);
131print(betti(list(VP5)),"betti");
132
133ideal p = x(0), x(1), x(2), x(3)-x(5), x(4)-x(5);
134size(reduce(VP5,groebner(p),1));
135ring P4 = 0, x(0..4), dp;
136ideal VP4 = preimage(P5,p,VP5);
137print(betti(list(VP4)),"betti");
138// ---------- Check Smoothness ------------
139if(not(defined(slocus))){ LIB "sing.lib"; }
140nvars(P4) - dim(groebner(slocus(VP4)));
141//-> 5
142// ----------------------------------------
143
144if(not(defined(sat))){ LIB "elim.lib"; // loads random.lib, too }
145ideal CI1 = randomid(VP4,2,100);
146ideal QES = sat(CI1,VP4)[1];
147resolution FQES = mres(QES,0);
148print(betti(FQES),"betti");
149// ---------- Check Smoothness ------------
150nvars(P4) - dim(groebner(slocus(QES)));
151//-> 5
152// ----------------------------------------
153
154setring P5;
155ideal q = x(0)-x(1), x(1)-x(2), x(2)-x(3), x(3)-x(4), x(4)-x(5);
156size(reduce(VP5,groebner(q),1));
157setring P4;
158ideal CS = preimage(P5,q,VP5);
159print(betti(list(CS)),"betti");
160// ---------- Check Smoothness ------------
161nvars(P5) - dim(groebner(slocus(CS)));
162//-> 6
163// ----------------------------------------
164ideal CI2 = matrix(CS)*randommat(3,2,maxideal(1),100);
165ideal B = sat(CI2,CS)[1];
166print(betti(list(B)),"betti");
167
168setring P5;
169ideal L = x(0)+x(1)+x(2), x(3), x(4), x(5);
170nvars(P5) - dim(groebner(VP5+L));
171//-> 6
172ring P3 = 0, y(0..3), dp;
173ideal SRS = preimage(P5,L,VP5); SRS;
174//-> y(1)^2*y(2)^2-y(0)*y(1)*y(2)*y(3)+y(1)^2*y(3)^2+y(2)^2*y(3)^2
175
176tst_status(1);$
177
Note: See TracBrowser for help on using the repository browser.