source: git/Tst/Manual/Solving_systems_of_polynomial_equations.tst @ 6fb723

spielwiese
Last change on this file since 6fb723 was 894057, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
ADD: Tests from online manual (res+stat on mamawutz): short ones Tst/Manual/s.lst
  • Property mode set to 100644
File size: 2.1 KB
Line 
1LIB "tst.lib"; tst_init();
2LIB "solve.lib";
3ring r=0,x(1..5),dp;
4poly f0= x(1)^3+x(2)^2+x(3)^2+x(4)^2-x(5)^2;
5poly f1= x(2)^3+x(1)^2+x(3)^2+x(4)^2-x(5)^2;
6poly f2=x(3)^3+x(1)^2+x(2)^2+x(4)^2-x(5)^2;
7poly f3=x(4)^2+x(1)^2+x(2)^2+x(3)^2-x(5)^2;
8poly f4=x(5)^2+x(1)^2+x(2)^2+x(3)^2;
9ideal i=f0,f1,f2,f3,f4;
10ideal 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)
14dim(si);
15//
16// the number of complex solutions (counted with multiplicities) is:
17vdim(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:
21option(redSB);
22ideal maxI=maxideal(1);
23ideal j=sat(si,maxI)[1];  // output is Groebner basis
24vdim(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):
29ring R=0,x(1..5),lp;
30ideal j=fglm(r,j);
31list L=triangMH(j);
32size(L);                 // number of triangular components
33L[1];                    // the first component
34//
35// We compute floating point approximations for the solutions (with 30 digits)
36def S=triang_solve(L,30);
37setring S;
38size(rlist);             // number of different non-zero solutions
39rlist[1];                // the first solution
40//
41// Alternatively, we could have applied directly the solve command:
42setring r;
43def T=solve(i,30,1,"nodisplay");  // compute all solutions with mult's
44setring T;
45size(SOL);               // number of different solutions
46SOL[1][1]; SOL[1][2];    // first solution and its multiplicity
47SOL[size(SOL)];          // solutions of highest multiplicity
48//
49// Or, we could remove the multiplicities first, by computing the
50// radical:
51setring r;
52ideal k=std(radical(i));
53vdim(k);                 // number of different complex solutions
54def T1=solve(k,30,"nodisplay");  // compute all solutions with mult's
55setring T1;
56size(SOL);               // number of different solutions
57SOL[1];
58tst_status(1);$
Note: See TracBrowser for help on using the repository browser.