Changeset 0d69875 in git
- Timestamp:
- Jun 29, 1999, 11:05:16 AM (24 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 31cb04bad383e04297522d6946776d17b7452307
- Parents:
- 9a6c4ae84f7d2709f65215910c1238b8642ea6ff
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/solve.lib
r9a6c4a r0d69875 1 1 /////////////////////////////////////////////////////////////////////////////// 2 2 3 version="$Id: solve.lib,v 1. 2 1999-06-28 16:48:58 SingularExp $";3 version="$Id: solve.lib,v 1.3 1999-06-29 09:05:16 wenk Exp $"; 4 4 info=" 5 5 LIBRARY: solve.lib PROCEDURES TO SOLVE POLYNOMIAL SYSTEMS … … 9 9 mp_res_mat(i,..); multipolynomial resultant matrix of ideal i 10 10 laguerre_solve(p,..); find all roots of univariate polynom p 11 interpolate(i,j ,d);interpolate poly from evaluation points i and results j11 interpolate(i,j); interpolate poly from evaluation points i and results j 12 12 "; 13 13 … … 18 18 k=0: use sparse resultant matrix of Gelfand, Kapranov and Zelevinsky 19 19 k=1: use resultant matrix of Macaulay (k=0 is default) 20 l>0: defines precision of fractional part if ground field is Q20 l>0: defines precision of fractional part if ground field is Q 21 21 m=0,1,2: number of iterations for approximation of roots (default=2) 22 ASSUME: i is a zerodimensional ideal with 23 nvars(basering) = ncols(i) = number of vars actually occuring in i 22 ASSUME: i is a zerodimensional ideal with 23 nvars(basering) = ncols(i) = number of vars actually occuring in i 24 24 RETURN: list of all (complex) roots of the polynomial system i = 0, 25 of type number if the ground field is the complex numbers,26 of type string if the ground field is the rational or real numbers25 of type number if the ground field is the complex numbers, 26 of type string if the ground field is the rational or real numbers 27 27 EXAMPLE: example ures_solve; shows an example 28 28 " 29 29 { 30 int typ= 2;30 int typ=0; 31 31 int polish=2; 32 32 int prec=30; 33 33 34 if ( size(#) >= 1 ) 35 { 36 typ= #[1]; 37 if ( typ < 0 || typ > 1 ) 38 { 39 ERROR("// Valid values for second parameter are: 40 // 0: use sparse Resultant (default) 41 // 1: use Macaulay Resultant"); 42 } 43 } 44 if ( size(#) >= 2 ) 45 { 46 prec= #[2]; 47 if ( prec == 0 ) { prec = 30; } 48 if ( prec < 0 ) 49 { 50 "// Fourth parameter must be positive!"; 51 return(); 52 } 53 } 54 if ( size(#) >= 3 ) 55 { 56 polish= #[3]; 57 if ( polish < 0 || polish > 3 ) 58 { 59 "// Valid values for third parameter are: "; 60 "// 0,1,2: number of iterations for approximation of roots"; 61 return(); 62 } 63 if ( polish == 0 ) { polish = 3; } 64 } 65 66 if ( size(#) > 3 ) 67 { 68 // Error 69 "// only three parameters allowed!"; 70 return(); 71 } 34 if ( size(#) >= 1 ) 35 { 36 typ= #[1]; 37 if ( typ < 0 || typ > 1 ) 38 { 39 ERROR("Valid values for second parameter k are: 40 0: use sparse Resultant (default) 41 1: use Macaulay Resultant"); 42 } 43 } 44 if ( size(#) >= 2 ) 45 { 46 prec= #[2]; 47 if ( prec == 0 ) { prec = 30; } 48 if ( prec < 0 ) 49 { 50 ERROR("Third parameter l must be positive!"); 51 } 52 } 53 if ( size(#) >= 3 ) 54 { 55 polish= #[3]; 56 if ( polish < 0 || polish > 2 ) 57 { 58 ERROR("Valid values for fourth parameter m are: 59 0,1,2: number of iterations for approximation of roots"); 60 } 61 } 62 63 if ( size(#) > 3 ) 64 { 65 ERROR("only three parameters allowed!"); 66 } 72 67 73 68 int digits= system("setFloatDigits",prec); 74 69 75 70 return(uressolve(gls,typ,polish)); 76 71 77 72 } 78 73 example … … 86 81 87 82 pause; 88 // now with complex coefficient field, precision is 10 digits 83 // now with complex coefficient field, precision is 10 digits 89 84 ring rsc= (real,10,I),(x,y),lp; 90 ideal i = x2 + y2 - 8, x2 + xy + 2y2;85 ideal i = x2 + y2 - 8, x2 + xy + 2y2; 91 86 ures_solve(i); 92 87 // result is a list of (x,y)-coordinates of complex numbers … … 96 91 proc laguerre_solve( poly f, list # ) 97 92 "USAGE: laguerre_solve( p[,l,m]); f poly, l,m integers 98 l>0: defines precision of fractional part if ground field is Q93 l>0: defines precision of fractional part if ground field is Q 99 94 m=0,1,2: number of iterations for approximation of roots (default=2) 100 95 ASSUME: p is an univariate polynom … … 103 98 " 104 99 { 105 int polish= 3;100 int polish=2; 106 101 int prec=30; 107 102 108 if ( size(#) >= 1 ) 109 { 110 prec= #[1]; 111 if ( prec == 0 ) { prec = 30; } 112 if ( prec < 0 ) 113 { 114 "// Fisrt parameter must be positive!"; 115 return(); 116 } 117 } 118 if ( size(#) >= 2 ) 119 { 120 polish= #[2]; 121 if ( polish == 0 ) { polish = 3; } 122 if ( polish < 0 || polish > 2 ) 123 { 124 "// Valid values for third parameter are: "; 125 "// 0,1,2: number of iterations for approximation of roots"; 126 return(); 127 } 128 } 129 if ( size(#) > 2 ) 130 { 131 "// only two parameters allowed!"; 132 return(); 133 } 103 if ( size(#) >= 1 ) 104 { 105 prec= #[1]; 106 if ( prec == 0 ) { prec = 30; } 107 if ( prec < 0 ) 108 { 109 ERROR("Fisrt parameter must be positive!"); 110 } 111 } 112 if ( size(#) >= 2 ) 113 { 114 polish= #[2]; 115 if ( polish < 0 || polish > 2 ) 116 { 117 ERROR("Valid values for third parameter are: 118 0,1,2: number of iterations for approximation of roots"); 119 } 120 } 121 if ( size(#) > 2 ) 122 { 123 ERROR("only two parameters allowed!"); 124 } 134 125 135 126 int digits= system("setFloatDigits",prec); 136 127 137 128 return(laguerre(f,polish)); 138 129 139 130 } 140 131 example … … 158 149 /////////////////////////////////////////////////////////////////////////////// 159 150 160 proc mp_res_mat( ideal gls, list # )151 proc mp_res_mat( ideal i, list # ) 161 152 "USAGE: mp_res_mat(i[,k]); i ideal, k integer 162 153 k=0: sparse resultant matrix of Gelfand, Kapranov and Zelevinsky 163 154 k=1: resultant matrix of Macaulay (k=0 is default) 164 155 ASSUME: nvars(basering) = ncols(i)-1 = number of vars actually occuring in i, 165 for k=1 i must be homogeneous 166 RETURN: module representing the multipolynomial resultant matrix 156 for k=1 i must be homogeneous 157 RETURN: module representing the multipolynomial resultant matrix 167 158 EXAMPLE: example mp_res_mat; shows an example 168 159 " … … 170 161 int typ=2; 171 162 172 if ( size(#) == 1 ) 173 { 174 typ= #[1]; 175 if ( typ == 0 ) { typ = 2; } 176 if ( typ < 0 || typ > 2 ) 177 { 178 "// Valid values for third parameter are: "; 179 "// 0: sparse resultant (default)"; 180 "// 1: Macaulay resultant"; 181 return(); 182 } 183 } 184 if ( size(#) > 1 ) 185 { 186 "// only two parameters allowed!"; 187 return(); 188 } 189 return(mpresmat(gls,typ)); 163 if ( size(#) == 1 ) 164 { 165 typ= #[1]; 166 if ( typ < 0 || typ > 1 ) 167 { 168 ERROR("Valid values for third parameter are: 169 0: sparse resultant (default) 170 1: Macaulay resultant"); 171 } 172 } 173 if ( size(#) > 1 ) 174 { 175 ERROR("only two parameters allowed!"); 176 } 177 178 return(mpresmat(i,typ)); 179 190 180 } 191 181 example … … 194 184 // compute resultant matrix in ring with parameters (sparse resultant matrix) 195 185 ring rsq= (0,u0,u1,u2),(x1,x2),lp; 196 ideal gls= u0+u1*x1+u2*x2,x1^2 + x2^2 - 10,x1^2 + x1*x2 + 2*x2^2 - 16;197 module m = mp_res_mat( gls);186 ideal i= u0+u1*x1+u2*x2,x1^2 + x2^2 - 10,x1^2 + x1*x2 + 2*x2^2 - 16; 187 module m = mp_res_mat(i); 198 188 print(m); 199 189 // computing sparse resultant … … 203 193 // compute resultant matrix (Macaulay resultant matrix) 204 194 ring rdq= (0,u0,u1,u2),(x0,x1,x2),lp; 205 ideal h gls= homog(imap(rsq,gls),x0);195 ideal h= homog(imap(rsq,i),x0); 206 196 hgls; 207 module m = mp_res_mat(h gls,1);197 module m = mp_res_mat(h,1); 208 198 print(m); 209 199 // computing Macaulay resultant (should be the same as above!) … … 213 203 // compute numerical sparse resultant matrix 214 204 setring rsq; 215 ideal glsr= 15+2*x1+5*x2,x1^2 + x2^2 - 10,x1^2 + x1*x2 + 2*x2^2 - 16;216 module mn = mp_res_mat( glsr);205 ideal ir= 15+2*x1+5*x2,x1^2 + x2^2 - 10,x1^2 + x1*x2 + 2*x2^2 - 16; 206 module mn = mp_res_mat(ir); 217 207 print(mn); 218 208 // computing sparse resultant … … 221 211 /////////////////////////////////////////////////////////////////////////////// 222 212 223 proc interpolate( ideal p, ideal w )224 "USAGE: interpolate(p,v ); p,v ideals225 ASSUME: ground field K is the rational or real or complexnumbers,213 proc interpolate( ideal p, ideal w, int d ) 214 "USAGE: interpolate(p,v,d); p,v ideals, d int 215 ASSUME: ground field K is the rational numbers, 226 216 p and v consist of numbers of the ground filed K, p must have 227 n elements, v must have N=(d+1)^n elements where n=nvars(basering) 228 and d=deg(f) (f is the unknown polynomial in K[x1,...,xn]) 217 n elements, v must have N=(d+1)^n elements where n=nvars(basering) 218 and d=deg(f) (f is the unknown polynomial in K[x1,...,xn]) 229 219 COMPUTE: polynomial f with values given by v at points p1,..,pN derived from p; 230 220 more precisely: consider p as point in K^n and v as N elements in K, 231 221 let p1,..,pN be the points in K^n obtained by evaluating all monomials 232 of degree <= dat p in lexicographical order,222 of degree 0,1,...,N at p in lexicographical order, 233 223 then the procedure computes the polynomial f satisfying f(pi) = v[i] 234 224 RETURN: polynomial f of degree d … … 237 227 " 238 228 { 239 return(vandermonde(p,w ));229 return(vandermonde(p,w,d)); 240 230 } 241 231 example … … 244 234 ring r1 = 0,(x),lp; 245 235 // First example: 246 // deg(f) = 4, 236 // deg(f) = 4, 247 237 // v = values of f at points 3^0, 3^1, 3^2, 3^3, 3^4 248 238 ideal v=16,0,11376,1046880,85949136; 249 interpolate( 3, v );239 interpolate( 3, v, 4 ); 250 240 251 241 ring r2 = 0,(x,y),dp; 252 // Second example: 242 // Second example: 253 243 // deg(f) = 3 254 244 // valuation point (2,3) … … 256 246 ideal p = 2,3; 257 247 ideal v= 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16; 258 interpolate( p,v ); 259 } 260 /////////////////////////////////////////////////////////////////////////////// 248 interpolate( p,v,3 ); 249 } 250 /////////////////////////////////////////////////////////////////////////////// 251 252 253 254 255 256
Note: See TracChangeset
for help on using the changeset viewer.