1 | LIB "tst.lib"; |
---|
2 | tst_init(); |
---|
3 | |
---|
4 | LIB "rootisolation.lib"; |
---|
5 | |
---|
6 | // start with examples |
---|
7 | example bounds; |
---|
8 | example length; |
---|
9 | example boxSet; |
---|
10 | example ivmatInit; |
---|
11 | example ivmatSet; |
---|
12 | example unitMatrix; |
---|
13 | example ivmatGaussian; |
---|
14 | example evalPolyAtBox; |
---|
15 | example evalJacobianAtBox; |
---|
16 | example rootIsolationNoPreprocessing; |
---|
17 | example rootIsolation; |
---|
18 | |
---|
19 | // some interval/box only stuff |
---|
20 | ring R = 0,(x,y,z),dp; |
---|
21 | interval J = -2,1/5; J; |
---|
22 | // not enough intervals for box |
---|
23 | box B = list(J,J); B; |
---|
24 | // right number |
---|
25 | B = list(J,J,J); B; |
---|
26 | // too many intervals for box |
---|
27 | B = list(J,J,J,J); B; |
---|
28 | kill J,B,R; |
---|
29 | |
---|
30 | // trivial example |
---|
31 | ring R = 0,x,dp; |
---|
32 | ideal I = x; |
---|
33 | box B = list(bounds(-1,1)); |
---|
34 | list roots = rootIsolation(I,B); roots; |
---|
35 | kill roots, B, R; |
---|
36 | |
---|
37 | // maximal ideal with single root |
---|
38 | ring R = 0,(x,y,z),dp; |
---|
39 | ideal I = x-3,y-2,z+2/3; |
---|
40 | box B = list(bounds(-5,5), bounds(-5,5), bounds(-5,5)); |
---|
41 | list roots = rootIsolation(I,B); roots; |
---|
42 | kill roots, B, R; |
---|
43 | |
---|
44 | // roots of I lie on initial boundary |
---|
45 | ring R = 0,(x,y),dp; |
---|
46 | ideal I = x2-4,y2-4; |
---|
47 | box B = list(bounds(-2,2), bounds(-2,2)); |
---|
48 | list roots = rootIsolation(I,B); roots; |
---|
49 | kill roots, B, R; |
---|
50 | |
---|
51 | // roots of I lie on initial boundary for several |
---|
52 | // iterations |
---|
53 | ring R = 0,(x,y),dp; |
---|
54 | ideal I = (x2-1)*(x2-4)*(x2-9),(y2-1)*(y2-4)*(y2-9); |
---|
55 | box B = list(bounds(-1,1), bounds(-1,1)); |
---|
56 | list roots = rootIsolation(I,B); roots; |
---|
57 | kill roots, B, R; |
---|
58 | |
---|
59 | // starting box is a point |
---|
60 | ring R = 0,(x,y),dp; |
---|
61 | ideal I = x2-1,y2-9; |
---|
62 | box B = list(bounds(-1,-1), bounds(3,3)); |
---|
63 | list roots = rootIsolation(I,B); roots; |
---|
64 | kill roots, B, R; |
---|
65 | |
---|
66 | // no real roots |
---|
67 | ring R = 0,(x,y),dp; |
---|
68 | ideal I = x2+1,y; |
---|
69 | box B = list(bounds(-100,100),bounds(-100,100)); |
---|
70 | list roots = rootIsolation(I,B); roots; |
---|
71 | kill roots, B, R; |
---|
72 | |
---|
73 | // fixed bug: fglm lookup clashes with blackbox type |
---|
74 | ring R = 0,(x,y),dp; |
---|
75 | ideal I = x2-1,y-3; |
---|
76 | interval fastGB = -10,10; |
---|
77 | box B = list(fastGB, fastGB); |
---|
78 | list roots = rootIsolation(I,B); roots; |
---|
79 | kill roots, fastGB, B, R; |
---|
80 | |
---|
81 | // eps > 0, some boxes land in result[1] |
---|
82 | ring R = 0,(x,y),dp; |
---|
83 | ideal I = 2x2-xy+2y2-2,2x2-3xy+3y2-2; |
---|
84 | box B = list(bounds(-3/2,3/2), bounds(-3/2,3/2)); |
---|
85 | list roots = rootIsolation(I,B,1/10); roots; |
---|
86 | kill roots, B, R; |
---|
87 | |
---|
88 | // too many generators but reduced Groebner basis with 2 generators exists |
---|
89 | ring R = 0,(x,y),dp; |
---|
90 | ideal I = |
---|
91 | x3-4x2y+5y2+4x, |
---|
92 | 20y4-60x2y-5xy2-25y3+11x2-84xy+100y2+60x+100y+59, |
---|
93 | 4xy3+16x2y+xy2+5y3+x2+4xy-20y2-12x-16y+1, |
---|
94 | 4x2y2-xy2-5y3-x2-4xy-1; |
---|
95 | box B = list(bounds(-4,4), bounds(-4,4)); |
---|
96 | list roots = rootIsolation(I, B); roots; |
---|
97 | kill roots, B, R; |
---|
98 | |
---|
99 | // 6 generators (this is a Groebner basis), no reduced GB has 3 generators |
---|
100 | ring R = 0,(x,y,z),dp; |
---|
101 | ideal I = yz-x,xz-y,y2-z2,xy-z,x2-z2,z3-z; |
---|
102 | box B = list(bounds(-5,5),bounds(-5,5),bounds(-5,5)); |
---|
103 | list roots = rootIsolation(I, B); roots; |
---|
104 | kill roots, B, R; |
---|
105 | |
---|
106 | // no radical but zero-dimensional, |V(I)| = 2 |
---|
107 | ring R = 0,(x,y,z),dp; |
---|
108 | ideal I = y2-xy-2zx,y3+z2+1,x2yz-yz; |
---|
109 | box B = list(bounds(-5,5), bounds(-5,5), bounds(-5,5)); |
---|
110 | list roots = rootIsolation(I, B); roots; |
---|
111 | kill roots, B, R; |
---|
112 | |
---|
113 | // not zero-dimensional |
---|
114 | ring R = 0,(x,y,z),dp; |
---|
115 | ideal I = x2-x,y2-1,x; |
---|
116 | box B = list(bounds(-1,1),bounds(-1,1),bounds(-1,1)); |
---|
117 | list roots = rootIsolation(I, B); roots; |
---|
118 | kill roots, B, R; |
---|
119 | |
---|
120 | // automatically determine starting box |
---|
121 | ring R = 0,(x,y),dp; |
---|
122 | ideal I = 2x2-xy+2y2-2,2x2-3xy+3y2-2; |
---|
123 | list roots = rootIsolation(I); roots; |
---|
124 | kill roots, R; |
---|
125 | |
---|
126 | // apply to primary decomposition |
---|
127 | ring R = 0,(x,y,z),dp; |
---|
128 | ideal I = yz-x,xz-y,y2-z2,xy-z,x2-z2,z3-z; |
---|
129 | list roots = rootIsolationPrimdec(I); roots; |
---|
130 | kill roots, R; |
---|
131 | |
---|
132 | // slightly longer example |
---|
133 | ring R = 0,(a,b,c,d,t),dp; |
---|
134 | ideal I = |
---|
135 | a4+a2c2+3c4-1, |
---|
136 | 4a3b+2abc2+2a2cd+12c3d, |
---|
137 | 6a2b2+b2c2+4abcd+a2d2+18c2d2-1, |
---|
138 | 4ab3+2b2cd+2abd2+12cd3, |
---|
139 | b4+b2d2+3d4-t; |
---|
140 | interval i = -100,100; |
---|
141 | interval j = 0,2; |
---|
142 | box B = list(i,i,i,i,j); |
---|
143 | list roots1 = rootIsolation(I,B); roots1; |
---|
144 | // compare to case where we use triangular decomposition |
---|
145 | list roots2 = rootIsolation(std(I),B); roots2; |
---|
146 | kill roots1, roots2, i, j, B, R; |
---|
147 | |
---|
148 | tst_status(1);$; |
---|
149 | // vim: ft=singular |
---|