# source:git/Tst/BuchDL/Sol_Exe_5.tst@9558c5f

spielwiese
Last change on this file since 9558c5f was 9558c5f, checked in by Hans Schönemann <hannes@…>, 18 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: 6.9 KB
Line
1LIB "tst.lib";
2tst_init();
3
4
5//======================  Exercise 5.1 =============================
6proc min_generating_set (matrix P,S)
7"USAGE:  min_generating_set(P,S);   P,S matrix
8ASSUME: The entries of P,S are homogeneous and ordered by ascending
9        degrees. The first entry of S equals 1. (As satisfied by
10        the first two output matrices of invariant_ring(G).)
11RETURN: ideal
12NOTE:   The given generators for the output ideal form a minimal
13        generating set for the ring generated by the entries of
14        P,S. The generators are homogeneous and ordered by
15        descending degrees.
16"
17{
18  if (defined(flatten)==0) { LIB "matrix.lib"; }
19  ideal I1,I2 = flatten(P),flatten(S);
20  int i1,i2 = size(I1),size(I2);
21  // We order the generators by descending degrees
22  // (the first generator 1 of I2 is omitted):
23  int i,j,s = i1,i2,i1+i2-1;
24  ideal I;
25  for (int k=1; k<=s; k++)
26  {
27    if (i==0) { I[k]=I2[j]; j--; }
28    else
29    {
30      if (j==0) { I[k]=I1[i]; i--; }
31      else
32      {
33        if (deg(I1[i])>deg(I2[j])) { I[k]=I1[i]; i--; }
34        else { I[k]=I2[j]; j--; }
35      }
36    }
37  }
38  intvec deg_I = deg(I[1..s]);
39  int n = nvars(basering);
40  def BR = basering;
41
42  // Create a new ring with elimination order:
43  //---------------------------------------------------------------
44  // ****    this part uses the command ringlist which is      ****
45  // ****     only available in SINGULAR-3-0-0 or newer        ****
46  //---------------------------------------------------------------
47  list rData = ringlist(BR);
48  intvec wDp;
49  for (k=1; k<=n; k++) {
50    rData[2][k] ="x("+string(k)+ ")";
51    wDp[k]=1;
52  }
53  for (k=1; k<=s; k++) { rData[2][n+k] ="y("+string(k)+ ")"; }
54  rData[3][1] = list("dp",wDp);
55  rData[3][2] = list("wp",deg_I);
56  def R_aux = ring(rData);
57  setring R_aux;
58  //---------------------------------------------------------------
59
60  ideal J;
61  map phi = BR, x(1..n);
62  ideal I = phi(I);
63  for (k=1; k<=s; k++) { J[k] = y(k)-I[k]; }
64  option(redSB);
65  J = std(J);
66
67  // Remove all generators that are depending on some x(i) from J:
68  int s_J = size(J);
69  for (k=1; k<=s_J; k++) { if (J[k]>=x(n)) {J[k]=0;} }
70
71  // The monomial order on K[y] is chosen such that linear leading
72  // terms in J are in 1-1 correspondence to superfluous generators
73  // in I :
75  intvec to_remove;
76  i=1;
77  for (k=1; k<=s; k++)
78  {
79    if (reduce(y(k),J_1jet)==0){ to_remove[i]=k; i++; }
80  }
81  setring BR;
82  if (to_remove == 0) { return(ideal(I)); }
83  for (i=1; i<=size(to_remove); i++)
84  {
85    I[to_remove[i]] = 0;
86  }
87  I = simplify(I,2);
88  return(I);
89}
90
91ring R1 = 0, (x,y), dp;
92matrix P[1][3] = x2+y2, x2-y2, x3-y3;
93matrix S[1][5] = 1, x-y, x3-xy2, x4-y4, xy3+y4;
94min_generating_set(P,S);
95//-> _[1]=x2-y2
96//-> _[2]=x2+y2
97//-> _[3]=x-y
98
99ring R = 2, x(1..4), dp;
100matrix A[4][4];
101A[1,4]=1; A[2,1]=1; A[3,2]=1; A[4,3]=1;
102if (not(defined(invariant_ring))){ LIB "finvar.lib"; }
103matrix P,S = invariant_ring(A);
104ideal MGS = min_generating_set(P,S);
105deg(MGS[1]);
106//-> 5
107
108
109kill R,R1;
110//======================  Exercise 5.2 =============================
111proc is_unit (poly f)
112"USAGE:  is_unit(f);   f poly
113RETURN: int;  1 if f is a unit in the active ring,
114              0 otherwise.
115"
116{
118}
119
120ring R = 0, (x,y), dp;
121poly f = 3+x;
122is_unit(f);
123ring R1 = 0, (x,y), ds;
124is_unit(imap(R,f));
125ring R2 = 0, (x,y), (ds(1),dp);
126is_unit(imap(R,f));
127ring R3 = 0, (x,y), (dp(1),ds);
128is_unit(imap(R,f));
129
130proc invert_unit (poly u, int d)
131"USAGE:   invert_unit(u,d);   u poly, d int
132RETURN:  poly;
133NOTE:    If u is a unit in the active ring, the output polynomial
134         is the power series expansion of the inverse of u up to
135         order d. Otherwise, the zero polynomial is returned.
136"
137{
138  if (is_unit(u)==0) { return(poly(0)); }
139  poly u_0 = jet(u,0);
140  u = jet(1-u/u_0,d);
141  poly u_1 = u;
142  poly inv = 1 + u_1;
143  for (int i=2; i<=d; i++)
144  {
145    u_1 = jet(u_1*u,d);
146    inv = inv + u_1;
147  }
148  return(inv/u_0);
149}
150
151setring R1;
152poly inv_f = invert_unit(imap(R,f),100);
154//-> 1/1546132562196033993109383389296863818106322566003x101
155
156
157kill R,R1,R2,R3;
158//======================  Exercise 5.3 =============================
159if (not(defined(minAssGTZ))){ LIB "primdec.lib"; }
160ring R = 0, (x,y,z), dp;
161poly f = ((x4+y4-z4)^4-x2y5z9)*(x4+y4-z4);
162ideal Slocf = f,jacob(f);
163list SLoc = minAssGTZ(Slocf);
164SLoc;
165//-> [1]:
166//->    _[1]=x4+y4
167//->    _[2]=z
168//-> [2]:
169//->    _[1]=y-z
170//->    _[2]=x
171//-> [3]:
172//->    _[1]=y+z
173//->    _[2]=x
174//-> [4]:
175//->    _[1]=y2+z2
176//->    _[2]=x
177//-> [5]:
178//->    _[1]=x2+z2
179//->    _[2]=y
180//-> [6]:
181//->    _[1]=y
182//->    _[2]=x+z
183//-> [7]:
184//->    _[1]=y
185//->    _[2]=x-z
186
187if (not(defined(hnexpansion))){ LIB "hnoether.lib"; }
188ring R_loc1 = 0, (u,v), ds;
189map phi = R,u,v-1,1;
190poly f = phi(f);
191def L1 = hnexpansion(f);
192def HNE_ring1 = L1[1];
193setring HNE_ring1;
194list INV = invariants(hne);
195// Number of branches:
196size(INV)-1;
197//-> 3
198// Intersection Multiplicities of the branches:
199print(INV[size(INV)][2]);
200//->     0     1     1
201//->     1     0     2
202//->     1     2     0
203
204for (int i=1; i<size(INV); i++)
205{
206 if (INV[i][5]==0){ print("branch No."+string(i)+" is smooth");}
207}
208
209ring R_loc2 = (0,a), (u,v), ds;
210minpoly = a2+1;
211map phi = R,u,v-a,1;
212poly f = phi(f);
213def L2 = hnexpansion(f);
214def HNE_ring2 = L2[1];
215setring HNE_ring2;
216displayInvariants(hne);
217
218ring R_loc3 = (0,a), (u,v), ds;
219minpoly = a4+1;
220map phi = R,1,v-a,u;
221poly f = phi(f);
222def L3 = hnexpansion(f);
223displayInvariants(L3);
224
225
226kill R,R_loc1,R_loc2,R_loc3,HNE_ring1,HNE_ring2,L1,L2,i,INV;
227//======================  Exercise 5.4 =============================
228ring R = 0, (x,y,z), dp;
229poly f = 3y3-3xy2-2xy3+x2y3+x3;
230poly C = homog(f,z);
231ideal I = jacob(C);
232I = std(I);
233if(not(defined(primdecGTZ))){ LIB "primdec.lib"; }
234list SLoc = primdecGTZ(I);
235SLoc;
236factorize(jet(f,3));
237//-> [1]:
238//->    _[1]=1
239//->    _[2]=x3-3xy2+3y3
240//-> [2]:
241//->    1,1
242
244for (int k=1; k<=3; k++)
245{
247}
251
252if (not(defined(randomid))){ LIB "random.lib"; }
254ideal I(1) = f(1),C;
255ideal I(2) = f(2),C;
256ideal B(1) = sat(I(1),I)[1];
257ideal B(2) = sat(I(2),I)[1];
258
260option(redSB);
262L' = simplify(L',6);
263poly f' =  randomid(L',1,10)[1];
264ideal I' = f',C;
265ideal B(3) = sat(I',L')[1];
266
268L'' = simplify(L'',6);  L'';
269poly f''(1),f''(2) = L'';
270
271ring R_t = (0,t), (x,y,z), dp;
272poly f'' = imap(R,f''(1)) + t*imap(R,f''(2));
273ideal I_t = f'', imap(R,C);
274I_t = std(I_t);
275ideal L'' = imap(R,L'');
276I_t = sat(I_t,L'')[1];
277I_t = std(subst(I_t,z,1));
278def phi_x = reduce(x,I_t);  phi_x;
279def phi_y = reduce(y,I_t);  phi_y;
280
281map testmap = R, phi_x, phi_y, 1;
282testmap(C);
283//-> 0
284ring S = 0, (t,x,y), dp;
285ideal I_t = imap(R_t,I_t);
286eliminate(I_t,t);
287//-> _[1]=x2y3-2xy3+x3-3xy2+3y3
288
289tst_status(1);\$
290
Note: See TracBrowser for help on using the repository browser.