[66ee88] | 1 | LIB "tst.lib"; |
---|
| 2 | tst_init(); |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | //====================== Example 6.8 ============================= |
---|
| 6 | option(redSB); |
---|
| 7 | ring R = 0, x(1..5), lp; |
---|
| 8 | poly f1 = x(1)^2+x(1)+2*x(2)*x(5)+2*x(3)*x(4); |
---|
| 9 | poly f2 = 2*x(1)*x(2)+x(2)+2*x(3)*x(5)+x(4)^2; |
---|
| 10 | poly f3 = 2*x(1)*x(3)+x(2)^2+x(3)+2*x(4)*x(5); |
---|
| 11 | poly f4 = 2*x(1)*x(4)+2*x(2)*x(3)+x(4)+x(5)^2; |
---|
| 12 | poly f5 = 2*x(1)*x(5)+2*x(2)*x(4)+x(3)^2+x(5); |
---|
| 13 | ideal I = f1^2,f2^2,f3,f4,f5; |
---|
| 14 | list L = facstd(I); |
---|
| 15 | size(L); // number of sets in the decomposition |
---|
| 16 | //-> 12 |
---|
[7c99d0] | 17 | L[10]; |
---|
[66ee88] | 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 |
---|
| 23 | list L2 = facstd(I,5*x(5)-1); |
---|
| 24 | size(L2); |
---|
| 25 | //-> 11 |
---|
| 26 | ring R1 = 0, x(1..5), dp; |
---|
| 27 | ideal I = imap(R,I); |
---|
| 28 | |
---|
| 29 | // fix CL: hier hat SINGULAR ein bug!!!! (manchmal voellig falsches Ergebnis) |
---|
| 30 | size(facstd(I)); |
---|
| 31 | //-> 1 |
---|
| 32 | size(facstd(I,5*x(5)-1)); |
---|
| 33 | //-> 1 |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | //============== Example 6.13 (continued session) ======================== |
---|
| 37 | if (not(defined(triangMH))){ LIB "triang.lib"; } |
---|
| 38 | setring R; |
---|
| 39 | ideal G = groebner(I); // option(redSB) is already set |
---|
| 40 | list 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) ======================== |
---|
| 62 | if (not(defined(triang_solve))){ LIB "solve.lib"; } |
---|
| 63 | triang_solve(T,20); // 20 digits should be displayed |
---|
| 64 | //-> // ** Laguerre: Too many iterations! |
---|
| 65 | //-> // ** rootContainer::solver: No roots found! |
---|
[7cd077] | 66 | if (not(defined(primdecGTZ))){ LIB "primdec.lib"; } |
---|
[66ee88] | 67 | list TR; |
---|
| 68 | int k,j; |
---|
| 69 | for (k=1; k<=size(T); k++) |
---|
| 70 | { TR = TR + triangMH(std(zeroRad(T[k]))); } |
---|
| 71 | triang_solve(TR,20); |
---|
| 72 | //-> // ** Laguerre: Too many iterations! |
---|
| 73 | //-> // ** rootContainer::solver: No roots found! |
---|
| 74 | for (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 |
---|
| 78 | list TS = TR[1]; |
---|
| 79 | ideal J,JJ,LL; |
---|
| 80 | for (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 | } |
---|
| 87 | size(TS); // number of triangular bases |
---|
| 88 | //-> 11 |
---|
| 89 | def RC = triang_solve(TS,20); |
---|
| 90 | setring RC; |
---|
| 91 | basering; |
---|
| 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 |
---|
| 99 | size(rlist); // number of complex solutions |
---|
| 100 | //-> 32 |
---|
| 101 | rlist[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 | |
---|
| 116 | kill R,R1,RC,j,k; |
---|
| 117 | //================ Example 6.16 (new Session) ======================== |
---|
| 118 | ring R = 0, (x,y,z), lp; |
---|
| 119 | ideal I = z5+z3-2z2-2, y2+z2+1, x2+2yx-x-y-z2-3; |
---|
| 120 | def F = factorize(I[1],1); F; |
---|
| 121 | //-> F[1]=z3-2 |
---|
| 122 | //-> F[2]=z2+1 |
---|
| 123 | ring R1 = (0,a), (x,y), lp; |
---|
[ef52d6] | 124 | map phi = R,x,y,a; |
---|
[853a8a] | 125 | number n = number(phi(F)[2]); minpoly = n; if(defined(phi)){kill phi;} map phi = R,x,y,a; |
---|
[66ee88] | 126 | ideal Iz = phi(I); // substitute a for z |
---|
| 127 | Iz = simplify(Iz,2); Iz; // remove zero generators |
---|
| 128 | //-> Iz[1]=y2 |
---|
| 129 | //-> Iz[2]=x2+2*xy-x-y-2 |
---|
| 130 | ideal Izy = reduce(Iz,std(y)); // substitute 0 for y |
---|
| 131 | Izy = simplify(Izy,2); Izy; |
---|
| 132 | //-> Izy[1]=x2-x-2 |
---|
| 133 | def Fzy = factorize(Izy[1],1); Fzy; |
---|
| 134 | //-> Fzy[1]=x-2 |
---|
| 135 | //-> Fzy[2]=x+1 |
---|
| 136 | ring R2 = (0,b), (x,y), lp; |
---|
[ef52d6] | 137 | map phi = R,x,y,b; |
---|
[853a8a] | 138 | number n = number(phi(F)[1]); minpoly = n; if(defined(phi)){kill phi;} map phi = R,x,y,b; |
---|
[66ee88] | 139 | ideal Iz = phi(I); // substitute a for z |
---|
| 140 | Iz = simplify(Iz,2); Iz; // remove zero generators |
---|
| 141 | //-> Iz[1]=y2+(b2+1) |
---|
| 142 | //-> Iz[2]=x2+2*xy-x-y+(-b2-3) |
---|
| 143 | def Fz = factorize(Iz[1],1); Fz; |
---|
| 144 | //-> Fz[1]=y2+(b2+1) |
---|
| 145 | if (not(defined(primitive))){ LIB "primitiv.lib"; } |
---|
| 146 | ring S = 0, (b,c), dp; |
---|
| 147 | ideal E = b3-2, c2+(b2+1); |
---|
| 148 | def L = primitive(E); L; |
---|
| 149 | //-> L[1]=c6+3c4+3c2+5 |
---|
| 150 | //-> L[2]=1/2c4+c2+1/2 |
---|
| 151 | //-> L[3]=c |
---|
| 152 | ring R3 = (0,c), x, lp; |
---|
| 153 | def L = imap(S,L); |
---|
[ef52d6] | 154 | map phi = R, x, L[3], L[2]; |
---|
| 155 | number n = number(L[1]); kill phi, L; minpoly = n; def L = imap(S,L); map phi = R, x, L[3], L[2]; |
---|
[66ee88] | 156 | ideal Izy = simplify(phi(I),2); Izy; |
---|
| 157 | //-> Izy[1]=x2+(2c-1)*x+(c2-c-2) |
---|
| 158 | def Fzy = factorize(Izy[1],1); Fzy; |
---|
| 159 | //-> Fzy[1]=x+(c+1) |
---|
| 160 | //-> Fzy[2]=x+(c-2) |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | kill R,R1,R2,R3,S; |
---|
| 164 | //================ Example 6.19 (new Session) ======================== |
---|
| 165 | ring S = 0, (x,y), dp; |
---|
| 166 | poly f, g = xy2-xy-y3+1, x2y2-x2y+xy-1; |
---|
| 167 | poly r = resultant(f,g,x); r; |
---|
| 168 | //-> y8-y7+y6-3y5+y4+y3+y2-y; |
---|
| 169 | factorize(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 |
---|
| 176 | ideal I1 = eliminate(ideal(f,g),x); |
---|
| 177 | I1; |
---|
| 178 | //-> I1[1]=y6+y4-2y3-y2+1 |
---|
| 179 | factorize(I1[1],2); |
---|
| 180 | //-> [1]: |
---|
| 181 | //-> _[1]=y-1 |
---|
| 182 | //-> _[2]=y5+y4+2y3-y-1 |
---|
| 183 | //-> [2]: |
---|
| 184 | //-> 1,1 |
---|
| 185 | |
---|
| 186 | |
---|
| 187 | kill S; |
---|
| 188 | //================ Remark 6.20 (new Session) ======================== |
---|
| 189 | ring S = 0, (x,y), dp; |
---|
| 190 | poly f, g = x2+y2-1, x2+2y2-1; |
---|
| 191 | resultant(f,g,x); |
---|
| 192 | //-> y4 |
---|
| 193 | eliminate(ideal(f,g),x); |
---|
| 194 | //-> _[1]=y2 |
---|
| 195 | |
---|
| 196 | |
---|
| 197 | kill S; |
---|
| 198 | //================ Remark 6.23 (new Session) ======================== |
---|
| 199 | ring R = 0, (x,y,t), dp; |
---|
| 200 | poly f = x-t32; |
---|
| 201 | poly g = y-t48+t56+t60+t62+t63; |
---|
| 202 | int aa = timer; |
---|
| 203 | poly h = resultant(f,g,t); |
---|
| 204 | h; |
---|
| 205 | //-> x63-595965x62-32x61y+6143174x61+3656768x60y+464x59y2-70859517x60 |
---|
| 206 | //-> -65651616x59y-13277840x58y2-4064x57y3+49771514x59+220805184x58y+ |
---|
| 207 | //-> [...] |
---|
| 208 | //-> -448x8y27-88x7y28-120x6y28+32x5y29+16x3y30-y32 |
---|
| 209 | deg(h); // the total degree |
---|
| 210 | //-> 63 |
---|
| 211 | size(h); // number of terms of h |
---|
| 212 | //-> 257 |
---|
| 213 | |
---|
| 214 | |
---|
| 215 | kill R,aa; |
---|
| 216 | //================ Example 6.24 (new Session) ======================== |
---|
| 217 | ring R = 0, (x,y,z,t,u(2),u(3)), dp; |
---|
| 218 | poly f(1), f(2), f(3) = x-t, y-t2, z-t3; |
---|
| 219 | poly h = resultant(f(1), u(2)*f(2)+u(3)*f(3), t); |
---|
| 220 | h; |
---|
| 221 | //-> x^3*u(3)+x^2*u(2)-y*u(2)-z*u(3) |
---|
| 222 | ideal CO = coeffs(coeffs(h,u(2)),u(3)); |
---|
| 223 | simplify(CO,2); // remove zeros among generators of CO |
---|
| 224 | //-> _[1]=x^3-z |
---|
| 225 | //-> _[2]=x^2-y |
---|
| 226 | resultant(f(1),f(2),t); |
---|
| 227 | //-> -x^2+y |
---|
| 228 | resultant(f(1),f(3),t); |
---|
| 229 | //-> x^3-z |
---|
| 230 | |
---|
| 231 | |
---|
| 232 | kill R; |
---|
| 233 | //================ Example 6.32 (new Session) ======================== |
---|
| 234 | ring R = (0,u,v,w), (x,y,z), dp; |
---|
| 235 | poly f1 = x3+y-xy-1; |
---|
| 236 | poly f2 = x2+y2+4x+4y-2; |
---|
| 237 | ideal I = ux+vy+wz, homog(f1,z) , homog(f2,z); |
---|
| 238 | def M0 = mpresmat(I,1); // the evaluated matrix M_0 |
---|
| 239 | nrows(M0); // the number of rows of M_0 |
---|
| 240 | //-> 15 |
---|
| 241 | poly D0 = det(M0); // the value of D_0 |
---|
| 242 | D0; |
---|
| 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 |
---|
| 244 | int aa = timer; |
---|
| 245 | factorize(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) ======================== |
---|
| 257 | map phi = R,-1,0,z; |
---|
| 258 | poly D0x = phi(D0); |
---|
| 259 | factorize(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 |
---|
| 267 | map psi = R,0,-1,z; |
---|
| 268 | poly D0y = psi(D0); |
---|
| 269 | factorize(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 | |
---|
| 280 | kill R,aa; |
---|
| 281 | //================ Example 6.41 (new Session) ======================== |
---|
| 282 | ring R = (0,a(1..3),b(1..3),c(1..3)), (x,y), dp; |
---|
| 283 | poly f0 = a(1)+a(2)*xy+a(3)*y2; |
---|
| 284 | poly f1 = b(1)+b(2)*xy+b(3)*y2; |
---|
| 285 | poly f2 = c(1)*x+c(2)*y+c(3)*xy; |
---|
| 286 | ideal I = f0, f1, f2; |
---|
| 287 | def M0 = mpresmat(I,0); // depends on random choices |
---|
| 288 | print(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)) |
---|
| 298 | def p = det(M0); |
---|
| 299 | p; |
---|
| 300 | //-> (-a(1)^3*b(1)*b(2)*b(3)^2*c(3)^2+ [...] |
---|
| 301 | |
---|
| 302 | ring S = 0, (a(1..3),b(1..3),c(1..3)), dp; |
---|
| 303 | poly p = imap(R,p); |
---|
| 304 | factorize(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 | |
---|
| 309 | kill R,S; |
---|
| 310 | //================ Example 6.45 (new Session) ======================== |
---|
| 311 | ring R = (0,u,v,w), (x,y), dp; |
---|
| 312 | poly f1 = x3+y-xy-1; |
---|
| 313 | poly f2 = x2+y2+4x+4y-2; |
---|
| 314 | ideal I = u+vx+wy, f1, f2; |
---|
| 315 | def M0 = mpresmat(I,0); // the evaluated sparse resultant matrix |
---|
| 316 | nrows(M0); |
---|
| 317 | //-> 13 |
---|
| 318 | def D0 = det(M0); |
---|
| 319 | ring S = 0, (u,v,w), dp; |
---|
| 320 | poly D0 = imap(R,D0); |
---|
| 321 | map phi = S,u,-1,0; |
---|
| 322 | factorize(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 |
---|
| 330 | map psi = S,u,0,-1; |
---|
| 331 | factorize(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 | |
---|
| 341 | map psi_13 = S,u,1,3; |
---|
| 342 | factorize(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 | |
---|
| 353 | tst_status(1);$ |
---|
| 354 | |
---|