# source:git/Tst/BuchDL/Ex_L6.tst@853a8a

spielwiese
Last change on this file since 853a8a was 853a8a, checked in by Oleksandr Motsak <motsak@…>, 10 years ago
Fixed BuchDL/Ex_L6.tst (updated test script)
• Property mode set to `100644`
File size: 10.2 KB
Line
1LIB "tst.lib";
2tst_init();
3
4
5//======================  Example 6.8 =============================
6option(redSB);
7ring R = 0, x(1..5), lp;
8poly f1 = x(1)^2+x(1)+2*x(2)*x(5)+2*x(3)*x(4);
9poly f2 = 2*x(1)*x(2)+x(2)+2*x(3)*x(5)+x(4)^2;
10poly f3 = 2*x(1)*x(3)+x(2)^2+x(3)+2*x(4)*x(5);
11poly f4 = 2*x(1)*x(4)+2*x(2)*x(3)+x(4)+x(5)^2;
12poly f5 = 2*x(1)*x(5)+2*x(2)*x(4)+x(3)^2+x(5);
13ideal I = f1^2,f2^2,f3,f4,f5;
14list L = facstd(I);
15size(L);     // number of sets in the decomposition
16//->   12
17L[10];
18//->   _[1]=5*x(5)-1
19//->   _[2]=5*x(4)-1
20//->   _[3]=5*x(3)-1
21//->   _[4]=5*x(2)-1
22//->   _[5]=5*x(1)+4
23list L2 = facstd(I,5*x(5)-1);
24size(L2);
25//->   11
26ring R1 = 0, x(1..5), dp;
27ideal I = imap(R,I);
28
29// fix CL: hier hat SINGULAR ein bug!!!! (manchmal voellig falsches Ergebnis)
30size(facstd(I));
31//->   1
32size(facstd(I,5*x(5)-1));
33//->   1
34
35
36//==============  Example 6.13 (continued session)  ========================
37if (not(defined(triangMH))){ LIB "triang.lib"; }
38setring R;
39ideal G = groebner(I);  // option(redSB) is already set
40list T = triangMH(G); T;
41//->   [1]:
42//->      _[1]=x(5)
43//->      _[2]=x(4)
44//->      _[3]=x(3)
45//->      _[4]=x(2)^2
46//->      _[5]=x(1)^4+2*x(1)^3+x(1)^2
47//->   [2]:
48//->      _[1]=9765625*x(5)^10-1
49//->      _[2]=x(4)-15625*x(5)^7
50//->      _[3]=x(3)-25*x(5)^3
51//->      _[4]=x(2)^2-781250*x(2)*x(5)^9+15625*x(5)^8
52//->      _[5]=2*x(1)+31250*x(2)*x(5)^6+625*x(5)^5+1
53//->   [3]:
54//->      _[1]=95367431640625*x(5)^20-1201171875*x(5)^10+1
55//->      _[2]=11*x(4)^2-1281738281250*x(4)*x(5)^17[...]
56//->      _[3]=11*x(3)+152587890625*x(4)*x(5)^16-1906250*x(4)*x(5)^6[...]
57//->      _[4]=22*x(2)+275*x(4)*x(5)^2+16021728515625*x(5)^19[...]
58//->      _[5]=22*x(1)+3814697265625*x(4)*x(5)^18-47656250*x(4)*x(5)^8[...]
59
60
61//==============  Example 6.14 (continued session)  ========================
62if (not(defined(triang_solve))){ LIB "solve.lib"; }
63triang_solve(T,20);      // 20 digits should be displayed
64//->   // ** Laguerre: Too many iterations!
65//->   // ** rootContainer::solver: No roots found!
66if (not(defined(primdecGTZ))){ LIB "primdec.lib"; }
67list TR;
68int k,j;
69for (k=1; k<=size(T); k++)
70  { TR = TR + triangMH(std(zeroRad(T[k]))); }
71triang_solve(TR,20);
72//->   // ** Laguerre: Too many iterations!
73//->   // ** rootContainer::solver: No roots found!
74for (k=1; k<=size(TR); k++) { print(TR[k][1]); }
75//->   x(5)
76//->   9765625*x(5)^10-1
77//->   95367431640625*x(5)^20-1201171875*x(5)^10+1
78list TS = TR[1];
79ideal J,JJ,LL;
80for (k=2; k<=size(TR); k++)
81{  J = TR[k];
82   LL = factorize(J[1],2)[1]; // returns nonconstant factors only
83   for (j=1; j<=size(LL); j++)
84   {  JJ = LL[j],J[2..size(J)];
85      TS = TS+list(JJ);  }
86}
87size(TS);      // number of triangular bases
88//->   11
89def RC = triang_solve(TS,20);
90setring RC;
91basering;
92//->   //   characteristic : 0 (complex:20 digits, additional 20 digits)
93//->   //   1 parameter    : I
94//->   //   minpoly        : (I^2+1)
95//->   //   number of vars : 5
96//->   //        block   1 : ordering lp
97//->   //                  : names    x(1) x(2) x(3) x(4) x(5)
98//->   //        block   2 : ordering C
99size(rlist);   // number of complex solutions
100//->   32
101rlist[3];      // the third solution
102//->   [3]:
103//->      [1]:
104//->         -0.8
105//->      [2]:
106//->         (-0.16180339887498948482-I*0.11755705045849462583)
107//->      [3]:
108//->         (0.06180339887498948482+I*0.19021130325903071442)
109//->      [4]:
110//->         (0.06180339887498948482-I*0.19021130325903071442)
111//->      [5]:
112//->         (-0.16180339887498948482+I*0.11755705045849462583)
113
114
115
116kill R,R1,RC,j,k;
117//================  Example 6.16 (new Session)  ========================
118ring R  = 0, (x,y,z), lp;
119ideal I = z5+z3-2z2-2, y2+z2+1, x2+2yx-x-y-z2-3;
120def F = factorize(I[1],1); F;
121//->   F[1]=z3-2
122//->   F[2]=z2+1
123ring R1 = (0,a), (x,y), lp;
124map phi = R,x,y,a;
125number n = number(phi(F)[2]); minpoly = n; if(defined(phi)){kill phi;} map phi = R,x,y,a;
126ideal Iz = phi(I);              // substitute a for z
127Iz = simplify(Iz,2); Iz;        // remove zero generators
128//->   Iz[1]=y2
129//->   Iz[2]=x2+2*xy-x-y-2
130ideal Izy = reduce(Iz,std(y)); // substitute 0 for y
131Izy = simplify(Izy,2); Izy;
132//->   Izy[1]=x2-x-2
133def Fzy = factorize(Izy[1],1); Fzy;
134//->   Fzy[1]=x-2
135//->   Fzy[2]=x+1
136ring R2 = (0,b), (x,y), lp;
137map phi = R,x,y,b;
138number n = number(phi(F)[1]); minpoly = n; if(defined(phi)){kill phi;} map phi = R,x,y,b;
139ideal Iz = phi(I);              // substitute a for z
140Iz = simplify(Iz,2); Iz;        // remove zero generators
141//->   Iz[1]=y2+(b2+1)
142//->   Iz[2]=x2+2*xy-x-y+(-b2-3)
143def Fz = factorize(Iz[1],1);  Fz;
144//->   Fz[1]=y2+(b2+1)
145if (not(defined(primitive))){ LIB "primitiv.lib"; }
146ring S = 0, (b,c), dp;
147ideal E = b3-2, c2+(b2+1);
148def L = primitive(E); L;
149//->   L[1]=c6+3c4+3c2+5
150//->   L[2]=1/2c4+c2+1/2
151//->   L[3]=c
152ring R3 = (0,c), x, lp;
153def L = imap(S,L);
154map phi = R, x, L[3], L[2];
155number n = number(L[1]); kill phi, L; minpoly = n; def L = imap(S,L); map phi = R, x, L[3], L[2];
156ideal Izy = simplify(phi(I),2); Izy;
157//->   Izy[1]=x2+(2c-1)*x+(c2-c-2)
158def Fzy = factorize(Izy[1],1);  Fzy;
159//->   Fzy[1]=x+(c+1)
160//->   Fzy[2]=x+(c-2)
161
162
163kill R,R1,R2,R3,S;
164//================  Example 6.19 (new Session)  ========================
165ring S = 0, (x,y), dp;
166poly f, g = xy2-xy-y3+1, x2y2-x2y+xy-1;
167poly r = resultant(f,g,x); r;
168//->   y8-y7+y6-3y5+y4+y3+y2-y;
169factorize(r,2);     // display nonconstant factors only
170//->   [1]:
171//->      _[1]=y-1
172//->      _[2]=y
173//->      _[3]=y5+y4+2y3-y-1
174//->   [2]:
175//->      2,1,1
176ideal I1 = eliminate(ideal(f,g),x);
177I1;
178//->   I1[1]=y6+y4-2y3-y2+1
179factorize(I1[1],2);
180//->   [1]:
181//->      _[1]=y-1
182//->      _[2]=y5+y4+2y3-y-1
183//->   [2]:
184//->      1,1
185
186
187kill S;
188//================  Remark 6.20 (new Session)  ========================
189ring S = 0, (x,y), dp;
190poly f, g = x2+y2-1, x2+2y2-1;
191resultant(f,g,x);
192//->   y4
193eliminate(ideal(f,g),x);
194//->   _[1]=y2
195
196
197kill S;
198//================  Remark 6.23 (new Session)  ========================
199ring R = 0, (x,y,t), dp;
200poly f = x-t32;
201poly g = y-t48+t56+t60+t62+t63;
202int aa = timer;
203poly h = resultant(f,g,t);
204h;
205//->   x63-595965x62-32x61y+6143174x61+3656768x60y+464x59y2-70859517x60
206//->   -65651616x59y-13277840x58y2-4064x57y3+49771514x59+220805184x58y+
207//->   [...]
208//->   -448x8y27-88x7y28-120x6y28+32x5y29+16x3y30-y32
209deg(h);                  // the total degree
210//->   63
211size(h);                 // number of terms of h
212//->   257
213
214
215kill R,aa;
216//================  Example 6.24 (new Session)  ========================
217ring R = 0, (x,y,z,t,u(2),u(3)), dp;
218poly f(1), f(2), f(3) = x-t, y-t2, z-t3;
219poly h = resultant(f(1), u(2)*f(2)+u(3)*f(3), t);
220h;
221//->   x^3*u(3)+x^2*u(2)-y*u(2)-z*u(3)
222ideal CO = coeffs(coeffs(h,u(2)),u(3));
223simplify(CO,2);       // remove zeros among generators of CO
224//->   _[1]=x^3-z
225//->   _[2]=x^2-y
226resultant(f(1),f(2),t);
227//->   -x^2+y
228resultant(f(1),f(3),t);
229//->   x^3-z
230
231
232kill R;
233//================  Example 6.32 (new Session)  ========================
234ring R = (0,u,v,w), (x,y,z), dp;
235poly f1 = x3+y-xy-1;
236poly f2 = x2+y2+4x+4y-2;
237ideal I = ux+vy+wz, homog(f1,z) , homog(f2,z);
238def M0 = mpresmat(I,1);  // the evaluated matrix M_0
239nrows(M0);               // the number of rows of M_0
240//->   15
241poly D0 = det(M0);       // the value of D_0
242D0;
243//->   12*x6-64*x5y+140*x4y2-352*x3y3+804*x2y4-864*xy5+324*y6-16*x5z+56*x4yz+32*x3y2z+48*x2y3z-336*xy4z+216*y5z-36*x4z2+64*x3yz2-264*x2y2z2+672*xy3z2-564*y4z2+16*x3z3+32*x2yz3-208*xy2z3-160*y3z3+20*x2z4+32*xyz4+236*y2z4-56*yz5+4*z6
244int aa = timer;
245factorize(D0);
246//->   [1]:
247//->      _[1]=4
248//->      _[2]=3*x3-x2y+9*xy2-27*y3-7*x2z-14*xyz-27*y2z+xz2+11*yz2-z3
249//->      _[3]=x-3*y+z
250//->      _[4]=x-y-z
251//->      _[5]=x-y+z
252//->   [2]:
253//->      1,1,1,1,1
254//->   0
255
256//==============  Example 6.33 (continued session)  ========================
257map phi = R,-1,0,z;
258poly D0x = phi(D0);
259factorize(D0x);           // x-coordinates
260//->   [1]:
261//->      _[1]=4
262//->      _[2]=z-1
263//->      _[3]=z3+z2+7*z+3
264//->      _[4]=z+1
265//->   [2]:
266//->      1,2,1,1
267map psi = R,0,-1,z;
268poly D0y = psi(D0);
269factorize(D0y);           // y-coordinates
270//->   [1]:
271//->      _[1]=4
272//->      _[2]=z-1
273//->      _[3]=z3+11*z2+27*z-27
274//->      _[4]=z+1
275//->      _[5]=z+3
276//->   [2]:
277//->      1,1,1,1,1
278
279
280kill R,aa;
281//================  Example 6.41 (new Session)  ========================
282ring R = (0,a(1..3),b(1..3),c(1..3)), (x,y), dp;
283poly f0 = a(1)+a(2)*xy+a(3)*y2;
284poly f1 = b(1)+b(2)*xy+b(3)*y2;
285poly f2 = c(1)*x+c(2)*y+c(3)*xy;
286ideal I = f0, f1, f2;
287def M0 = mpresmat(I,0);      // depends on random choices
288print(M0);
289//->   (b(1)),0,     0,     0,     0,     0,     0,     0,     0,
290//->   0,     (a(1)),0,     (b(1)),0,     0,     0,     0,     0,
291//->   (b(3)),0,     (a(1)),0,     (b(1)),0,     (c(2)),0,     0,
292//->   0,     (a(3)),0,     (b(3)),0,     0,     0,     (c(2)),0,
293//->   0,     0,     (a(3)),0,     (b(3)),0,     0,     0,     0,
294//->   (b(2)),0,     0,     0,     0,     (b(1)),(c(1)),0,     (a(1)),
295//->   0,     (a(2)),0,     (b(2)),0,     0,     (c(3)),(c(1)),0,
296//->   0,     0,     (a(2)),0,     (b(2)),(b(3)),0,     (c(3)),(a(3)),
297//->   0,     0,     0,     0,     0,     (b(2)),0,     0,     (a(2))
298def p = det(M0);
299p;
300//->   (-a(1)^3*b(1)*b(2)*b(3)^2*c(3)^2+ [...]
301
302ring S = 0, (a(1..3),b(1..3),c(1..3)), dp;
303poly p = imap(R,p);
304factorize(p,1);
305//->   _[1]=b(1)
306//->   _[2]=a(3)^3*b(1)^2*b(2)*c(1)^2-a(2)*a(3)^2*b(1)^2*b(3)*c(1)^2- [...]
307
308
309kill R,S;
310//================  Example 6.45 (new Session)  ========================
311ring R = (0,u,v,w), (x,y), dp;
312poly f1 = x3+y-xy-1;
313poly f2 = x2+y2+4x+4y-2;
314ideal I = u+vx+wy, f1, f2;
315def M0 = mpresmat(I,0);  // the evaluated sparse resultant matrix
316nrows(M0);
317//->   13
318def D0 = det(M0);
319ring S = 0, (u,v,w), dp;
320poly D0 = imap(R,D0);
321map phi = S,u,-1,0;
322factorize(phi(D0));      // determine x-coordinates of solutions
323//->   [1]:
324//->      _[1]=2
325//->      _[2]=u-1
326//->      _[3]=u3+u2+7u+3
327//->      _[4]=u+1
328//->   [2]:
329//->      1,2,1,1
330map psi = S,u,0,-1;
331factorize(psi(D0));      // determine y-coordinates of solutions
332//->   [1]:
333//->      _[1]=2
334//->      _[2]=u-1
335//->      _[3]=u3+11u2+27u-27
336//->      _[4]=u+1
337//->      _[5]=u+3
338//->   [2]:
339//->      1,1,1,1,1
340
341map psi_13 = S,u,1,3;
342factorize(psi_13(D0));
343//->   [1]:
344//->      _[1]=2
345//->      _[2]=u3-34u2+292u+648
346//->      _[3]=u-2
347//->      _[4]=u+2
348//->      _[5]=u-8
349//->   [2]:
350//->      1,1,1,1,1
351
352
353tst_status(1);\$
354
Note: See TracBrowser for help on using the repository browser.