1 | LIB "tst.lib"; tst_init(); |
---|
2 | proc milnorNumber (poly g) |
---|
3 | { |
---|
4 | "Milnor number:"; |
---|
5 | return(vdim(std(jacob(g)))); |
---|
6 | } |
---|
7 | |
---|
8 | proc tjurinaNumber |
---|
9 | { |
---|
10 | "Tjurina number:"; |
---|
11 | return(vdim(std(jacob(#[1])+#[1]))); |
---|
12 | } |
---|
13 | |
---|
14 | proc milnor_tjurina (poly f) |
---|
15 | { |
---|
16 | ideal j=jacob(f); |
---|
17 | list L=vdim(std(j)),vdim(std(j+f)); |
---|
18 | return(L); |
---|
19 | } |
---|
20 | |
---|
21 | proc real_sols (number b, number c) |
---|
22 | "USAGE: real_sols (b,c); b,c number |
---|
23 | ASSUME: active basering has characteristic 0 |
---|
24 | RETURN: list: first entry is an integer (the number of different real |
---|
25 | solutions). If this number is non-negative, the list has as second |
---|
26 | entry a ring in which the list SOL of real solutions of x^2+bx+c=0 |
---|
27 | is stored (as floating point number, precision 30 digits). |
---|
28 | NOTE: This procedure calls laguerre_solve from solve.lib. |
---|
29 | " |
---|
30 | { |
---|
31 | def oldring = basering; // assign name to the ring active when |
---|
32 | // calling the procedure |
---|
33 | number disc = b^2-4*c; |
---|
34 | if (disc>0) { int n_of_sols = 2; } |
---|
35 | if (disc==0) { int n_of_sols = 1; } |
---|
36 | string s = nameof(var(1)); // name of first ring variable |
---|
37 | if (disc>=0) { |
---|
38 | execute("ring rinC =(complex,30),("+s+"),lp;"); |
---|
39 | if (not(defined(laguerre_solve))) { LIB "solve.lib"; } |
---|
40 | poly f = x2+imap(oldring,b)*x+imap(oldring,c); |
---|
41 | // f is a local ring-dependent variable |
---|
42 | list SOL = laguerre_solve(f,30); |
---|
43 | export SOL; // make SOL a global ring-dependent variable |
---|
44 | // such variables are still accessible when the |
---|
45 | // ring is among the return values of the proc |
---|
46 | setring oldring; |
---|
47 | return(list(n_of_sols,rinC)); |
---|
48 | } |
---|
49 | else { |
---|
50 | return(list(0)); |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | // |
---|
55 | // We now apply the procedures which are defined by the |
---|
56 | // lines of code above: |
---|
57 | // |
---|
58 | ring r = 0,(x,y),ds; |
---|
59 | poly f = x7+y7+(x-y)^2*x2y2; |
---|
60 | |
---|
61 | milnorNumber(f); |
---|
62 | tjurinaNumber(f); |
---|
63 | milnor_tjurina(f); // a list containing Milnor and Tjurina number |
---|
64 | |
---|
65 | def L=real_sols(2,1); |
---|
66 | L[1]; // number of real solutions of x^2+2x+1 |
---|
67 | def R1=L[2]; |
---|
68 | setring R1; |
---|
69 | listvar(R1); // only global ring-dependent objects are still alive |
---|
70 | SOL; // the real solutions |
---|
71 | |
---|
72 | setring r; |
---|
73 | L=real_sols(1,1); |
---|
74 | L[1]; // number of reals solutions of x^2+x+1 |
---|
75 | |
---|
76 | setring r; |
---|
77 | L=real_sols(1,-5); |
---|
78 | L[1]; // number of reals solutions of x^2+x-5 |
---|
79 | def R3=L[2]; |
---|
80 | setring R3; SOL; // the real solutions |
---|
81 | tst_status(1);$ |
---|