1 | LIB "tst.lib"; |
---|
2 | tst_init(); |
---|
3 | |
---|
4 | |
---|
5 | //====================== Exercise 4.1 ============================= |
---|
6 | ring R = 0, (t,w,x,y,z), dp; |
---|
7 | ideal I = w2xy+w2xz+w2z2, tx2y+x2yz+x2z2, twy2+ty2z+y2z2, |
---|
8 | t2wx+t2wz+t2z2; |
---|
9 | if(not(defined(primdecGTZ))){ LIB "primdec.lib"; } |
---|
10 | list L = primdecGTZ(I); |
---|
11 | |
---|
12 | int s = size(L); // number of components |
---|
13 | int i,j; |
---|
14 | for (i=1; i<=s; i++) |
---|
15 | { |
---|
16 | L[i][1]=std(L[i][1]); |
---|
17 | L[i][2]=std(L[i][2]); |
---|
18 | // test for primeness: |
---|
19 | if ( size( reduce( lead(L[i][2]), std(lead(L[i][1])) ) ) > 0 ) |
---|
20 | { |
---|
21 | print(string(i)+"th component is not prime and of dimension " |
---|
22 | +string(dim(L[i][2]))+"."); |
---|
23 | } |
---|
24 | else |
---|
25 | { |
---|
26 | print(string(i)+"th component is prime and of dimension " |
---|
27 | +string(dim(L[i][2]))+"."); |
---|
28 | } |
---|
29 | } |
---|
30 | |
---|
31 | for (i=1; i<=s; i++) |
---|
32 | { |
---|
33 | for (j=1; j<=s; j++) |
---|
34 | { |
---|
35 | if (( dim(L[j][2]) > dim(L[i][2]) ) and |
---|
36 | ( size(reduce(L[j][2],L[i][2],1)) == 0 )) |
---|
37 | { |
---|
38 | print(string(i)+"th component is embedded."); |
---|
39 | j=s; |
---|
40 | } |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | |
---|
45 | kill R,s,i,j; |
---|
46 | //====================== Exercise 4.2 ============================= |
---|
47 | ring R = 0, (b,s,t,u,v,w,x,y,z), dp; |
---|
48 | ideal I = wy-vz, vx-uy, tv-sw, su-bv, tuy-bvz; |
---|
49 | if(not(defined(normal))){ LIB "normal.lib"; } |
---|
50 | list nor = normal(I); |
---|
51 | for (int i=1; i<=size(nor); i++) { def R_nor(i) = nor[i]; } |
---|
52 | setring R_nor(1); |
---|
53 | R_nor(1); norid; normap; |
---|
54 | setring R_nor(2); |
---|
55 | R_nor(2); norid; normap; |
---|
56 | setring R_nor(3); |
---|
57 | R_nor(3); norid; normap; |
---|
58 | |
---|
59 | setring R; |
---|
60 | primdecGTZ(I); |
---|
61 | |
---|
62 | |
---|
63 | kill R,R_nor(1),R_nor(2),R_nor(3),i,nor; |
---|
64 | //====================== Exercise 4.3 ============================= |
---|
65 | ring R = 32003, (x,y,z,a,b,c,d), dp; |
---|
66 | ideal I = a-xy, b-y2, c-yz, d-y3; |
---|
67 | I = I, z2-x5-y5; |
---|
68 | ideal J = eliminate(I,y); |
---|
69 | ring S = 32003, (x,z,a,b,c,d), dp; |
---|
70 | ideal J = imap(R,J); |
---|
71 | attrib(J,"isSB",1); |
---|
72 | J; |
---|
73 | dim(J); |
---|
74 | //-> 2 |
---|
75 | if(not(defined(normal))){ LIB "normal.lib"; } |
---|
76 | list nor = normal(J); |
---|
77 | def R_nor = nor[1]; setring R_nor; |
---|
78 | norid; normap; |
---|
79 | |
---|
80 | |
---|
81 | kill R,S,nor,R_nor; |
---|
82 | //====================== Exercise 4.4 ============================= |
---|
83 | ring R = 0, x(1..3), dp; |
---|
84 | matrix D[3][3] = x(1), x(2), x(3)^2-1, |
---|
85 | x(2), x(3), x(1)*x(2)+x(3)+1, |
---|
86 | x(3)^2-1, x(1)*x(2)+x(3)+1, 0; |
---|
87 | ideal I = det(D), x(1)*x(3)-x(2)^2; |
---|
88 | matrix Df = jacob(I); |
---|
89 | I = std(I); |
---|
90 | int c = nvars(R) - dim(I); c; |
---|
91 | //-> 2 |
---|
92 | if (not(defined(equidimMax))){ LIB "primdec.lib"; } |
---|
93 | ideal I_max = equidimMax(I); |
---|
94 | size(reduce(I_max,I)); |
---|
95 | //-> 0 |
---|
96 | |
---|
97 | ideal J = minor(Df,c), I; |
---|
98 | J = groebner(J); |
---|
99 | sat(I,J); |
---|
100 | //-> [1]: |
---|
101 | //-> _[1]=1 |
---|
102 | //-> [2]: |
---|
103 | //-> 2 |
---|
104 | |
---|
105 | ideal J_max = equidimMax(J); |
---|
106 | size(reduce(J_max,J)); |
---|
107 | //-> 0 |
---|
108 | matrix DJ = jacob(J); |
---|
109 | ideal SLoc = minor(DJ,c), J; |
---|
110 | groebner(SLoc); |
---|
111 | //-> _[1]=1 |
---|
112 | |
---|
113 | //---------Alternatively: check sqrt(J)=J---------- |
---|
114 | ideal sqrtJ = radical(J); |
---|
115 | size(reduce(sqrtJ,J)); |
---|
116 | //-> 0 |
---|
117 | |
---|
118 | |
---|
119 | kill R,c; |
---|
120 | //====================== Exercise 4.5 ============================= |
---|
121 | proc maximaldegree (ideal I) |
---|
122 | "USAGE: maximaldegree(I); I=ideal |
---|
123 | RETURN: integer; the maximum degree of the given |
---|
124 | generators for I |
---|
125 | NOTE: return value is -1 if I=0 |
---|
126 | " |
---|
127 | { |
---|
128 | if (size(I)>0) |
---|
129 | { |
---|
130 | int i,dd; |
---|
131 | int d = deg(I[1]); |
---|
132 | for (i=2; i<=size(I); i++) |
---|
133 | { |
---|
134 | dd = deg(I[i]); |
---|
135 | if (dd>d) { d = dd; } |
---|
136 | } |
---|
137 | return(d); |
---|
138 | } |
---|
139 | else |
---|
140 | { |
---|
141 | return(-1); |
---|
142 | } |
---|
143 | } |
---|
144 | |
---|
145 | proc zeros (poly f) |
---|
146 | "USAGE: zeros(f); f poly |
---|
147 | ASSUME: the active ring is univariate |
---|
148 | RETURN: ring |
---|
149 | NOTE: In the output ring, f decomposes into linear factors. The |
---|
150 | list of solutions of f=0 may be accessed by typing, for |
---|
151 | instance, |
---|
152 | def RRR=zeros(f); setring RRR; ZEROS; |
---|
153 | " |
---|
154 | { |
---|
155 | if (nvars(basering)!=1) |
---|
156 | { ERROR("The active ring is not univariate"); } |
---|
157 | if (deg(f)<=0){ ERROR("f is a constant polynomial"); } |
---|
158 | def R_aux = basering; |
---|
159 | ideal facts_f = factorize(f,1); |
---|
160 | int d = maximaldegree(facts_f); |
---|
161 | int counter=size(facts_f); |
---|
162 | int i; |
---|
163 | while (d>1) |
---|
164 | { |
---|
165 | if (defined(primitive)==0){ LIB "primitiv.lib"; } |
---|
166 | while (deg(facts_f[counter])<=1) { counter--; } |
---|
167 | if (defined(minpoly)) { poly g = minpoly; } |
---|
168 | else { poly g=0; } |
---|
169 | poly h = facts_f[counter]; |
---|
170 | if (g==0) |
---|
171 | { |
---|
172 | ring R_aux2 = (char(basering),a), x, dp; |
---|
173 | map psi = R_aux,a; |
---|
174 | minpoly = number(psi(h)); |
---|
175 | ideal facts_old = imap(R_aux,facts_f); |
---|
176 | ideal facts_f; |
---|
177 | for (i=1; i<=size(facts_old); i++) |
---|
178 | { |
---|
179 | facts_f = facts_f, factorize(facts_old[i],1); |
---|
180 | } |
---|
181 | } |
---|
182 | else |
---|
183 | { |
---|
184 | ring R_aux1 = char(basering), (a,x), dp; |
---|
185 | poly g = imap(R_aux,g); |
---|
186 | poly h = imap(R_aux,h); |
---|
187 | ideal facts_f = imap(R_aux,facts_f); |
---|
188 | ideal I = g,h; |
---|
189 | ideal Prim = primitive(I); |
---|
190 | poly MP_new = Prim[1]; |
---|
191 | poly a_new = Prim[2]; |
---|
192 | poly x_new = Prim[3]; |
---|
193 | ring R_aux2 = (char(basering),a), x, dp; |
---|
194 | map psi = R_aux1,0,a; |
---|
195 | minpoly = number(psi(MP_new)); |
---|
196 | poly a_new = psi(a_new); |
---|
197 | poly x_new = psi(x_new); |
---|
198 | map phi = R_aux1,a_new,x; |
---|
199 | ideal facts_old = phi(facts_f); |
---|
200 | ideal facts_f; |
---|
201 | for (i=1; i<=size(facts_old); i++) |
---|
202 | { |
---|
203 | facts_f = facts_f, factorize(facts_old[i],1); |
---|
204 | } |
---|
205 | kill R_aux1; |
---|
206 | } |
---|
207 | facts_f = simplify(facts_f,2); |
---|
208 | kill R_aux; |
---|
209 | def R_aux = R_aux2; |
---|
210 | setring R_aux; |
---|
211 | kill R_aux2; |
---|
212 | d = maximaldegree(facts_f); |
---|
213 | } |
---|
214 | ideal ZEROS = -subst(facts_f,x,0); |
---|
215 | export(ZEROS); |
---|
216 | return(R_aux); |
---|
217 | } |
---|
218 | |
---|
219 | ring R = 167, x, dp; |
---|
220 | def RRR = zeros(x100-13); |
---|
221 | setring RRR; |
---|
222 | ZEROS; |
---|
223 | poly g = 1; |
---|
224 | for (int i=1; i<=size(ZEROS); i++) { g = g*(x-ZEROS[i]); } |
---|
225 | g; |
---|
226 | //-> x100-13 |
---|
227 | |
---|
228 | |
---|
229 | kill i,RRR,R; |
---|
230 | //====================== Exercise 4.6 ============================= |
---|
231 | ring R = 0, (x,y,z), dp; |
---|
232 | ideal MI_2 = maxideal(2); |
---|
233 | ideal MI_3 = maxideal(3); |
---|
234 | ideal MI_4 = maxideal(4); |
---|
235 | ring R_ext = 0, (a(1..6),b(1..6),c(1..6),x,y,z), dp; |
---|
236 | ideal MI_2 = imap(R,MI_2); |
---|
237 | matrix A[6][1] = a(1..6); |
---|
238 | matrix B[6][1] = b(1..6); |
---|
239 | matrix C[6][1] = c(1..6); |
---|
240 | poly F(0) = (matrix(MI_2)*A)[1,1]; |
---|
241 | poly F(1) = (matrix(MI_2)*B)[1,1]; |
---|
242 | poly F(2) = (matrix(MI_2)*C)[1,1]; |
---|
243 | ideal G = x2*F(0), xy*F(0), xz*F(0), yz*F(0), x2*F(1), |
---|
244 | xy*F(1), xz*F(1), y2*F(1), yz*F(1), x2*F(2), |
---|
245 | xy*F(2), xz*F(2), y2*F(2), yz*F(2), z2*F(2); |
---|
246 | ideal MI_4 = imap(R,MI_4); |
---|
247 | matrix M = coeffs(G,MI_4,xyz); |
---|
248 | poly D_0 = det(M); |
---|
249 | deg(D_0); size(D_0); |
---|
250 | //-> 15 |
---|
251 | //-> 37490 |
---|
252 | |
---|
253 | ideal G_ext = x2*F(1), x2*F(2), y2*F(2); |
---|
254 | ideal MI_ext = x2y2, x2z2, y2z2; |
---|
255 | matrix M_ext = coeffs(G_ext,MI_ext,xyz); |
---|
256 | poly D_0_ext = det(M_ext); |
---|
257 | poly Res = D_0/D_0_ext; |
---|
258 | deg(Res); size(Res); |
---|
259 | //-> 12 |
---|
260 | //-> 21894 |
---|
261 | |
---|
262 | |
---|
263 | // session continued..... |
---|
264 | //====================== Exercise 4.7 ============================= |
---|
265 | ring S = 0,(x,y,z,a(1..10)), (dp(2),dp(11)); |
---|
266 | ideal MI_2 = imap(R,MI_2); |
---|
267 | ideal MI_3 = imap(R,MI_3); |
---|
268 | matrix A[10][1] = a(10),a(9),a(7),a(4),a(8),a(6),a(3),a(5),a(2), |
---|
269 | a(1); |
---|
270 | poly F = (matrix(MI_3)*A)[1,1]; |
---|
271 | ideal J = diff(F,x), diff(F,y), diff(F,z); |
---|
272 | if (not(defined(flatten))){ LIB "matrix.lib"; } |
---|
273 | map phi = R_ext, flatten(coeffs(diff(F,x),MI_2,xyz)), |
---|
274 | flatten(coeffs(diff(F,y),MI_2,xyz)), |
---|
275 | flatten(coeffs(diff(F,z),MI_2,xyz)); |
---|
276 | poly D = phi(Res); |
---|
277 | deg(D); size(D); |
---|
278 | //-> 12 |
---|
279 | //-> 2040 |
---|
280 | |
---|
281 | tst_status(1);$ |
---|
282 | |
---|