1 | LIB "tst.lib"; tst_init(); |
---|
2 | LIB "solve.lib"; |
---|
3 | ring r=0,x(1..5),dp; |
---|
4 | poly f0= x(1)^3+x(2)^2+x(3)^2+x(4)^2-x(5)^2; |
---|
5 | poly f1= x(2)^3+x(1)^2+x(3)^2+x(4)^2-x(5)^2; |
---|
6 | poly f2=x(3)^3+x(1)^2+x(2)^2+x(4)^2-x(5)^2; |
---|
7 | poly f3=x(4)^2+x(1)^2+x(2)^2+x(3)^2-x(5)^2; |
---|
8 | poly f4=x(5)^2+x(1)^2+x(2)^2+x(3)^2; |
---|
9 | ideal i=f0,f1,f2,f3,f4; |
---|
10 | ideal si=std(i); |
---|
11 | // |
---|
12 | // dimension of a solution set (here: 0) can be read from a Groebner bases |
---|
13 | // (with respect to any global monomial ordering) |
---|
14 | dim(si); |
---|
15 | // |
---|
16 | // the number of complex solutions (counted with multiplicities) is: |
---|
17 | vdim(si); |
---|
18 | // |
---|
19 | // The given system has a multiple solution at the origin. We use facstd |
---|
20 | // to compute equations for the non-zero solutions: |
---|
21 | option(redSB); |
---|
22 | ideal maxI=maxideal(1); |
---|
23 | ideal j=sat(si,maxI)[1]; // output is Groebner basis |
---|
24 | vdim(j); // number of non-zero solutions (with mult's) |
---|
25 | // |
---|
26 | // We compute a triangular decomposition for the ideal I. This requires first |
---|
27 | // the computation of a lexicographic Groebner basis (we use the FGLM |
---|
28 | // conversion algorithm): |
---|
29 | ring R=0,x(1..5),lp; |
---|
30 | ideal j=fglm(r,j); |
---|
31 | list L=triangMH(j); |
---|
32 | size(L); // number of triangular components |
---|
33 | L[1]; // the first component |
---|
34 | // |
---|
35 | // We compute floating point approximations for the solutions (with 30 digits) |
---|
36 | def S=triang_solve(L,30); |
---|
37 | setring S; |
---|
38 | size(rlist); // number of different non-zero solutions |
---|
39 | rlist[1]; // the first solution |
---|
40 | // |
---|
41 | // Alternatively, we could have applied directly the solve command: |
---|
42 | setring r; |
---|
43 | def T=solve(i,30,1,"nodisplay"); // compute all solutions with mult's |
---|
44 | setring T; |
---|
45 | size(SOL); // number of different solutions |
---|
46 | SOL[1][1]; SOL[1][2]; // first solution and its multiplicity |
---|
47 | SOL[size(SOL)]; // solutions of highest multiplicity |
---|
48 | // |
---|
49 | // Or, we could remove the multiplicities first, by computing the |
---|
50 | // radical: |
---|
51 | setring r; |
---|
52 | ideal k=std(radical(i)); |
---|
53 | vdim(k); // number of different complex solutions |
---|
54 | def T1=solve(k,30,"nodisplay"); // compute all solutions with mult's |
---|
55 | setring T1; |
---|
56 | size(SOL); // number of different solutions |
---|
57 | SOL[1]; |
---|
58 | tst_status(1);$ |
---|