Changeset 087a94 in git
- Timestamp:
- Mar 25, 2009, 12:27:13 PM (14 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
- Children:
- 16ed2f5aab6d00da628b5f73458c7045c9adaaf6
- Parents:
- 76afcdc23066a190fc8c0d2d82b16b5fd08c0215
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/tropical.lib
r76afcd r087a94 1 version="$Id: tropical.lib,v 1.1 1 2009-03-16 11:32:31keilen Exp $";1 version="$Id: tropical.lib,v 1.12 2009-03-25 11:27:13 keilen Exp $"; 2 2 category="Tropical Geometry"; 3 3 info=" … … 8 8 @* Thomas Markwig, email: keilen@mathematik.uni-kl.de 9 9 10 WARNING: 11 - tropicalLifting will only work under LINUX and if in addition gfan is installed. 12 @* - drawTropicalCurve and drawTropicalNewtonSubdivision will only display the tropical 13 curve under LINUX and if in addition latex and kghostview are installed. 14 @* - In tropicalLifting the basering needs the parameter t as a variable, while otherwise 15 it needs it as a parameter. 10 WARNING: 11 - tropicalLifting will only work with LINUX and if in addition gfan is installed. 12 @*- drawTropicalCurve and drawTropicalNewtonSubdivision will only display the 13 @* tropical curve with LINUX and if in addition latex and kghostview 14 @* are installed. 15 @*- For tropicalLifting in the definition of the basering the parameter t 16 @* from the Puiseux series field C{{t}} must be defined as a variable, 17 @* while for all other procedures it must be defined as a parameter. 16 18 17 19 THEORY: 18 Fix some base field K and a bunch of lattice points v0,...,vm in the integer lattice Z^n, 19 then this defines a toric variety as the closure of (K*)^n in the projective space P^m, where 20 the torus is embedded via the map sending a point x in (K*)^n to the point (x^v0,...,x^vm). 21 The generic hyperplane sections are just the images of the hypersurfaces in (K*)^n defined by 22 the polynomials f=a0*x^v0+...+am*x^vm=0. Some properties of these hypersurfaces can be studied 23 via tropicalisation. 24 25 For this we suppose that K=C{{t}} is the field of Puiseux series over the field of complex 26 numbers (or any other field with a valuation into the real numbers). One associates to the 27 hypersurface given by f=a0*x^v0+...+am*x^vm the tropical hypersurface defined by the tropicalisation 28 trop(f)=min{val(a0)+<v0,x>,...,val(am)+<vm,x>}. Here, <v,x> denotes the standard scalar product 29 of the integer vector v in Z^n with the vector x=(x1,...,xn) of variables, so that trop(f) is 30 a piecewise linear function on R^n. The corner locus of this function (i.e. the points at which 31 the minimum is attained a least twice) is the tropical hypersurface defined by trop(f). 32 The theorem of Newton-Kapranov states that this tropical hypersurface is the same as if one 33 computes pointwise the valuation of the hypersurface given by f. The analogue holds true if one 34 replaces one equation f by an ideal I. A constructive proof of the theorem is given by an adapted 35 version of the Newton-Puiseux algorithm. The hard part is to find a point in the variety over 36 C{{t}} which corresponds to a given point in the tropical variety. 37 38 It is the purpose of this library to provide basic means to deal with tropical varieties. 39 Of course we cannot represent the field of Puiseux series over C in its full strength, however, 40 in order to compute interesting examples it will be sufficient to replace the complex numbers C 41 by the rational numbers Q and to replace Puiseux series in t by rational functions in t, 42 i.e. we replace C{{t}} by Q(t), or sometimes even by Q[t]. Note, that this in particular 43 forbits rational exponents for the t's. 44 45 Moreover, in Singular no negative exponents of monomials are allowed, so that the integer vectors 46 vi will have to have non-negative entries. Shifting all exponents by a fixed integer vector does not 47 change the tropicalisation nor does it change the toric variety. 48 Thus this does not cause any restriction. 49 If, however, for some reason you prefer to work with general vi, then you have to pass right away to 50 the tropicalisation of the equations, whereever this is allowed -- these are linear polynomials 51 where the constant coefficient correspond to the valuation of the original coefficient and where 52 the non-constant coefficient correspond to the exponents of the monomials, thus they may be rational 53 numbers respectively negative numbers: 54 e.g. if f=t^{1/2}*x^{-2}*y^3+2t*x*y+4 then trop(f)=min{1/2-2x+3y,1+x+y,0}. 55 56 The main tools provided in this library are as follows: 57 @* - tropicalLifting implements the constructive proof of the Theorem of Newton-Kapranov and constructs 58 a point in the variety over C{{t}} corresponding to a given point in the 59 corresponding tropical variety associated to an ideal I; the generators of 60 I have to be in the polynomial ring Q[t,x1,...,xn] considered as a subring of 61 C{{t}}[x1,...,xn]; a solution will be constructed up to given order; note that 62 several field extensions of Q might be necessary thoughout the intermediate 63 computations; the procedures uses the external program gfan 64 @* - drawTropicalCurve visualises a tropical plane curve either given by a polynomial in Q(t)[x,y] 65 or by a list of linear polynomials of the form ax+by+c with a,b in Z and c in Q; 66 latex must be installed on your computer 67 @* - tropicalJInvariant computes the tropical j-invaiant of a tropical elliptic curve 68 @* - jInvariant computes the j-invariant of an elliptic curve 69 @* - weierstrassFom computes the Weierstrass form of an elliptic curve 70 71 PROCEDURES CONCERNED WITH TROPICAL LIFTING: 72 tropicalLifting(ideal,intvec,int) computes a point in the tropical variety of ideal over intvec 73 displayTropicalLifting(list) displays the output of tropicalLifting 74 75 PROCEDURES CONCERNED WITH DRAWING TROPICAL CURVES: 76 tropicalCurve(list) computes a tropical curve and its Newton subdivision 77 drawTropicalCurve(poly) produces a post script image of the tropical curve defined by poly 78 drawNewtonSubdivision(poly) produces a post script image of the Newton subdivision a tropical curve 79 80 PROCEDURES CONCERNED WITH J-INVARIANTS: 81 tropicalJInvariant(poly) computes the tropical j-invariant of the tropical curve poly 82 weierstrassForm(poly) computes the Weierstrass form of a cubic polynomial 83 jInvariant(poly) computes the j-invariant of a cubic polynomial 20 Fix some base field K and a bunch of lattice points v0,...,vm in the integer 21 lattice Z^n, then this defines a toric variety as the closure of (K*)^n in 22 the projective space P^m, where the torus is embedded via the map sending a 23 point x in (K*)^n to the point (x^v0,...,x^vm). 24 The generic hyperplane sections are just the images of the hypersurfaces 25 in (K*)^n defined by the polynomials f=a0*x^v0+...+am*x^vm=0. Some properties 26 of these hypersurfaces can be studied via tropicalisation. 27 28 For this we suppose that K=C{{t}} is the field of Puiseux series over the 29 field of complex numbers (or any other field with a valuation into the real 30 numbers). One associates to the hypersurface given by f=a0*x^v0+...+am*x^vm 31 the tropical hypersurface defined by the tropicalisation 32 trop(f)=min{val(a0)+<v0,x>,...,val(am)+<vm,x>}. 33 Here, <v,x> denotes the standard scalar product of the integer vector v in Z^n 34 with the vector x=(x1,...,xn) of variables, so that trop(f) is a piecewise 35 linear function on R^n. The corner locus of this function (i.e. the points 36 at which the minimum is attained a least twice) is the tropical hypersurface 37 defined by trop(f). 38 The theorem of Newton-Kapranov states that this tropical hypersurface is 39 the same as if one computes pointwise the valuation of the hypersurface 40 given by f. The analogue holds true if one replaces one equation f by an 41 ideal I. A constructive proof of the theorem is given by an adapted 42 version of the Newton-Puiseux algorithm. The hard part is to find a point 43 in the variety over C{{t}} which corresponds to a given point in the 44 tropical variety. 45 46 It is the purpose of this library to provide basic means to deal with 47 tropical varieties. Of course we cannot represent the field of Puiseux 48 series over C in its full strength, however, in order to compute interesting 49 examples it will be sufficient to replace the complex numbers C by the 50 rational numbers Q and to replace Puiseux series in t by rational functions 51 in t, i.e. we replace C{{t}} by Q(t), or sometimes even by Q[t]. 52 Note, that this in particular forbits rational exponents for the t's. 53 54 Moreover, in Singular no negative exponents of monomials are allowed, so 55 that the integer vectors vi will have to have non-negative entries. 56 Shifting all exponents by a fixed integer vector does not change the 57 tropicalisation nor does it change the toric variety. Thus this does not 58 cause any restriction. 59 If, however, for some reason you prefer to work with general vi, then you 60 have to pass right away to the tropicalisation of the equations, whereever 61 this is allowed -- these are linear polynomials where the constant coefficient 62 correspond to the valuation of the original coefficient and where 63 the non-constant coefficient correspond to the exponents of the monomials, 64 thus they may be rational numbers respectively negative numbers: 65 e.g. if f=t^{1/2}*x^{-2}*y^3+2t*x*y+4 then trop(f)=min{1/2-2x+3y,1+x+y,0}. 66 67 The main tools provided in this library are as follows: 68 @* - tropicalLifting implements the constructive proof of the Theorem of 69 Newton-Kapranov and constructs a point in the variety 70 over C{{t}} corresponding to a given point in the 71 corresponding tropical variety associated to an 72 ideal I; the generators of I have to be in the 73 polynomial ring Q[t,x1,...,xn] considered as a 74 subring of C{{t}}[x1,...,xn]; a solution will be 75 constructed up to given order; note that several 76 field extensions of Q might be necessary thoughout 77 the intermediate computations; the procedures uses 78 the external program gfan 79 @* - drawTropicalCurve visualises a tropical plane curve either given by a 80 polynomial in Q(t)[x,y] or by a list of linear 81 polynomials of the form ax+by+c with a,b in Z and c 82 in Q; latex must be installed on your computer 83 @* - tropicalJInvariant computes the tropical j-invaiant of a tropical 84 elliptic curve 85 @* - jInvariant computes the j-invariant of an elliptic curve 86 @* - weierstrassForm computes the Weierstrass form of an elliptic curve 87 88 PROCEDURES FOR TROPICAL LIFTING: 89 tropicalLifting computes a point in the tropical variety 90 displayTropicalLifting displays the output of tropicalLifting 91 92 PROCEDURES FOR DRAWING TROPICAL CURVES: 93 tropicalCurve computes a tropical curve and its Newton subdivision 94 drawTropicalCurve produces a post script image of a tropical curve 95 drawNewtonSubdivision produces a post script image of a Newton subdivision 96 97 PROCEDURES FOR J-INVARIANTS: 98 tropicalJInvariant computes the tropical j-invariant of a tropical curve 99 weierstrassForm computes the Weierstrass form of a cubic polynomial 100 jInvariant computes the j-invariant of a cubic polynomial 84 101 85 102 GENERAL PROCEDURES: 86 conicWithTangents(list) computes a conic through five points and the tangents in these points87 tropicalise(poly) computes the tropicalisation of thepolynomial88 tropicaliseSet(ideal) computes the tropicalisation of all polynomials in the ideal89 tInitialForm(poly,intvec) computes the tInitial form of poly in Q[t,x_1,...,x_n] w.r.t. intvec90 tInitialIdeal(ideal,intvec) computes the tInitial form of ideal in Q[t,x_1,...,x_n] w.r.t. intvec91 initialForm(poly,intvec) computes the initial form of poly in Q[x_1,...,x_n] w.r.t. intvec92 initialIdeal(ideal,intvec) computes the initial ideal of an ideal in Q[x_1,...,x_n] w.r.t. intvec93 94 PROCEDURES CONCERNED WITH THELATEX CONVERSION:95 texNumber(poly)outputs the texcommand for the leading coefficient of poly96 texPolynomial(poly) outputs the texcommand for the polynomial poly97 texMatrix(matrix)outputs the texcommand for the matrix98 texDrawBasic(list) embeds theoutput of texDrawTropical in a texdraw environment99 texDrawTropical(list)computes the texdraw commands for a tropical curve100 texDrawNewtonSubdivision(list) computes the texdraw commands for a Newton subdivision101 texDrawTriangulation(list,list) computes thetexdraw commands for a triangulation103 conicWithTangents computes a conic through five points with tangents 104 tropicalise computes the tropicalisation of a polynomial 105 tropicaliseSet computes the tropicalisation several polynomials 106 tInitialForm computes the tInitial form of a poly in Q[t,x_1,...,x_n] 107 tInitialIdeal computes the tInitial ideal of an ideal in Q[t,x_1,...,x_n] 108 initialForm computes the initial form of poly in Q[x_1,...,x_n] 109 initialIdeal computes the initial ideal of an ideal in Q[x_1,...,x_n] 110 111 PROCEDURES FOR LATEX CONVERSION: 112 texNumber outputs the texcommand for the leading coefficient of poly 113 texPolynomial outputs the texcommand for the polynomial poly 114 texMatrix outputs the texcommand for the matrix 115 texDrawBasic embeds output of texDrawTropical in a texdraw environment 116 texDrawTropical computes the texdraw commands for a tropical curve 117 texDrawNewtonSubdivision computes texdraw commands for a Newton subdivision 118 texDrawTriangulation computes texdraw commands for a triangulation 102 119 103 120 AUXILARY PROCEDURES: 104 radicalMemberShip(poly,ideal) checks if the poly is contained in the radical of ideal105 tInitialFormPar(poly,intvec) computes the t-initial form of poly in Q(t)[x_1,...,x_n] w.r.t. intvec106 tInitialFormParMax(poly,intvec) same as tInitialFormPar, but uses maximum instead of minimum107 solveTInitialFormPar(ideal) displays the approximated solution of a zero-dimensionalideal108 detropcialise(poly)computes the detropicalisation of a linear form109 dualConic(poly) computes the dual of the affine plane conic defined by poly110 parameterSubstitute(poly,int)substitutes in the poly the parameter t by t^N111 tropcialSubst(poly,int,list) computes the tropical polynomial of poly with certain substitutions112 randomPoly(int,int,int)computes a polynomial with random coefficients113 cleanTmp() removes the latex and ps files from /tmpcreated by other procedures121 radicalMemberShip checks radical membership 122 tInitialFormPar computes the t-initial form of poly in Q(t)[x_1,...,x_n] 123 tInitialFormParMax same as tInitialFormPar, but uses maximum 124 solveTInitialFormPar displays approximated solution of a 0-dim ideal 125 detropicalise computes the detropicalisation of a linear form 126 dualConic computes the dual of an affine plane conic 127 parameterSubstitute substitutes in the poly the parameter t by t^N 128 tropicalSubst makes certain substitutions in a tropical polynomial 129 randomPoly computes a polynomial with random coefficients 130 cleanTmp clears /tmp from files created by other procedures 114 131 115 132 KEYWORDS: tropical curves; tropical polynomials … … 117 134 "; 118 135 119 /////////////////////////////////////////////////////////////////////////////// /////136 /////////////////////////////////////////////////////////////////////////////// 120 137 /// Auxilary Static Procedures in this Library 121 /////////////////////////////////////////////////////////////////////////////// /////138 /////////////////////////////////////////////////////////////////////////////// 122 139 /// - phiOmega 123 140 /// - cutdown … … 138 155 /// - eliminatecomponents 139 156 /// - findzerosAndBasictransform 140 /// - ordermaximalideals 157 /// - ordermaximalideals 141 158 /// - verticesTropicalCurve 142 159 /// - bunchOfLines … … 171 188 /// - jInvariantOfA2x2Curve 172 189 /// - jInvariantOfAPuiseuxCubic 173 ////////////////////////////////////////////////////////////////////////////// ///////174 175 176 177 ////////////////////////////////////////////////////////////////////////////// //////190 ////////////////////////////////////////////////////////////////////////////// 191 192 193 194 ////////////////////////////////////////////////////////////////////////////// 178 195 LIB "random.lib"; 179 196 LIB "solve.lib"; … … 184 201 LIB "primdec.lib"; 185 202 LIB "absfact.lib"; 186 ////////////////////////////////////////////////////////////////////////////// //////187 188 /////////////////////////////////////////////////////////////////////////////// /////189 /// Procedures concerned with tropical parametrisation 190 /////////////////////////////////////////////////////////////////////////////// ////203 ////////////////////////////////////////////////////////////////////////////// 204 205 /////////////////////////////////////////////////////////////////////////////// 206 /// Procedures concerned with tropical parametrisation 207 /////////////////////////////////////////////////////////////////////////////// 191 208 192 209 proc tropicalLifting (ideal i,intvec w,int ordnung,list #) 193 210 "USAGE: tropicalLifting(i,w,ord[,opt]); i ideal, w intvec, ord int, opt string 194 ASSUME: - i is an ideal in Q[t,x_1,...,x_n], w=(w_0,w_1,...,w_n) 195 and (w_1/w_0,...,w_n/w_0) is in the tropical variety of i, 196 and ord is the order up to which a point in V(i) over Q{{t}} lying over 197 (w_1/w_0,...,w_n/w_0) shall be computed; w_0 may NOT be ZERO 198 @* - the basering should not have any parameters on its own 199 and it should have a global monomial ordering, e.g. ring r=0,(t,x(1..n)),dp; 200 @* - the first variable of the basering will be treated as the parameter t 201 in the Puiseux series field !!!! 202 @* - the optional parameter opt should be one or more strings among the following: 211 ASSUME: - i is an ideal in Q[t,x_1,...,x_n], w=(w_0,w_1,...,w_n) 212 and (w_1/w_0,...,w_n/w_0) is in the tropical variety of i, 213 and ord is the order up to which a point in V(i) over Q{{t}} 214 lying over (w_1/w_0,...,w_n/w_0) shall be computed; 215 w_0 may NOT be ZERO 216 @* - the basering should not have any parameters on its own 217 and it should have a global monomial ordering, 218 e.g. ring r=0,(t,x(1..n)),dp; 219 @* - the first variable of the basering will be treated as the 220 parameter t in the Puiseux series field !!!! 221 @* - the optional parameter opt should be one or more strings among 222 the following: 203 223 @* 'isZeroDimensional' : the dimension i is zero (not to be checked); 204 @* 'isPrime' : the ideal is prime over Q(t)[x_1,...,x_n] (not to be checked); 205 @* 'isInTrop' : (w_1/w_0,...,w_n/w_0) is in the tropical variety (not to be checked); 206 @* 'oldGfan' : uses gfan version 0.2.1 or less 207 @* 'findAll' : find all solutions of a zero-dimensional ideal over (w_1/w_0,...,w_n/w_0) 224 @* 'isPrime' : the ideal is prime over Q(t)[x_1,...,x_n] 225 (not to be checked); 226 @* 'isInTrop' : (w_1/w_0,...,w_n/w_0) is in the tropical 227 variety (not to be checked); 228 @* 'oldGfan' : uses gfan version 0.2.1 or less 229 @* 'findAll' : find all solutions of a zero-dimensional 230 ideal over (w_1/w_0,...,w_n/w_0) 208 231 @* 'noAbs' : do NOT use absolute primary decomposition 209 232 @* 'noResubst' : avoids computing the resubstitution 210 233 RETURN: IF THE OPTION 'findAll' WAS NOT SET THEN: 211 234 @* list, containing one lifting of the given point (w_1/w_0,...,w_n/w_0) 212 in the tropical variety of i to a point in V(i) over Puiseux series field up to213 the first ord terms; more precisely:235 in the tropical variety of i to a point in V(i) over Puiseux 236 series field up to the first ord terms; more precisely: 214 237 @* IF THE OPTION 'noAbs' WAS NOT SET THEN: 215 238 @* l[1] = ring Q[a]/m[[t]] … … 225 248 @* IF THE OPITON 'findAll' WAS NOT SET THEN: 226 249 @* list, containing ALL liftings of the given point ((w_1/w_0,...,w_n/w_0) 227 in the tropical variety of i to a point in V(i) over Puiseux series field up to 228 the first ord terms, if the ideal is zero-dimensional over Q{{t}}; 229 more precisely, each entry of the list is a list l as computed if 230 'find_all' was NOT set 250 in the tropical variety of i to a point in V(i) over Puiseux 251 series field up to the first ord terms, if the ideal is 252 zero-dimensional over Q{{t}}; 253 more precisely, each entry of the list is a list l as computed 254 if 'find_all' was NOT set 231 255 @* WE NOW DESCRIBE THE LIST ENTRIES IF 'findAll' WAS NOT SET: 232 @* - the ring l[1] contains an ideal LIFT, which contains 256 @* - the ring l[1] contains an ideal LIFT, which contains 233 257 a point in V(i) lying over w up to the first ord terms; 234 @* - and if the integer l[2] is N then t has to be replaced by t^1/N in the 235 lift, or alternatively replace t by t^N in the defining ideal 236 @* - if the k+1st entry of l[3] is non-zero, then the kth component of LIFT has to 237 be multiplied t^(-l[3][k]/l[3][1]) AFTER substituting t by t^1/N 238 @* - unless the option 'noResubst' was set, the kth entry of list l[4] 258 @* - and if the integer l[2] is N then t has to be replaced by t^1/N 259 in the lift, or alternatively replace t by t^N in the defining ideal 260 @* - if the k+1st entry of l[3] is non-zero, then the kth component of 261 LIFT has to be multiplied t^(-l[3][k]/l[3][1]) AFTER substituting t 262 by t^1/N 263 @* - unless the option 'noResubst' was set, the kth entry of list l[4] 239 264 is a string which represents the kth generator of 240 the ideal i where the coordinates have been replaced by the result of the lift; 241 the t-order of the kth entry should in principle be larger than the t-degree of LIFT 242 @* - if the option 'noAbs' was set, then the string in l[5] defines a maximal ideal in the 243 field Q[X(1),...,X(k)], where X(1),...,X(k) are the parameters of the ring in l[1]; 244 the basefield of the ring in l[1] should be considered modulo this ideal 245 REMARK: - it is best to use the procedure displayTropicalLifting to display the result 265 the ideal i where the coordinates have been replaced by the result 266 of the lift; 267 the t-order of the kth entry should in principle be larger than the 268 t-degree of LIFT 269 @* - if the option 'noAbs' was set, then the string in l[5] defines 270 a maximal ideal in the field Q[X(1),...,X(k)], where X(1),...,X(k) 271 are the parameters of the ring in l[1]; 272 the basefield of the ring in l[1] should be considered modulo this 273 ideal 274 REMARK: - it is best to use the procedure displayTropicalLifting to 275 display the result 246 276 @* - the option 'findAll' cannot be used if 'noAbs' is set 247 @* - if the parameter 'findAll' is set AND the ideal i is zero-dimensional in Q{{t}}[x_1,...,x_n] 248 then ALL points in V(i) lying over w are computed up to order ord; if the ideal 249 is not-zero dimenisonal, then only all points in the ideal after cutting down 250 to dimension zero will be computed 251 @* - the procedure REQUIRES that the program GFAN is installed on your computer; 252 if you have GFAN version less than 0.3.0 then you MUST use the optional 253 parameter 'oldGfan' 254 @* - the procedure requires the Singular procedure absPrimdecGTZ to be present in 255 the package primdec.lib, unless the option 'noAbs' is set; but even if absPrimdecGTZ 256 is present it might be necessary to set the option 'noAbs' in order to avoid 257 the costly absolute primary decomposition; the side effect is that the field 258 extension which is computed throughout the recursion might need more only one 277 @* - if the parameter 'findAll' is set AND the ideal i is zero-dimensional 278 in Q{{t}}[x_1,...,x_n] then ALL points in V(i) lying over w are 279 computed up to order ord; if the ideal is not-zero dimenisonal, then 280 only all points in the ideal after cutting down to dimension zero 281 will be computed 282 @* - the procedure REQUIRES that the program GFAN is installed on your 283 computer; if you have GFAN version less than 0.3.0 then you MUST 284 use the optional parameter 'oldGfan' 285 @* - the procedure requires the Singular procedure absPrimdecGTZ to be 286 present in the package primdec.lib, unless the option 'noAbs' is set; 287 but even if absPrimdecGTZ is present it might be necessary to set 288 the option 'noAbs' in order to avoid the costly absolute primary 289 decomposition; the side effect is that the field extension which is 290 computed throughout the recursion might need more only one 259 291 parameter to be described 260 292 @* - since Q is infinite, the procedure finishes with probability one 261 @* - you can call the procedure with Z/pZ as base field instead of Q, but there 262 are some problems you should be aware of: 263 @* + the Puiseux series field over the algebraic closure of Z/pZ is NOT algebraicall closed, 264 and thus there may not exist a point in V(i) over the Puiseux series field 265 with the desired valuation; so there is no chance that the procedure produced 266 a sensible output - e.g. if i=tx^p-tx-1 267 @* + if the dimension of i over Z/pZ(t) is not zero the process of reduction to 268 zero might not work if the characteristic is small and you are unlucky 269 @* + the option 'noAbs' has to be used since absolute primary decomposition in 270 Singular only works in characteristic zero 271 @* - the basefield should either be Q or Z/pZ for some prime p; field extensions 272 will be computed where necessary; if you need parameters or field extensions 273 from the beginning they should rather be simulated as variables possibly adding 274 their relations to the ideal; the weights for the additional variables should be zero 293 @* - you can call the procedure with Z/pZ as base field instead of Q, 294 but there are some problems you should be aware of: 295 @* + the Puiseux series field over the algebraic closure of Z/pZ is 296 NOT algebraicall closed, and thus there may not exist a point in 297 V(i) over the Puiseux series field with the desired valuation; 298 so there is no chance that the procedure produced a sensible output 299 - e.g. if i=tx^p-tx-1 300 @* + if the dimension of i over Z/pZ(t) is not zero the process of 301 reduction to zero might not work if the characteristic is small 302 and you are unlucky 303 @* + the option 'noAbs' has to be used since absolute primary 304 decomposition in Singular only works in characteristic zero 305 @* - the basefield should either be Q or Z/pZ for some prime p; 306 field extensions will be computed where necessary; if you need 307 parameters or field extensions from the beginning they should 308 rather be simulated as variables possibly adding their relations to 309 the ideal; the weights for the additional variables should be zero 275 310 EXAMPLE: example tropicalLifting; shows an example" 276 311 { … … 280 315 ERROR("The procedure is not implemented for rings with parameters. See: help tropicalLifting; for more information"); 281 316 } 282 // in order to avoid unpleasent surprises with the names of the variables we change283 // to a ring where the variables have names t and x(1),...,x(n)317 // in order to avoid unpleasent surprises with the names of the variables 318 // we change to a ring where the variables have names t and x(1),...,x(n) 284 319 def ALTERRING=basering; 285 320 if (nvars(basering)==2) … … 322 357 noabs=1; 323 358 } 324 // this option is not documented -- it prevents the execution of gfan and just asks 325 // for wneu to be inserted -- it can be used to check problems with the precedure 326 // without calling gfan, if wneu is know from previous computations 359 // this option is not documented -- it prevents the execution of gfan and 360 // just asks for wneu to be inserted -- it can be used to check problems 361 // with the precedure without calling gfan, if wneu is know from previous 362 // computations 327 363 if (#[j]=="noGfan") 328 364 { … … 334 370 } 335 371 } 336 // if the basering has characteristic not equal to zero, then absolute factorisation 372 // if the basering has characteristic not equal to zero, 373 // then absolute factorisation 337 374 // is not available, and thus we need the option noAbs 338 375 /* … … 347 384 { 348 385 Error("The first coordinate of your input w must be NON-ZERO, since it is a DENOMINATOR!"); 349 } 386 } 350 387 // if w_0<0, then replace w by -w, so that the "denominator" w_0 is positive 351 388 if (w[1]<0) … … 354 391 } 355 392 intvec prew=w; // stores w for later reference 356 // for our computations, w[1] represents the weight of t and this should be -w_0 !!! 393 // for our computations, w[1] represents the weight of t and this 394 // should be -w_0 !!! 357 395 w[1]=-w[1]; 358 396 // if w_0!=-1 then replace t by t^-w_0 and w_0 by -1 … … 363 401 w[1]=-1; 364 402 } 365 // if some entry of w is positive, we have to make a transformation, 403 // if some entry of w is positive, we have to make a transformation, 366 404 // which moves it to something non-positive 367 405 for (j=2;j<=nvars(basering);j++) … … 375 413 } 376 414 prew[1]=prew[1]+w[1]; 377 prew=prew-w; // this now contains the positive part of the original w, but the original first comp. of w 415 prew=prew-w; // this now contains the positive part of the original w, 416 // but the original first comp. of w 378 417 // pass to a ring which represents Q[t]_<t>[x1,...,xn] 379 418 // for this, unfortunately, t has to be the last variable !!! … … 388 427 { 389 428 variablen=variablen+var(j); 390 } 429 } 391 430 map GRUNDPHI=BASERING,t,variablen; 392 431 ideal i=GRUNDPHI(i); 393 // compute the initial ideal of i and test if w is in the tropical variety of i 432 // compute the initial ideal of i and test if w is in the tropical 433 // variety of i 394 434 // - the last entry 1 only means that t is the last variable in the ring 395 435 ideal ini=tInitialIdeal(i,w,1); 396 436 if (isintrop==0) // test if w is in trop(i) only if isInTrop has not been set 397 { 437 { 398 438 poly product=1; 399 439 for (j=1;j<=nvars(basering)-1;j++) … … 401 441 product=product*var(j); 402 442 } 403 if (radicalMemberShip(product,ini)==1) // if w is not in Trop(i) return an error message443 if (radicalMemberShip(product,ini)==1) // if w is not in Trop(i) - error 404 444 { 405 445 ERROR("The integer vector is not in the tropical variety of the ideal."); 406 446 } 407 447 } 408 // compute next the dimension of i in K(t)[x] and cut the ideal down to dim ension zero448 // compute next the dimension of i in K(t)[x] and cut the ideal down to dim 0 409 449 if (iszerodim==0) // do so only if is_dim_zero is not set 410 450 { … … 413 453 int dd=dim(i); 414 454 setring GRUNDRING; 415 // if the dimension is not zero, we cut the ideal down to dimension zero and compute the 455 // if the dimension is not zero, we cut the ideal down to dimension zero 456 // and compute the 416 457 // t-initial ideal of the new ideal at the same time 417 458 if(dd!=0) 418 459 { 419 // the procedurce cutdown computes a new ring, in which there lives a zero-dimensional 420 // ideal which has been computed by cutting down the input with generic linear forms 421 // of the type x_i1-p_1,...,x_id-p_d for some polynomials p_1,...,p_d not depending 422 // on the variables x_i1,...,x_id; that way we have reduced the number of variables by dd !!! 423 // the new zero-dimensional ideal is called i, its t-initial ideal (with respect to 424 // the new w=CUTDOWN[2]) is ini, and finally there is a list repl in the ring 425 // which contains at the polynomial p_j at position i_j and a zero otherwise; 460 // the procedurce cutdown computes a new ring, in which there lives a 461 // zero-dimensional 462 // ideal which has been computed by cutting down the input with 463 // generic linear forms 464 // of the type x_i1-p_1,...,x_id-p_d for some polynomials 465 // p_1,...,p_d not depending 466 // on the variables x_i1,...,x_id; that way we have reduced 467 // the number of variables by dd !!! 468 // the new zero-dimensional ideal is called i, its t-initial 469 // ideal (with respect to 470 // the new w=CUTDOWN[2]) is ini, and finally there is a list 471 // repl in the ring 472 // which contains at the polynomial p_j at position i_j and 473 //a zero otherwise; 426 474 if (isprime==0) // the minimal associated primes of i are computed 427 475 { … … 444 492 list liftrings; // will contain the final result 445 493 // if the procedure is called without 'findAll' then it may happen, that no 446 // proper solution is found when dd>0; in that case we have to start all over again; 494 // proper solution is found when dd>0; in that case we have 495 // to start all over again; 447 496 // this is controlled by the while-loop 448 497 while (size(liftrings)==0) 449 498 { 450 // compute thelifting for the zero-dimensional ideal via tropicalparametrise499 // compute lifting for the zero-dimensional ideal via tropicalparametrise 451 500 if (noabs==1) // do not use absolute primary decomposition 452 501 { … … 459 508 // compute the liftrings by resubstitution 460 509 kk=1; // counts the liftrings 461 int isgood; // test in the non-zerodimensional case if the result has the correct valuation 510 int isgood; // test in the non-zerodimensional case 511 // if the result has the correct valuation 462 512 for (jj=1;jj<=size(TP);jj++) 463 513 { 464 // the list TP contains as a first entry the ring over which the tropical parametrisation 514 // the list TP contains as a first entry the ring over which the 515 // tropical parametrisation 465 516 // of the (possibly cutdown ideal) i lives 466 517 def LIFTRING=TP[jj][1]; 467 // if the dimension of i originally was not zero, then we have to fill in the missing 518 // if the dimension of i originally was not zero, 519 // then we have to fill in the missing 468 520 // parts of the parametrisation 469 521 if (dd!=0) 470 522 { 471 // we need a ring where the parameters X_1,...,X_k from LIFTRING are present, 523 // we need a ring where the parameters X_1,...,X_k 524 // from LIFTRING are present, 472 525 // and where also the variables of CUTDOWNRING live 473 526 execute("ring REPLACEMENTRING=("+charstr(LIFTRING)+"),("+varstr(CUTDOWNRING)+"),dp;"); 474 list repl=imap(CUTDOWNRING,repl); // get the replacement rules from CUTDOWNRING 475 ideal PARA=imap(LIFTRING,PARA); // get the zero-dim. parametrisation from LIFTRING 527 list repl=imap(CUTDOWNRING,repl); // get the replacement rules 528 // from CUTDOWNRING 529 ideal PARA=imap(LIFTRING,PARA); // get the zero-dim. parametrisatio 530 // from LIFTRING 476 531 // compute the lift of the solution of the original ideal i 477 532 ideal LIFT; 478 533 k=1; 479 for (j=1;j<=nvars(GRUNDRING)-1;j++) // the lift has as many components as GRUNDRING has variables!=t 534 // the lift has as many components as GRUNDRING has variables!=t 535 for (j=1;j<=nvars(GRUNDRING)-1;j++) 480 536 { 481 if (repl[j]==0) // if repl[j]=0, then the corresponding variable was not eliminated 537 // if repl[j]=0, then the corresponding variable was not eliminated 538 if (repl[j]==0) 482 539 { 483 LIFT[j]=PARA[k]; // thus the lift has been computed by tropicalparametrise 540 LIFT[j]=PARA[k]; // thus the lift has been 541 // computed by tropicalparametrise 484 542 k++; // k checks how many entries of PARA have already been used 485 543 } 486 else // if repl[j]!=0, then repl[j] contains thereplacement rule for the lift544 else // if repl[j]!=0, repl[j] contains replacement rule for the lift 487 545 { 488 LIFT[j]=repl[j]; // we still have to replace the vars in repl[j] by the corresp. entries of PARA 489 for (l=1;l<=nvars(CUTDOWNRING)-1;l++) // replace all variables!=t (from CUTDOWNRING) 546 LIFT[j]=repl[j]; // we still have to replace the vars 547 // in repl[j] by the corresp. entries of PARA 548 // replace all variables!=t (from CUTDOWNRING) 549 for (l=1;l<=nvars(CUTDOWNRING)-1;l++) 490 550 { 491 LIFT[j]=subst(LIFT[j],var(l),PARA[l]); // substitute the kth variable by PARA[k] 551 // substitute the kth variable by PARA[k] 552 LIFT[j]=subst(LIFT[j],var(l),PARA[l]); 492 553 } 493 554 } 494 555 } 495 556 setring LIFTRING; 496 ideal LIFT=imap(REPLACEMENTRING,LIFT); 497 // test now if the LIFT has the correct valuation !!! 498 // note: it may happen, that when resubstituting PARA into the replacement rules 499 // there occured some unexpected cancellation; we only know that for SOME 500 // solution of the zero-dimensional reduction NO canellation will occur, 501 // but for others this may very well happen; this in particular means that 502 // we possibly MUST compute all zero-dimensional solutions when cutting down! 557 ideal LIFT=imap(REPLACEMENTRING,LIFT); 558 // test now if the LIFT has the correct valuation !!! 559 // note: it may happen, that when resubstituting PARA into 560 // the replacement rules 561 // there occured some unexpected cancellation; 562 // we only know that for SOME 563 // solution of the zero-dimensional reduction NO 564 // canellation will occur, 565 // but for others this may very well happen; 566 // this in particular means that 567 // we possibly MUST compute all zero-dimensional 568 // solutions when cutting down! 503 569 intvec testw=precutdownw[1]; 504 570 for (j=1;j<=size(LIFT);j++) … … 522 588 } 523 589 kill PARA; 524 if (isgood==1) // only if LIFT has the right valuation we have to do something 525 { 526 // it remains to reverse the original substitutions, where appropriate !!! 527 // if some entry of the original w was positive, we replace the corresponding 528 // variable x_i by t^-w[i]*x_i, so we must now replace the corresponding entry 590 // only if LIFT has the right valuation we have to do something 591 if (isgood==1) 592 { 593 // it remains to reverse the original substitutions, 594 // where appropriate !!! 595 // if some entry of the original w was positive, 596 // we replace the corresponding 597 // variable x_i by t^-w[i]*x_i, so we must now replace 598 // the corresponding entry 529 599 // LIFT[i] by t^-w[i]*LIFT[i] --- the original w is stored in prew 530 600 // PROBLEM: THIS CANNOT BE DONE SINCE -w[i] IS NEGATIVE … … 539 609 } 540 610 */ 541 if ((noabs==0) and (defined(@a)==-1)) // if LIFTRING contains a parameter @a, change it to a 611 // if LIFTRING contains a parameter @a, change it to a 612 if ((noabs==0) and (defined(@a)==-1)) 542 613 { 543 // pass first to a ring where a and @a are variables in order to use maps 614 // pass first to a ring where a and @a 615 // are variables in order to use maps 544 616 poly mp=minpoly; 545 617 ring INTERRING=char(LIFTRING),(t,@a,a),dp; … … 549 621 // replace @a by a in minpoly and in LIFT 550 622 map phi=INTERRING,t,a,a; 551 mp=phi(mp); 623 mp=phi(mp); 552 624 LIFT=phi(LIFT); 553 625 // pass now to a ring whithout @a and with a as parameter … … 556 628 ideal LIFT=imap(INTERRING,LIFT); 557 629 kill INTERRING; 558 } 630 } 559 631 // then export LIFT 560 export(LIFT); 632 export(LIFT); 561 633 // test the result by resubstitution 562 setring GRUNDRING; 634 setring GRUNDRING; 563 635 list resubst; 564 636 if (noresubst==0) … … 569 641 } 570 642 else 571 { 643 { 572 644 resubst=tropicalliftingresubstitute(substitute(i,t,t^(TP[jj][2])),list(LIFTRING),N*TP[jj][2]); 573 645 } 574 646 } 575 647 setring BASERING; 576 // Finally, if t has been replaced by t^N, then we have to change the 648 // Finally, if t has been replaced by t^N, then we have to change the 577 649 // third entry of TP by multiplying by N. 578 650 if (noabs==1) … … 590 662 kill LIFTRING; 591 663 } 592 // if dd!=0 and the procedure was called without the option findAll, then it might very well 593 // be the case that no solution is found, since only one solution for the zero-dimensional 594 // reduction was computed and this one might have had cancellations when resubstituting; 664 // if dd!=0 and the procedure was called without the 665 // option findAll, then it might very well 666 // be the case that no solution is found, since 667 // only one solution for the zero-dimensional 668 // reduction was computed and this one might have 669 // had cancellations when resubstituting; 595 670 // if so we have to restart the process with the option findAll 596 671 if (size(liftrings)==0) … … 599 674 "The procedure will be restarted with the option 'findAll'."; 600 675 "Go on by hitting RETURN!"; 601 findall=1; 676 findall=1; 602 677 noabs=0; 603 678 setring CUTDOWNRING; … … 605 680 "i";i; 606 681 "ini";tInitialIdeal(i,w,1); 607 682 608 683 /* 609 684 setring GRUNDRING; … … 623 698 } 624 699 } 625 // if internally the option findall was set, then return only the first solution 700 // if internally the option findall was set, then return 701 // only the first solution 626 702 if (defined(hadproblems)!=0) 627 703 { … … 631 707 if (voice+printlevel>=2) 632 708 { 633 709 634 710 "The procedure has created a list of lists. The jth entry of this list 635 711 contains a ring, an integer and an intvec. 636 712 In this ring lives an ideal representing the wanted lifting, 637 713 if the integer is N then in the parametrisation t has to be replaced by t^1/N, 638 and if the ith component of the intvec is w[i] then the ith component in LIFT 714 and if the ith component of the intvec is w[i] then the ith component in LIFT 639 715 should be multiplied by t^-w[i]/N in order to get the parametrisation. 640 716 641 717 Suppose your list has the name L, then you can access the 1st ring via: 642 718 "; 643 719 if (findall==1) 644 720 { 645 "def LIFTRing=L[1][1]; setring LIFTRing; LIFT; 721 "def LIFTRing=L[1][1]; setring LIFTRing; LIFT; 646 722 "; 647 723 } 648 724 else 649 725 { 650 "def LIFTRing=L[1]; setring LIFTRing; LIFT; 726 "def LIFTRing=L[1]; setring LIFTRing; LIFT; 651 727 "; 652 } 728 } 653 729 } 654 730 if (findall==1) // if all solutions have been computed, return a list of lists … … 656 732 return(liftrings); 657 733 } 658 else // if only one solution was to be computed, then return only the first list in liftrings734 else //if only 1 solution was to be computed, return the 1st list in liftrings 659 735 { 660 736 liftrings=liftrings[1]; … … 675 751 def LIFTRing=LIST[1]; 676 752 setring LIFTRing; 677 // LIFT contains the first 4 terms of a point in the variety of i 753 // LIFT contains the first 4 terms of a point in the variety of i 678 754 // over the Puiseux series field C{{t}} whose order is -w[1]/w[0]=1 679 755 LIFT; … … 703 779 // NOTE: since the last component of v is positive, the lifting 704 780 // must start with a negative power of t, which in Singular 705 // is not allowed for a variable. 781 // is not allowed for a variable. 706 782 def LIFTRing3=LIST[1]; 707 783 setring LIFTRing3; … … 713 789 } 714 790 791 /////////////////////////////////////////////////////////////////////////////// 792 715 793 proc displayTropicalLifting (list troplift,list #) 716 "USAGE: 717 ASSUME: 718 719 RETURN: 720 NOTE: 721 @* 722 723 EXAMPLE: 794 "USAGE: displaytropcallifting(troplift[,#]); troplift list, # list 795 ASSUME: troplift is the output of tropicalLifting; the optional parameter 796 # can be the string 'subst' 797 RETURN: none 798 NOTE: - the procedure displays the output of the procedure tropicalLifting 799 @* - if the optional parameter 'subst' is given, then the lifting is 800 substituted into the ideal and the result is displayed 801 EXAMPLE: example displayTropicalLifting; shows an example" 724 802 { 725 803 int j; … … 756 834 string Kstring="Z/"+string(char(LIFTRing))+"Z"; 757 835 } 758 if (size(troplift)==4) // this means that tropicalLifting was called with absolute primary decomposition 759 { 836 // this means that tropicalLifting was called with 837 // absolute primary decomposition 838 if (size(troplift)==4) 839 { 760 840 setring LIFTRing; 761 841 "The lifting of the point in the tropical variety lives in the ring"; 762 842 if ((size(LIFTpar)==0) and (N==1)) 763 843 { 764 Kstring+"[[t]]"; 844 Kstring+"[[t]]"; 765 845 } 766 846 if ((size(LIFTpar)==0) and (N!=1)) 767 847 { 768 Kstring+"[[t^(1/"+string(N)+")]]"; 848 Kstring+"[[t^(1/"+string(N)+")]]"; 769 849 } 770 850 if ((size(LIFTpar)!=0) and (N!=1)) 771 { 772 Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]"; 851 { 852 Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]"; 773 853 } 774 854 if ((size(LIFTpar)!=0) and (N==1)) 775 { 776 Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]"; 855 { 856 Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]"; 777 857 } 778 858 } … … 791 871 } 792 872 if ((size(LIFTpar)!=0) and (N!=1)) 793 { 794 Kstring+"["+LIFTpar+"]/M[[t^(1/"+string(N)+")]]"; 873 { 874 Kstring+"["+LIFTpar+"]/M[[t^(1/"+string(N)+")]]"; 795 875 "where M is the maximal ideal"; 796 876 "M=<"+m+">"; 797 877 } 798 878 if ((size(LIFTpar)!=0) and (N==1)) 799 { 800 Kstring+"["+LIFTpar+"]/M[[t]]"; 879 { 880 Kstring+"["+LIFTpar+"]/M[[t]]"; 801 881 "where M is the maximal ideal"; 802 882 "M=<"+m+">"; 803 } 883 } 804 884 } 805 885 ""; … … 828 908 } 829 909 } 830 } 910 } 831 911 } 832 912 example … … 841 921 842 922 843 //////////////////////////////////////////////////////////////////////////////////// 844 /// Procedures concerned with drawing a tropical curve or a Newton subdivision 845 //////////////////////////////////////////////////////////////////////////////////// 923 /////////////////////////////////////////////////////////////////////////////// 924 /// Procedures concerned with drawing a tropical curve or a Newton subdivision 925 /////////////////////////////////////////////////////////////////////////////// 926 846 927 proc tropicalCurve (def tp,list #) 847 928 "USAGE: tropicalCurve(tp[,#]); tp list, # optional list 848 ASSUME: tp is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c 849 representing a tropical Laurent polynomial defining a tropical plane curve; 850 alternatively tp can be a polynomial in Q(t)[x,y] defining a tropical plane curve 851 via the valuation map; 852 the basering must have a global monomial ordering, two variables and up to one parameter! 853 RETURN: list, each entry i=1,...,size(l)-1 corresponds to a vertex in the tropical plane 854 curve defined by tp 929 ASSUME: tp is list of linear polynomials of the form ax+by+c 930 with integers a, b and a rational number c representing 931 a tropical Laurent polynomial defining a tropical plane curve; 932 alternatively tp can be a polynomial in Q(t)[x,y] defining a 933 tropical plane curve via the valuation map; 934 the basering must have a global monomial ordering, 935 two variables and up to one parameter! 936 RETURN: list, each entry i=1,...,size(l)-1 corresponds to a vertex 937 in the tropical plane curve defined by tp 855 938 l[i][1] = x-coordinate of the ith vertex 856 939 l[i][2] = y-coordinate of the ith vertex 857 l[i][3] = intmat, if j is an entry in the first row of intmat then the ith vertex of 858 the tropical curve is connected to the jth vertex with multiplicity given 940 l[i][3] = intmat, if j is an entry in the first row 941 of intmat then the ith vertex of 942 the tropical curve is connected to the 943 jth vertex with multiplicity given 859 944 by the corresponding entry in the second row 860 l[i][4] = list of lists, the first entry of a list is a primitive integer vector 861 defining the direction of an unbounded edge emerging from the ith vertex 862 of the graph, the corresponding second entry in the list is the multiplicity 863 of the unbounded edge 864 l[i][5] = a polynomial whose monomials mark the vertices in the Newton polygon 865 corresponding to the entries in tp which take the common minimum 866 at the ith vertex -- if some coefficient a or b of the linear polynomials 867 in the input was negative, then each monomial has to be shifted by 945 l[i][4] = list of lists, the first entry of a list is 946 a primitive integer vector defining the direction 947 of an unbounded edge emerging from the ith vertex 948 of the graph, the corresponding second entry in 949 the list is the multiplicity of the unbounded edge 950 l[i][5] = a polynomial whose monomials mark the vertices 951 in the Newton polygon corresponding to the entries 952 in tp which take the common minimum at the ith 953 vertex -- if some coefficient a or b of the 954 linear polynomials in the input was negative, 955 then each monomial has to be shifted by 868 956 the values in l[size(l)][3] 869 l[size(l)][1] = list, the entries describe the boundary points of the Newton subdivision 870 l[size(l)][2] = list, the entries are pairs of integer vectors defining an interior 871 edge of the Newton subdivision 872 l[size(l)][3] = intvec, the monmials occuring in l[i][5] have to be shifted by this 873 vector in order to represent marked vertices in the Newton polygon 874 NOTE: here the tropical polynomial is supposed to be the MINIMUM of the linear forms in tp, 875 unless the optional input #[1] is the string 'max' 957 l[size(l)][1] = list, the entries describe the boundary 958 points of the Newton subdivision 959 l[size(l)][2] = list, the entries are pairs of integer 960 vectors defining an interior 961 edge of the Newton subdivision 962 l[size(l)][3] = intvec, the monmials occuring in l[i][5] 963 have to be shifted by this vector 964 in order to represent marked 965 vertices in the Newton polygon 966 NOTE: here the tropical polynomial is supposed to be the MINIMUM 967 of the linear forms in tp, unless the optional input #[1] 968 is the string 'max' 876 969 EXAMPLE: example tropicalCurve; shows an example" 877 970 { … … 885 978 ERROR("The basering should have a global monomial ordering, e.g. ring r=(0,t),(x,y),dp;"); 886 979 } 887 // if you insert a single polynomial instead of an ideal representing a tropicalised polynomial, 888 // then we compute first the tropicalisation of this polynomial -- this feature is not 889 // documented in the above help string 980 // if you insert a single polynomial instead of an ideal 981 // representing a tropicalised polynomial, 982 // then we compute first the tropicalisation of this polynomial 983 // -- this feature is not documented in the above help string 890 984 if (typeof(tp)=="poly") 891 985 { 892 // exclude the case that the basering has not precisely one parameter and two indeterminates 986 // exclude the case that the basering has not precisely 987 // one parameter and two indeterminates 893 988 if ((npars(basering)!=1) or (nvars(basering)!=2)) 894 989 { 895 ERROR("The basering should have precisely one parameter and two indeterminates!"); 990 ERROR("The basering should have precisely one parameter and two indeterminates!"); 896 991 } 897 992 poly f=tp; … … 902 997 if (nvars(basering) != 2) 903 998 { 904 ERROR("The basering should have precisely two indeterminates!"); 905 } 906 // -1) Exclude the pathological case that the defining tropical polynomial has only one term, 907 // so that the tropical variety is not defined. 999 ERROR("The basering should have precisely two indeterminates!"); 1000 } 1001 // -1) Exclude the pathological case that the defining 1002 // tropical polynomial has only one term, 1003 // so that the tropical variety is not defined. 908 1004 if (size(tp)==1) 909 1005 { … … 911 1007 intmat M[2][1]=0,0; 912 1008 return(list(list(0,0,M,list(),detropicalise(tp[1])),list(list(leadexp(detropicalise(tp[1]))),list()))); 913 } 914 // 0) If the input was a list of linear polynomials, then some coefficient of x or y can be negative, 915 // i.e. the input corresponds to the tropical curve of a Laurent polynomial. In that case we should 916 // add some ax+by, so that all coefficients are positive. This does not change the tropical curve. 917 // however, we have to save (a,b), since the Newton polygone has to be shifted by (-a,-b). 1009 } 1010 // 0) If the input was a list of linear polynomials, 1011 // then some coefficient of x or y can be negative, 1012 // i.e. the input corresponds to the tropical curve 1013 // of a Laurent polynomial. In that case we should 1014 // add some ax+by, so that all coefficients are positive. 1015 // This does not change the tropical curve. 1016 // however, we have to save (a,b), since the Newton 1017 // polygone has to be shifted by (-a,-b). 918 1018 poly aa,bb; // koeffizienten 919 1019 for (i=1;i<=size(tp);i++) … … 926 1026 { 927 1027 bb=koeffizienten(tp[i],2); 928 } 1028 } 929 1029 } 930 1030 if ((aa!=0) or (bb!=0)) … … 935 1035 } 936 1036 } 937 // 1) compute the vertices of the tropical curve defined by tp and the Newton subdivision 1037 // 1) compute the vertices of the tropical curve 1038 // defined by tp and the Newton subdivision 938 1039 list vtp=verticesTropicalCurve(tp,#); 939 // if vtp is empty, then the Newton polygone is just a line segment and constitutes a bunch of lines 1040 // if vtp is empty, then the Newton polygone is just 1041 // a line segment and constitutes a bunch of lines 940 1042 // which can be computed by bunchOfLines 941 1043 if (size(vtp)==0) … … 943 1045 return(bunchOfLines(tp)); 944 1046 } 945 // 2) store all vertices belonging to the ith part of the 1047 // 2) store all vertices belonging to the ith part of the 946 1048 // Newton subdivision in the list vtp[i] as 4th entry, 947 1049 // and store those, which are not corners of the ith subdivision polygon 948 1050 // in vtp[i][6] 949 poly nwt; 1051 poly nwt; 950 1052 list boundaryNSD; // stores the boundary of a Newton subdivision 951 intmat zwsp[2][1]; // used for intermediate storage 1053 intmat zwsp[2][1]; // used for intermediate storage 952 1054 for (i=1;i<=size(vtp);i++) 953 1055 { 954 1056 k=1; 955 nwt=vtp[i][3]; // the polynomial representing the ith part of the Newton subdivision 956 // store the vertices of the ith part of the Newton subdivision in the list newton 957 list newton; 1057 nwt=vtp[i][3]; // the polynomial representing the 1058 // ith part of the Newton subdivision 1059 // store the vertices of the ith part of the 1060 // Newton subdivision in the list newton 1061 list newton; 958 1062 while (nwt!=0) 959 1063 { … … 962 1066 k++; 963 1067 } 964 boundaryNSD=findOrientedBoundary(newton);// a list of the vertices of the Newton subdivision as integer vectors (only those on the boundary, and oriented clockwise) 1068 boundaryNSD=findOrientedBoundary(newton);// a list of the vertices 1069 // of the Newton subdivision 1070 // as integer vectors (only those 1071 // on the boundary, and oriented 1072 // clockwise) 965 1073 vtp[i][4]=boundaryNSD[1]; 966 1074 vtp[i][5]=boundaryNSD[2]; 967 vtp[i][6]=zwsp; // the entries of the first row will denote to which vertex the ith one is connected 968 // and the entries of the second row will denote with which multiplicity 1075 vtp[i][6]=zwsp; // the entries of the first row will denote to which 1076 // vertex the ith one is connected 1077 // and the entries of the second row will denote 1078 //with which multiplicity 969 1079 kill newton; // we kill the superflous list 970 1080 } 971 // 3) Next we build for each part of the Newton subdivision the list of all pairs of vertices on the 1081 // 3) Next we build for each part of the Newton 1082 // subdivision the list of all pairs of vertices on the 972 1083 // boundary, which are involved, including those which are not corners 973 1084 list pairs,pair; … … 985 1096 kill ipairs; 986 1097 } 987 // 4) Check for all pairs of verticies in the Newton diagram if they 1098 // 4) Check for all pairs of verticies in the Newton diagram if they 988 1099 // occur in two different parts of the Newton subdivision 989 int deleted; // if a pair occurs in two NSD, it can be removed from both - deleted is then set to 1 990 list inneredges; // contains the list of all pairs contained in two NSD - these are inner the edges of NSD 1100 int deleted; // if a pair occurs in two NSD, it can be removed 1101 // from both - deleted is then set to 1 1102 list inneredges; // contains the list of all pairs contained in two NSD 1103 // - these are inner the edges of NSD 991 1104 int ggt; 992 1105 d=1; // counts the inner edges 993 1106 for (i=1;i<=size(pairs)-1;i++) 994 { 1107 { 995 1108 for (j=i+1;j<=size(pairs);j++) 996 1109 { … … 999 1112 deleted=0; 1000 1113 for (l=size(pairs[j]);l>=1 and deleted==0;l--) 1001 { 1114 { 1002 1115 if (((pairs[i][k][1]==pairs[j][l][1]) and (pairs[i][k][2]==pairs[j][l][2])) or ((pairs[i][k][1]==pairs[j][l][2]) and (pairs[i][k][2]==pairs[j][l][1]))) 1003 1116 { 1004 inneredges[d]=pairs[i][k]; // the new inner edge is saved in inneredges,1117 inneredges[d]=pairs[i][k]; // new inner edge is saved in inneredges 1005 1118 d++; 1006 1119 ggt=abs(gcd(pairs[i][k][1][1]-pairs[i][k][2][1],pairs[i][k][1][2]-pairs[i][k][2][2])); 1007 zwsp=j,ggt; // and it is recorded that the ith and jth vertex should be connected with mult ggt 1120 zwsp=j,ggt; // and it is recorded that the ith and jth 1121 // vertex should be connected with mult ggt 1008 1122 vtp[i][6]=intmatconcat(vtp[i][6],zwsp); 1009 1123 zwsp=i,ggt; 1010 1124 vtp[j][6]=intmatconcat(vtp[j][6],zwsp); 1011 pairs[i]=delete(pairs[i],k); // finally the pair is deleted from both sets of pairs 1125 pairs[i]=delete(pairs[i],k); // finally the pair is deleted 1126 // from both sets of pairs 1012 1127 pairs[j]=delete(pairs[j],l); 1013 1128 deleted=1; … … 1017 1132 } 1018 1133 } 1019 // 5) The entries in vtp[i][6] are ordered, multiple entries are removed, and the1020 // redundant zero is removed as well1134 // 5) The entries in vtp[i][6] are ordered, multiple entries are removed, 1135 // and the redundant zero is removed as well 1021 1136 for (i=1;i<=size(vtp);i++) 1022 1137 { … … 1048 1163 } 1049 1164 } 1050 // 6.3) Order the vertices such that passing from one to the next we travel along1051 // t he boundary of the Newton polytope clock wise.1165 // 6.3) Order the vertices such that passing from one to the next we 1166 // travel along the boundary of the Newton polytope clock wise. 1052 1167 boundaryNSD=findOrientedBoundary(vertices); 1053 1168 list orderedvertices=boundaryNSD[1]; 1054 1169 // 7) Find the unbounded edges emerging from a vertex in the tropical curve. 1055 // For this we check the remaining pairs for the ith NSD. Each pair is ordered according 1056 // to the order in which the vertices occur in orderedvertices. The direction of the 1057 // unbounded edge is then the outward pointing primitive normal vector to the vector 1170 // For this we check the remaining pairs for the ith NSD. 1171 // Each pair is ordered according 1172 // to the order in which the vertices occur in orderedvertices. 1173 // The direction of the 1174 // unbounded edge is then the outward pointing primitive normal 1175 // vector to the vector 1058 1176 // pointing from the first vertex in a pair to the second one. 1059 1177 intvec normalvector; // stores the outward pointing normal vector 1060 1178 intvec zwspp; // used for intermediate storage 1061 int zw,pos1,pos2; // stores the gcd of entries of the non-normalised normal vector, etc. 1179 int zw,pos1,pos2; // stores the gcd of entries of the 1180 // non-normalised normal vector, etc. 1062 1181 int gestorben; // tests if unbounded edges are multiple 1063 1182 for (i=1;i<=size(pairs);i++) 1064 1183 { 1065 list ubedges; // stores the unbounded edges 1184 list ubedges; // stores the unbounded edges 1066 1185 k=1; // counts the unbounded edges 1067 1186 for (j=1;j<=size(pairs[i]);j++) 1068 1187 { 1069 pos1=positionInList(orderedvertices,pairs[i][j][1]); // computes the position of the vertices in the 1070 pos2=positionInList(orderedvertices,pairs[i][j][2]); // pair in the list orderedvertices 1188 // computes the position of the vertices in the 1189 pos1=positionInList(orderedvertices,pairs[i][j][1]); 1190 // pair in the list orderedvertices 1191 pos2=positionInList(orderedvertices,pairs[i][j][2]); 1071 1192 if (((pos1>pos2) and !((pos1==size(orderedvertices)) and (pos2==1))) or ((pos2==size(orderedvertices)) and (pos1==1))) // reorders them if necessary 1072 1193 { … … 1075 1196 pairs[i][j][2]=zwspp; 1076 1197 } 1077 normalvector=pairs[i][j][2]-pairs[i][j][1]; // the vector pointing from vertex 1 in the pair to vertex2 1198 // the vector pointing from vertex 1 in the pair to vertex2 1199 normalvector=pairs[i][j][2]-pairs[i][j][1]; 1078 1200 ggt=gcd(normalvector[1],normalvector[2]); // the gcd of the entries 1079 zw=normalvector[2]; 1201 zw=normalvector[2]; // create the outward pointing normal vector 1080 1202 normalvector[2]=-normalvector[1]/ggt; 1081 1203 normalvector[1]=zw/ggt; 1082 1204 if (size(#)==0) // we are computing w.r.t. minimum 1083 1205 { 1084 ubedges[k]=list(normalvector,ggt); // store the outward pointing normal vector1206 ubedges[k]=list(normalvector,ggt); // store outward pointing normal vec. 1085 1207 } 1086 1208 else // we are computing w.r.t. maximum 1087 1209 { 1088 ubedges[k]=list(-normalvector,ggt); // store the outward pointing normal vector1210 ubedges[k]=list(-normalvector,ggt); //store outward pointing normal vec. 1089 1211 } 1090 1212 k++; … … 1107 1229 kill ubedges; 1108 1230 } 1109 // 8) Store the computed information for the ith part of the NSD in the list graph[i]. 1231 // 8) Store the computed information for the ith part 1232 // of the NSD in the list graph[i]. 1110 1233 list graph,gr; 1111 1234 for (i=1;i<=size(vtp);i++) 1112 1235 { 1113 gr[1]=vtp[i][1]; // the first coordinate of the ith vertex of the tropical curve 1114 gr[2]=vtp[i][2]; // the second coordinate of the ith vertex of the tropical curve 1115 gr[3]=vtp[i][6]; // to which vertices is the ith vertex of the tropical curve connected 1116 gr[4]=vtp[i][7]; // the directions unbounded edges emerging from the ith vertex of the trop. curve 1117 gr[5]=vtp[i][3]; // the vertices of the boundary of the ith part of the NSD 1236 // the first coordinate of the ith vertex of the tropical curve 1237 gr[1]=vtp[i][1]; 1238 // the second coordinate of the ith vertex of the tropical curve 1239 gr[2]=vtp[i][2]; 1240 // to which vertices is the ith vertex of the tropical curve connected 1241 gr[3]=vtp[i][6]; 1242 // the directions unbounded edges emerging from the ith 1243 // vertex of the trop. curve 1244 gr[4]=vtp[i][7]; 1245 // the vertices of the boundary of the ith part of the NSD 1246 gr[5]=vtp[i][3]; 1118 1247 graph[i]=gr; 1119 1248 } … … 1134 1263 } 1135 1264 } 1136 // 10) Finally store the boundary vertices and the inner edges as last entry in the list graph. 1265 // 10) Finally store the boundary vertices and 1266 // the inner edges as last entry in the list graph. 1137 1267 // This represents the NSD. 1138 1268 graph[size(vtp)+1]=list(boundaryNSD[2],inneredges,shiftvector); … … 1150 1280 // the coordinates of the first vertex are graph[1][1],graph[1][2]; 1151 1281 graph[1][1],graph[1][2]; 1152 // the first vertex is connected to the vertices 1282 // the first vertex is connected to the vertices 1153 1283 // graph[1][3][1,1..ncols(graph[1][3])] 1154 1284 intmat M=graph[1][3]; 1155 1285 M[1,1..ncols(graph[1][3])]; 1156 // the weights of the edges to these vertices are 1286 // the weights of the edges to these vertices are 1157 1287 // graph[1][3][2,1..ncols(graph[1][3])] 1158 1288 M[2,1..ncols(graph[1][3])]; 1159 1289 // from the first vertex emerge size(graph[1][4]) unbounded edges 1160 1290 size(graph[1][4]); 1161 // the primitive integral direction vector of the first unbounded edge 1291 // the primitive integral direction vector of the first unbounded edge 1162 1292 // of the first vertex 1163 1293 graph[1][4][1][1]; 1164 1294 // the weight of the first unbounded edge of the first vertex 1165 1295 graph[1][4][1][2]; 1166 // the monomials which are part of the Newton subdivision of the first vertex 1296 // the monomials which are part of the Newton subdivision of the first vertex 1167 1297 graph[1][5]; 1168 // connecting the points in graph[size(graph)][1] we get 1298 // connecting the points in graph[size(graph)][1] we get 1169 1299 // the boundary of the Newton polytope 1170 1300 graph[size(graph)][1]; 1171 // an entry in graph[size(graph)][2] is a pair of points 1301 // an entry in graph[size(graph)][2] is a pair of points 1172 1302 // in the Newton polytope bounding an inner edge 1173 1303 graph[size(graph)][2][1]; 1174 1304 } 1175 1305 1306 ///////////////////////////////////////////////////////////////////////// 1307 1176 1308 proc drawTropicalCurve (def f,list #) 1177 1309 "USAGE: drawTropicalCurve(f[,#]); f poly or list, # optional list 1178 ASSUME: f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c 1179 representing a tropical Laurent polynomial defining a tropical plane curve; 1180 alternatively f can be a polynomial in Q(t)[x,y] defining a tropical plane curve 1181 via the valuation map; 1182 the basering must have a global monomial ordering, two variables and up to one parameter! 1310 ASSUME: f is list of linear polynomials of the form ax+by+c with 1311 integers a, b and a rational number c representing a tropical 1312 Laurent polynomial defining a tropical plane curve; 1313 alternatively f can be a polynomial in Q(t)[x,y] defining 1314 a tropical plane curve via the valuation map; 1315 the basering must have a global monomial ordering, two 1316 variables and up to one parameter! 1183 1317 RETURN: NONE 1184 NOTE: - the procedure produces the files /tmp/tropicalcurveNUMBER.tex and 1185 /tmp/tropicalcurveNUMBER.ps, where NUMBER is a random four digit integer; 1186 moreover it displays the tropical curve defined by f via kghostview; 1187 if you wish to remove all these files from /tmp, call the procedure cleanTmp 1318 NOTE: - the procedure produces the files /tmp/tropicalcurveNUMBER.tex and 1319 /tmp/tropicalcurveNUMBER.ps, where NUMBER is a random four 1320 digit integer; 1321 moreover it displays the tropical curve via kghostview; 1322 if you wish to remove all these files from /tmp, 1323 call the procedure cleanTmp 1188 1324 @* - edges with multiplicity greater than one carry this multiplicity 1189 @* - if # is empty, then the tropical curve is computed w.r.t. minimum, if #[1] is the 1190 string 'max', then it is computed w.r.t. maximum 1191 @* - if the last optional argument is 'onlytexfile' then only the latex file 1192 is produced; this option should be used if kghostview is not installed on 1193 your system 1194 @* - note that lattice points in the Newton subdivision which are black correspond to markings 1195 of the marked subdivision, while lattice points in grey are not marked 1325 @* - if # is empty, then the tropical curve is computed w.r.t. minimum, 1326 if #[1] is the string 'max', then it is computed w.r.t. maximum 1327 @* - if the last optional argument is 'onlytexfile' then only the 1328 latex file is produced; this option should be used if kghostview 1329 is not installed on your system 1330 @* - note that lattice points in the Newton subdivision which are 1331 black correspond to markings of the marked subdivision, 1332 while lattice points in grey are not marked 1196 1333 EXAMPLE: example drawTropicalCurve shows an example" 1197 1334 { 1198 // check if the option "onlytexfile" is set, so thatonly a tex file is produced1335 // check if the option "onlytexfile" is set, then only a tex file is produced 1199 1336 if (size(#)!=0) 1200 1337 { … … 1210 1347 if (typeof(f)=="poly") 1211 1348 { 1212 // exclude the case that the basering has not precisely one parameter and two indeterminates 1349 // exclude the case that the basering has not precisely 1350 // one parameter and two indeterminates 1213 1351 if ((npars(basering)!=1) or (nvars(basering)!=2)) 1214 1352 { 1215 ERROR("The basering should have precisely one parameter and two indeterminates!"); 1353 ERROR("The basering should have precisely one parameter and two indeterminates!"); 1216 1354 } 1217 1355 texf=texPolynomial(f); // write the polynomial over Q(t) 1218 list graph=tropicalCurve(tropicalise(f,#),#); // the graph of the tropicalisationof f1356 list graph=tropicalCurve(tropicalise(f,#),#); // graph of tropicalis. of f 1219 1357 } 1220 1358 if (typeof(f)=="list") … … 1224 1362 texf="\\mbox{\\tt The defining equation was not handed over!}"; 1225 1363 list graph=f; 1226 } 1364 } 1227 1365 else 1228 1366 { // write the tropical polynomial defined by f 1229 1367 if (size(#)==0) 1230 { 1368 { 1231 1369 texf="\\min\\{"; 1232 1370 } … … 1237 1375 for (j=1;j<=size(f);j++) 1238 1376 { 1239 texf=texf+texPolynomial(f[j]); 1377 texf=texf+texPolynomial(f[j]); 1240 1378 if (j<size(f)) 1241 1379 { … … 1246 1384 texf=texf+"\\}"; 1247 1385 } 1248 } 1386 } 1249 1387 list graph=tropicalCurve(f,#); // the graph of the tropical polynomial f 1250 1388 } … … 1264 1402 \\addtolength{\\topmargin}{-\\headheight} 1265 1403 \\addtolength{\\topmargin}{-\\topskip} 1266 \\setlength{\\textheight}{267mm} 1404 \\setlength{\\textheight}{267mm} 1267 1405 \\addtolength{\\textheight}{\\topskip} 1268 1406 \\addtolength{\\textheight}{-\\footskip} 1269 1407 \\addtolength{\\textheight}{-30pt} 1270 \\setlength{\\oddsidemargin}{-1in} 1408 \\setlength{\\oddsidemargin}{-1in} 1271 1409 \\addtolength{\\oddsidemargin}{20mm} 1272 1410 \\setlength{\\evensidemargin}{\\oddsidemargin} 1273 \\setlength{\\textwidth}{170mm} 1411 \\setlength{\\textwidth}{170mm} 1274 1412 1275 1413 \\begin{document} 1276 1414 \\parindent0cm 1277 1415 \\begin{center} 1278 \\large\\bf The Tropicalisation of 1416 \\large\\bf The Tropicalisation of 1279 1417 1280 1418 \\bigskip … … 1300 1438 1301 1439 \\begin{center} 1302 "+texDrawNewtonSubdivision(graph,#)+" 1440 "+texDrawNewtonSubdivision(graph,#)+" 1303 1441 \\end{center} 1304 1442 \\end{document}"; … … 1307 1445 int rdnum=random(1000,9999); 1308 1446 write(":w /tmp/tropicalcurve"+string(rdnum)+".tex",TEXBILD); 1309 system("sh","cd /tmp; latex /tmp/tropicalcurve"+string(rdnum)+".tex; dvips /tmp/tropicalcurve"+string(rdnum)+".dvi -o; /bin/rm tropicalcurve"+string(rdnum)+".log; /bin/rm tropicalcurve"+string(rdnum)+".aux; /bin/rm tropicalcurve"+string(rdnum)+".ps?; /bin/rm tropicalcurve"+string(rdnum)+".dvi; kghostview tropicalcurve"+string(rdnum)+".ps &"); 1447 system("sh","cd /tmp; latex /tmp/tropicalcurve"+string(rdnum)+".tex; dvips /tmp/tropicalcurve"+string(rdnum)+".dvi -o; /bin/rm tropicalcurve"+string(rdnum)+".log; /bin/rm tropicalcurve"+string(rdnum)+".aux; /bin/rm tropicalcurve"+string(rdnum)+".ps?; /bin/rm tropicalcurve"+string(rdnum)+".dvi; kghostview tropicalcurve"+string(rdnum)+".ps &"); 1310 1448 } 1311 1449 else … … 1324 1462 drawTropicalCurve(f); 1325 1463 // we can instead apply the procedure to a tropical polynomial and use "maximum" 1326 poly g= t3*(x7+y7+1)+1/t3*(x4+y4+x2+y2+x3y+xy3)+1/t21*x2y2;1464 poly g=1/t3*(x7+y7+1)+t3*(x4+y4+x2+y2+x3y+xy3)+t21*x2y2; 1327 1465 list tropical_g=tropicalise(g); 1328 1466 tropical_g; … … 1330 1468 } 1331 1469 1470 ///////////////////////////////////////////////////////////////////////// 1471 1332 1472 proc drawNewtonSubdivision (def f,list #) 1333 1473 "USAGE: drawTropicalCurve(f[,#]); f poly, # optional list 1334 ASSUME: f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c 1335 representing a tropical Laurent polynomial defining a tropical plane curve; 1336 alternatively f can be a polynomial in Q(t)[x,y] defining a tropical plane curve 1337 via the valuation map; 1338 the basering must have a global monomial ordering, two variables and up to one parameter! 1474 ASSUME: f is list of linear polynomials of the form ax+by+c with integers 1475 a, b and a rational number c representing a tropical Laurent 1476 polynomial defining a tropical plane curve; 1477 alternatively f can be a polynomial in Q(t)[x,y] defining a tropical 1478 plane curve via the valuation map; 1479 the basering must have a global monomial ordering, two variables 1480 and up to one parameter! 1339 1481 RETURN: NONE 1340 NOTE: - the procedure produces the files /tmp/newtonsubdivisionNUMBER.tex, 1341 and /tmp/newtonsubdivisionNUMBER.ps, where NUMBER is a random four digit integer; 1482 NOTE: - the procedure produces the files /tmp/newtonsubdivisionNUMBER.tex, 1483 and /tmp/newtonsubdivisionNUMBER.ps, where NUMBER is a random 1484 four digit integer; 1342 1485 moreover it desplays the tropical curve defined by f via kghostview; 1343 if you wish to remove all these files from /tmp, call the procedure cleanTmp 1344 @* if # is empty, then the tropical curve is computed w.r.t. minimum, if #[1] is the 1345 string 'max', then it is computed w.r.t. maximum 1346 @* - note that lattice points in the Newton subdivision which are black correspond to markings 1347 of the marked subdivision, while lattice points in grey are not marked 1486 if you wish to remove all these files from /tmp, call the procedure 1487 cleanTmp; 1488 @* if # is empty, then the tropical curve is computed w.r.t. minimum, 1489 if #[1] is the string 'max', then it is computed w.r.t. maximum 1490 @* - note that lattice points in the Newton subdivision which are black 1491 correspond to markings of the marked subdivision, while lattice 1492 points in grey are not marked 1348 1493 EXAMPLE: example drawNewtonSubdivision; shows an example" 1349 1494 { … … 1353 1498 { 1354 1499 texf=texPolynomial(f); // write the polynomial over Q(t) 1355 list graph=tropicalCurve(tropicalise(f,#),#); // the graph of the tropicalisationof f1500 list graph=tropicalCurve(tropicalise(f,#),#); // graph of tropicalis. of f 1356 1501 } 1357 1502 else 1358 1503 { // write the tropical polynomial defined by f 1359 1504 if (size(#)==0) 1360 { 1505 { 1361 1506 texf="\\min\\{"; 1362 1507 } … … 1367 1512 for (j=1;j<=size(f);j++) 1368 1513 { 1369 texf=texf+texPolynomial(f[j]); 1514 texf=texf+texPolynomial(f[j]); 1370 1515 if (j<size(f)) 1371 1516 { … … 1376 1521 texf=texf+"\\}"; 1377 1522 } 1378 } 1523 } 1379 1524 list graph=tropicalCurve(f,#); // the graph of the tropical polynomial f 1380 1525 } … … 1384 1529 \\parindent0cm 1385 1530 \\begin{center} 1386 \\large\\bf The Newtonsubdivison of 1531 \\large\\bf The Newtonsubdivison of 1387 1532 \\begin{displaymath} 1388 1533 f="+texf+" … … 1392 1537 1393 1538 \\begin{center} 1394 "+texDrawNewtonSubdivision(graph)+ 1539 "+texDrawNewtonSubdivision(graph)+ 1395 1540 " \\end{center} 1396 1541 … … 1398 1543 int rdnum=random(1000,9999); 1399 1544 write(":w /tmp/newtonsubdivision"+string(rdnum)+".tex",TEXBILD); 1400 system("sh","cd /tmp; latex /tmp/newtonsubdivision"+string(rdnum)+".tex; dvips /tmp/newtonsubdivision"+string(rdnum)+".dvi -o; /bin/rm newtonsubdivision"+string(rdnum)+".log; /bin/rm newtonsubdivision"+string(rdnum)+".aux; /bin/rm newtonsubdivision"+string(rdnum)+".ps?; /bin/rm newtonsubdivision"+string(rdnum)+".dvi; kghostview newtonsubdivision"+string(rdnum)+".ps &"); 1545 system("sh","cd /tmp; latex /tmp/newtonsubdivision"+string(rdnum)+".tex; dvips /tmp/newtonsubdivision"+string(rdnum)+".dvi -o; /bin/rm newtonsubdivision"+string(rdnum)+".log; /bin/rm newtonsubdivision"+string(rdnum)+".aux; /bin/rm newtonsubdivision"+string(rdnum)+".ps?; /bin/rm newtonsubdivision"+string(rdnum)+".dvi; kghostview newtonsubdivision"+string(rdnum)+".ps &"); 1401 1546 // return(TEXBILD); 1402 1547 } … … 1417 1562 } 1418 1563 1419 /////////////////////////////////////////////////////////////////////////////// /////1564 /////////////////////////////////////////////////////////////////////////////// 1420 1565 /// Procedures concerned with cubics 1421 /////////////////////////////////////////////////////////////////////////////// /////1566 /////////////////////////////////////////////////////////////////////////////// 1422 1567 1423 1568 proc tropicalJInvariant (def f,list #) 1424 1569 "USAGE: tropicalJInvariant(f[,#]); f poly or list, # optional list 1425 ASSUME: f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c 1426 representing a tropical Laurent polynomial defining a tropical plane curve; 1427 alternatively f can be a polynomial in Q(t)[x,y] defining a tropical plane curve 1428 via the valuation map; 1429 @* the basering must have a global monomial ordering, two variables and up to one parameter! 1430 RETURN: number, if the graph underlying the tropical curve has precisely one loop then its weighted 1431 lattice length is returned, otherwise the result will be -1 1432 NOTE: - if the tropical curve is elliptic and its embedded graph has precisely one loop, 1433 then the weigthed lattice length of the loop is its tropical j-invariant 1434 @* - the procedure checks if the embedded graph of the tropical curve has genus one, 1435 but it does NOT check if the loop can be resolved, so that the curve is not 1436 a proper tropical elliptic curve 1437 @* - if the embedded graph of a tropical elliptic curve has more than one loop, then 1438 all but one can be resolved, but this is not observed by this procedure, so it 1439 will not compute the j-invariant 1440 @* - if # is empty, then the tropical curve is computed w.r.t. minimum, if #[1] is the 1441 string 'max', then it is computed w.r.t. maximum 1442 @* - the tropicalJInvariant of a plane tropical cubic is the 'cycle length' of the 1443 cubic as introduced in the paper: 1444 Erik Katz, Hannah Markwig, Thomas Markwig: The j-invariant of a cubic tropical plane curve. 1570 ASSUME: f is list of linear polynomials of the form ax+by+c with integers 1571 a, b and a rational number c representing a tropical Laurent 1572 polynomial defining a tropical plane curve; 1573 alternatively f can be a polynomial in Q(t)[x,y] defining a 1574 tropical plane curve via the valuation map; 1575 @* the basering must have a global monomial ordering, two variables 1576 and up to one parameter! 1577 RETURN: number, if the graph underlying the tropical curve has precisely 1578 one loop then its weighted lattice length is returned, 1579 otherwise the result will be -1 1580 NOTE: - if the tropical curve is elliptic and its embedded graph has 1581 precisely one loop, then the weigthed lattice length of 1582 the loop is its tropical j-invariant 1583 @* - the procedure checks if the embedded graph of the tropical 1584 curve has genus one, but it does NOT check if the loop can 1585 be resolved, so that the curve is not a proper tropical 1586 elliptic curve 1587 @* - if the embedded graph of a tropical elliptic curve has more 1588 than one loop, then all but one can be resolved, but this is 1589 not observed by this procedure, so it will not compute 1590 the j-invariant 1591 @* - if # is empty, then the tropical curve is computed w.r.t. minimum, 1592 if #[1] is the string 'max', then it is computed w.r.t. maximum 1593 @* - the tropicalJInvariant of a plane tropical cubic is the 1594 'cycle length' of the cubic as introduced in the paper: 1595 Eric Katz, Hannah Markwig, Thomas Markwig: The j-invariant 1596 of a cubic tropical plane curve. 1445 1597 EXAMPLE: example tropicalJInvariant; shows an example" 1446 1598 { … … 1455 1607 { 1456 1608 if (typeof(f[1])=="list") 1457 { 1609 { 1458 1610 list graph=f; 1459 1611 } … … 1467 1619 { 1468 1620 ERROR("This is no valid input."); 1469 } 1621 } 1470 1622 } 1471 1623 } … … 1484 1636 genus=-genus/2; // we have counted each bounded edge twice 1485 1637 genus=genus+size(graph); // the genus is 1-#bounded_edges+#vertices 1486 // 3) if the embedded graph has not genus one, we cannot compute the j-invariant 1638 // 3) if the embedded graph has not genus one, 1639 // we cannot compute the j-invariant 1487 1640 if(genus!=1) 1488 1641 { … … 1495 1648 else 1496 1649 { 1497 intmat nullmat[2][1]; // used to set 1498 // 4) find a vertex which has only one bounded edge, if none exists zero is returned, 1650 intmat nullmat[2][1]; // used to set 1651 // 4) find a vertex which has only one bounded edge, 1652 // if none exists zero is returned, 1499 1653 // otherwise the number of the vertex in the list graph 1500 int nonloopvertex=findNonLoopVertex(graph); 1501 int dv; // checks if the vertex has been found to which the nonloopvertex is connected 1502 intmat delvert; // takes for a moment graph[i][3] of the vertex to which nonloopvertex is connected 1503 // 5) delete successively vertices in the graph which have only one bounded edge 1654 int nonloopvertex=findNonLoopVertex(graph); 1655 int dv; //checks if vert. has been found to which nonloopvertex is connected 1656 intmat delvert; // takes for a moment graph[i][3] of the vertex 1657 // to which nonloopvertex is connected 1658 // 5) delete successively vertices in the graph which 1659 // have only one bounded edge 1504 1660 while (nonloopvertex>0) 1505 1661 { 1506 // find the only vertex to which the nonloopvertex is connected, when it is found 1662 // find the only vertex to which the nonloopvertex 1663 // is connected, when it is found 1507 1664 // delete the connection in graph[i][3] and set dv=1 1508 1665 dv=0; … … 1516 1673 { 1517 1674 delvert=graph[i][3]; 1518 delvert=intmatcoldelete(delvert,j); // delete the connection (note, there must have been two!) 1675 delvert=intmatcoldelete(delvert,j); // delete the connection (note 1676 // there must have been two!) 1519 1677 dv=1; 1520 1678 graph[i][3]=delvert; … … 1523 1681 } 1524 1682 } 1525 graph[nonloopvertex][3]=nullmat; // the only connection of nonloopvertex is killed 1526 nonloopvertex=findNonLoopVertex(graph); // find the next vertex which has only one edge 1683 graph[nonloopvertex][3]=nullmat; // the only connection of nonloopvertex 1684 // is killed 1685 nonloopvertex=findNonLoopVertex(graph); // find the next vertex 1686 // which has only one edge 1527 1687 } 1528 1688 // 6) find the loop and the weights of the edges 1529 1689 intvec loop,weights; // encodes the loop and the edges 1530 1690 i=1; 1531 // start by finding some vertex which belongs to the loop 1532 while (loop==0) 1533 { 1534 if (ncols(graph[i][3])==1) // the graph[i][3] of a vertex in the loop has 2 columns, all others have 1 1691 // start by finding some vertex which belongs to the loop 1692 while (loop==0) 1693 { 1694 // if graph[i][3] of a vertex in the loop has 2 columns, all others have 1 1695 if (ncols(graph[i][3])==1) 1535 1696 { 1536 1697 i++; … … 1538 1699 else 1539 1700 { 1540 loop[1]=i; // a starting vertex is found 1541 loop[2]=graph[i][3][1,1]; // it is connected to the vertex with this number1701 loop[1]=i; // a starting vertex is found 1702 loop[2]=graph[i][3][1,1]; // it is connected to vertex with this number 1542 1703 weights[2]=graph[i][3][2,1]; // and the edge has this weight 1543 1704 } … … 1547 1708 while (j!=i) // the loop ends with the same vertex with which it starts 1548 1709 { 1549 // the first row of graph[j][3] has two entries corresponding to the two vertices 1550 // to which the active vertex j is connected; one is loop[k-1], i.e. the one which 1710 // the first row of graph[j][3] has two entries 1711 // corresponding to the two vertices 1712 // to which the active vertex j is connected; 1713 // one is loop[k-1], i.e. the one which 1551 1714 // precedes j in the loop; we have to choose the other one 1552 if (graph[j][3][1,1]==loop[k-1]) 1715 if (graph[j][3][1,1]==loop[k-1]) 1553 1716 { 1554 1717 loop[k+1]=graph[j][3][1,2]; … … 1561 1724 } 1562 1725 j=loop[k+1]; // set loop[k+1] the new active vertex 1563 k++; 1564 } 1726 k++; 1727 } 1565 1728 // 7) compute for each edge in the loop the lattice length 1566 poly xcomp,ycomp; // the x- and y-components of the vectors connecting two vertices of the loop 1567 number nenner; // the product of the denominators of the x- and y-components 1729 poly xcomp,ycomp; // the x- and y-components of the vectors 1730 // connecting two vertices of the loop 1731 number nenner; // the product of the denominators of 1732 // the x- and y-components 1568 1733 number jinvariant; // the j-invariant 1569 int eins,zwei,ggt; 1734 int eins,zwei,ggt; 1570 1735 for (i=1;i<=size(loop)-1;i++) // compute the lattice length for each edge 1571 1736 { 1572 xcomp=graph[loop[i]][1]-graph[loop[i+1]][1]; 1573 ycomp=graph[loop[i]][2]-graph[loop[i+1]][2]; 1737 xcomp=graph[loop[i]][1]-graph[loop[i+1]][1]; 1738 ycomp=graph[loop[i]][2]-graph[loop[i+1]][2]; 1574 1739 nenner=denominator(leadcoef(xcomp))*denominator(leadcoef(ycomp)); 1575 execute("eins="+string(numerator(leadcoef(nenner*xcomp)))+";"); 1576 execute("zwei="+string(numerator(leadcoef(nenner*ycomp)))+";"); 1577 ggt=gcd(eins,zwei); // the lattice length is the "gcd" of the x-component and the y-component 1578 jinvariant=jinvariant+ggt/(nenner*weights[i+1]); // divided by the weight of the edge 1579 } 1580 return(jinvariant); 1740 execute("eins="+string(numerator(leadcoef(nenner*xcomp)))+";"); 1741 execute("zwei="+string(numerator(leadcoef(nenner*ycomp)))+";"); 1742 ggt=gcd(eins,zwei); // the lattice length is the "gcd" 1743 // of the x-component and the y-component 1744 jinvariant=jinvariant+ggt/(nenner*weights[i+1]); // divided by the 1745 // weight of the edge 1746 } 1747 return(jinvariant); 1581 1748 } 1582 1749 } … … 1592 1759 // the curve can have arbitrary degree 1593 1760 tropicalJInvariant(t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2); 1594 // the procedure does not realise, if the embedded graph of the tropical 1761 // the procedure does not realise, if the embedded graph of the tropical 1595 1762 // curve has a loop that can be resolved 1596 1763 tropicalJInvariant(1+x+y+xy+tx2y+txy2); 1597 1764 // but it does realise, if the curve has no loop at all ... 1598 1765 tropicalJInvariant(x+y+1); 1599 // or if the embedded graph has more than one loop - even if only one 1766 // or if the embedded graph has more than one loop - even if only one 1600 1767 // cannot be resolved 1601 1768 tropicalJInvariant(1+x+y+xy+tx2y+txy2+t3x5+t3y5+tx2y2+t2xy4+t2yx4); 1602 1769 } 1603 1770 1771 ///////////////////////////////////////////////////////////////////////// 1772 1604 1773 proc weierstrassForm (poly f,list #) 1605 1774 "USAGE: weierstrassForm(wf[,#]); wf poly, # list 1606 ASSUME: wf is a a polynomial whose Newton polygon has precisely one interior lattice1607 point, so that it defines an elliptic curve on the toric surface corresponding1608 to the Newton polygon1775 ASSUME: wf is a a polynomial whose Newton polygon has precisely one 1776 interior lattice point, so that it defines an elliptic curve 1777 on the toric surface corresponding to the Newton polygon 1609 1778 RETURN: poly, the Weierstrass normal form of the polynomial 1610 NOTE: - the algorithm for the coefficients of the Weierstrass form is due to1611 Fernando Rodriguez Villegas, villegas@math.utexas.edu1779 NOTE: - the algorithm for the coefficients of the Weierstrass form is due 1780 to Fernando Rodriguez Villegas, villegas@math.utexas.edu 1612 1781 @* - the characteristic of the base field should not be 2 or 3 1613 @* - if an additional argument # is given, a simplified Weierstrass form1614 is computed1782 @* - if an additional argument # is given, a simplified Weierstrass 1783 form is computed 1615 1784 EXAMPLE: example weierstrassForm; shows an example" 1616 1785 { … … 1669 1838 } 1670 1839 1840 ///////////////////////////////////////////////////////////////////////// 1841 1671 1842 proc jInvariant (poly f,list #) 1672 "USAGE: jInvariant(f[,#]); f poly, # list 1673 ASSUME: - f is a a polynomial whose Newton polygon has precisely one interior lattice 1674 point, so that it defines an elliptic curve on the toric surface corresponding 1675 to the Newton polygon 1676 @* - it the optional argument # is present the base field should be Q(t) and 1677 the optional argument should be one of the following strings: 1678 @* 'ord' : then the return value is of type integer, namely the order of the j-invariant 1679 @* 'split' : then the return value is a list of two polynomials, such that the quotient 1680 of these two is the j-invariant 1843 "USAGE: jInvariant(f[,#]); f poly, # list 1844 ASSUME: - f is a a polynomial whose Newton polygon has precisely one 1845 interior lattice point, so that it defines an elliptic curve 1846 on the toric surface corresponding to the Newton polygon 1847 @* - it the optional argument # is present the base field should be 1848 Q(t) and the optional argument should be one of the following 1849 strings: 1850 @* 'ord' : then the return value is of type integer, 1851 namely the order of the j-invariant 1852 @* 'split' : then the return value is a list of two polynomials, 1853 such that the quotient of these two is the j-invariant 1681 1854 RETURN: poly, the j-invariant of the elliptic curve defined by poly 1682 NOTE: the characteristic of the base field should not be 2 or 3, unless the input is a plane cubic 1855 NOTE: the characteristic of the base field should not be 2 or 3, 1856 unless the input is a plane cubic 1683 1857 EXAMPLE: example jInvariant; shows an example" 1684 1858 { … … 1705 1879 echo=2; 1706 1880 ring r=(0,t),(x,y),dp; 1707 // jInvariant computes the j-invariant of a cubic 1881 // jInvariant computes the j-invariant of a cubic 1708 1882 jInvariant(x+y+x2y+y3+1/t*xy); 1709 // if the ground field has one parameter t, then we can instead 1883 // if the ground field has one parameter t, then we can instead 1710 1884 // compute the order of the j-invariant 1711 1885 jInvariant(x+y+x2y+y3+1/t*xy,"ord"); … … 1715 1889 poly h=x22y11+x19y10+x17y9+x16y9+x12y7+x9y6+x7y5+x2y3+x14y8; 1716 1890 // its j-invariant is 1717 jInvariant(h); 1718 } 1719 1720 1721 1722 /////////////////////////////////////////////////////////////////////////////// /////1891 jInvariant(h); 1892 } 1893 1894 1895 1896 /////////////////////////////////////////////////////////////////////////////// 1723 1897 /// Procedures concerned with conics 1724 /////////////////////////////////////////////////////////////////////////////// /////1898 /////////////////////////////////////////////////////////////////////////////// 1725 1899 1726 1900 proc conicWithTangents (list points,list #) … … 1729 1903 RETURN: list, l[1] = the list points of the five given points 1730 1904 @* l[2] = the conic f passing through the five points 1731 @* l[3] = list of equations of t he tangents to f in the given points1732 @* l[4] = ideal, t he tropicalisation of f (i.e. alist of linear forms)1905 @* l[3] = list of equations of tangents to f in the given points 1906 @* l[4] = ideal, tropicalisation of f (i.e. list of linear forms) 1733 1907 @* l[5] = a list of the tropicalisation of the tangents 1734 1908 @* l[6] = a list containing the vertices of the tropical conic f 1735 @* l[7] = a list containing lists with thevertices of the tangents1736 @* l[8] = a string which contains the latex-code to draw the tropical1737 conic and its tropicalised tangents1738 @* l[9] = if # is non-empty, this is the same data for the dual conic1739 and the points dual to the computed tangents1909 @* l[7] = a list containing lists with vertices of the tangents 1910 @* l[8] = a string which contains the latex-code to draw the 1911 tropical conic and its tropicalised tangents 1912 @* l[9] = if # is non-empty, this is the same data for the dual 1913 conic and the points dual to the computed tangents 1740 1914 NOTE: the points must be generic, i.e. no three on a line 1741 1915 EXAMPLE: example conicWithTangents; shows an example" … … 1758 1932 ring LINRING=(0,t),(x,y,a(1..6)),lp; 1759 1933 list points=imap(BASERING,points); 1760 ideal I; // the ideal will contain the linear equations given by the conic and the points 1934 ideal I; // the ideal will contain the linear equations given by the conic 1935 // and the points 1761 1936 for (i=1;i<=5;i++) 1762 1937 { … … 1778 1953 ring tRING=0,t,ls; 1779 1954 list pointdenom=imap(BASERING,pointdenom); 1780 list pointnum=imap(BASERING,pointnum); 1955 list pointnum=imap(BASERING,pointnum); 1781 1956 intvec pointcoordinates; 1782 1957 for (i=1;i<=size(pointdenom);i++) … … 1854 2029 We consider the concic through the following five points: 1855 2030 \\begin{displaymath} 1856 "; 2031 "; 1857 2032 string texf=texDrawTropical(graphf,list("",scalefactor)); 1858 2033 for (i=1;i<=size(points);i++) … … 1892 2067 \\end{document}"; 1893 2068 setring BASERING; 1894 // If # non-empty, compute the dual conic and the tangents through the dual points 2069 // If # non-empty, compute the dual conic and the tangents 2070 // through the dual points 1895 2071 // corresponding to the tangents of the given conic. 1896 2072 if (size(#)>0) 1897 2073 { 1898 2074 list dualpoints; 1899 for (i=1;i<=size(points);i++) 2075 for (i=1;i<=size(points);i++) 1900 2076 { 1901 2077 dualpoints[i]=list(leadcoef(tangents[i])/substitute(tangents[i],x,0,y,0),leadcoef(tangents[i]-lead(tangents[i]))/substitute(tangents[i],x,0,y,0)); … … 1921 2097 // conic[2] is the equation of the conic f passing through the five points 1922 2098 conic[2]; 1923 // conic[3] is a list containing the equations of the tangents 2099 // conic[3] is a list containing the equations of the tangents 1924 2100 // through the five points 1925 2101 conic[3]; 1926 2102 // conic[4] is an ideal representing the tropicalisation of the conic f 1927 2103 conic[4]; 1928 // conic[5] is a list containing the tropicalisation 2104 // conic[5] is a list containing the tropicalisation 1929 2105 // of the five tangents in conic[3] 1930 2106 conic[5]; 1931 // conic[6] is a list containing the vertices of the tropical conic 2107 // conic[6] is a list containing the vertices of the tropical conic 1932 2108 conic[6]; 1933 2109 // conic[7] is a list containing the vertices of the five tangents 1934 2110 conic[7]; 1935 // conic[8] contains the latex code to draw the tropical conic and 1936 // its tropicalised tangents; it can written in a file, processed and 1937 // displayed via kghostview 1938 write(":w /tmp/conic.tex",conic[8]); 1939 system("sh","cd /tmp; latex /tmp/conic.tex; dvips /tmp/conic.dvi -o; 2111 // conic[8] contains the latex code to draw the tropical conic and 2112 // its tropicalised tangents; it can written in a file, processed and 2113 // displayed via kghostview 2114 write(":w /tmp/conic.tex",conic[8]); 2115 system("sh","cd /tmp; latex /tmp/conic.tex; dvips /tmp/conic.dvi -o; 1940 2116 kghostview conic.ps &"); 1941 // with an optional argument the same information for the dual conic is computed 2117 // with an optional argument the same information for the dual conic is computed 1942 2118 // and saved in conic[9] 1943 2119 conic=conicWithTangents(points,1); 1944 2120 conic[9][2]; // the equation of the dual conic 1945 2121 } 1946 1947 /////////////////////////////////////////////////////////////////////////////// /////2122 2123 /////////////////////////////////////////////////////////////////////////////// 1948 2124 /// Procedures concerned with tropicalisation 1949 /////////////////////////////////////////////////////////////////////////////// /////2125 /////////////////////////////////////////////////////////////////////////////// 1950 2126 1951 2127 proc tropicalise (poly f,list #) … … 1953 2129 ASSUME: f is a polynomial in Q(t)[x_1,...,x_n] 1954 2130 RETURN: list, the linear forms of the tropicalisation of f 1955 NOTE: if # is empty, then the valuation of t will be 1, 1956 @* if # is the string 'max' it will be -1; 1957 @* the latter supposes that we consider the maximum of the the computed1958 linear forms, the former that we consider their minimum2131 NOTE: if # is empty, then the valuation of t will be 1, 2132 @* if # is the string 'max' it will be -1; 2133 @* the latter supposes that we consider the maximum of the the 2134 computed linear forms, the former that we consider their minimum 1959 2135 EXAMPLE: example tropicalise; shows an example" 1960 2136 { … … 1978 2154 { 1979 2155 tropicalf[i]=tropicalf[i]+exp[j]*var(j); 1980 } 2156 } 1981 2157 f=f-lead(f); 1982 2158 } … … 1992 2168 1993 2169 2170 ///////////////////////////////////////////////////////////////////////// 2171 1994 2172 proc tropicaliseSet (ideal i) 1995 "USAGE: 1996 ASSUME: 1997 RETURN: 1998 EXAMPLE: 2173 "USAGE: tropicaliseSet(i); i ideal 2174 ASSUME: i is an ideal in Q(t)[x_1,...,x_n] 2175 RETURN: list, the jth entry is the tropicalisation of the jth generator of i 2176 EXAMPLE: example tropicaliseSet; shows an example" 1999 2177 { 2000 2178 list tropicalid; … … 2014 2192 } 2015 2193 2016 proc tInitialForm (poly f, intvec w) 2194 ///////////////////////////////////////////////////////////////////////// 2195 2196 proc tInitialForm (poly f, intvec w) 2017 2197 "USAGE: tInitialForm(f,w); f a polynomial, w an integer vector 2018 2198 ASSUME: f is a polynomial in Q[t,x_1,...,x_n] and w=(w_0,w_1,...,w_n) 2019 2199 RETURN: poly, the t-initialform of f(t,x) w.r.t. w evaluated at t=1 2020 NOTE: the t-initialform is the sum of the terms with MAXIMAL weighted order w.r.t. w 2200 NOTE: the t-initialform is the sum of the terms with MAXIMAL 2201 weighted order w.r.t. w 2021 2202 EXAMPLE: example tInitialForm; shows an example" 2022 2203 { … … 2027 2208 // do the same for the remaining part of f and compare the results 2028 2209 // keep only the smallest ones 2029 int vglgewicht; 2030 f=f-lead(f); 2210 int vglgewicht; 2211 f=f-lead(f); 2031 2212 while (f!=0) 2032 2213 { … … 2043 2224 initialf=initialf+lead(f); 2044 2225 } 2045 } 2226 } 2046 2227 f=f-lead(f); 2047 2228 } … … 2059 2240 } 2060 2241 2061 proc tInitialIdeal (ideal i,intvec w,list #) 2242 ///////////////////////////////////////////////////////////////////////// 2243 2244 proc tInitialIdeal (ideal i,intvec w,list #) 2062 2245 "USAGE: tInitialIdeal(i,w); i ideal, w intvec 2063 ASSUME: i is an ideal in Q[t,x_1,...,x_n] and w=(w_0,...,w_n) 2246 ASSUME: i is an ideal in Q[t,x_1,...,x_n] and w=(w_0,...,w_n) 2064 2247 RETURN: ideal ini, the t-initial ideal of i with respect to w" 2065 2248 { 2066 2249 // THE PROCEDURE WILL BE CALLED FROM OTHER PROCEDURES INSIDE THIS LIBRARY; 2067 // IN THIS CASE THE VARIABLE t WILL INDEED BE THE LAST VARIABLE INSTEAD OF THE FIRST, 2250 // IN THIS CASE THE VARIABLE t WILL INDEED BE THE LAST VARIABLE INSTEAD OF 2251 // THE FIRST, 2068 2252 // AND WE THEREFORE HAVE TO MOVE IT BACK TO THE FRONT! 2069 2253 // THIS IS NOT DOCUMENTED FOR THE GENERAL USER!!!! … … 2088 2272 // ... and compute a standard basis with 2089 2273 // respect to the homogenised ordering defined by w. Since the generators 2090 // of i will be homogeneous it we can instead take the ordering wp 2091 // with the weightvector (0,w) replaced by (M,...,M)+(0,w) for some 2092 // large M, so that all entries are positive 2093 int M=-minInIntvec(w)[1]+1; // find M such that w[j]+M is strictly positive for all j 2274 // of i will be homogeneous it we can instead take the ordering wp 2275 // with the weightvector (0,w) replaced by (M,...,M)+(0,w) for some 2276 // large M, so that all entries are positive 2277 int M=-minInIntvec(w)[1]+1; // find M such that w[j]+M is 2278 // strictly positive for all j 2094 2279 intvec whomog=M+1; 2095 2280 for (j=1;j<=size(w);j++) … … 2098 2283 } 2099 2284 execute("ring WEIGHTRING=("+charstr(basering)+"),("+varstr(basering)+"),(wp("+string(whomog)+"));"); 2100 // map i to the new ring and compute a GB of i, then dehomogenise i, 2101 // so that we can be sure, that the 2285 // map i to the new ring and compute a GB of i, then dehomogenise i, 2286 // so that we can be sure, that the 2102 2287 // initial forms of the generators generate the initial ideal 2103 2288 ideal i=subst(groebner(imap(HOMOGRING,i)),@s,1); … … 2130 2315 } 2131 2316 2317 ///////////////////////////////////////////////////////////////////////// 2318 2132 2319 proc initialForm (poly f, intvec w) 2133 2320 "USAGE: initialForm(f,w); f a polynomial, w an integer vector … … 2161 2348 } 2162 2349 2350 ///////////////////////////////////////////////////////////////////////// 2351 2163 2352 proc initialIdeal (ideal i, intvec w) 2164 2353 "USAGE: initialIdeal(i,w); i ideal, w intvec … … 2190 2379 } 2191 2380 2192 /////////////////////////////////////////////////////////////////////////////// /////2381 /////////////////////////////////////////////////////////////////////////////// 2193 2382 /// PROCEDURES CONCERNED WITH THE LATEX CONVERSION 2194 //////////////////////////////////////////////////////////////////////////////////// 2195 2383 /////////////////////////////////////////////////////////////////////////////// 2196 2384 2197 2385 proc texNumber (poly p) 2198 "USAGE: 2199 RETURN: string, the tex command representing theleading coefficient of f using \frac2200 EXAMPLE: 2386 "USAGE: texNumber(f); f poly 2387 RETURN: string, tex command representing leading coefficient of f using \frac 2388 EXAMPLE: example texNumber; shows an example" 2201 2389 { 2202 2390 number n=leadcoef(p); … … 2239 2427 texNumber((3t2-1)/t3); 2240 2428 } 2429 2430 ///////////////////////////////////////////////////////////////////////// 2241 2431 2242 2432 proc texPolynomial (poly f) … … 2300 2490 } 2301 2491 2492 ///////////////////////////////////////////////////////////////////////// 2493 2302 2494 proc texMatrix (matrix M) 2303 2495 "USAGE: texMatrix(M); M matrix … … 2342 2534 2343 2535 2536 ///////////////////////////////////////////////////////////////////////// 2537 2344 2538 proc texDrawBasic (list texdraw) 2345 2539 "USAGE: texDrawBasic(texdraw); list texdraw 2346 ASSUME: texdraw is a list of strings representing texdraw commands (as produced by 2347 texDrawTropical) which should be embedded into a texdraw environment 2540 ASSUME: texdraw is a list of strings representing texdraw commands 2541 (as produced by texDrawTropical) which should be embedded into 2542 a texdraw environment 2348 2543 RETURN: string, a texdraw environment enclosing the input 2349 2544 NOTE: is called from conicWithTangents … … 2364 2559 \\end{texdraw}"; 2365 2560 return(texdrawtp); 2366 } 2561 } 2367 2562 example 2368 2563 { … … 2375 2570 } 2376 2571 2572 ///////////////////////////////////////////////////////////////////////// 2573 2377 2574 proc texDrawTropical (list graph,list #) 2378 2575 "USAGE: texDrawTropical(graph[,#]); graph list, # optional list 2379 2576 ASSUME: graph is the output of tropicalCurve 2380 2577 RETURN: string, the texdraw code of the tropical plane curve encoded by graph 2381 NOTE: - if the list # is non-empty, the first entry should be a string; if this string is 'max', 2382 then the tropical curve is considered with respect to the maximum; otherwise the curve 2383 is considered with respect to the minimum and the string can be used to 2384 insert further texdraw commands (e.g. to have a lighter image as when called 2385 from inside conicWithTangents); 2386 @* - the procedure computes a scalefactor for the texdraw command which should 2387 help to display the curve in the right way; this may, however, be a bad idea 2388 if several texDrawTropical outputs are put together to form one image; the 2389 scalefactor can be prescribed by a second optional entry of type poly 2578 NOTE: - if the list # is non-empty, the first entry should be a string; 2579 if this string is 'max', then the tropical curve is considered 2580 with respect to the maximum; otherwise the curve is considered 2581 with respect to the minimum and the string can be used to insert 2582 further texdraw commands (e.g. to have a lighter image as when called 2583 from inside conicWithTangents); 2584 @* - the procedure computes a scalefactor for the texdraw command which 2585 should help to display the curve in the right way; this may, 2586 however, be a bad idea if several texDrawTropical outputs are 2587 put together to form one image; the scalefactor can be prescribed 2588 by a second optional entry of type poly 2390 2589 @* - the list # is optional and may as well be empty 2391 2590 EXAMPLE: example texDrawTropical; shows an example" 2392 2591 { 2393 2592 int i,j; 2394 // deal first with the pathological case that the input polynomial was a monomial 2395 // and does therefore not define a tropical curve, and check if the Newton polytope is 2593 // deal first with the pathological case that 2594 // the input polynomial was a monomial 2595 // and does therefore not define a tropical curve, 2596 // and check if the Newton polytope is 2396 2597 // a line segment so that the curve defines a bunch of lines 2397 2598 int bunchoflines; 2398 if (size(graph[size(graph)][1])==1) // the boundary of the Newton polytope consists of a single point 2599 // if the boundary of the Newton polytope consists of a single point 2600 if (size(graph[size(graph)][1])==1) 2399 2601 { 2400 2602 return(string()); … … 2408 2610 M[2,i]=graph[size(graph)][1][i][2]; 2409 2611 } 2410 if ((size(graph[size(graph)][1])-size(syz(M)))==1) // then the Newton polytope is a line segment 2612 // then the Newton polytope is a line segment 2613 if ((size(graph[size(graph)][1])-size(syz(M)))==1) 2411 2614 { 2412 2615 bunchoflines=1; … … 2415 2618 // go on with the case that a tropical curve is defined 2416 2619 if (size(#)==0) 2417 { 2620 { 2418 2621 string texdrawtp=" 2419 2622 … … 2423 2626 { 2424 2627 if ((#[1]!="max") and (#[1]!="")) 2425 { 2628 { 2426 2629 string texdrawtp=#[1]; 2427 2630 } … … 2471 2674 for (i=1;i<=size(graph)-1;i++) 2472 2675 { 2473 if (bunchoflines==0) // if the curve is a bunch of lines no vertex has to be drawn 2676 // if the curve is a bunch of lines no vertex has to be drawn 2677 if (bunchoflines==0) 2474 2678 { 2475 2679 texdrawtp=texdrawtp+" 2476 2680 \\move ("+decimal(graph[i][1]-centerx)+" "+decimal(graph[i][2]-centery)+") \\fcir f:0 r:"+decimal(2/(leadcoef(scalefactor)*10),size(string(int(scalefactor)))+1); 2477 2681 } 2478 for (j=1;j<=ncols(graph[i][3]);j++) // draw the bounded edges emerging from the ith vertex 2479 { 2480 if (i<graph[i][3][1,j]) // don't draw it twice - and if there is only one vertex and graph[i][3][1,1] 2481 { // is thus 0, nothing is done 2682 // draw the bounded edges emerging from the ith vertex 2683 for (j=1;j<=ncols(graph[i][3]);j++) 2684 { 2685 // don't draw it twice - and if there is only one vertex 2686 // and graph[i][3][1,1] is thus 0, nothing is done 2687 if (i<graph[i][3][1,j]) 2688 { 2482 2689 texdrawtp=texdrawtp+" 2483 2690 \\move ("+decimal(graph[i][1]-centerx)+" "+decimal(graph[i][2]-centery)+") \\lvec ("+decimal(graph[graph[i][3][1,j]][1]-centerx)+" "+decimal(graph[graph[i][3][1,j]][2]-centery)+")"; 2484 if (graph[i][3][2,j]>1) // if the multiplicity is more than one, denote it in the picture 2691 // if the multiplicity is more than one, denote it in the picture 2692 if (graph[i][3][2,j]>1) 2485 2693 { 2486 2694 texdrawtp=texdrawtp+" … … 2489 2697 } 2490 2698 } 2491 for (j=1;j<=size(graph[i][4]);j++) // draw the unbounded edges emerging from the ith vertex 2492 { 2493 // they should not be too long 2699 // draw the unbounded edges emerging from the ith vertex 2700 // they should not be too long 2701 for (j=1;j<=size(graph[i][4]);j++) 2702 { 2494 2703 relxy=shorten(list(decimal(3*graph[i][4][j][1][1]/scalefactor),decimal(3*graph[i][4][j][1][2]/scalefactor),"2.5")); 2495 2704 texdrawtp=texdrawtp+" 2496 2705 \\move ("+decimal(graph[i][1]-centerx)+" "+decimal(graph[i][2]-centery)+") \\rlvec ("+relxy[1]+" "+relxy[2]+")"; 2497 if (graph[i][4][j][2]>1) // if the multiplicity is more than one, denote it in the picture 2706 // if the multiplicity is more than one, denote it in the picture 2707 if (graph[i][4][j][2]>1) 2498 2708 { 2499 2709 texdrawtp=texdrawtp+" … … 2540 2750 } 2541 2751 2752 ///////////////////////////////////////////////////////////////////////// 2753 2542 2754 proc texDrawNewtonSubdivision (list graph,list #) 2543 2755 "USAGE: texDrawNewtonSubdivision(graph[,#]); graph list, # optional list 2544 2756 ASSUME: graph is the output of tropicalCurve 2545 RETURN: string, the texdraw code of the Newton subdivision of the tropical plane curve encoded by graph 2546 NOTE: - the list # should contain as only entry a string; if this string is 'max', then 2547 the tropical curve is considered with respect to the maximum; otherwise the curve 2548 is considered with respect to the minimum and the string can be used to 2549 insert further texdraw commands (e.g. to have a lighter image as when called 2550 from inside conicWithTangents); the list # is optional and may as well be empty 2551 @* - note that lattice points in the Newton subdivision which are black correspond to markings 2552 of the marked subdivision, while lattice points in grey are not marked 2757 RETURN: string, the texdraw code of the Newton subdivision of the 2758 tropical plane curve encoded by graph 2759 NOTE: - the list # should contain as only entry a string; if this string 2760 is 'max', then the tropical curve is considered with respect 2761 to the maximum; otherwise the curve is considered with respect 2762 to the minimum and the string can be used to insert further 2763 texdraw commands (e.g. to have a lighter image as when called 2764 from inside conicWithTangents); the list # is optional and may 2765 as well be empty 2766 @* - note that lattice points in the Newton subdivision which are 2767 black correspond to markings of the marked subdivision, 2768 while lattice points in grey are not marked 2553 2769 EXAMPLE: example texDrawNewtonSubdivision; shows an example" 2554 2770 { 2555 2771 int i,j,k,l; 2556 2772 list boundary=graph[size(graph)][1]; 2557 list inneredges=graph[size(graph)][2]; 2773 list inneredges=graph[size(graph)][2]; 2558 2774 intvec shiftvector=graph[size(graph)][3]; 2559 2775 string subdivision; 2560 // find themaximal and minimal x- and y-coordinates and define the scalefactor2776 // find maximal and minimal x- and y-coordinates and define the scalefactor 2561 2777 poly maxx,maxy=1,1; 2562 2778 for (i=1;i<=size(boundary);i++) … … 2567 2783 poly scalefactor=minOfPolys(list(12/leadcoef(maxx),12/leadcoef(maxy))); 2568 2784 if (scalefactor<1) 2569 { 2785 { 2570 2786 subdivision=subdivision+" 2571 2787 \\relunitscale"+ decimal(scalefactor); … … 2575 2791 { 2576 2792 subdivision=subdivision+" 2577 \\move ("+string(boundary[i][1])+" "+string(boundary[i][2])+") 2793 \\move ("+string(boundary[i][1])+" "+string(boundary[i][2])+") 2578 2794 \\lvec ("+string(boundary[i+1][1])+" "+string(boundary[i+1][2])+")"; 2579 } 2795 } 2580 2796 subdivision=subdivision+" 2581 \\move ("+string(boundary[size(boundary)][1])+" "+string(boundary[size(boundary)][2])+") 2797 \\move ("+string(boundary[size(boundary)][1])+" "+string(boundary[size(boundary)][2])+") 2582 2798 \\lvec ("+string(boundary[1][1])+" "+string(boundary[1][2])+") 2583 2799 … … 2586 2802 { 2587 2803 subdivision=subdivision+" 2588 \\move ("+string(inneredges[i][1][1])+" "+string(inneredges[i][1][2])+") 2804 \\move ("+string(inneredges[i][1][1])+" "+string(inneredges[i][1][2])+") 2589 2805 \\lvec ("+string(inneredges[i][2][1])+" "+string(inneredges[i][2][2])+")"; 2590 2806 } … … 2606 2822 } 2607 2823 } 2608 // deal with the pathological cases 2824 // deal with the pathological cases 2609 2825 if (size(boundary)==1) // then the Newton polytope is a point 2610 2826 { … … 2661 2877 { 2662 2878 subdivision=subdivision+" 2663 \\move ("+string(markings[i][1])+" "+string(markings[i][2])+") 2879 \\move ("+string(markings[i][1])+" "+string(markings[i][2])+") 2664 2880 \\fcir f:0 r:"+decimal(2/(8*scalefactor),size(string(int(scalefactor)))+1); 2665 2881 } 2666 2882 // enclose subdivision in the texdraw environment 2667 string texsubdivision=" 2883 string texsubdivision=" 2668 2884 \\begin{texdraw} 2669 \\drawdim cm \\relunitscale 1 2885 \\drawdim cm \\relunitscale 1 2670 2886 \\linewd 0.05" 2671 2887 +subdivision+" … … 2681 2897 poly f=x+y+x2y+xy2+1/t*xy; 2682 2898 list graph=tropicalCurve(f); 2683 // compute the texdraw code of the Newton subdivision of the tropical curve 2899 // compute the texdraw code of the Newton subdivision of the tropical curve 2684 2900 texDrawNewtonSubdivision(graph); 2685 2901 } 2902 2903 ///////////////////////////////////////////////////////////////////////// 2686 2904 2687 2905 proc texDrawTriangulation (list triang,list polygon) 2688 2906 "USAGE: texDrawTriangulation(triang,polygon); triang,polygon list 2689 ASSUME: polygon is a list of integer vectors describing the lattice points of a marked polygon; 2690 triang is a list of integer vectors describing a triangulation of the marked polygon 2691 in the sense that an integer vector of the form (i,j,k) describes the triangle formed 2692 by polygon[i], polygon[j] and polygon[k] 2693 RETURN: string, a texdraw code for the triangulation described by triang without the texdraw environment 2907 ASSUME: polygon is a list of integer vectors describing the 2908 lattice points of a marked polygon; 2909 triang is a list of integer vectors describing a 2910 triangulation of the marked polygon 2911 in the sense that an integer vector of the form (i,j,k) describes 2912 the triangle formed by polygon[i], polygon[j] and polygon[k] 2913 RETURN: string, a texdraw code for the triangulation described 2914 by triang without the texdraw environment 2694 2915 EXAMPLE: example texDrawTriangulation; shows an example" 2695 2916 { … … 2699 2920 "; 2700 2921 int i,j; // indices 2701 list pairs,markings; // stores edges of the triangulation, respecively the marked points 2702 // for each triangle store the edges and marked points of the triangle 2922 list pairs,markings; // stores edges of the triangulation, respecively 2923 // the marked points for each triangle store the edges and marked 2924 // points of the triangle 2703 2925 for (i=1;i<=size(triang);i++) 2704 2926 { … … 2708 2930 markings[3*i-2]=triang[i][1]; 2709 2931 markings[3*i-1]=triang[i][2]; 2710 markings[3*i]=triang[i][3]; 2932 markings[3*i]=triang[i][3]; 2711 2933 } 2712 2934 // delete redundant pairs which occur more than once … … 2741 2963 { 2742 2964 latex=latex+" 2743 \\move ("+string(polygon[markings[i]][1])+" "+string(polygon[markings[i]][2])+") 2965 \\move ("+string(polygon[markings[i]][1])+" "+string(polygon[markings[i]][2])+") 2744 2966 \\fcir f:0 r:0.08"; 2745 2967 } … … 2748 2970 { 2749 2971 latex=latex+" 2750 \\move ("+string(polygon[pairs[i][1]][1])+" "+string(polygon[pairs[i][1]][2])+") 2972 \\move ("+string(polygon[pairs[i][1]][1])+" "+string(polygon[pairs[i][1]][2])+") 2751 2973 \\lvec ("+string(polygon[pairs[i][2]][1])+" "+string(polygon[pairs[i][2]][2])+")"; 2752 2974 } … … 2755 2977 { 2756 2978 latex=latex+" 2757 \\move ("+string(polygon[i][1])+" "+string(polygon[i][2])+") 2979 \\move ("+string(polygon[i][1])+" "+string(polygon[i][2])+") 2758 2980 \\fcir f:0.7 r:0.04"; 2759 2981 } … … 2764 2986 "EXAMPLE:"; 2765 2987 echo=2; 2766 // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 2988 // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 2767 2989 // with all integer points as markings 2768 2990 list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),intvec(0,0), 2769 2991 intvec(2,1),intvec(0,1),intvec(1,2),intvec(0,2),intvec(0,3); 2770 // define a triangulation by connecting the only interior point 2992 // define a triangulation by connecting the only interior point 2771 2993 // with the vertices 2772 2994 list triang=intvec(1,2,5),intvec(1,5,10),intvec(1,2,10); … … 2775 2997 } 2776 2998 2777 /////////////////////////////////////////////////////////////////////////////// /////2778 /// Auxilary Procedures 2779 /////////////////////////////////////////////////////////////////////////////// /////2999 /////////////////////////////////////////////////////////////////////////////// 3000 /// Auxilary Procedures 3001 /////////////////////////////////////////////////////////////////////////////// 2780 3002 2781 3003 proc radicalMemberShip (poly f,ideal i) 2782 3004 "USAGE: radicalMemberShip (f,i); f poly, i ideal 2783 RETURN: int, 1 if f is in the radical of i, 0 else" 3005 RETURN: int, 1 if f is in the radical of i, 0 else 3006 EXAMPLE: example radicalMemberShip; shows an example" 2784 3007 { 2785 3008 def BASERING=basering; … … 2809 3032 } 2810 3033 2811 /////////////////////////////////////////////////////////////////////////////// /////3034 /////////////////////////////////////////////////////////////////////////////// 2812 3035 /// Auxilary Procedures concerned with initialforms 2813 /////////////////////////////////////////////////////////////////////////////// /////3036 /////////////////////////////////////////////////////////////////////////////// 2814 3037 2815 3038 proc tInitialFormPar (poly f, intvec w) 2816 "USAGE: 2817 ASSUME: 2818 RETURN: 2819 NOTE: 2820 EXAMPLE: 3039 "USAGE: tInitialFormPar(f,w); f a polynomial, w an integer vector 3040 ASSUME: f is a polynomial in Q(t)[x_1,...,x_n] and w=(w_1,...,w_2) 3041 RETURN: poly, the t-initialform of f(t,x) w.r.t. (1,w) evaluated at t=1 3042 NOTE: the t-initialform are the terms with MINIMAL weighted order w.r.t. (1,w) 3043 EXAMPLE: example tInitialFormPar; shows an example" 2821 3044 { 2822 3045 // compute first the t-order of the leading coefficient of f (leitkoef[1]) and 2823 // the rational constant corresponding to this order in leadkoef(f) (leitkoef[2]) 3046 // the rational constant corresponding to this order in leadkoef(f) 3047 // (leitkoef[2]) 2824 3048 list leitkoef=simplifyToOrder(f); 2825 3049 execute("poly koef="+leitkoef[2]+";"); … … 2830 3054 // do the same for the remaining part of f and compare the results 2831 3055 // keep only the smallest ones 2832 int vglgewicht; 2833 f=f-lead(f); 3056 int vglgewicht; 3057 f=f-lead(f); 2834 3058 while (f!=0) 2835 3059 { 2836 leitkoef=simplifyToOrder(f); 3060 leitkoef=simplifyToOrder(f); 2837 3061 vglgewicht=leitkoef[1]+scalarproduct(w,leadexp(f)); 2838 3062 if (vglgewicht<gewicht) … … 2849 3073 initialf=initialf+koef*leadmonom(f); 2850 3074 } 2851 } 3075 } 2852 3076 f=f-lead(f); 2853 3077 } … … 2864 3088 } 2865 3089 3090 ///////////////////////////////////////////////////////////////////////// 3091 2866 3092 proc tInitialFormParMax (poly f, intvec w) 2867 "USAGE: 2868 ASSUME: 2869 RETURN: 2870 NOTE: 2871 EXAMPLE: 3093 "USAGE: tInitialFormParMax(f,w); f a polynomial, w an integer vector 3094 ASSUME: f is a polynomial in Q(t)[x_1,...,x_n] and w=(w_1,...,w_2) 3095 RETURN: poly, the t-initialform of f(t,x) w.r.t. (-1,w) evaluated at t=1 3096 NOTE: the t-initialform are the terms with MAXIMAL weighted order w.r.t. (1,w) 3097 EXAMPLE: example tInitialFormParMax; shows an example" 2872 3098 { 2873 3099 // compute first the t-order of the leading coefficient of f (leitkoef[1]) and 2874 // the rational constant corresponding to this order in leadkoef(f) (leitkoef[2]) 2875 list leitkoef=simplifyToOrder(f); 3100 // the rational constant corresponding to this order in leadkoef(f) 3101 // (leitkoef[2]) 3102 list leitkoef=simplifyToOrder(f); 2876 3103 execute("poly koef="+leitkoef[2]+";"); 2877 3104 // take in lead(f) only the term of lowest t-order and set t=1 … … 2882 3109 // keep only the largest ones 2883 3110 int vglgewicht; 2884 f=f-lead(f); 3111 f=f-lead(f); 2885 3112 while (f!=0) 2886 3113 { … … 2900 3127 initialf=initialf+koef*leadmonom(f); 2901 3128 } 2902 } 3129 } 2903 3130 f=f-lead(f); 2904 3131 } … … 2915 3142 } 2916 3143 3144 ///////////////////////////////////////////////////////////////////////// 3145 2917 3146 proc solveTInitialFormPar (ideal i) 2918 3147 "USAGE: solveTInitialFormPar(i); i ideal 2919 ASSUME: i is a zero-dimensional ideal in Q(t)[x_1,...,x_n] generated by the (1,w)-homogeneous 2920 elements for some integer vector w - i.e. by the (1,w)-initialforms of polynomials 3148 ASSUME: i is a zero-dimensional ideal in Q(t)[x_1,...,x_n] generated 3149 by the (1,w)-homogeneous elements for some integer vector w 3150 - i.e. by the (1,w)-initialforms of polynomials 2921 3151 RETURN: none 2922 NOTE: the procedure just displays complex approximations of the solution set of i 3152 NOTE: the procedure just displays complex approximations 3153 of the solution set of i 2923 3154 EXAMPLE: example solveTInitialFormPar; shows an example" 2924 3155 { … … 2942 3173 } 2943 3174 2944 proc detropicalise (poly p) 2945 "USAGE: detropicalise(f); f poly 2946 ASSUME: f is a linear polynomial with an arbitrary constant term and 2947 positive integer coefficients as further coefficients; 2948 RETURN: poly, the detropicalisation of (the non-constant part of) f 2949 NOTE: the output will be a monomial and the constant coefficient has been ignored 2950 EXAMPLE: example detropicalise; shows an example" 3175 ///////////////////////////////////////////////////////////////////////// 3176 3177 proc detropicalise (poly p) 3178 "USAGE: detropicalise(f); f poly 3179 ASSUME: f is a linear polynomial with an arbitrary constant term and 3180 positive integer coefficients as further coefficients; 3181 RETURN: poly, the detropicalisation of (the non-constant part of) f 3182 NOTE: the output will be a monomial and the constant coefficient 3183 has been ignored 3184 EXAMPLE: example detropicalise; shows an example" 2951 3185 { 2952 3186 poly dtp=1; … … 2954 3188 { 2955 3189 if (leadmonom(p)!=1) 2956 { 3190 { 2957 3191 dtp=dtp*leadmonom(p)^int(leadcoef(p)); 2958 3192 } … … 2969 3203 } 2970 3204 2971 /////////////////////////////////////////////////////////////////////////////// /////3205 /////////////////////////////////////////////////////////////////////////////// 2972 3206 /// Auxilary Procedures concerned with conics 2973 /////////////////////////////////////////////////////////////////////////////// /////3207 /////////////////////////////////////////////////////////////////////////////// 2974 3208 2975 3209 proc dualConic (poly f) … … 3001 3235 } 3002 3236 3003 /////////////////////////////////////////////////////////////////////////////// /////3237 /////////////////////////////////////////////////////////////////////////////// 3004 3238 /// Auxilary Procedures concerned with substitution 3005 /////////////////////////////////////////////////////////////////////////////// /////3239 /////////////////////////////////////////////////////////////////////////////// 3006 3240 3007 3241 proc parameterSubstitute (poly f,int N) 3008 "USAGE: parameterSubstitute(f,N); f poly, N int 3009 ASSUME: f is a polynomial in Q(t)[x_1,...,x_n] describing a plane curve over Q(t) 3010 RETURN: poly, f with t replaced by t^N 3011 EXAMPLE: example parameterSubstitute; shows an example" 3242 "USAGE: parameterSubstitute(f,N); f poly, N int 3243 ASSUME: f is a polynomial in Q(t)[x_1,...,x_n] describing 3244 a plane curve over Q(t) 3245 RETURN: poly, f with t replaced by t^N 3246 EXAMPLE: example parameterSubstitute; shows an example" 3012 3247 { 3013 3248 def BASERING=basering; … … 3031 3266 } 3032 3267 3268 ///////////////////////////////////////////////////////////////////////// 3269 3033 3270 proc tropicalSubst (poly f,int N,list #) 3034 "USAGE: 3035 ASSUME: 3036 3037 RETURN: 3038 3039 3040 EXAMPLE: 3271 "USAGE: parameterSubstitute(f,N,L); f poly, N int, L list 3272 ASSUME: f is a polynomial in Q(t)[x_1,...,x_k] 3273 and L is a list of the form var(i_1),poly_1,...,v(i_k),poly_k 3274 RETURN: list, the list is the tropical polynomial which we get from f 3275 by replacing the i-th variable be the i-th polynomial 3276 but in the i-th polynomial the parameter t is replaced by t^1/N 3277 EXAMPLE: example tropicalSubst; shows an example" 3041 3278 { 3042 3279 f=parameterSubstitute(f,N); … … 3058 3295 poly f=t2x+1/t*y-1; 3059 3296 tropicalSubst(f,2,x,x+t,y,tx+y+t2); 3060 // The procedure can be used to study the effect of a transformation of 3297 // The procedure can be used to study the effect of a transformation of 3061 3298 // the form x -> x+t^b, with b a rational number, on the tropicalisation and 3062 3299 // the j-invariant of a cubic over the Puiseux series. 3063 3300 f=t7*y3+t3*y2+t*(x3+xy2+y+1)+xy; 3064 // - the j-invariant, and hence its valuation, does not change under the transformation 3301 // - the j-invariant, and hence its valuation, 3302 // does not change under the transformation 3065 3303 jInvariant(f,"ord"); 3066 // - b=3/2, then the cycle length of the tropical cubic equals -val(j-inv) 3067 list g32=tropicalSubst(f,2,x,x+t3,y,y); 3304 // - b=3/2, then the cycle length of the tropical cubic equals -val(j-inv) 3305 list g32=tropicalSubst(f,2,x,x+t3,y,y); 3068 3306 tropicalJInvariant(g32); 3069 3307 // - b=1, then it is still true, but only just ... … … 3075 3313 } 3076 3314 3315 ///////////////////////////////////////////////////////////////////////// 3316 3077 3317 proc randomPoly (int d,int ug, int og, list #) 3078 "USAGE: randomPoly(d,ug,og[,#]); d, ug, og int, # list 3318 "USAGE: randomPoly(d,ug,og[,#]); d, ug, og int, # list 3079 3319 ASSUME: the basering has a parameter t 3080 RETURN: poly, a polynomial of degree d where the coefficients are of the form t^j with 3081 j a random integer between ug and og 3082 NOTE: if an optional argument # is given, then the coefficients are instead either of the 3083 form t^j as above or they are zero, and this is chosen randomly 3320 RETURN: poly, a polynomial of degree d where the coefficients are 3321 of the form t^j with j a random integer between ug and og 3322 NOTE: if an optional argument # is given, then the coefficients are 3323 instead either of the form t^j as above or they are zero, 3324 and this is chosen randomly 3084 3325 EXAMPLE: example randomPoly; shows an example" 3085 3326 { … … 3096 3337 { 3097 3338 if (size(#)!=0) 3098 { 3339 { 3099 3340 k=random(0,1); 3100 3341 } 3101 3342 if (k==0) 3102 { 3343 { 3103 3344 j=random(ug,og); 3104 3345 randomPolynomial=randomPolynomial+t^j*m[i]; … … 3122 3363 } 3123 3364 3365 ///////////////////////////////////////////////////////////////////////// 3366 3124 3367 proc cleanTmp () 3125 3368 "USAGE: cleanTmp() … … 3128 3371 RETURN: none" 3129 3372 { 3130 system("sh","cd /tmp; /bin/rm -f tropicalcurve*; /bin/rm -f tropicalnewtonsubdivision*"); 3131 } 3132 3133 ////////////////////////////////////////////////////////////////////////////// ///3134 ////////////////////////////////////////////////////////////////////////////// ///3373 system("sh","cd /tmp; /bin/rm -f tropicalcurve*; /bin/rm -f tropicalnewtonsubdivision*"); 3374 } 3375 3376 ////////////////////////////////////////////////////////////////////////////// 3377 ////////////////////////////////////////////////////////////////////////////// 3135 3378 /// AUXILARY PROCEDURES, WHICH ARE DECLARED STATIC 3136 ////////////////////////////////////////////////////////////////////////////// ///3137 ////////////////////////////////////////////////////////////////////////////// ///3138 3139 ////////////////////////////////////////////////////////////////////////////// ///3379 ////////////////////////////////////////////////////////////////////////////// 3380 ////////////////////////////////////////////////////////////////////////////// 3381 3382 ////////////////////////////////////////////////////////////////////////////// 3140 3383 /// Procedures used in tropicalparametriseNoabs respectively in tropicalLifting: 3141 3384 /// - phiOmega … … 3154 3397 /// - choosegfanvector 3155 3398 /// - tropicalliftingresubstitute 3156 ////////////////////////////////////////////////////////////////////////////// ///3399 ////////////////////////////////////////////////////////////////////////////// 3157 3400 3158 3401 static proc phiOmega (ideal i,int j,int wj) … … 3181 3424 3182 3425 3426 ///////////////////////////////////////////////////////////////////////// 3427 3183 3428 static proc cutdown (ideal jideal,intvec wvec,int dimension,list #) 3184 3429 "USAGE: cutdown(i,w,d); i ideal, w intvec, d int, # list 3185 ASSUME: i an ideal in Q[t,x_1,...,x_n], (w_1,...,w_n) is in the tropical variety of jideal 3186 and d=dim(i)>0, in Q(t)[x]; the optional parameter # can contain the string 'isPrime' 3187 to indicate that the input ideal is prime and no minimal associated primes have 3430 ASSUME: i an ideal in Q[t,x_1,...,x_n], (w_1,...,w_n) is in the tropical 3431 variety of jideal and d=dim(i)>0, in Q(t)[x]; the optional 3432 parameter # can contain the string 'isPrime' to indicate that 3433 the input ideal is prime and no minimal associated primes have 3188 3434 to be computed 3189 RETURN: list, the first entry is a ring, namely the basering where some variables have been 3190 eliminated, and the ring contains the ideal i (with the same variables eliminated), 3191 the t-initial ideal ini of i (w.r.t. the weight vector where the entries 3192 corresponding to the deleted variables have been eliminated) and a list 3193 repl where for each eliminated variable there is one entry, namely a polynomial 3194 in the remaining variables and t that explains how resubstitution of a solution 3195 for the new i gives a solution for the old i; the second entry is the weight vector 3196 wvec with the components corresponding to the eliminated variables removed 3197 NOTE: needs the libraries random.lib and primdec.lib; is called from tropicalLifting" 3198 { 3199 // IDEA: i is an ideal of dimension d; we want to cut it with d random linear 3435 RETURN: list, the first entry is a ring, namely the basering where some 3436 variables have been eliminated, and the ring contains 3437 the ideal i (with the same variables eliminated), 3438 the t-initial ideal ini of i (w.r.t. the weight vector 3439 where the entries corresponding to the deleted variables 3440 have been eliminated) and a list repl where for each 3441 eliminated variable there is one entry, namely a polynomial 3442 in the remaining variables and t that explains how 3443 resubstitution of a solution for the new i gives a solution 3444 for the old i; the second entry is the weight vector 3445 wvec with the components corresponding to the eliminated 3446 variables removed 3447 NOTE: needs the libraries random.lib and primdec.lib; 3448 is called from tropicalLifting" 3449 { 3450 // IDEA: i is an ideal of dimension d; we want to cut it with d random linear 3200 3451 // forms in such a way that the resulting 3201 3452 // ideal is 0-dim and still contains w in the tropical variety 3202 // NOTE: t is the last variable in the basering 3453 // NOTE: t is the last variable in the basering 3203 3454 ideal pideal; //this is the ideal we want to return 3204 3455 ideal cutideal; … … 3218 3469 for (j1=1;j1<=nvars(basering)-1;j1++) 3219 3470 { 3220 variablen=variablen+var(j1); //read the set of variables (needed to make the quotring later) 3221 product=product*var(j1); //make product of all variables (needed for the initial-monomial-check later 3222 } 3471 variablen=variablen+var(j1); // read the set of variables 3472 // (needed to make the quotring later) 3473 product=product*var(j1); // make product of all variables 3474 // (needed for the initial-monomial-check later 3475 } 3223 3476 execute("ring QUOTRING=("+charstr(basering)+",t),("+string(variablen)+"),dp;"); 3224 3477 setring BASERING; 3225 // change to quotring where we want to compute the primary decomposition of i3478 // change to quotring where we want to compute the primary decomposition of i 3226 3479 if (size(#)==0) // we only have to do so if isPrime is not set 3227 3480 { 3228 3481 setring QUOTRING; 3229 ideal jideal=imap(BASERING,jideal); 3230 list primp=minAssGTZ(jideal); //compute the primary decomposition 3482 ideal jideal=imap(BASERING,jideal); 3483 list primp=minAssGTZ(jideal); //compute the primary decomposition 3231 3484 for (j1=1;j1<=size(primp);j1++) 3232 { 3485 { 3233 3486 for(j2=1;j2<=size(primp[j1]);j2++) 3234 3487 { 3235 primp[j1][j2]=primp[j1][j2]/content(primp[j1][j2]);// clear all denominators 3236 } 3488 // clear all denominators 3489 primp[j1][j2]=primp[j1][j2]/content(primp[j1][j2]); 3490 } 3237 3491 } 3238 3492 setring BASERING; 3239 3493 list primp=imap(QUOTRING,primp); 3240 3494 // if i is not primary itself 3241 // go through the list of min. ass. primes and find the first one which has w in its tropical variety 3242 if (size(primp)>1) 3495 // go through the list of min. ass. primes and find the first 3496 // one which has w in its tropical variety 3497 if (size(primp)>1) 3243 3498 { 3244 3499 j1=1; … … 3247 3502 //compute the t-initial of the associated prime 3248 3503 // - the last entry 1 only means that t is the last variable in the ring 3249 primini=tInitialIdeal(primp[j1],wvec,1); 3250 // check if it contains a monomial (resp if the product of var is in the radical) 3251 if (radicalMemberShip(product,primini)==0) 3252 { 3253 jideal=primp[j1];// if w is in the tropical variety of the prime, we take that 3504 primini=tInitialIdeal(primp[j1],wvec,1); 3505 // check if it contains a monomial (resp if the product of var 3506 // is in the radical) 3507 if (radicalMemberShip(product,primini)==0) 3508 { 3509 // if w is in the tropical variety of the prime, we take that 3510 jideal=primp[j1]; 3254 3511 setring QUOTRING; 3255 3512 dimension=dim(groebner(imap(BASERING,jideal)));//compute its dimension 3256 3513 setring BASERING; 3257 3514 winprim=1; // and stop the checking 3258 } 3515 } 3259 3516 j1=j1+1; //else we look at the next associated prime 3260 3517 } … … 3263 3520 { 3264 3521 jideal=primp[1]; //if i is primary itself we take its prime instead 3265 } 3522 } 3266 3523 } 3267 3524 // now we start as a first try to intersect with a hyperplane parallel to 3268 3525 // coordinate axes, because this would make our further computations 3269 // a lot easier. 3270 // We choose a subset of our n variables of size d=dim(ideal). For each of these 3271 // variables, we want to fix a value: x_i= a_i*t^-w_i. This will only work if the 3272 // projection of the d-dim variety to the other n-d variables is the whole n-d plane. 3273 // Then a general choice for a_i will intersect the variety in finitely many points. 3274 // If the projection is not the whole n-d plane, then a general choice will not work. 3275 // We could determine if we picked a good d-subset of variables using elimination 3276 // (NOTE, there EXIST d variables such that a random choice of a_i's would work!). 3277 // But since this involves many computations, we prefer to choose randomly and just 3278 // try in the end if our intersected ideal satisfies our requirements. If this does not 3526 // a lot easier. 3527 // We choose a subset of our n variables of size d=dim(ideal). 3528 // For each of these 3529 // variables, we want to fix a value: x_i= a_i*t^-w_i. 3530 // This will only work if the 3531 // projection of the d-dim variety to the other n-d variables 3532 // is the whole n-d plane. 3533 // Then a general choice for a_i will intersect the variety 3534 // in finitely many points. 3535 // If the projection is not the whole n-d plane, 3536 // then a general choice will not work. 3537 // We could determine if we picked a good 3538 // d-subset of variables using elimination 3539 // (NOTE, there EXIST d variables such that 3540 // a random choice of a_i's would work!). 3541 // But since this involves many computations, 3542 // we prefer to choose randomly and just 3543 // try in the end if our intersected ideal 3544 // satisfies our requirements. If this does not 3279 3545 // work, we give up this try and use our second intersection idea, which 3280 3546 // will work for a Zariksi-open subset (i.e. almost always). 3281 3547 // 3282 // As random subset of d variables we choose those for which the absolute value of the 3283 // wvec-coordinate is smallest, because this will give us the smallest powers of t and hence 3284 // less effort in following computations. Note that the smallest absolute value have those 3285 // which are biggest, because wvec is negative. 3548 // As random subset of d variables we choose 3549 // those for which the absolute value of the 3550 // wvec-coordinate is smallest, because this will 3551 // give us the smallest powers of t and hence 3552 // less effort in following computations. 3553 // Note that the smallest absolute value have those 3554 // which are biggest, because wvec is negative. 3286 3555 //print("first try"); 3287 3556 intvec wminust=intvecdelete(wvec,1); … … 3290 3559 A[1,1..size(wminust)]=-wminust; 3291 3560 A[2,1..size(wminust)]=1..size(wminust); 3292 // sort this matrix in order to get the d biggest entries and their position in wvec 3293 A=sortintmat(A); 3294 // we construct a vector which has 1 at entry j if j belongs to the list 3561 // sort this matrix in order to get 3562 // the d biggest entries and their position in wvec 3563 A=sortintmat(A); 3564 // we construct a vector which has 1 at entry j if j belongs to the list 3295 3565 // of the d biggest entries of wvec and a 0 else 3296 3566 for (j1=1;j1<=nvars(basering)-1;j1++) //go through the variables … … 3301 3571 { 3302 3572 setvec[j1]=1;//put a 1 3303 } 3304 } 3305 } 3306 // using this 0/1-vector we produce a random constant (i.e. coeff in Q times something in t) 3307 // for each of the biggest variables, we add the forms x_i-random constant to the ideal 3308 // and we save the constant at the i-th place of a list we want to return for later computations 3573 } 3574 } 3575 } 3576 // using this 0/1-vector we produce 3577 // a random constant (i.e. coeff in Q times something in t) 3578 // for each of the biggest variables, 3579 // we add the forms x_i-random constant to the ideal 3580 // and we save the constant at the i-th place of 3581 // a list we want to return for later computations 3309 3582 j3=0; 3310 3583 while (j3<=1) … … 3316 3589 { 3317 3590 if(setvec[j1]==1)//if x_i belongs to the biggest variables 3318 { 3591 { 3319 3592 if ((j3==1) and ((char(basering)==0) or (char(basering)>3))) 3320 { 3593 { 3321 3594 randomp1=random(1,3); 3322 randomp=t^(A[1,j2])*randomp1;//make a random constant --- first we try small numbers 3323 } 3595 randomp=t^(A[1,j2])*randomp1;// make a random constant 3596 // --- first we try small numbers 3597 } 3324 3598 if ((j3==2) and ((char(basering)==0) or (char(basering)>100))) 3325 3599 { 3326 3600 randomp1=random(1,100); 3327 randomp=t^(A[1,j2])*randomp1;//make a random constant --- next we try bigger numbers 3328 } 3601 randomp=t^(A[1,j2])*randomp1;// make a random constant 3602 // --- next we try bigger numbers 3603 } 3329 3604 else 3330 3605 { … … 3338 3613 else 3339 3614 { 3340 ergl[j1]=0; //if the variable belongs not the the d biggest ones, save 0 in the list 3615 ergl[j1]=0; //if the variable belongs not the the d biggest ones, 3616 //save 0 in the list 3341 3617 erglini[j1]=0; 3342 } 3618 } 3343 3619 } 3344 3620 // print(ergl);print(pideal); 3345 // now we check if we made a good choice of pideal, i.e. if dim=0 and 3621 // now we check if we made a good choice of pideal, i.e. if dim=0 and 3346 3622 // wvec is still in the tropical variety 3347 // change to quotring where we compute dimension3623 // change to quotring where we compute dimension 3348 3624 cutideal=pideal; 3349 3625 for(j1=1;j1<=nvars(basering)-1;j1++) 3350 3626 { 3351 3627 if(setvec[j1]==1) 3352 { 3353 cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 3354 } 3628 { 3629 cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 3630 } 3355 3631 } 3356 3632 setring QUOTRING; … … 3364 3640 { 3365 3641 // compute the t-initial of the associated prime 3366 // - the last 1 just means that the variable t is the last variable in the ring 3642 // - the last 1 just means that the variable t is 3643 // the last variable in the ring 3367 3644 pini=tInitialIdeal(cutideal,wvec ,1); 3368 3645 //print("initial"); 3369 3646 //print(pini); 3370 // and if the initial w.r.t. t contains no monomial as we want (checked with 3647 // and if the initial w.r.t. t contains no monomial 3648 // as we want (checked with 3371 3649 // radical-membership of the product of all variables) 3372 if (radicalMemberShip(product,pini)==0) 3373 { 3374 // we made the right choice and now we substitute the variables in the ideal 3375 //to get an ideal in less variables 3376 // also we make a projected vector from wvec only the components of the remaining variables 3650 if (radicalMemberShip(product,pini)==0) 3651 { 3652 // we made the right choice and now 3653 // we substitute the variables in the ideal 3654 // to get an ideal in less variables 3655 // also we make a projected vector 3656 // from wvec only the components of the remaining variables 3377 3657 wvecp=wvec; 3378 variablen=0; 3658 variablen=0; 3379 3659 j2=0; 3380 3660 for(j1=1;j1<=nvars(basering)-1;j1++) … … 3389 3669 else 3390 3670 { 3391 variablen=variablen+var(j1); //read the set of remaining variables (needed to make quotring later) 3392 } 3393 } 3671 variablen=variablen+var(j1); // read the set of remaining variables 3672 // (needed to make quotring later) 3673 } 3674 } 3394 3675 // return pideal, the initial and the list ergl which tells us 3395 3676 // which variables we replaced by which form … … 3401 3682 export(ini); 3402 3683 export(repl); 3403 return(list(BASERINGLESS1,wvecp)); 3684 return(list(BASERINGLESS1,wvecp)); 3404 3685 } 3405 3686 } 3406 3687 } 3407 3688 // this is our second try to cut down, which we only use if the first try 3408 // didn't work out. We intersect with d general hyperplanes (i.e. we don't choose 3689 // didn't work out. We intersect with d general hyperplanes 3690 // (i.e. we don't choose 3409 3691 // them to be parallel to coordinate hyperplanes anymore. This works out with 3410 3692 // probability 1. 3411 3693 // 3412 // We choose general hyperplanes, i.e. linear forms which involve all x_i. 3413 // Each x_i has to be multiplied bz t^(w_i) in order to get the same weight (namely 0) 3694 // We choose general hyperplanes, i.e. linear forms which involve all x_i. 3695 // Each x_i has to be multiplied bz t^(w_i) in order 3696 // to get the same weight (namely 0) 3414 3697 // for each term. As we cannot have negative exponents, we multiply 3415 // the whole form by t^minimumw. Notice that then in the first form, 3698 // the whole form by t^minimumw. Notice that then in the first form, 3416 3699 // there is one term without t- the term of the variable 3417 3700 // x_i such that w_i is minimal. That is, we can solve for this variable. 3418 // In the second form, we can replace that variable, and divide by t as much as possible. 3419 // Then there is again one term wihtout t - the term of the variable with second least w. 3701 // In the second form, we can replace that variable, 3702 // and divide by t as much as possible. 3703 // Then there is again one term wihtout t - 3704 // the term of the variable with second least w. 3420 3705 // So we can solve for this one again and also replace it in the first form. 3421 // Since all our coefficients are chosen randomly, we can also from the beginning on 3422 // choose the set of variables which belong to the d smallest entries of wvec 3423 // (t not counting) and pick random forms g_i(t,x') (where x' is the set of remaining variables) 3424 // and set x_i=g_i(t,x'). 3706 // Since all our coefficients are chosen randomly, 3707 // we can also from the beginning on 3708 // choose the set of variables which belong to the d smallest entries of wvec 3709 // (t not counting) and pick random forms g_i(t,x') 3710 // (where x' is the set of remaining variables) 3711 // and set x_i=g_i(t,x'). 3425 3712 // 3426 3713 // make a matrix with first row wvec (without t) and second row 1..n 3427 3714 //print("second try"); 3428 3715 setring BASERING; 3429 A[1,1..size(wminust)]=wminust; 3716 A[1,1..size(wminust)]=wminust; 3430 3717 A[2,1..size(wminust)]=1..size(wminust); 3431 // sort this matrix in otder to get the d smallest entries (without counting the t-entry) 3718 // sort this matrix in otder to get the d smallest entries 3719 // (without counting the t-entry) 3432 3720 A=sortintmat(A); 3433 3721 randomp=0; 3434 3722 setvec=0; 3435 3723 setvec[nvars(basering)-1]=0; 3436 // we construct a vector which has 1 at entry j if j belongs to the list of 3724 // we construct a vector which has 1 at entry j if j belongs to the list of 3437 3725 // the d smallest entries of wvec and a 0 else 3438 3726 for (j1=1;j1<=nvars(basering)-1;j1++) //go through the variables … … 3454 3742 { 3455 3743 j2=j2+1; 3456 wvecp=intvecdelete(wvecp,j1+2-j2);//delete the components we substitute from wvec 3744 wvecp=intvecdelete(wvecp,j1+2-j2);// delete the components 3745 // we substitute from wvec 3457 3746 } 3458 3747 else 3459 3748 { 3460 variablen=variablen+var(j1); //read the set of remaining variables (needed to make the quotring later) 3461 } 3462 } 3749 variablen=variablen+var(j1); // read the set of remaining variables 3750 // (needed to make the quotring later) 3751 } 3752 } 3463 3753 setring BASERING; 3464 3754 execute("ring BASERINGLESS2=("+charstr(BASERING)+"),("+string(variablen)+",t),(dp("+string(ncols(variablen))+"),lp(1));"); 3465 // using the 0/1-vector which tells us which variables belong to the set of smallest entries of wvec 3466 // we construct a set of d random linear polynomials of the form x_i=g_i(t,x'), 3755 // using the 0/1-vector which tells us which variables belong 3756 // to the set of smallest entries of wvec 3757 // we construct a set of d random linear 3758 // polynomials of the form x_i=g_i(t,x'), 3467 3759 // where the set of all x_i is the set of 3468 // all variables which are in the list of smallest entries in wvec, and x' are the other variables. 3469 // We add these d random linear polynomials to the indeal pideal, i.e. we intersect 3760 // all variables which are in the list of smallest 3761 // entries in wvec, and x' are the other variables. 3762 // We add these d random linear polynomials to 3763 // the ideal pideal, i.e. we intersect 3470 3764 // with these and hope to get something 3471 // 0-dim which still contains wvec in its tropical variety. Also, we produce a list ergl 3765 // 0-dim which still contains wvec in its 3766 // tropical variety. Also, we produce a list ergl 3472 3767 // with g_i at the i-th position. 3473 3768 // This is a list we want to return. … … 3475 3770 setring BASERING; 3476 3771 pideal=jideal; 3477 for(j1=1;j1<=dimension;j1++)//go through the list of variables corres to the d smallest in wvec3478 { 3772 for(j1=1;j1<=dimension;j1++)//go through the list of variables 3773 { // corres to the d smallest in wvec 3479 3774 if ((char(basering)==0) or (char(basering)>3)) 3480 { 3775 { 3481 3776 randomp1=random(1,3); 3482 3777 randomp=randomp1*t^(-A[1,j1]); … … 3491 3786 if(setvec[j2]==0)//if x_j belongs to the set x' 3492 3787 { 3493 // add a random term with the suitable power of t to the random linear form 3788 // add a random term with the suitable power 3789 // of t to the random linear form 3494 3790 if ((char(basering)==0) or (char(basering)>3)) 3495 3791 { … … 3515 3811 } 3516 3812 //print(ergl); 3517 // Again, we have to test if we made a good choice to intersect,i.e. we have to check whether 3813 // Again, we have to test if we made a good choice 3814 // to intersect,i.e. we have to check whether 3518 3815 // pideal is 0-dim and contains wvec in the tropical variety. 3519 3816 cutideal=pideal; … … 3522 3819 if(setvec[j1]==1) 3523 3820 { 3524 cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 3525 } 3821 cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 3822 } 3526 3823 } 3527 3824 setring QUOTRING; … … 3535 3832 { 3536 3833 // compute the t-initial of the associated prime 3537 // - the last 1 just means that the variable t is the last variable in the ring 3834 // - the last 1 just means that the variable t 3835 // is the last variable in the ring 3538 3836 pini=tInitialIdeal(cutideal,wvec ,1); 3539 3837 //print("initial"); … … 3541 3839 // and if the initial w.r.t. t contains no monomial as we want (checked with 3542 3840 // radical-membership of the product of all variables) 3543 if (radicalMemberShip(product,pini)==0) 3841 if (radicalMemberShip(product,pini)==0) 3544 3842 { 3545 3843 // we want to replace the variables x_i by the forms -g_i in 3546 // our ideal in order to return an ideal with less variables 3844 // our ideal in order to return an ideal with less variables 3547 3845 // first we substitute the chosen variables 3548 3846 for(j1=1;j1<=nvars(basering)-1;j1++) … … 3561 3859 export(ini); 3562 3860 export(repl); 3563 return(list(BASERINGLESS2,wvecp)); 3861 return(list(BASERINGLESS2,wvecp)); 3564 3862 } 3565 3863 } 3566 3864 // now we try bigger numbers 3567 while (1) //a never-ending loop which will stop with prob. 1 as we find a suitable ideal with that prob3568 { 3865 while (1) //a never-ending loop which will stop with prob. 1 3866 { // as we find a suitable ideal with that prob 3569 3867 setring BASERING; 3570 3868 pideal=jideal; 3571 for(j1=1;j1<=dimension;j1++)//go through the list of variables corres to the d smallest in wvec3572 { 3869 for(j1=1;j1<=dimension;j1++)//go through the list of variables 3870 { // corres to the d smallest in wvec 3573 3871 randomp1=random(1,100); 3574 3872 randomp=randomp1*t^(-A[1,j1]); 3575 3873 for(j2=1;j2<=nvars(basering)-1;j2++)//go through all variables 3576 { 3874 { 3577 3875 if(setvec[j2]==0)//if x_j belongs to the set x' 3578 3876 { 3579 // add a random term with the suitable power of t to the random linear form 3877 // add a random term with the suitable power 3878 // of t to the random linear form 3580 3879 if ((char(basering)==0) or (char(basering)>100)) 3581 { 3880 { 3582 3881 randomp2=random(1,100); 3583 3882 randomp1=randomp1+randomp2*var(j2); … … 3600 3899 } 3601 3900 //print(ergl); 3602 // Again, we have to test if we made a good choice to intersect,i.e. we have to check whether 3901 // Again, we have to test if we made a good choice to 3902 // intersect,i.e. we have to check whether 3603 3903 // pideal is 0-dim and contains wvec in the tropical variety. 3604 3904 cutideal=pideal; … … 3607 3907 if(setvec[j1]==1) 3608 3908 { 3609 cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 3610 } 3909 cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 3910 } 3611 3911 } 3612 3912 setring QUOTRING; … … 3616 3916 //print(dimp); 3617 3917 kill cutideal; 3618 setring BASERING; 3918 setring BASERING; 3619 3919 if (dimp==0) // if it is 0 as we want 3620 3920 { 3621 3921 // compute the t-initial of the associated prime 3622 // - the last 1 just means that the variable t is the last variable in the ring 3922 // - the last 1 just means that the variable t 3923 // is the last variable in the ring 3623 3924 pini=tInitialIdeal(cutideal,wvec ,1); 3624 3925 //print("initial"); 3625 3926 //print(pini); 3626 // and if the initial w.r.t. t contains no monomial as we want (checked with 3927 // and if the initial w.r.t. t contains no monomial 3928 // as we want (checked with 3627 3929 // radical-membership of the product of all variables) 3628 if (radicalMemberShip(product,pini)==0) 3930 if (radicalMemberShip(product,pini)==0) 3629 3931 { 3630 3932 // we want to replace the variables x_i by the forms -g_i in … … 3637 3939 pideal=subst(pideal,var(j1),ergl[j1]);//substitute it 3638 3940 pini=subst(pini,var(j1),erglini[j1]); 3639 } 3640 } 3941 } 3942 } 3641 3943 // return pideal and the list ergl which tells us 3642 3944 // which variables we replaced by which form … … 3648 3950 export(ini); 3649 3951 export(repl); 3650 return(list(BASERINGLESS2,wvecp)); 3651 } 3652 } 3653 } 3654 } 3655 3952 return(list(BASERINGLESS2,wvecp)); 3953 } 3954 } 3955 } 3956 } 3957 3958 3959 ///////////////////////////////////////////////////////////////////////// 3656 3960 3657 3961 static proc tropicalparametriseNoabs (ideal i,intvec ww,int ordnung,int gfanold,int nogfan,list #) 3658 "USAGE: tropicalparametriseNoabs(i,tw,ord,gf,ng[,#]); i ideal, tw intvec, ord int, gf,ng int, # opt. list 3659 ASSUME: - i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], tw=(w_0,w_1,...,w_n,0,...,0) 3660 and (w_0,...,w_n,0,...,0) is in the tropical variety of i, 3661 and ord is the order up to which a point in V(i) over C((t)) lying over w shall be computed; 3962 "USAGE: tropicalparametriseNoabs(i,tw,ord,gf,ng[,#]); i ideal, tw intvec, ord int, gf,ng int, # opt. list 3963 ASSUME: - i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], 3964 tw=(w_0,w_1,...,w_n,0,...,0) and (w_0,...,w_n,0,...,0) is in 3965 the tropical variety of i, and ord is the order up to which a point 3966 in V(i) over C((t)) lying over w shall be computed; 3662 3967 - moreover, k should be zero if the procedure is not called recursively; 3663 - the point in the tropical variety is supposed to lie in the NEGATIVE orthant; 3664 - the ideal is zero-dimensional when considered in (Q(t)[X_1,...,X_k]/m)[x_1,...,x_n], 3665 where m=#[2] is a maximal ideal in Q(t)[X_1,...,X_k]; 3968 - the point in the tropical variety is supposed to lie in the NEGATIVE 3969 orthant; 3970 - the ideal is zero-dimensional when considered 3971 in (Q(t)[X_1,...,X_k]/m)[x_1,...,x_n], 3972 where m=#[2] is a maximal ideal in Q(t)[X_1,...,X_k]; 3666 3973 - gf is 0 if version 2.2 or larger is used and it is 1 else 3667 - ng is 1 if gfan should not be executed 3974 - ng is 1 if gfan should not be executed 3668 3975 RETURN: list, l[1] = ring Q(0,X_1,...,X_r)[[t]] 3669 3976 l[2] = int 3670 3977 l[3] = string 3671 3978 NOTE: - the procedure is also called recursively by itself, and 3672 if it is called in the first recursion, the list # is empty, 3673 otherwise #[1] is an integer, one more than the number of true variables x_1,...,x_n, 3979 if it is called in the first recursion, the list # is empty, 3980 otherwise #[1] is an integer, one more than the number 3981 of true variables x_1,...,x_n, 3674 3982 and #[2] will contain the maximal ideal m in the variables X_1,...X_k 3675 3983 by which the ring Q[t,x_1,...,x_n,X_1,...,X_k] should be divided to 3676 3984 work correctly in K[t,x_1,...,x_n] where K=Q[X_1,...,X_k]/m is a field 3677 3985 extension of Q; 3678 - the ring l[1] contains an ideal PARA, which contains the parametrisation 3679 of a point in V(i) lying over w up to the first ord terms; 3680 - the string m=l[3] contains the code of the maximal ideal m, by which we have 3681 to divide Q[X_1,...,X_r] in order to have the appropriate field extension 3682 over which the parametrisation lives; 3683 - and if the integer l[2] is N then t has to be replaced by t^1/N in the 3684 parametrisation, or alternatively replace t by t^N in the defining ideal 3685 - the procedure REQUIRES that the program GFAN is installed on your computer" 3986 - the ring l[1] contains an ideal PARA, which contains the 3987 parametrisation of a point in V(i) lying over w up to the 3988 first ord terms; 3989 - the string m=l[3] contains the code of the maximal ideal m, 3990 by which we have to divide Q[X_1,...,X_r] in order to have 3991 the appropriate field extension over which the parametrisation lives; 3992 - and if the integer l[2] is N then t has to be replaced by t^1/N in 3993 the parametrisation, or alternatively replace t by t^N in the 3994 defining ideal 3995 - the procedure REQUIRES that the program GFAN is installed on 3996 your computer" 3686 3997 { 3687 3998 def ALTRING=basering; … … 3690 4001 if (size(#)==2) // this means the precedure has been called recursively 3691 4002 { 3692 // how many variables are true variables, and how many come from the field extension 4003 // how many variables are true variables, and how many come 4004 // from the field extension 3693 4005 // only true variables have to be transformed 3694 4006 int anzahlvariablen=#[1]; 3695 4007 ideal gesamt_m=std(#[2]); // stores all maxideals used for field extensions 3696 4008 // find the zeros of the w-initial ideal and transform the ideal i; 3697 // findzeros and basictransformideal need to know how many of the variables are true variables 4009 // findzeros and basictransformideal need to know how 4010 // many of the variables are true variables 3698 4011 list m_ring=findzeros(i,ww,anzahlvariablen); 3699 4012 list btr=basictransformideal(i,ww,m_ring,anzahlvariablen); … … 3701 4014 else // the procedure has been called by tropicalLifting 3702 4015 { 3703 // how many variables are true variables, and how many come from the field extension3704 // only true variables have to be transformed4016 // how many variables are true variables, and how many come from 4017 // the field extension only true variables have to be transformed 3705 4018 int anzahlvariablen=nvars(basering); 3706 4019 ideal gesamt_m; // stores all maxideals used for field extensions … … 3708 4021 ideal ini=#[1]; 3709 4022 // find the zeros of the w-initial ideal and transform the ideal i; 3710 // we should hand the t-initial ideal ine to findzeros, since we know it already 4023 // we should hand the t-initial ideal ine to findzeros, 4024 // since we know it already 3711 4025 list m_ring=findzeros(i,ww,ini); 3712 4026 list btr=basictransformideal(i,ww,m_ring); … … 3721 4035 def TRRING=btr[1]; 3722 4036 setring TRRING; 3723 ideal gesamt_m=imap(PREVIOUSRING,gesamt_m)+m; // add the newly found maximal ideal to the previous ones 4037 ideal gesamt_m=imap(PREVIOUSRING,gesamt_m)+m; // add the newly found maximal 4038 // ideal to the previous ones 3724 4039 } 3725 4040 else … … 3728 4043 list a=btr[2]; 3729 4044 ideal m=btr[3]; 3730 gesamt_m=gesamt_m+m; // add the newly found maximal ideal to the previous ones 4045 gesamt_m=gesamt_m+m; // add the newly found maximal 4046 // ideal to the previous ones 3731 4047 } 3732 4048 // check if there is a solution which has the n-th component zero, 3733 // if so, then eliminate the n-th variable from sat(i+x_n,t), otherwise leave i as it is; 3734 // then check if the (remaining) ideal has as solution where the n-1st component is zero, 4049 // if so, then eliminate the n-th variable from sat(i+x_n,t), 4050 // otherwise leave i as it is; 4051 // then check if the (remaining) ideal has as solution 4052 // where the n-1st component is zero, 3735 4053 // and procede as before; do the same for the remaining variables; 3736 // this way we make sure that the remaining ideal has a solution which has no component zero; 4054 // this way we make sure that the remaining ideal has 4055 // a solution which has no component zero; 3737 4056 intvec deletedvariables; // the jth entry is set 1, if we eliminate x_j 3738 4057 int numberdeletedvariables; // the number of eliminated variables 3739 ideal variablen; // will contain the variables which are not eliminated 3740 intvec tw=ww; // in case some variables are deleted, we have to store the old weight vector 4058 ideal variablen; // will contain the variables which are not eliminated 4059 intvec tw=ww; // in case some variables are deleted, 4060 // we have to store the old weight vector 3741 4061 deletedvariables[anzahlvariablen]=0; 3742 ideal I,LI; 4062 ideal I,LI; 3743 4063 i=i+m; // if a field extension was necessary, then i has to be extended by m 3744 4064 for (jj=anzahlvariablen-1;jj>=1;jj--) // the variable t is the last one !!! … … 3746 4066 I=sat(ideal(var(jj)+i),t)[1]; 3747 4067 LI=subst(I,var(nvars(basering)),0); 3748 for (kk=1;kk<=size(deletedvariables)-1;kk++) //size(deletedvariables)=anzahlvariablen(before elim.) 4068 //size(deletedvariables)=anzahlvariablen(before elim.) 4069 for (kk=1;kk<=size(deletedvariables)-1;kk++) 3749 4070 { 3750 4071 LI=subst(LI,var(kk),0); 3751 4072 } 3752 if (size(LI)==0) // if no power of t is in lead(I) (where the X(i) are considered as field elements)3753 { 3754 // get rid of var(jj) 4073 if (size(LI)==0) // if no power of t is in lead(I) 4074 { // (where the X(i) are considered as field elements) 4075 // get rid of var(jj) 3755 4076 i=eliminate(I,var(jj)); 3756 4077 deletedvariables[jj]=1; 3757 anzahlvariablen--; // if a variable is eliminated, then the number of true variables drops 4078 anzahlvariablen--; // if a variable is eliminated, 4079 // then the number of true variables drops 3758 4080 numberdeletedvariables++; 3759 4081 } … … 3764 4086 } 3765 4087 variablen=invertorder(variablen); 3766 // store also the additional variables and t, since they for sure have not been eliminated 4088 // store also the additional variables and t, 4089 // since they for sure have not been eliminated 3767 4090 for (jj=anzahlvariablen+numberdeletedvariables-1;jj<=nvars(basering);jj++) 3768 4091 { 3769 4092 variablen=variablen+var(jj); 3770 4093 } 3771 // if some variables have been eliminated, then pass to a new ring which has less variables, 4094 // if some variables have been eliminated, 4095 // then pass to a new ring which has less variables, 3772 4096 // but if no variables are left, then we are done 3773 4097 def BASERING=basering; 3774 if ((numberdeletedvariables>0) and (anzahlvariablen>1)) // if only t remains, all true variables are gone3775 { 4098 if ((numberdeletedvariables>0) and (anzahlvariablen>1)) // if only t remains, 4099 { // all true variables are gone 3776 4100 execute("ring NEURING=("+charstr(basering)+"),("+string(variablen)+"),(dp("+string(size(variablen)-1)+"),lp(1));"); 3777 4101 ideal i=imap(BASERING,i); 3778 ideal gesamt_m=imap(BASERING,gesamt_m); 3779 } 3780 // now we have to compute a point ww on the tropical variety of the transformed ideal i; 3781 // of course, we only have to do so, if we have not yet reached the order up to which we 4102 ideal gesamt_m=imap(BASERING,gesamt_m); 4103 } 4104 // now we have to compute a point ww on the tropical variety 4105 // of the transformed ideal i; 4106 // of course, we only have to do so, if we have not yet 4107 // reached the order up to which we 3782 4108 // were supposed to do our computations 3783 if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains, all true variables are gone3784 { 4109 if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains, 4110 { // all true variables are gone 3785 4111 def PREGFANRING=basering; 3786 4112 if (nogfan!=1) 3787 { 4113 { 3788 4114 // pass to a ring which has variables which are suitable for gfan 3789 4115 execute("ring GFANRING=("+charstr(basering)+"),(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z),dp;"); 3790 ideal phiideal=b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z; 4116 ideal phiideal=b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z; 3791 4117 phiideal[nvars(PREGFANRING)]=a; // map t to a 3792 map phi=PREGFANRING,phiideal; 4118 map phi=PREGFANRING,phiideal; 3793 4119 ideal i=phi(i); 3794 // homogenise the ideal i with the first not yet used variable in our ring, since gfan 3795 // only handles homogenous ideals; in principle for this one has first to compute a 3796 // standard basis of i and homogenise that, but for the tropical variety (says Anders) 4120 // homogenise the ideal i with the first not yet 4121 // used variable in our ring, since gfan 4122 // only handles homogenous ideals; in principle 4123 // for this one has first to compute a 4124 // standard basis of i and homogenise that, 4125 // but for the tropical variety (says Anders) 3797 4126 // it suffices to homogenise an arbitrary system of generators 3798 // i=groebner(i); 4127 // i=groebner(i); 3799 4128 i=homog(i,maxideal(1)[nvars(PREGFANRING)+1]); 3800 4129 // if gfan version >= 0.3.0 is used and the characteristic … … 3808 4137 write(":a /tmp/gfaninput","{"+string(i)+"}"); 3809 4138 } 3810 else 4139 else 3811 4140 { 3812 4141 // write the ideal to a file which gfan takes as input and call gfan … … 3829 4158 string trop=read("/tmp/gfanoutput"); 3830 4159 setring PREGFANRING; 3831 intvec wneu=-1; // this integer vector will store the point on the tropical variety 4160 intvec wneu=-1; // this integer vector will store 4161 // the point on the tropical variety 3832 4162 wneu[nvars(basering)]=0; 3833 4163 // for the time being simply stop Singular and set wneu by yourself 3834 4164 int goon=1; 3835 4165 trop; 3836 "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY NON-POSITIVE ENTRIES AND STARTS WITH A NEGATIVE ONE,"; 4166 "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY"; 4167 "NON-POSITIVE ENTRIES AND STARTS WITH A NEGATIVE ONE,"; 3837 4168 "E.G. (-3,-4,-1,-5,0,0,0) - the last entry will always be 0 -"; 3838 4169 "THEN TYPE THE FOLLOWING COMMAND IN SINGULAR: wneu=-3,-4,-1,-5,0,0;"; … … 3840 4171 "IF YOU WANT wneu TO BE TESTED, THEN SET goon=0;"; 3841 4172 ~ 3842 // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE TROPICAL PREVARIETY 3843 // test, if wneu really is in the tropical variety 3844 while (goon==0) 4173 // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE 4174 // TROPICAL PREVARIETY 4175 // test, if wneu really is in the tropical variety 4176 while (goon==0) 3845 4177 { 3846 4178 if (testw(reduce(i,std(gesamt_m)),wneu,anzahlvariablen)==1) … … 3858 4190 { 3859 4191 system("sh","gfan_tropicallifting -n "+string(anzahlvariablen)+" --noMult -c < /tmp/gfaninput > /tmp/gfanoutput"); 3860 // read the result from gfan and store it to a string, which in a later version 4192 // read the result from gfan and store it to a string, 4193 // which in a later version 3861 4194 // should be interpreded by Singular 3862 4195 intvec wneu=choosegfanvector(read("/tmp/gfanoutput"),0)[1]; … … 3870 4203 } 3871 4204 } 3872 // if we have not yet computed our parametrisation up to the required order and 3873 // zero is not yet a solution, then we have to go on by calling the procedure recursively; 4205 // if we have not yet computed our parametrisation 4206 // up to the required order and 4207 // zero is not yet a solution, then we have 4208 // to go on by calling the procedure recursively; 3874 4209 // if all variables were deleted, then i=0 and thus anzahlvariablen==0 3875 4210 if ((ordnung>1) and (anzahlvariablen>1)) 3876 { 3877 // we call the procedure with the transformed ideal i, the new weight vector, with the 3878 // required order lowered by one, and with additional parameters, namely the number of 3879 // true variables and the maximal ideal that was computed so far to describe the field extension 4211 { 4212 // we call the procedure with the transformed ideal i, 4213 // the new weight vector, with the 4214 // required order lowered by one, and with 4215 // additional parameters, namely the number of 4216 // true variables and the maximal ideal that 4217 // was computed so far to describe the field extension 3880 4218 list PARALIST=tropicalparametriseNoabs(i,wneu,ordnung-1,gfanold,nogfan,anzahlvariablen,gesamt_m); 3881 // the output will be a ring, in which the parametrisation lives, and a string, which contains 4219 // the output will be a ring, in which the 4220 // parametrisation lives, and a string, which contains 3882 4221 // the maximal ideal that describes the necessary field extension 3883 4222 def PARARing=PARALIST[1]; … … 3885 4224 string PARAm=PARALIST[3]; 3886 4225 setring PARARing; 3887 // if some variables have been eliminated in before, then we have to insert zeros 4226 // if some variables have been eliminated in before, 4227 // then we have to insert zeros 3888 4228 // into the parametrisation for those variables 3889 4229 if (numberdeletedvariables>0) … … 3891 4231 ideal PARAneu=PARA; 3892 4232 int k; 3893 for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++) // t admits no parametrisation3894 { 4233 for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++) // t admits 4234 { // no parametrisation 3895 4235 if (deletedvariables[jj]!=1) 3896 4236 { … … 3905 4245 } 3906 4246 } 3907 // otherwise we are done and we can start to compute the last step of the parametrisation 4247 // otherwise we are done and we can start to compute 4248 // the last step of the parametrisation 3908 4249 else 3909 4250 { 3910 4251 // we store the information on m in a string 3911 4252 string PARAm=string(gesamt_m); 3912 // we define the weight of t, i.e. in the parametrisation t has to be replaced by t^1/tweight 4253 // we define the weight of t, i.e. in the parametrisation t 4254 // has to be replaced by t^1/tweight 3913 4255 int tweight=-tw[1]; 3914 // if additional variables were necessary, we introduce them now as parameters; 3915 // in any case the parametrisation ring will have only one variable, namely t, 3916 // and its order will be local, so that it displays the lowest term in t first 4256 // if additional variables were necessary, 4257 // we introduce them now as parameters; 4258 // in any case the parametrisation ring will 4259 // have only one variable, namely t, 4260 // and its order will be local, so that it 4261 // displays the lowest term in t first 3917 4262 if (anzahlvariablen+numberdeletedvariables<nvars(basering)) 3918 4263 { … … 3924 4269 } 3925 4270 ideal PARA; // will contain the parametrisation 3926 // we start by initialising the entries to be zero; one entry for each true variable 3927 // here we also have to consider the variables that we have eliminated in before 4271 // we start by initialising the entries to be zero; 4272 // one entry for each true variable 4273 // here we also have to consider the variables 4274 // that we have eliminated in before 3928 4275 for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++) 3929 4276 { … … 3931 4278 } 3932 4279 } 3933 // we now have to change the parametrisation by reverting the transformations that we have done 4280 // we now have to change the parametrisation by 4281 // reverting the transformations that we have done 3934 4282 list a=imap(BASERING,a); 3935 if (defined(wneu)==0) // when tropicalparametriseNoabs is called for the last time, it does not3936 { // enter the part, where wneu is defined and the variable t should have3937 intvec wneu=-1; // weight -14283 if (defined(wneu)==0) // when tropicalparametriseNoabs is called for the 4284 { // last time, it does not enter the part, where wneu is defined and the 4285 intvec wneu=-1; // variable t should have weight -1 3938 4286 } 3939 4287 for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++) … … 3941 4289 PARA[jj]=(PARA[jj]+a[jj+1])*t^(tw[jj+1]*tweight/ww[1]); 3942 4290 } 3943 // if we have reached the stop-level, i.e. either we had only to compute up to order 1 3944 // or zero was a solution of the ideal, then we have to export the computed parametrisation 4291 // if we have reached the stop-level, i.e. either 4292 // we had only to compute up to order 1 4293 // or zero was a solution of the ideal, then we have 4294 // to export the computed parametrisation 3945 4295 // otherwise it has already been exported before 3946 4296 // note, if all variables were deleted, then i==0 and thus testaufnull==0 3947 4297 if ((ordnung==1) or (anzahlvariablen==1)) 3948 { 4298 { 3949 4299 export(PARA); 3950 4300 } 3951 4301 // kill the gfan files in /tmp 3952 4302 system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput"); 3953 // we return a list which contains the parametrisation ring (with the parametrisation ideal) 3954 // and the string representing the maximal ideal describing the necessary field extension 4303 // we return a list which contains the 4304 // parametrisation ring (with the parametrisation ideal) 4305 // and the string representing the maximal ideal 4306 // describing the necessary field extension 3955 4307 return(list(PARARing,tweight,PARAm)); 3956 4308 } 3957 4309 4310 ///////////////////////////////////////////////////////////////////////// 4311 3958 4312 static proc findzeros (ideal i,intvec w,list #) 3959 "USAGE: findzeros(i,w[,#]); i ideal, w intvec, # an optional list 3960 ASSUME: i is an ideal in Q[t,x_1,...,x_n,X_n+1,...,X_m] and w=(w_0,...,w_n,0,...,0) 3961 is in the tropical variety of i 3962 RETURN: list, l[1] = is polynomial ring containing an associated maximal ideal m of the w-initial 3963 ideal of i which does not contain any monomial and where the variables 3964 which do not lead to a field extension have already been eliminated, 3965 and containing a list a such that the non-zero entries of a correspond 3966 to the values of the zero of the associated maximal ideal for the 4313 "USAGE: findzeros(i,w[,#]); i ideal, w intvec, # an optional list 4314 ASSUME: i is an ideal in Q[t,x_1,...,x_n,X_n+1,...,X_m] and 4315 w=(w_0,...,w_n,0,...,0) is in the tropical variety of i 4316 RETURN: list, l[1] = is polynomial ring containing an associated maximal 4317 ideal m of the w-initial ideal of i which does not 4318 contain any monomial and where the variables 4319 which do not lead to a field extension have already 4320 been eliminated, and containing a list a such that 4321 the non-zero entries of a correspond to the values 4322 of the zero of the associated maximal ideal for the 3967 4323 eliminated variables 3968 4324 l[2] = number of variables which have not been eliminated 3969 l[3] = intvec, if the entry is one then the corresponding variable has not 3970 been eliminated 3971 NOTE: the procedure is called from inside the recursive procedure tropicalparametriseNoabs; 3972 if it is called in the first recursion, the list #[1] contains the t-initial ideal 3973 of i w.r.t. w, otherwise #[1] is an integer, one more than the number of true 3974 variables x_1,...,x_n" 3975 { 3976 def BASERING=basering; 4325 l[3] = intvec, if the entry is one then the corresponding 4326 variable has not been eliminated 4327 NOTE: the procedure is called from inside the recursive procedure 4328 tropicalparametriseNoabs; 4329 if it is called in the first recursion, the list #[1] contains 4330 the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer, 4331 one more than the number of true variables x_1,...,x_n" 4332 { 4333 def BASERING=basering; 3977 4334 // set anzahlvariablen to the number of true variables 3978 4335 if (typeof(#[1])=="int") … … 3980 4337 int anzahlvariablen=#[1]; 3981 4338 // compute the initial ideal of i 3982 // - the last 1 just means that the variable t is the last variable in the ring 4339 // - the last 1 just means that the variable t is the last 4340 // variable in the ring 3983 4341 ideal ini=tInitialIdeal(i,w,1); 3984 4342 } … … 3986 4344 { 3987 4345 int anzahlvariablen=nvars(basering); 3988 ideal ini=#[1]; // the t-initial ideal has been computed in before and was handed over 3989 } 3990 // move to a polynomial ring with global monomial ordering - the variable t is superflous 4346 ideal ini=#[1]; // the t-initial ideal has been computed 4347 // in before and was handed over 4348 } 4349 // move to a polynomial ring with global monomial ordering 4350 // - the variable t is superflous 3991 4351 ideal variablen; 3992 4352 for (int j=1;j<=nvars(basering)-1;j++) 3993 { 4353 { 3994 4354 variablen=variablen+var(j); 3995 4355 } … … 3997 4357 ideal ini=imap(BASERING,ini); 3998 4358 // compute the associated primes of the initialideal 3999 // ordering the maximal ideals shall help to avoid unneccessary field extensions 4359 // ordering the maximal ideals shall help to avoid 4360 // unneccessary field extensions 4000 4361 list maximalideals=ordermaximalidealsNoabs(minAssGTZ(std(ini)),anzahlvariablen); 4001 4362 ideal m=maximalideals[1][1]; // the first associated maximal ideal 4002 4363 int neuvar=maximalideals[1][2]; // the number of new variables needed 4003 intvec neuevariablen=maximalideals[1][3]; // the information which variable leads to a new one 4004 list a=maximalideals[1][4]; // a_k is the kth component of a zero of m, if it is not zero 4005 // eliminate from m the superflous variables, that is those ones, which do not lead to 4006 // a new variable 4364 intvec neuevariablen=maximalideals[1][3]; // the information which variable 4365 // leads to a new one 4366 list a=maximalideals[1][4]; // a_k is the kth component of a 4367 // zero of m, if it is not zero 4368 // eliminate from m the superflous variables, that is those ones, 4369 // which do not lead to a new variable 4007 4370 poly elimvars=1; 4008 4371 for (j=1;j<=anzahlvariablen-1;j++) … … 4013 4376 } 4014 4377 } 4015 m=eliminate(m,elimvars); 4016 export(a); 4378 m=eliminate(m,elimvars); 4379 export(a); 4017 4380 export(m); 4018 4381 list m_ring=INITIALRING,neuvar,neuevariablen; … … 4022 4385 4023 4386 4387 ///////////////////////////////////////////////////////////////////////// 4388 4024 4389 static proc basictransformideal (ideal i,intvec w,list m_ring,list #) 4025 "USAGE: basictransformideal(i,w,m_ring[,#]); i ideal, w intvec, m_ring list, # an optional list 4026 ASSUME: i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], w=(w_0,...,w_n,0,...,0) 4027 is in the tropical variety of i, and m_ring contains a ring containing a maximal ideal m needed 4028 to describe the field extension over which a corresponding associated maximal ideal of the 4029 initialideal of i, considered in (Q[X_1,...,X_k]/m_alt)(t)[x_1,...,x_n], 4030 has a zero, and containing a list a describing the zero of m, and m_ring contains 4031 the information how many new variables are needed for m 4032 RETURN: list, either l[1] = ideal, i transformed by x_j -> (a_j+x_j)*t^w_j 4033 l[2] = list, a_1,...,a_n a point in V(m) 4034 l[3] = ideal, the maximal ideal m 4035 or l[1] = ring which contains the ideals i and m, and the list a 4036 NOTE: the procedure is called from inside the recursive procedure tropicalparametriseNoabs; 4037 if it is called in the first recursion, the list # is empty, 4038 otherwise #[1] is an integer, the number of true variables x_1,...,x_n; 4039 during the procedure we check if a field extension is necessary to express 4040 a zero (a_1,...,a_n) of m; if so, we have to introduce new variables and 4041 a list containing a ring is returned, otherwise the list containing i, a and m 4042 is returned; 4043 the ideal m will be changed during the procedure since all variables which reduce 4044 to a polynomial in X_1,...,X_k modulo m will be eliminated, while the others are 4045 replaced by new variables X_k+1,...,X_k'" 4390 "USAGE: basictransformideal(i,w,m_ring[,#]); i ideal, w intvec, m_ring list, # an optional list 4391 ASSUME: i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], 4392 w=(w_0,...,w_n,0,...,0) is in the tropical variety of i, and 4393 m_ring contains a ring containing a maximal ideal m needed 4394 to describe the field extension over which a corresponding 4395 associated maximal ideal of the initialideal of i, considered 4396 in (Q[X_1,...,X_k]/m_alt)(t)[x_1,...,x_n], has a zero, and 4397 containing a list a describing the zero of m, and m_ring contains 4398 the information how many new variables are needed for m 4399 RETURN: list, either l[1] = ideal, i transformed by x_j -> (a_j+x_j)*t^w_j 4400 l[2] = list, a_1,...,a_n a point in V(m) 4401 l[3] = ideal, the maximal ideal m 4402 or l[1] = ring which contains the ideals i and m, and the list a 4403 NOTE: the procedure is called from inside the recursive procedure 4404 tropicalparametriseNoabs; 4405 if it is called in the first recursion, the list # is empty, 4406 otherwise #[1] is an integer, the number of true variables x_1,...,x_n; 4407 during the procedure we check if a field extension is necessary 4408 to express a zero (a_1,...,a_n) of m; if so, we have to introduce 4409 new variables and a list containing a ring is returned, otherwise 4410 the list containing i, a and m is returned; 4411 the ideal m will be changed during the procedure since all variables 4412 which reduce to a polynomial in X_1,...,X_k modulo m will be eliminated, 4413 while the others are replaced by new variables X_k+1,...,X_k'" 4046 4414 { 4047 4415 def BASERING=basering; // the variable t is acutally the LAST variable !!! … … 4053 4421 wdegs[j]=deg(i[j],intvec(w[2..size(w)],w[1])); 4054 4422 } 4055 // how many variables are true variables, and how many come from the field extension 4423 // how many variables are true variables, 4424 // and how many come from the field extension 4056 4425 // only real variables have to be transformed 4057 4426 if (size(#)>0) … … 4067 4436 // get the information if any new variables are needed from m_ring 4068 4437 int neuvar=m_ring[2]; // number of variables which have to be added 4069 intvec neuevariablen=m_ring[3]; // [i]=1, if for the ith comp. of a zero of m a new variable is needed 4438 intvec neuevariablen=m_ring[3]; // [i]=1, if for the ith comp. 4439 // of a zero of m a new variable is needed 4070 4440 def MRING=m_ring[1]; // MRING contains a and m 4071 list a=imap(MRING,a); // (a_1,...,a_n)=(a[2],...,a[n+1]) will be a common zero of the ideal m 4072 ideal m=std(imap(MRING,m)); // m is zero, if neuvar==0, otherwise we change the ring anyway 4073 // if a field extension is needed, then extend the polynomial ring by new variables X_k+1,...,X_k'; 4441 list a=imap(MRING,a); // (a_1,...,a_n)=(a[2],...,a[n+1]) will be 4442 // a common zero of the ideal m 4443 ideal m=std(imap(MRING,m)); // m is zero, if neuvar==0, 4444 // otherwise we change the ring anyway 4445 // if a field extension is needed, then extend the polynomial 4446 // ring by new variables X_k+1,...,X_k'; 4074 4447 if (neuvar>0) 4075 4448 { 4076 // change to a ring where for each variable needed in m a new variable has been introduced 4449 // change to a ring where for each variable needed 4450 // in m a new variable has been introduced 4077 4451 ideal variablen; 4078 4452 // extract the variables x_1,...,x_n … … 4084 4458 // map i into the new ring 4085 4459 ideal i=imap(BASERING,i); 4086 // define a map phi which maps the true variables, which are not 4460 // define a map phi which maps the true variables, which are not 4087 4461 // reduced to polynomials in the additional variables modulo m, to 4088 // the corresponding newly introduced variables, and which maps 4462 // the corresponding newly introduced variables, and which maps 4089 4463 // the old additional variables to themselves 4090 4464 ideal phiideal; 4091 4465 k=1; 4092 for (j=2;j<=size(neuevariablen);j++) // starting with 2, since the first entry corresponds to t4093 { 4466 for (j=2;j<=size(neuevariablen);j++) // starting with 2, since the 4467 { // first entry corresponds to t 4094 4468 if(neuevariablen[j]==1) 4095 4469 { … … 4099 4473 else 4100 4474 { 4101 phiideal[j-1]=0; 4475 phiideal[j-1]=0; 4102 4476 } 4103 4477 } … … 4106 4480 phiideal=phiideal,X(1..nvars(BASERING)-anzahlvariablen); 4107 4481 } 4108 map phi=MRING,phiideal; 4109 // map m and a to the new ring via phi, so that the true variables in m and a are replaced by 4482 map phi=MRING,phiideal; 4483 // map m and a to the new ring via phi, so that the true variables 4484 // in m and a are replaced by 4110 4485 // the corresponding newly introduced variables 4111 4486 ideal m=std(phi(m)); 4112 4487 list a=phi(a); 4113 4488 } 4114 // replace now the zeros among the a_j by the corresponding newly introduced variables; 4115 // note that no component of a can be zero since the maximal ideal m contains no variable! 4116 // moreover, substitute right away in the ideal i the true variable x_j by (a_j+x_j)*t^w_j 4489 // replace now the zeros among the a_j by the corresponding 4490 // newly introduced variables; 4491 // note that no component of a can be zero 4492 // since the maximal ideal m contains no variable! 4493 // moreover, substitute right away in the ideal i 4494 // the true variable x_j by (a_j+x_j)*t^w_j 4117 4495 zaehler=nvars(BASERING)-anzahlvariablen+1; 4118 for (j=1;j<=anzahlvariablen;j++) 4496 for (j=1;j<=anzahlvariablen;j++) 4119 4497 { 4120 4498 if ((a[j]==0) and (j!=1)) // a[1]=0, since t->t^w_0 4121 { 4499 { 4122 4500 a[j]=X(zaehler); 4123 4501 zaehler++; … … 4126 4504 { 4127 4505 if (j!=1) // corresponds to x_(j-1) -- note t is the last variable 4128 { 4506 { 4129 4507 i[k]=substitute(i[k],var(j-1),(a[j]+var(j-1))*t^(-w[j])); 4130 4508 } … … 4138 4516 for (j=1;j<=ncols(i);j++) 4139 4517 { 4140 if (wdegs[j]<0) // if wdegs[j]==0 there is no need to divide, and we made sure that it is no positive4141 { 4518 if (wdegs[j]<0) // if wdegs[j]==0 there is no need to divide, and 4519 { // we made sure that it is no positive 4142 4520 i[j]=i[j]/t^(-wdegs[j]); 4143 4521 } 4144 4522 } 4145 // since we want to consider i now in the ring (Q[X_1,...,X_k']/m)[t,x_1,...,x_n] 4146 // we can reduce i modulo m, so that "constant terms" which are "zero" since they 4523 // since we want to consider i now in the ring 4524 // (Q[X_1,...,X_k']/m)[t,x_1,...,x_n] 4525 // we can reduce i modulo m, so that "constant terms" 4526 // which are "zero" since they 4147 4527 // are in m will disappear; simplify(...,2) then really removes them 4148 4528 i=simplify(reduce(i,m),2); 4149 // if new variables have been introduced, we have to return the ring containing i, a and m 4529 // if new variables have been introduced, we have 4530 // to return the ring containing i, a and m 4150 4531 // otherwise we can simply return a list containing i, a and m 4151 4532 if (neuvar>0) … … 4163 4544 } 4164 4545 4546 ///////////////////////////////////////////////////////////////////////// 4547 4165 4548 static proc testw (ideal i,intvec w,int anzahlvariablen,list #) 4166 4549 "USAGE: testw(i,w,n); i ideal, w intvec, n number 4167 ASSUME: i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k] and w=(w_0,...,w_n,0,...,0) 4168 RETURN: int b, 0 if the t-initial ideal of i considered in Q(X_1,...,X_k)[t,x_1,...,x_n] 4169 is monomial free, 1 else 4550 ASSUME: i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k] and 4551 w=(w_0,...,w_n,0,...,0) 4552 RETURN: int b, 0 if the t-initial ideal of i considered in 4553 Q(X_1,...,X_k)[t,x_1,...,x_n] is monomial free, 1 else 4170 4554 NOTE: the procedure is called by tinitialform" 4171 4555 { … … 4180 4564 ideal tin=tInitialIdeal(i,w,1); 4181 4565 } 4182 4566 4183 4567 int j; 4184 4568 ideal variablen; … … 4212 4596 def BASERING=basering; 4213 4597 if (anzahlvariablen<nvars(basering)) 4214 { 4598 { 4215 4599 execute("ring TINRING=("+charstr(basering)+","+string(Parameter)+"),("+string(variablen)+"),dp;"); 4216 4600 } … … 4222 4606 poly monom=imap(BASERING,monom); 4223 4607 return(radicalMemberShip(monom,tin)); 4224 } 4608 } 4609 4610 ///////////////////////////////////////////////////////////////////////// 4225 4611 4226 4612 static proc simplifyToOrder (poly f) 4227 4613 "USAGE: simplifyToOrder(f); f a polynomial 4228 ASSUME: f is a polynomial in Q(t)[x_1,...,x_n] 4614 ASSUME: f is a polynomial in Q(t)[x_1,...,x_n] 4229 4615 RETURN: list, l[1] = t-order of leading term of f 4230 4616 l[2] = the rational coefficient of the term of lowest t-order … … 4245 4631 } 4246 4632 4633 ///////////////////////////////////////////////////////////////////////// 4634 4247 4635 static proc scalarproduct (intvec w,intvec v) 4248 4636 "USAGE: scalarproduct(w,v); w,v intvec 4249 ASSUME: w and v are integer vectors of the same length 4637 ASSUME: w and v are integer vectors of the same length 4250 4638 RETURN: int, the scalarproduct of v and w 4251 4639 NOTE: the procedure is called by tropicalparametriseNoabs" … … 4258 4646 return(sp); 4259 4647 } 4648 4649 ///////////////////////////////////////////////////////////////////////// 4260 4650 4261 4651 static proc intvecdelete (intvec w,int i) … … 4283 4673 } 4284 4674 4675 ///////////////////////////////////////////////////////////////////////// 4676 4285 4677 static proc invertorder (ideal i) 4286 4678 "USAGE: intvertorder(i); i ideal … … 4296 4688 } 4297 4689 4690 ///////////////////////////////////////////////////////////////////////// 4691 4298 4692 static proc ordermaximalidealsNoabs (list minassi,int anzahlvariablen) 4299 4693 "USAGE: ordermaximalidealsNoabs(minassi); minassi list 4300 4694 ASSUME: minassi is a list of maximal ideals 4301 RETURN: list, the procedure orders the maximal ideals in minassi according to how many new 4302 variables are needed to describe the zeros of the ideal 4695 RETURN: list, the procedure orders the maximal ideals in minassi according 4696 to how many new variables are needed to describe the zeros 4697 of the ideal 4303 4698 l[j][1] = jth maximal ideal 4304 4699 l[j][2] = the number of variables needed 4305 l[j][3] = intvec, if for the kth variable a new variable is needed to 4306 define the corresponding zero of l[j][1], then the k+1st entry is one 4307 l[j][4] = list, if for the kth variable no new variable is needed to 4308 define the corresponding zero of l[j][1], then its value is the k+1st entry 4700 l[j][3] = intvec, if for the kth variable a new variable is 4701 needed to define the corresponding zero of 4702 l[j][1], then the k+1st entry is one 4703 l[j][4] = list, if for the kth variable no new variable is 4704 needed to define the corresponding zero of 4705 l[j][1], then its value is the k+1st entry 4309 4706 NOTE: if a maximal ideal contains a variable, it is removed from the list; 4310 4707 the procedure is called by findzeros" … … 4314 4711 int pruefer; // is set one if a maximal ideal contains a variable 4315 4712 list minassisort; // will contain the output 4316 for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort to fix its initial length 4713 for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort 4714 // to fix its initial length 4317 4715 list zwischen; // needed for reordering 4318 list a; 4716 list a;// (a_1,...,a_n)=(a[2],...,a[n+1]) will be a common zero of the ideal m 4319 4717 poly nf; // normalform of a variable w.r.t. m 4320 intvec neuevariablen; // ith entry is 1, if for the ith component of a zero of m a new variable is needed 4718 intvec neuevariablen; // ith entry is 1, if for the ith component of a zero 4719 // of m a new variable is needed 4321 4720 intvec testvariablen; // integer vector of length n=number of variables 4322 // compute for each maximal ideal the number of new variables, which are needed to describe 4323 // its zeros -- note, a new variable is needed if modulo the maximal ideal it does not reduce 4721 // compute for each maximal ideal the number of new variables, 4722 // which are needed to describe 4723 // its zeros -- note, a new variable is needed if modulo 4724 // the maximal ideal it does not reduce 4324 4725 // to something which only depends on the following variables; 4325 // if no new variable is needed, then store the value a variable reduces to in the list a; 4726 // if no new variable is needed, then store the value 4727 // a variable reduces to in the list a; 4326 4728 for (j=size(minassi);j>=1;j--) 4327 4729 { 4328 a[1]=poly(0); // the first entry in a and in neuevariablen corresponds to the variable t, 4730 a[1]=poly(0); // the first entry in a and in neuevariablen 4731 // corresponds to the variable t, 4329 4732 neuevariablen[1]=0; // which is not present in the INITIALRING 4330 4733 neuvar=0; … … 4333 4736 { 4334 4737 nf=reduce(var(k),minassi[j]); 4335 // if a variable reduces to zero, then the maximal ideal contains a variable and we can delete it 4738 // if a variable reduces to zero, then the maximal ideal 4739 // contains a variable and we can delete it 4336 4740 if (nf==0) 4337 4741 { 4338 4742 pruefer=1; 4339 4743 } 4340 // set the entries of testvariablen corresponding to the first k variables to 1, and the others to 0 4744 // set the entries of testvariablen corresponding to the first 4745 // k variables to 1, and the others to 0 4341 4746 for (l=1;l<=nvars(basering);l++) 4342 4747 { 4343 4748 if (l<=k) 4344 { 4749 { 4345 4750 testvariablen[l]=1; 4346 4751 } … … 4350 4755 } 4351 4756 } 4352 // if the variable x_j reduces to a polynomial in x_j+1,...,x_n,X_1,...,X_k modulo m 4353 // then we can eliminate x_j from the maximal ideal (since we do not need any 4354 // further field extension to express a_j) and a_j will just be this normalform, 4757 // if the variable x_j reduces to a polynomial 4758 // in x_j+1,...,x_n,X_1,...,X_k modulo m 4759 // then we can eliminate x_j from the maximal ideal 4760 // (since we do not need any 4761 // further field extension to express a_j) and a_j 4762 // will just be this normalform, 4355 4763 // otherwise we have to introduce a new variable in order to express a_j; 4356 4764 if (scalarproduct(leadexp(nf),testvariablen)==0) 4357 4765 { 4358 a[k+1]=nf; 4766 a[k+1]=nf; // a_k is the normal form of the kth variable modulo m 4359 4767 neuevariablen[k+1]=0; // no new variable is needed 4360 } 4768 } 4361 4769 else 4362 4770 { 4363 a[k+1]=poly(0); // a_k is set to zero until we have introduced the new variable 4771 a[k+1]=poly(0); // a_k is set to zero until we have 4772 // introduced the new variable 4364 4773 neuevariablen[k+1]=1; 4365 neuvar++; 4774 neuvar++; // the number of newly needed variables is raised by one 4366 4775 } 4367 4776 } 4368 4777 // if the maximal ideal contains a variable, we simply delete it 4369 4778 if (pruefer==0) 4370 { 4779 { 4371 4780 minassisort[j]=list(minassi[j],neuvar,neuevariablen,a); 4372 4781 } 4373 // otherwise we store the information on a, neuevariablen and neuvar together with the ideal 4782 // otherwise we store the information on a, 4783 // neuevariablen and neuvar together with the ideal 4374 4784 else 4375 4785 { … … 4379 4789 } 4380 4790 } 4381 // sort the maximal ideals ascendingly according to the number of new variables needed to 4791 // sort the maximal ideals ascendingly according to 4792 // the number of new variables needed to 4382 4793 // express the zero of the maximal ideal 4383 4794 for (j=2;j<=size(minassi);j++) … … 4385 4796 l=j; 4386 4797 for (k=j-1;k>=1;k--) 4387 { 4798 { 4388 4799 if (minassisort[l][2]<minassisort[k][2]) 4389 4800 { … … 4398 4809 } 4399 4810 4811 ///////////////////////////////////////////////////////////////////////// 4812 4400 4813 static proc displaypoly(poly p,int N,int wj,int w1) 4401 4814 "USAGE: displaypoly(p,N,wj,w1); p poly, N, wj, w1 int 4402 4815 ASSUME: p is a polynomial in r=(0,X(1..k)),t,ls 4403 RETURN: string, the string of t^-wj/w1*p(t^1/N) 4816 RETURN: string, the string of t^-wj/w1*p(t^1/N) 4404 4817 NOTE: the procedure is called from displayTropicalLifting" 4405 4818 { … … 4419 4832 { 4420 4833 if (koeffizienten[j-ord(p)+1]!=0) 4421 { 4834 { 4422 4835 if ((j-(N*wj)/w1)==0) 4423 4836 { … … 4464 4877 return(dp); 4465 4878 } 4879 4880 ///////////////////////////////////////////////////////////////////////// 4466 4881 4467 4882 static proc displaycoef (poly p) 4468 4883 "USAGE: displaycoef(p); p poly 4469 RETURN: string, the string of p where brackets around have been added if they were missing 4884 RETURN: string, the string of p where brackets around 4885 have been added if they were missing 4470 4886 NOTE: the procedure is called from displaypoly" 4471 4887 { … … 4480 4896 } 4481 4897 } 4898 4899 ///////////////////////////////////////////////////////////////////////// 4482 4900 4483 4901 static proc choosegfanvector (string s,int findall) … … 4532 4950 } 4533 4951 4952 ///////////////////////////////////////////////////////////////////////// 4953 4534 4954 static proc tropicalliftingresubstitute (ideal i,list liftring,int N,list #) 4535 4955 "USAGE: tropicalliftingresubstitute(i,L,N[,#]); i ideal, L list, N int, # string 4536 ASSUME: i is an ideal and L[1] is a ring which contains the lifting of a point in the4537 tropical variety of i computed with tropicalLifting;4538 t has to be replaced by t^1/N in the lifting; #[1]=m is the string of the maximal4539 ideal defining the necessary field extension as computed by tropicalLifting,4540 if #[1] is present4956 ASSUME: i is an ideal and L[1] is a ring which contains the lifting of a 4957 point in the tropical variety of i computed with tropicalLifting; 4958 t has to be replaced by t^1/N in the lifting; #[1]=m is the string 4959 of the maximal ideal defining the necessary field extension as 4960 computed by tropicalLifting, if #[1] is present 4541 4961 RETURN: string, the lifting has been substituted into i 4542 4962 NOTE: the procedure is called from tropicalLifting" … … 4560 4980 ideal i=imap(BASERING,i); 4561 4981 } 4562 } 4982 } 4563 4983 else 4564 4984 { … … 4573 4993 } 4574 4994 // map the resulting i back to LIFTRing; 4575 // if noAbs, then reduce i modulo the maximal ideal before going back to LIFTRing 4995 // if noAbs, then reduce i modulo the maximal ideal 4996 // before going back to LIFTRing 4576 4997 if ((size(parstr(LIFTRing))!=0) and size(#)>0) 4577 4998 { … … 4589 5010 for (j=1;j<=ncols(i);j++) 4590 5011 { 4591 SUBSTTEST[j]=displaypoly(i[j],N,0,1); 5012 SUBSTTEST[j]=displaypoly(i[j],N,0,1); 4592 5013 } 4593 5014 return(SUBSTTEST); 4594 5015 } 4595 5016 4596 /////////////////////////////////////////////////////////////////////////////// /////4597 /// Procedures used in tropicalLifting when using absolute primary decomposition :5017 /////////////////////////////////////////////////////////////////////////////// 5018 /// Procedures used in tropicalLifting when using absolute primary decomposition 4598 5019 /// - tropicalparametrise 4599 5020 /// - eliminatecomponents 4600 5021 /// - findzerosAndBasictransform 4601 /// - ordermaximalideals 4602 /////////////////////////////////////////////////////////////////////////////// /////5022 /// - ordermaximalideals 5023 /////////////////////////////////////////////////////////////////////////////// 4603 5024 4604 5025 static proc tropicalparametrise (ideal i,intvec ww,int ordnung,int gfanold,int findall,int nogfan,list #) 4605 5026 "USAGE: tropicalparametrise(i,tw,ord,gf,fa,ng[,#]); i ideal, tw intvec, ord int, gf,fa,ng int, # opt. list 4606 ASSUME: - i is an ideal in Q[t,x_1,...,x_n,@a], tw=(w_0,w_1,...,w_n,0) 4607 and (w_0,...,w_n,0) is in the tropical variety of i, 4608 and ord is the order up to which a point in V(i) over K{{t}} lying over w shall be computed; 4609 - moreover, @a should be not be there if the procedure is not called recursively; 4610 - the point in the tropical variety is supposed to lie in the NEGATIVE orthant; 4611 - the ideal is zero-dimensional when considered in (K(t)[@a]/m)[x_1,...,x_n], 4612 where m=#[2] is a maximal ideal in K[@a]; 5027 ASSUME: - i is an ideal in Q[t,x_1,...,x_n,@a], tw=(w_0,w_1,...,w_n,0) 5028 and (w_0,...,w_n,0) is in the tropical variety of i, 5029 and ord is the order up to which a point in V(i) 5030 over K{{t}} lying over w shall be computed; 5031 - moreover, @a should be not be there if the procedure is not 5032 called recursively; 5033 - the point in the tropical variety is supposed to lie in the 5034 NEGATIVE orthant; 5035 - the ideal is zero-dimensional when considered in 5036 (K(t)[@a]/m)[x_1,...,x_n], where m=#[2] is a maximal ideal in K[@a]; 4613 5037 - gf is 0 if version 2.2 or larger is used and it is 1 else 4614 5038 - fa is 1 if all solutions should be found … … 4617 5041 l[2] = int 4618 5042 NOTE: - the procedure is also called recursively by itself, and 4619 if it is called in the first recursion, the list # is empty, 4620 otherwise #[1] is an integer, one more than the number of true variables x_1,...,x_n, 4621 and #[2] will contain the maximal ideal m in the variable @a 4622 by which the ring K[t,x_1,...,x_n,@a] should be divided to 4623 work correctly in L[t,x_1,...,x_n] where L=Q[@a]/m is a field 4624 extension of K 4625 - the ring l[1] contains an ideal PARA, which contains the parametrisation 4626 of a point in V(i) lying over w up to the first ord terms; 4627 - the string m contains the code of the maximal ideal m, by which we have 4628 to divide K[@a] in order to have the appropriate field extension 5043 if it is called in the first recursion, the list # is empty, 5044 otherwise #[1] is an integer, one more than the number of 5045 true variables x_1,...,x_n, and #[2] will contain the maximal 5046 ideal m in the variable @a by which the ring K[t,x_1,...,x_n,@a] 5047 should be divided to work correctly in L[t,x_1,...,x_n] where 5048 L=Q[@a]/m is a field extension of K 5049 - the ring l[1] contains an ideal PARA, which contains the 5050 parametrisation of a point in V(i) lying over w up to the first 5051 ord terms; 5052 - the string m contains the code of the maximal ideal m, by which we 5053 have to divide K[@a] in order to have the appropriate field extension 4629 5054 over which the parametrisation lives; 4630 5055 - and if the integer l[3] is N then t has to be replaced by t^1/N in the 4631 parametrisation, or alternatively replace t by t^N in the defining ideal 4632 - the procedure REQUIRES that the program GFAN is installed on your computer" 5056 parametrisation, or alternatively replace t by t^N in the defining 5057 ideal 5058 - the procedure REQUIRES that the program GFAN is installed 5059 on your computer" 4633 5060 { 4634 5061 def BASERING=basering; 4635 5062 int recursively; // is set 1 if the procedure is called recursively by itself 4636 5063 int ii,jj,kk,ll,jjj,kkk,lll; 4637 if (typeof(#[1])=="int") // this means the precedure has been called recursively 4638 { 4639 // how many variables are true variables, and how many come from the field extension 5064 if (typeof(#[1])=="int") // this means the precedure has been 5065 { // called recursively 5066 // how many variables are true variables, and how many come 5067 // from the field extension 4640 5068 // only true variables have to be transformed 4641 5069 int anzahlvariablen=#[1]; 4642 5070 // find the zeros of the w-initial ideal and transform the ideal i; 4643 // findzeros and basictransformideal need to know how many of the variables are true variables 5071 // findzeros and basictransformideal need to know 5072 // how many of the variables are true variables 4644 5073 // and do the basic transformation as well 4645 5074 list zerolist=#[2]; … … 4648 5077 else // the procedure has been called by tropicalLifting 4649 5078 { 4650 // how many variables are true variables, and how many come from the field extension 5079 // how many variables are true variables, and 5080 // how many come from the field extension 4651 5081 // only true variables have to be transformed 4652 5082 int anzahlvariablen=nvars(basering); 4653 list zerolist; // will carry the zeros which are computed in the recursion steps4654 5083 list zerolist; // will carry the zeros which are 5084 //computed in the recursion steps 4655 5085 // the initial ideal of i has been handed over as #[1] 4656 5086 ideal ini=#[1]; 4657 5087 // find the zeros of the w-initial ideal and transform the ideal i; 4658 // we should hand the t-initial ideal ine to findzeros, since we know it already; 5088 // we should hand the t-initial ideal ine to findzeros, 5089 // since we know it already; 4659 5090 // and do the basic transformation as well 4660 5091 list trring=findzerosAndBasictransform(i,ww,zerolist,findall,ini); 4661 5092 } 4662 5093 list wneulist; // carries all newly computed weight vector 4663 intvec wneu; // carries the newly computed weight vector 5094 intvec wneu; // carries the newly computed weight vector 4664 5095 int tweight; // carries the weight of t 4665 list PARALIST; // carries the result when tropicalparametrise is recursively called 5096 list PARALIST; // carries the result when tropicalparametrise 5097 // is recursively called 4666 5098 list eliminaterings; // carries the result of eliminatecomponents 4667 intvec deletedvariables; // contains the informationwhich variables have been deleted5099 intvec deletedvariables; // contains inform. which variables have been deleted 4668 5100 deletedvariables[anzahlvariablen-1]=0; // initialise this vector 4669 5101 int numberdeletedvariables; // the number of deleted variables … … 4671 5103 list liftings,partliftings; // the computed liftings (all resp. partly) 4672 5104 // consider each ring which has been returned when computing the zeros of the 4673 // the t-initial ideal, equivalently, consider each zero which has been returned 5105 // the t-initial ideal, equivalently, consider 5106 // each zero which has been returned 4674 5107 for (jj=1;jj<=size(trring);jj++) 4675 5108 { 4676 5109 def TRRING=trring[jj]; 4677 5110 setring TRRING; 4678 // check if a certain number of components lead to suitable solutions with zero components; 5111 // check if a certain number of components lead to suitable 5112 // solutions with zero components; 4679 5113 // compute them all if findall==1 4680 5114 eliminaterings=eliminatecomponents(i,m,oldanzahlvariablen,findall,oldanzahlvariablen-1,deletedvariables); 4681 // consider each of the rings returned by eliminaterings ... there is at least one !!! 5115 // consider each of the rings returned by eliminaterings ... 5116 // there is at least one !!! 4682 5117 for (ii=1;ii<=size(eliminaterings);ii++) 4683 5118 { 4684 numberdeletedvariables=oldanzahlvariablen-eliminaterings[ii][2]; // #variables eliminated 4685 anzahlvariablen=eliminaterings[ii][2]; // #true variables which remain (including t) 4686 deletedvariables=eliminaterings[ii][3]; // a 1 in this vector says that variable was eliminated 5119 // #variables which have been eliminated 5120 numberdeletedvariables=oldanzahlvariablen-eliminaterings[ii][2]; 5121 // #true variables which remain (including t) 5122 anzahlvariablen=eliminaterings[ii][2]; 5123 // a 1 in this vector says that variable was eliminated 5124 deletedvariables=eliminaterings[ii][3]; 4687 5125 setring TRRING; // set TRRING - this is important for the loop 4688 def PREGFANRING=eliminaterings[ii][1]; // pass the ring computed by eliminatecomponents 5126 // pass the ring computed by eliminatecomponents 5127 def PREGFANRING=eliminaterings[ii][1]; 4689 5128 setring PREGFANRING; 4690 5129 poly m=imap(TRRING,m); // map the maximal ideal to this ring 4691 5130 list zero=imap(TRRING,zero); // map the vector of zeros to this ring 4692 // now we have to compute a point ww on the tropical variety of the transformed ideal i; 4693 // of course, we only have to do so, if we have not yet reached the order up to which we 5131 // now we have to compute a point ww on the tropical 5132 // variety of the transformed ideal i; 5133 // of course, we only have to do so, if we have 5134 // not yet reached the order up to which we 4694 5135 // were supposed to do our computations 4695 if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains, all true variables are gone4696 { 5136 if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains, 5137 { // all true variables are gone 4697 5138 if (nogfan!=1) 4698 { 5139 { 4699 5140 // pass to a ring which has variables which are suitable for gfan 4700 5141 execute("ring GFANRING=("+string(char(basering))+"),(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z),dp;"); 4701 ideal phiideal=b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z; 5142 ideal phiideal=b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z; 4702 5143 phiideal[nvars(PREGFANRING)]=a; // map t to a 4703 map phi=PREGFANRING,phiideal; 5144 map phi=PREGFANRING,phiideal; 4704 5145 ideal II=phi(i); 4705 // homogenise the ideal II with the first not yet used variable in our ring, since gfan 4706 // only handles homogenous ideals; in principle for this one has first to compute a 4707 // standard basis of II and homogenise that, but for the tropical variety (says Anders) 5146 // homogenise the ideal II with the first not yet 5147 // used variable in our ring, since gfan 5148 // only handles homogenous ideals; in principle for this 5149 // one has first to compute a 5150 // standard basis of II and homogenise that, 5151 // but for the tropical variety (says Anders) 4708 5152 // it suffices to homogenise an arbitrary system of generators 4709 // II=groebner(II); 5153 // II=groebner(II); 4710 5154 II=homog(II,maxideal(1)[nvars(PREGFANRING)+1]); 4711 5155 // if gfan version >= 0.3.0 is used and the characteristic … … 4745 5189 int goon=1; 4746 5190 trop; 4747 "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY NON-POSITIVE ENTRIES AND STARTS WITH A NEGATIVE ONE,"; 5191 "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY"; 5192 "NON-POSITIVE ENTRIES AND STARTS WITH A NEGATIVE ONE,"; 4748 5193 "E.G. (-3,-4,-1,-5,0,0,0) - the last entry will always be 0 -"; 4749 5194 "THEN TYPE THE FOLLOWING COMMAND IN SINGULAR: wneu=-3,-4,-1,-5,0,0;"; … … 4751 5196 "IF YOU WANT wneu TO BE TESTED, THEN SET goon=0;"; 4752 5197 ~ 4753 // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE TROPICAL PREVARIETY 4754 // test, if wneu really is in the tropical variety 5198 // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY 5199 // THE TROPICAL PREVARIETY 5200 // test, if wneu really is in the tropical variety 4755 5201 while (goon==0) 4756 5202 { … … 4759 5205 "CHOOSE A DIFFERENT RAY"; 4760 5206 ~ 4761 5207 } 4762 5208 else 4763 5209 { … … 4770 5216 { 4771 5217 system("sh","gfan_tropicallifting -n "+string(anzahlvariablen)+" --noMult -c < /tmp/gfaninput > /tmp/gfanoutput"); 4772 // read the result from gfan and store it to a string, which in a later version 5218 // read the result from gfan and store it to a string, 5219 // which in a later version 4773 5220 // should be interpreded by Singular 4774 5221 wneulist=choosegfanvector(read("/tmp/gfanoutput"),findall); … … 4792 5239 } 4793 5240 } 4794 // if we have not yet computed our parametrisation up to the required order and 4795 // zero is not yet a solution, then we have to go on by calling the procedure recursively; 5241 // if we have not yet computed our parametrisation up to 5242 // the required order and 5243 // zero is not yet a solution, then we have to go on 5244 // by calling the procedure recursively; 4796 5245 // if all variables were deleted, then i=0 and thus anzahlvariablen==0 4797 5246 lll=0; 4798 5247 if ((ordnung>1) and (anzahlvariablen>1)) 4799 { 5248 { 4800 5249 partliftings=list(); // initialise partliftings 4801 // we call the procedure with the transformed ideal i, the new weight vector, with the 4802 // required order lowered by one, and with additional parameters, namely the number of 4803 // true variables and the maximal ideal that was computed so far to describe the field extension 5250 // we call the procedure with the transformed 5251 // ideal i, the new weight vector, with the 5252 // required order lowered by one, and with 5253 // additional parameters, namely the number of 5254 // true variables and the maximal ideal that 5255 // was computed so far to describe the field extension 4804 5256 for (kk=1;kk<=size(wneulist);kk++) 4805 5257 { 4806 5258 wneu=wneulist[kk]; 4807 5259 PARALIST=tropicalparametrise(i,wneu,ordnung-1,gfanold,findall,nogfan,anzahlvariablen,zero); 4808 // the output will be a ring, in which the parametrisation lives, and a string, which contains 5260 // the output will be a ring, in which the 5261 // parametrisation lives, and a string, which contains 4809 5262 // the maximal ideal that describes the necessary field extension 4810 5263 for (ll=1;ll<=size(PARALIST);ll++) 4811 { 5264 { 4812 5265 def PARARing=PARALIST[ll][1]; 4813 5266 tweight=-ww[1]*PARALIST[ll][2]; 4814 5267 setring PARARing; 4815 // if some variables have been eliminated in before, then we have to insert zeros 5268 // if some variables have been eliminated 5269 // in before, then we have to insert zeros 4816 5270 // into the parametrisation for those variables 4817 5271 if (numberdeletedvariables>0) … … 4819 5273 ideal PARAneu=PARA; 4820 5274 kkk=0; 4821 for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++) // t admits no parametrisation4822 { 5275 for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++) 5276 { // t admits no parametrisation 4823 5277 if (deletedvariables[jjj]!=1) 4824 5278 { … … 4839 5293 } 4840 5294 } 4841 // otherwise we are done and we can start to compute the last step of the parametrisation 5295 // otherwise we are done and we can start 5296 // to compute the last step of the parametrisation 4842 5297 else 4843 5298 { 4844 // we define the weight of t, i.e. in the parametrisation t has to be replaced by t^1/tweight 5299 // we define the weight of t, i.e. in the 5300 // parametrisation t has to be replaced by t^1/tweight 4845 5301 tweight=-ww[1]; 4846 // if additional variables were necessary, we introduce them now as parameters; 4847 // in any case the parametrisation ring will have only one variable, namely t, 4848 // and its order will be local, so that it displays the lowest term in t first 5302 // if additional variables were necessary, 5303 // we introduce them now as parameters; 5304 // in any case the parametrisation ring will 5305 // have only one variable, namely t, 5306 // and its order will be local, so that it 5307 // displays the lowest term in t first 4849 5308 if (anzahlvariablen<nvars(basering)) 4850 5309 { … … 4857 5316 } 4858 5317 ideal PARA; // will contain the parametrisation 4859 // we start by initialising the entries to be zero; one entry for each true variable 4860 // here we also have to consider the variables that we have eliminated in before 5318 // we start by initialising the entries to be zero; 5319 // one entry for each true variable 5320 // here we also have to consider the variables 5321 // that we have eliminated in before 4861 5322 for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++) 4862 5323 { … … 4869 5330 kill PARARing; 4870 5331 } 4871 // we now have to change the parametrisation by reverting the transformations that we have done 5332 // we now have to change the parametrisation by 5333 // reverting the transformations that we have done 4872 5334 for (lll=1;lll<=size(partliftings);lll++) 4873 5335 { 4874 if (size(partliftings[lll])==2) // when tropicalparametrise is called for the last time, it does not4875 { // enter the part, where wneu is defined and the variable t should have4876 wneu=-1; // weight -15336 if (size(partliftings[lll])==2) // when tropicalparametrise is called 5337 { // for the last time, it does not enter the part, where wneu is 5338 wneu=-1; // defined and the variable t should have weight -1 4877 5339 } 4878 5340 else … … 4888 5350 PARA[jjj]=(PARA[jjj]+zeros[size(zeros)][jjj+1])*t^(ww[jjj+1]*tweight/ww[1]); 4889 5351 } 4890 // delete the last entry in zero, since that one has been used for the transformation 5352 // delete the last entry in zero, since that one has 5353 // been used for the transformation 4891 5354 zeros=delete(zeros,size(zeros)); 4892 // in order to avoid redefining commands an empty zeros list should be removed 5355 // in order to avoid redefining commands an empty 5356 // zeros list should be removed 4893 5357 if (size(zeros)==0) 4894 5358 { … … 4906 5370 // kill the gfan files in /tmp 4907 5371 system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput"); 4908 // we return a list which contains lists of the parametrisation rings (with the parametrisation ideal) 5372 // we return a list which contains lists of the parametrisation 5373 // rings (with the parametrisation ideal) 4909 5374 // and an integer N such that t should be replaced by t^1/N 4910 5375 return(liftings); 4911 5376 } 4912 5377 5378 ///////////////////////////////////////////////////////////////////////// 5379 4913 5380 static proc eliminatecomponents (ideal i,ideal m,int anzahlvariablen,int findall,int lastvar,intvec deletedvariables) 4914 5381 "USAGE: eliminatecomponents(i,m,n,a,v,d); i,m ideal, n,a,v int, d intvec 4915 ASSUME: i is an ideal in Q[x_1,...,x_n,@a,t] and w=(-w_1/w_0,...,-w_n/w_0) 4916 is in the tropical variety of i considered in Q[@a]/m{{t}}[x_1,...,x_n]; 4917 considered in this ring i is zero-dimensional; @a need not be present 5382 ASSUME: i is an ideal in Q[x_1,...,x_n,@a,t] and w=(-w_1/w_0,...,-w_n/w_0) 5383 is in the tropical variety of i considered in 5384 Q[@a]/m{{t}}[x_1,...,x_n]; 5385 considered in this ring i is zero-dimensional; @a need not be present 4918 5386 in which case m is zero; 1<=v<=n 4919 5387 RETURN: list, L of lists … … 4921 5389 L[j][2] = an integer anzahlvariablen 4922 5390 L[j][3] = an intvec deletedvariables 4923 NOTE: - the procedure is called from inside the recursive procedure tropicalparametrise 4924 - the procedure checks for solutions which have certain components zero; these are 4925 separated from the rest by elimination and saturation; the integer deletedvariables 4926 records which variables have been eliminated; the integer anzahlvariablen records how 4927 many true variables remain after the elimination 4928 - if the integer a is one then all zeros of the ideal i are considered and found, otherwise 4929 only one is considered, so that L has length one" 5391 NOTE: - the procedure is called from inside the recursive 5392 procedure tropicalparametrise 5393 - the procedure checks for solutions which have certain 5394 components zero; these are separated from the rest by 5395 elimination and saturation; the integer deletedvariables 5396 records which variables have been eliminated; 5397 the integer anzahlvariablen records how many true variables remain 5398 after the elimination 5399 - if the integer a is one then all zeros of the ideal i are 5400 considered and found, otherwise only one is considered, so that L 5401 has length one" 4930 5402 { 4931 5403 def BASERING=basering; … … 4934 5406 // if all solutions have to be found 4935 5407 if (findall==1) 4936 { 5408 { 4937 5409 list saturatelist,eliminatelist; // carry the solution of the two tests 4938 // we test first if there is a solution which has the component lastvar zero and 5410 // we test first if there is a solution which has the component 5411 // lastvar zero and 4939 5412 // where the order of each component is strictly positive; 4940 // if so, we add this variable to the ideal and eliminate it - which amounts to 4941 // to projecting the solutions with this component zero to the hyperplane without this component; 4942 // for the test we compute the saturation with respect to t and replace each variable 4943 // x_i and also t by zero -- if the result is zero, then 1 is not in I:t^infty 5413 // if so, we add this variable to the ideal and 5414 // eliminate it - which amounts to 5415 // to projecting the solutions with this component 5416 // zero to the hyperplane without this component; 5417 // for the test we compute the saturation with 5418 // respect to t and replace each variable 5419 // x_i and also t by zero -- if the result is zero, 5420 // then 1 is not in I:t^infty 4944 5421 // (i.e. there is a solution which has the component lastvar zero) and 4945 // the result lives in the maximal ideal <t,x_1,...,[no x_lastvar],...,x_n> so that 5422 // the result lives in the maximal 5423 // ideal <t,x_1,...,[no x_lastvar],...,x_n> so that 4946 5424 // there is a solution which has strictly positive valuation 4947 5425 /* 4948 5426 // DER NACHFOLGENDE TEIL IST MUELL UND WIRD NICHT MEHR GAMACHT 4949 // for the test we simply compute the leading ideal and set all true variables zero; 4950 // since the ordering was an elimination ordering with respect to (@a if present and) t 4951 // there remains something not equal to zero if and only if there is polynomial which only 4952 // depends on t (and @a if present), but that is a unit in K{{t}}, which would show that there 5427 // for the test we simply compute the leading ideal 5428 // and set all true variables zero; 5429 // since the ordering was an elimination ordering 5430 // with respect to (@a if present and) t 5431 // there remains something not equal to zero 5432 // if and only if there is polynomial which only 5433 // depends on t (and @a if present), but that is 5434 // a unit in K{{t}}, which would show that there 4953 5435 // is no solution with the component lastvar zero; 4954 // however, we also have to ensure that if there exists a solution with the component lastvar 4955 // equal to zero then this component has a valuation with all strictly positive values!!!!; 4956 // for this we can either saturate the ideal after elimination with respect to <t,x_1,...,x_n> 4957 // and see if the saturated ideal is contained in <t,x_1,...x_n>+m, 4958 // or ALTERNATIVELY we can pass to the ring 0,(t,x_1,...,x_n,@a),(ds(n+1),dp(1)), 4959 // compute a standard basis of the elimination ideal (plus m) there and check if the dimension 1 4960 // (since we have not omitted the variable lastvar, this means that we have the ideal 4961 // generated by t,x_1,...,[no x_lastvar],...,x_n and this defines NO curve after omitting x_lastvar) 5436 // however, we also have to ensure that if there 5437 // exists a solution with the component lastvar 5438 // equal to zero then this component has a 5439 // valuation with all strictly positive values!!!!; 5440 // for this we can either saturate the ideal 5441 // after elimination with respect to <t,x_1,...,x_n> 5442 // and see if the saturated ideal is contained in <t,x_1,...x_n>+m, 5443 // or ALTERNATIVELY we can pass to the 5444 // ring 0,(t,x_1,...,x_n,@a),(ds(n+1),dp(1)), 5445 // compute a standard basis of the elimination 5446 // ideal (plus m) there and check if the dimension 1 5447 // (since we have not omitted the variable lastvar, 5448 // this means that we have the ideal 5449 // generated by t,x_1,...,[no x_lastvar],...,x_n 5450 // and this defines NO curve after omitting x_lastvar) 4962 5451 I=std(ideal(var(lastvar)+i)); 4963 5452 // first test, 4964 5453 LI=lead(reduce(I,std(m))); 4965 for (j=1;j<=anzahlvariablen-1;j++) //size(deletedvariables)=anzahlvariablen(before elimination) 5454 //size(deletedvariables)=anzahlvariablen(before elimination) 5455 for (j=1;j<=anzahlvariablen-1;j++) 4966 5456 { 4967 5457 LI=subst(LI,var(j),0); … … 4969 5459 if (size(LI)==0) // if no power of t is in lead(I) (where @a is considered as a field element) 4970 5460 */ 4971 I=reduce(sat(ideal(var(lastvar)+i),t)[1],std(m)); // get rid of the minimal polynomial for the test 5461 I=reduce(sat(ideal(var(lastvar)+i),t)[1],std(m)); // get rid of the minimal 5462 // polynomial for the test 4972 5463 LI=subst(I,var(nvars(basering)),0); 4973 for (j=1;j<=anzahlvariablen-1;j++) //size(deletedvariables)=anzahlvariablen(before elimination) 5464 //size(deletedvariables)=anzahlvariablen(before elimination) 5465 for (j=1;j<=anzahlvariablen-1;j++) 4974 5466 { 4975 5467 LI=subst(LI,var(j),0); 4976 5468 } 4977 if (size(LI)==0) // the saturation lives in the maximal ideal generated by t and the x_i4978 { 5469 if (size(LI)==0) // the saturation lives in the maximal 5470 { // ideal generated by t and the x_i 4979 5471 // get rid of var(lastvar) 4980 5472 I=eliminate(I,var(lastvar))+m; // add the minimal polynomial again … … 4990 5482 { 4991 5483 string elring="ring ELIMINATERING=("+charstr(basering)+"),("+string(simplify(reduce(maxideal(1),std(var(lastvar))),2))+"),("; 4992 } 4993 if (anzahlvariablen<nvars(basering)) // if @a was present, the ordersting needs an additional entry4994 { 5484 } 5485 if (anzahlvariablen<nvars(basering)) // if @a was present, the 5486 { // ordersting needs an additional entry 4995 5487 elring=elring+"dp(1),"; 4996 5488 } 4997 5489 elring=elring+"lp(1));"; 4998 execute(elring); 5490 execute(elring); 4999 5491 ideal i=imap(BASERING,I); // move the ideal I to the new ring 5000 // if not yet all variables have been checked, then go on with the next smaller variable, 5001 // else prepare the elimination ring and the neccessary information for return 5492 // if not yet all variables have been checked, 5493 // then go on with the next smaller variable, 5494 // else prepare the elimination ring and the neccessary 5495 // information for return 5002 5496 if (lastvar>1) 5003 5497 { … … 5011 5505 setring BASERING; 5012 5506 } 5013 // next we have to test if there is also a solution which has the variable lastvar non-zero; 5014 // to do so, we saturate with respect to this variable; since when considered over K{{t}} 5015 // the ideal is zero dimensional, this really removes all solutions with that component zero; 5507 // next we have to test if there is also a solution 5508 // which has the variable lastvar non-zero; 5509 // to do so, we saturate with respect to this variable; 5510 // since when considered over K{{t}} 5511 // the ideal is zero dimensional, this really removes 5512 // all solutions with that component zero; 5016 5513 // the checking is then done as above 5017 5514 i=std(sat(i,var(lastvar))[1]); 5018 5515 I=reduce(i,std(m)); // "remove" m from i 5019 // test first, if i still is in the ideal <t,x_1,...,x_n> -- if not, then 5020 // we know that i has no longer a point in the tropical variety with all components negative 5516 // test first, if i still is in the ideal <t,x_1,...,x_n> -- if not, then 5517 // we know that i has no longer a point in the tropical 5518 // variety with all components negative 5021 5519 LI=subst(I,var(nvars(basering)),0); 5022 for (j=1;j<=anzahlvariablen-1;j++) // set all variables t,x_1,...,x_n equal to zero5023 { 5520 for (j=1;j<=anzahlvariablen-1;j++) // set all variables 5521 { // t,x_1,...,x_n equal to zero 5024 5522 LI=subst(LI,var(j),0); 5025 5523 } 5026 5524 if (size(LI)==0) // the entries of i have not constant part 5027 { 5028 // check now, if the leading ideal of i contains an element which only depends on t 5525 { 5526 // check now, if the leading ideal of i contains an element 5527 // which only depends on t 5029 5528 LI=lead(I); 5030 for (j=1;j<=anzahlvariablen-1;j++) //size(deletedvariables)=anzahlvariablen(before elimination) 5529 //size(deletedvariables)=anzahlvariablen(before elimination) 5530 for (j=1;j<=anzahlvariablen-1;j++) 5031 5531 { 5032 5532 LI=subst(LI,var(j),0); 5033 5533 } 5034 if (size(LI)==0) // if no power of t is in lead(i) (where @a is considered as a field element) 5035 { 5036 // if not yet all variables have been tested, go on with the next smaller variable 5534 if (size(LI)==0) // if no power of t is in lead(i) 5535 { // (where @a is considered as a field element) 5536 // if not yet all variables have been tested, go on with the 5537 // next smaller variable 5037 5538 // else prepare the neccessary information for return 5038 5539 if (lastvar>1) … … 5041 5542 } 5042 5543 else 5043 { 5544 { 5044 5545 execute("ring SATURATERING=("+charstr(basering)+"),("+varstr(basering)+"),("+ordstr(basering)+");"); 5045 5546 ideal i=imap(BASERING,i); … … 5052 5553 return(eliminatelist+saturatelist); 5053 5554 } 5054 else // only one solution is searched for, we can do a simplified version of the above 5055 { 5056 // check if there is a solution which has the n-th component zero and with positive valuation, 5057 // if so, then eliminate the n-th variable from sat(i+x_n,t), otherwise leave i as it is; 5058 // then check if the (remaining) ideal has as solution where the n-1st component is zero ..., 5555 else // only one solution is searched for, we can do a simplified 5556 { // version of the above 5557 // check if there is a solution which has the n-th component 5558 // zero and with positive valuation, 5559 // if so, then eliminate the n-th variable from 5560 // sat(i+x_n,t), otherwise leave i as it is; 5561 // then check if the (remaining) ideal has as 5562 // solution where the n-1st component is zero ..., 5059 5563 // and procede as before; do the same for the remaining variables; 5060 // this way we make sure that the remaining ideal has a solution which has no component zero; 5061 ideal variablen; // will contain the variables which are not eliminated 5564 // this way we make sure that the remaining ideal has 5565 // a solution which has no component zero; 5566 ideal variablen; // will contain the variables which are not eliminated 5062 5567 for (j=anzahlvariablen-1;j>=1;j--) // the variable t is the last one !!! 5063 5568 { 5064 5569 I=sat(ideal(var(j)+i),t)[1]; 5065 5570 LI=subst(I,var(nvars(basering)),0); 5066 for (k=1;k<=size(deletedvariables);k++) //size(deletedvariables)=anzahlvariablen-1(before elimination) 5571 //size(deletedvariables)=anzahlvariablen-1(before elimination) 5572 for (k=1;k<=size(deletedvariables);k++) 5067 5573 { 5068 5574 LI=subst(LI,var(k),0); 5069 5575 } 5070 if (size(LI)==0) // if no power of t is in lead(I) (where the X(i) are considered as field elements)5071 { 5072 // get rid of var(j) 5576 if (size(LI)==0) // if no power of t is in lead(I) 5577 { // (where the X(i) are considered as field elements) 5578 // get rid of var(j) 5073 5579 i=eliminate(I,var(j)); 5074 5580 deletedvariables[j]=1; 5075 anzahlvariablen--; // if a variable is eliminated, then the number of true variables drops 5581 anzahlvariablen--; // if a variable is eliminated, 5582 // then the number of true variables drops 5076 5583 } 5077 5584 else … … 5081 5588 } 5082 5589 variablen=invertorder(variablen); 5083 // store also the additional variable and t, since they for sure have not been eliminated 5590 // store also the additional variable and t, 5591 // since they for sure have not been eliminated 5084 5592 for (j=size(deletedvariables)+1;j<=nvars(basering);j++) 5085 5593 { 5086 5594 variablen=variablen+var(j); 5087 5595 } 5088 // if there are variables left, then pass to a ring which only realises these variables5089 // else we are done5596 // if there are variables left, then pass to a ring which 5597 // only realises these variables else we are done 5090 5598 if (anzahlvariablen>1) 5091 5599 { … … 5095 5603 { 5096 5604 string elring="ring ELIMINATERING=("+charstr(basering)+"),("+string(variablen)+"),("; 5097 } 5098 if (size(deletedvariables)+1<nvars(basering)) // if @a was present, the ordersting needs an additional entry5099 { 5605 } 5606 if (size(deletedvariables)+1<nvars(basering)) // if @a was present, 5607 { // the ordersting needs an additional entry 5100 5608 elring=elring+"dp(1),"; 5101 5609 } 5102 5610 elring=elring+"lp(1));"; 5103 execute(elring); 5611 execute(elring); 5104 5612 ideal i=imap(BASERING,i); 5105 5613 ideal m=imap(BASERING,m); … … 5110 5618 } 5111 5619 5620 ///////////////////////////////////////////////////////////////////////// 5621 5112 5622 static proc findzerosAndBasictransform (ideal i,intvec w,list zerolist,int findall,list #) 5113 "USAGE: findzerosAndBasictransform(i,w,z,f[,#]); i ideal, w intvec, z list, f int,# an optional list 5114 ASSUME: i is an ideal in Q[t,x_1,...,x_n,@a] and w=(w_0,...,w_n,0) 5115 is in the tropical variety of i; @a need not be present; 5116 the list 'zero' contains the zeros computed in previous recursion steps; 5117 if 'f' is one then all zeros should be found and returned, otherwise only one 5118 RETURN: list, each entry is a ring corresponding to one conjugacy class of zeros of the t-initial 5119 ideal inside the torus; each of the rings contains the following objects 5120 ideal i = the ideal i, where the variable @a (if present) has 5121 possibly been transformed according to the new minimal polynomial, 5122 and where itself has been submitted to the basic transform 5123 of the algorithm given by the jth zero found for the t-initial ideal; 5124 note that the new minimal polynomial has already been added 5125 poly m = the new minimal polynomial for @a (it is zero if no @a is present) 5126 list zero = zero[k+1] is the kth component of a zero the t-initial ideal of i 5127 NOTE: - the procedure is called from inside the recursive procedure tropicalparametrise; 5128 if it is called in the first recursion, the list #[1] contains the t-initial ideal 5129 of i w.r.t. w, otherwise #[1] is an integer, one more than the number of true 5130 variables x_1,...,x_n 5131 - if #[2] is present, then it is an integer which tells whether ALL zeros should be 5132 found or not" 5623 "USAGE: findzerosAndBasictransform(i,w,z,f[,#]); i ideal, w intvec, z list, f int,# an optional list 5624 ASSUME: i is an ideal in Q[t,x_1,...,x_n,@a] and w=(w_0,...,w_n,0) 5625 is in the tropical variety of i; @a need not be present; 5626 the list 'zero' contains the zeros computed in previous recursion steps; 5627 if 'f' is one then all zeros should be found and returned, 5628 otherwise only one 5629 RETURN: list, each entry is a ring corresponding to one conjugacy class of 5630 zeros of the t-initial ideal inside the torus; each of the rings 5631 contains the following objects 5632 ideal i = the ideal i, where the variable @a (if present) has 5633 possibly been transformed according to the new 5634 minimal polynomial, and where itself has been 5635 submitted to the basic transform of the algorithm 5636 given by the jth zero found for the t-initial ideal; 5637 note that the new minimal polynomial has already 5638 been added