Changeset ae9fd9 in git for Singular/LIB/tropical.lib


Ignore:
Timestamp:
Jul 28, 2009, 12:26:27 PM (15 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
3f4e526e3cc452dc07c10ec2049456a441cf11d8
Parents:
1c5fa50a543d43c7bb0c21bc2e1c9a5f9849e140
Message:
*hannes: format


git-svn-id: file:///usr/local/Singular/svn/trunk@12023 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/tropical.lib

    r1c5fa5 rae9fd9  
    1 version="$Id: tropical.lib,v 1.18 2009-07-09 12:20:30 keilen Exp $";
     1version="$Id: tropical.lib,v 1.19 2009-07-28 10:26:27 Singular Exp $";
    22category="Tropical Geometry";
    33info="
     
    88@*               Thomas Markwig,  email: keilen@mathematik.uni-kl.de
    99
    10 WARNING: 
     10WARNING:
    1111- 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 
     12@*- drawTropicalCurve and drawTropicalNewtonSubdivision will only display the
     13@*  tropical curve with LINUX and if in addition latex and kghostview
    1414@*  are installed.
    15 @*- For tropicalLifting in the definition of the basering the parameter t 
     15@*- For tropicalLifting in the definition of the basering the parameter t
    1616@*  from the Puiseux series field C{{t}} must be defined as a variable,
    1717@*  while for all other procedures it must be defined as a parameter.
    1818
    1919THEORY:
    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 
     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
    2323  point x in (K*)^n to the point (x^v0,...,x^vm).
    24   The generic hyperplane sections are just the images of the hypersurfaces 
     24  The generic hyperplane sections are just the images of the hypersurfaces
    2525  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 
     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
    2929  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 
     30  numbers). One associates to the hypersurface given by f=a0*x^v0+...+am*x^vm
    3131  the tropical hypersurface defined by the tropicalisation
    32   trop(f)=min{val(a0)+<v0,x>,...,val(am)+<vm,x>}. 
     32  trop(f)=min{val(a0)+<v0,x>,...,val(am)+<vm,x>}.
    3333  Here, <v,x> denotes the standard scalar product of the integer vector v in Z^n
    3434  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 
     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
    4444  tropical variety.
    4545
    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]. 
     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].
    5252  Note, that this in particular forbids rational exponents for the t's.
    5353
    5454  Moreover, in @sc{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 
     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
    5858  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 
     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
    6161  this is allowed -- these are linear polynomials where the constant coefficient
    62   corresponds 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: 
     62  corresponds 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:
    6565  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}.
    6666
    6767  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 
     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
    7676                         field extensions of Q might be necessary throughout
    7777                         the intermediate computations; the procedures use
    7878                         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 
     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
    8282                         in Q; latex must be installed on your computer
    83 @*  - tropicalJInvariant computes the tropical j-invaiant of a tropical 
     83@*  - tropicalJInvariant computes the tropical j-invaiant of a tropical
    8484                         elliptic curve
    8585@*  - jInvariant         computes the j-invariant of an elliptic curve
    86 @*  - weierstrassForm     computes the Weierstrass form of an elliptic curve 
     86@*  - weierstrassForm     computes the Weierstrass form of an elliptic curve
    8787
    8888PROCEDURES FOR TROPICAL LIFTING:
    89   tropicalLifting()          computes a point in the tropical variety 
     89  tropicalLifting()          computes a point in the tropical variety
    9090  displayTropicalLifting()   displays the output of tropicalLifting
    9191
     
    107107  tInitialIdeal()      computes the tInitial ideal of an ideal in Q[t,x_1,...,x_n]
    108108  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] 
     109  initialIdeal()       computes the initial ideal of an ideal in Q[x_1,...,x_n]
    110110
    111111PROCEDURES FOR LATEX CONVERSION:
     
    115115  texDrawBasic()       embeds output of texDrawTropical in a texdraw environment
    116116  texDrawTropical()    computes the texdraw commands for a tropical curve
    117   texDrawNewtonSubdivision()   computes texdraw commands for a Newton subdivision 
     117  texDrawNewtonSubdivision()   computes texdraw commands for a Newton subdivision
    118118  texDrawTriangulation()       computes texdraw commands for a triangulation
    119119
     
    121121  radicalMemberShip()     checks radical membership
    122122  tInitialFormPar()       computes the t-initial form of poly in Q(t)[x_1,...,x_n]
    123   tInitialFormParMax()    same as tInitialFormPar, but uses maximum 
     123  tInitialFormParMax()    same as tInitialFormPar, but uses maximum
    124124  solveTInitialFormPar()  displays approximated solution of a 0-dim ideal
    125125  detropicalise()         computes the detropicalisation of a linear form
    126   dualConic()             computes the dual of an affine plane conic 
     126  dualConic()             computes the dual of an affine plane conic
    127127  parameterSubstitute()   substitutes in the polynomial the parameter t by t^N
    128128  tropicalSubst()         makes certain substitutions in a tropical polynomial
     
    155155/// - eliminatecomponents
    156156/// - findzerosAndBasictransform
    157 /// - ordermaximalideals 
     157/// - ordermaximalideals
    158158/// - verticesTropicalCurve
    159159/// - bunchOfLines
     
    204204
    205205///////////////////////////////////////////////////////////////////////////////
    206 /// Procedures concerned with tropical parametrisation 
     206/// Procedures concerned with tropical parametrisation
    207207///////////////////////////////////////////////////////////////////////////////
    208208
    209209proc tropicalLifting (ideal i,intvec w,int ordnung,list #)
    210210"USAGE:  tropicalLifting(i,w,ord[,opt]); i ideal, w intvec, ord int, opt string
    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; 
     211ASSUME:  - 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;
    215215           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, 
     216@*       - the basering should not have any parameters on its own
     217           and it should have a global monomial ordering,
    218218           e.g. ring r=0,(t,x(1..n)),dp;
    219 @*       - the first variable of the basering will be treated as the 
     219@*       - the first variable of the basering will be treated as the
    220220           parameter t in the Puiseux series field
    221 @*       - the optional parameter opt should be one or more strings among 
     221@*       - the optional parameter opt should be one or more strings among
    222222           the following:
    223223@*         'isZeroDimensional'  : the dimension i is zero (not to be checked);
    224 @*         'isPrime'            : the ideal is prime over Q(t)[x_1,...,x_n] 
     224@*         'isPrime'            : the ideal is prime over Q(t)[x_1,...,x_n]
    225225                                  (not to be checked);
    226 @*         'isInTrop'           : (w_1/w_0,...,w_n/w_0) is in the tropical 
     226@*         'isInTrop'           : (w_1/w_0,...,w_n/w_0) is in the tropical
    227227                                  variety (not to be checked);
    228 @*         'oldGfan'            : uses gfan version 0.2.1 or less 
    229 @*         'findAll'            : find all solutions of a zero-dimensional 
     228@*         'oldGfan'            : uses gfan version 0.2.1 or less
     229@*         'findAll'            : find all solutions of a zero-dimensional
    230230                                  ideal over (w_1/w_0,...,w_n/w_0)
    231231@*         'noAbs'              : do NOT use absolute primary decomposition
     
    233233RETURN:  IF THE OPTION 'findAll' WAS NOT SET THEN:
    234234@*       list, containing one lifting of the given point (w_1/w_0,...,w_n/w_0)
    235                in the tropical variety of i to a point in V(i) over Puiseux 
     235               in the tropical variety of i to a point in V(i) over Puiseux
    236236               series field up to the first ord terms; more precisely:
    237237@*             IF THE OPTION 'noAbs' WAS NOT SET, THEN:
     
    248248@*       IF THE OPITON 'findAll' WAS SET, THEN:
    249249@*       list, containing ALL liftings of the given point ((w_1/w_0,...,w_n/w_0)
    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 
     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
    252252               zero-dimensional over Q{{t}};
    253                more precisely, each entry of the list is a list l as computed 
     253               more precisely, each entry of the list is a list l as computed
    254254               if  'findAll' was NOT set
    255255@*       WE NOW DESCRIBE THE LIST ENTRIES IF 'findAll' WAS NOT SET:
    256 @*       - the ring l[1] contains an ideal LIFT, which contains 
     256@*       - the ring l[1] contains an ideal LIFT, which contains
    257257           a point in V(i) lying over w up to the first ord terms;
    258 @*       - and if the integer l[2] is N then t has to be replaced by t^1/N 
     258@*       - and if the integer l[2] is N then t has to be replaced by t^1/N
    259259           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 
     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
    262262           by t^1/N
    263 @*       - unless the option 'noResubst' was set, the kth entry of list l[4] 
     263@*       - unless the option 'noResubst' was set, the kth entry of list l[4]
    264264           is a string which represents the kth generator of
    265            the ideal i where the coordinates have been replaced by the result 
     265           the ideal i where the coordinates have been replaced by the result
    266266           of the lift;
    267            the t-order of the kth entry should in principle be larger than the 
     267           the t-order of the kth entry should in principle be larger than the
    268268           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) 
     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)
    271271           are the parameters of the ring in l[1];
    272            the basefield of the ring in l[1] should be considered modulo this 
     272           the basefield of the ring in l[1] should be considered modulo this
    273273           ideal
    274 REMARK:  - it is best to use the procedure displayTropicalLifting to 
     274REMARK:  - it is best to use the procedure displayTropicalLifting to
    275275           display the result
    276276@*       - the option 'findAll' cannot be used if 'noAbs' is set
    277277@*       - 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 
     278           in Q{{t}}[x_1,...,x_n] then ALL points in V(i) lying over w are
    279279           computed up to order ord; if the ideal is not-zero dimenisonal, then
    280280           only the points in the ideal after cutting down to dimension zero
    281281           will be computed
    282282@*       - 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 
     283           computer; if you have GFAN version less than 0.3.0 then you must
    284284           use the optional parameter 'oldGfan'
    285285@*       - the procedure requires the @sc{Singular} procedure absPrimdecGTZ to be
    286286           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 
     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
    290290           computed throughout the recursion might need more than one
    291291           parameter to be described
    292292@*       - since Q is infinite, the procedure finishes with probability one
    293 @*       - you can call the procedure with Z/pZ as base field instead of Q, 
     293@*       - you can call the procedure with Z/pZ as base field instead of Q,
    294294           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; 
     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;
    298298             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 
     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
    302302             and you are unlucky
    303 @*         + the option 'noAbs' has to be used since absolute primary 
     303@*         + the option 'noAbs' has to be used since absolute primary
    304304             decomposition in @sc{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 if 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 
     305@*       - the basefield should either be Q or Z/pZ for some prime p;
     306           field extensions will be computed if 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
    309309           the ideal; the weights for the additional variables should be zero
    310310EXAMPLE: example tropicalLifting;   shows an example"
     
    357357      noabs=1;
    358358    }
    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 
     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
    362362    // computations
    363363    if (#[j]=="noGfan")
     
    370370    }
    371371  }
    372   // if the basering has characteristic not equal to zero, 
     372  // if the basering has characteristic not equal to zero,
    373373  // then absolute factorisation
    374374  // is not available, and thus we need the option noAbs
     
    384384  {
    385385    Error("The first coordinate of your input w must be NON-ZERO, since it is a DENOMINATOR!");
    386   } 
     386  }
    387387  // if w_0<0, then replace w by -w, so that the "denominator" w_0 is positive
    388388  if (w[1]<0)
     
    391391  }
    392392  intvec prew=w; // stores w for later reference
    393   // for our computations, w[1] represents the weight of t and this 
     393  // for our computations, w[1] represents the weight of t and this
    394394  // should be -w_0 !!!
    395395  w[1]=-w[1];
     
    401401    w[1]=-1;
    402402  }
    403   // 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,
    404404  // which moves it to something non-positive
    405405  for (j=2;j<=nvars(basering);j++)
     
    427427  {
    428428    variablen=variablen+var(j);
    429   }   
     429  }
    430430  map GRUNDPHI=BASERING,t,variablen;
    431431  ideal i=GRUNDPHI(i);
    432   // compute the initial ideal of i and test if w is in the tropical 
    433   // variety of i 
     432  // compute the initial ideal of i and test if w is in the tropical
     433  // variety of i
    434434  // - the last entry 1 only means that t is the last variable in the ring
    435435  ideal ini=tInitialIdeal(i,w,1);
    436436  if (isintrop==0) // test if w is in trop(i) only if isInTrop has not been set
    437   {   
     437  {
    438438    poly product=1;
    439439    for (j=1;j<=nvars(basering)-1;j++)
     
    453453    int dd=dim(i);
    454454    setring GRUNDRING;
    455     // if the dimension is not zero, we cut the ideal down to dimension zero 
     455    // if the dimension is not zero, we cut the ideal down to dimension zero
    456456    // and compute the
    457457    // t-initial ideal of the new ideal at the same time
    458458    if(dd!=0)
    459459    {
    460       // the procedurce cutdown computes a new ring, in which there lives a 
     460      // the procedurce cutdown computes a new ring, in which there lives a
    461461      // zero-dimensional
    462       // ideal which has been computed by cutting down the input with 
     462      // ideal which has been computed by cutting down the input with
    463463      // 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 
     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
    467467      // the number of variables by dd !!!
    468       // the new zero-dimensional ideal is called i, its t-initial 
     468      // the new zero-dimensional ideal is called i, its t-initial
    469469      // ideal (with respect to
    470       // the new w=CUTDOWN[2]) is ini, and finally there is a list 
    471       // repl in the ring 
     470      // the new w=CUTDOWN[2]) is ini, and finally there is a list
     471      // repl in the ring
    472472      // which contains at the polynomial p_j at position i_j and
    473473      //a zero otherwise;
     
    492492  list liftrings; // will contain the final result
    493493  // if the procedure is called without 'findAll' then it may happen, that no
    494   // proper solution is found when dd>0; in that case we have 
     494  // proper solution is found when dd>0; in that case we have
    495495  // to start all over again;
    496496  // this is controlled by the while-loop
     
    508508    // compute the liftrings by resubstitution
    509509    kk=1;  // counts the liftrings
    510     int isgood;  // test in the non-zerodimensional case 
     510    int isgood;  // test in the non-zerodimensional case
    511511                 // if the result has the correct valuation
    512512    for (jj=1;jj<=size(TP);jj++)
    513513    {
    514       // the list TP contains as a first entry the ring over which the 
    515       // tropical parametrisation 
     514      // the list TP contains as a first entry the ring over which the
     515      // tropical parametrisation
    516516      // of the (possibly cutdown ideal) i lives
    517517      def LIFTRING=TP[jj][1];
    518       // if the dimension of i originally was not zero, 
     518      // if the dimension of i originally was not zero,
    519519      // then we have to fill in the missing
    520520      // parts of the parametrisation
    521521      if (dd!=0)
    522522      {
    523         // we need a ring where the parameters X_1,...,X_k 
     523        // we need a ring where the parameters X_1,...,X_k
    524524        // from LIFTRING are present,
    525525        // and where also the variables of CUTDOWNRING live
    526526        execute("ring REPLACEMENTRING=("+charstr(LIFTRING)+"),("+varstr(CUTDOWNRING)+"),dp;");
    527         list repl=imap(CUTDOWNRING,repl); // get the replacement rules 
     527        list repl=imap(CUTDOWNRING,repl); // get the replacement rules
    528528                                          // from CUTDOWNRING
    529         ideal PARA=imap(LIFTRING,PARA);   // get the zero-dim. parametrisatio 
     529        ideal PARA=imap(LIFTRING,PARA);   // get the zero-dim. parametrisatio
    530530                                          // from LIFTRING
    531531        // compute the lift of the solution of the original ideal i
     
    533533        k=1;
    534534        // the lift has as many components as GRUNDRING has variables!=t
    535         for (j=1;j<=nvars(GRUNDRING)-1;j++) 
     535        for (j=1;j<=nvars(GRUNDRING)-1;j++)
    536536        {
    537537          // if repl[j]=0, then the corresponding variable was not eliminated
    538           if (repl[j]==0) 
     538          if (repl[j]==0)
    539539          {
    540             LIFT[j]=PARA[k]; // thus the lift has been 
     540            LIFT[j]=PARA[k]; // thus the lift has been
    541541                             // computed by tropicalparametrise
    542542            k++; // k checks how many entries of PARA have already been used
     
    544544          else  // if repl[j]!=0, repl[j] contains replacement rule for the lift
    545545          {
    546             LIFT[j]=repl[j]; // we still have to replace the vars 
     546            LIFT[j]=repl[j]; // we still have to replace the vars
    547547                             // in repl[j] by the corresp. entries of PARA
    548548            // replace all variables!=t (from CUTDOWNRING)
    549             for (l=1;l<=nvars(CUTDOWNRING)-1;l++) 
     549            for (l=1;l<=nvars(CUTDOWNRING)-1;l++)
    550550            {
    551551              // substitute the kth variable by PARA[k]
    552               LIFT[j]=subst(LIFT[j],var(l),PARA[l]); 
     552              LIFT[j]=subst(LIFT[j],var(l),PARA[l]);
    553553            }
    554554          }
    555555        }
    556556        setring LIFTRING;
    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 
     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
    560560        //       the replacement rules
    561         //       there occured some unexpected cancellation; 
     561        //       there occured some unexpected cancellation;
    562562        //       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; 
     563        //       solution of the zero-dimensional reduction NO
     564        //       canellation will occur,
     565        //       but for others this may very well happen;
    566566        //       this in particular means that
    567         //       we possibly MUST compute all zero-dimensional 
     567        //       we possibly MUST compute all zero-dimensional
    568568        //       solutions when cutting down!
    569569        intvec testw=precutdownw[1];
     
    589589      kill PARA;
    590590      // 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, 
     591      if (isgood==1)
     592      {
     593        // it remains to reverse the original substitutions,
    594594        // where appropriate !!!
    595         // if some entry of the original w was positive, 
     595        // if some entry of the original w was positive,
    596596        // we replace the corresponding
    597597        // variable x_i by t^-w[i]*x_i, so we must now replace
     
    610610        */
    611611        // if LIFTRING contains a parameter @a, change it to a
    612         if ((noabs==0) and (defined(@a)==-1)) 
     612        if ((noabs==0) and (defined(@a)==-1))
    613613        {
    614           // pass first to a ring where a and @a 
     614          // pass first to a ring where a and @a
    615615          // are variables in order to use maps
    616616          poly mp=minpoly;
     
    621621          // replace @a by a in minpoly and in LIFT
    622622          map phi=INTERRING,t,a,a;
    623           mp=phi(mp);     
     623          mp=phi(mp);
    624624          LIFT=phi(LIFT);
    625625          // pass now to a ring whithout @a and with a as parameter
     
    628628          ideal LIFT=imap(INTERRING,LIFT);
    629629          kill INTERRING;
    630         }   
     630        }
    631631        // then export LIFT
    632         export(LIFT); 
     632        export(LIFT);
    633633        // test the  result by resubstitution
    634         setring GRUNDRING; 
     634        setring GRUNDRING;
    635635        list resubst;
    636636        if (noresubst==0)
     
    641641          }
    642642          else
    643           {     
     643          {
    644644            resubst=tropicalliftingresubstitute(substitute(i,t,t^(TP[jj][2])),list(LIFTRING),N*TP[jj][2]);
    645645          }
    646646        }
    647647        setring BASERING;
    648         // 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
    649649        // third entry of TP by multiplying by N.
    650650        if (noabs==1)
     
    662662      kill LIFTRING;
    663663    }
    664     // if dd!=0 and the procedure was called without the 
     664    // if dd!=0 and the procedure was called without the
    665665    // option findAll, then it might very well
    666     // be the case that no solution is found, since 
     666    // be the case that no solution is found, since
    667667    // only one solution for the zero-dimensional
    668     // reduction was computed and this one might have 
     668    // reduction was computed and this one might have
    669669    // had cancellations when resubstituting;
    670670    // if so we have to restart the process with the option findAll
     
    674674      "The procedure will be restarted with the option 'findAll'.";
    675675      "Go on by hitting RETURN!";
    676       findall=1;   
     676      findall=1;
    677677      noabs=0;
    678678      setring CUTDOWNRING;
     
    680680      "i";i;
    681681      "ini";tInitialIdeal(i,w,1);
    682      
     682
    683683/*
    684684      setring GRUNDRING;
     
    698698    }
    699699  }
    700   // if internally the option findall was set, then return 
     700  // if internally the option findall was set, then return
    701701  // only the first solution
    702702  if (defined(hadproblems)!=0)
     
    707707  if (voice+printlevel>=2)
    708708  {
    709      
     709
    710710      "The procedure has created a list of lists. The jth entry of this list
    711711contains a ring, an integer and an intvec.
    712712In this ring lives an ideal representing the wanted lifting,
    713713if the integer is N then in the parametrisation t has to be replaced by t^1/N,
    714 and if the ith component of the intvec is w[i] then the ith component in LIFT 
     714and if the ith component of the intvec is w[i] then the ith component in LIFT
    715715should be multiplied by t^-w[i]/N in order to get the parametrisation.
    716    
     716
    717717Suppose your list has the name L, then you can access the 1st ring via:
    718718";
    719719    if (findall==1)
    720720    {
    721       "def LIFTRing=L[1][1]; setring LIFTRing; LIFT; 
     721      "def LIFTRing=L[1][1]; setring LIFTRing; LIFT;
    722722";
    723723    }
    724724    else
    725725    {
    726       "def LIFTRing=L[1]; setring LIFTRing; LIFT; 
     726      "def LIFTRing=L[1]; setring LIFTRing; LIFT;
    727727";
    728     } 
     728    }
    729729  }
    730730  if (findall==1) // if all solutions have been computed, return a list of lists
     
    751751   def LIFTRing=LIST[1];
    752752   setring LIFTRing;
    753    // 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
    754754   // over the Puiseux series field C{{t}} whose order is -w[1]/w[0]=1
    755755   LIFT;
     
    779779   // NOTE: since the last component of v is positive, the lifting
    780780   //       must start with a negative power of t, which in Singular
    781    //       is not allowed for a variable. 
     781   //       is not allowed for a variable.
    782782   def LIFTRing3=LIST[1];
    783783   setring LIFTRing3;
     
    834834      string Kstring="Z/"+string(char(LIFTRing))+"Z";
    835835    }
    836     // this means that tropicalLifting was called with 
     836    // this means that tropicalLifting was called with
    837837    // absolute primary decomposition
    838     if (size(troplift)==4) 
    839     {     
     838    if (size(troplift)==4)
     839    {
    840840      setring LIFTRing;
    841841      "The lifting of the point in the tropical variety lives in the ring";
    842842      if ((size(LIFTpar)==0) and (N==1))
    843843      {
    844         Kstring+"[[t]]"; 
     844        Kstring+"[[t]]";
    845845      }
    846846      if ((size(LIFTpar)==0) and (N!=1))
    847847      {
    848         Kstring+"[[t^(1/"+string(N)+")]]"; 
     848        Kstring+"[[t^(1/"+string(N)+")]]";
    849849      }
    850850      if ((size(LIFTpar)!=0) and (N!=1))
    851       {   
    852         Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]"; 
     851      {
     852        Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]";
    853853      }
    854854      if ((size(LIFTpar)!=0) and (N==1))
    855       {   
    856         Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]"; 
     855      {
     856        Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]";
    857857      }
    858858    }
     
    871871      }
    872872      if ((size(LIFTpar)!=0) and (N!=1))
    873       {   
    874         Kstring+"["+LIFTpar+"]/M[[t^(1/"+string(N)+")]]"; 
     873      {
     874        Kstring+"["+LIFTpar+"]/M[[t^(1/"+string(N)+")]]";
    875875        "where M is the maximal ideal";
    876876        "M=<"+m+">";
    877877      }
    878878      if ((size(LIFTpar)!=0) and (N==1))
    879       {   
    880         Kstring+"["+LIFTpar+"]/M[[t]]"; 
     879      {
     880        Kstring+"["+LIFTpar+"]/M[[t]]";
    881881        "where M is the maximal ideal";
    882882        "M=<"+m+">";
    883       }     
     883      }
    884884    }
    885885    "";
     
    908908      }
    909909    }
    910   }     
     910  }
    911911}
    912912example
     
    922922
    923923///////////////////////////////////////////////////////////////////////////////
    924 /// Procedures concerned with drawing a tropical curve or a Newton subdivision 
     924/// Procedures concerned with drawing a tropical curve or a Newton subdivision
    925925///////////////////////////////////////////////////////////////////////////////
    926926
    927927proc tropicalCurve (def tp,list #)
    928928"USAGE:      tropicalCurve(tp[,#]); tp list, # optional list
    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 
     929ASSUME:      tp is list of linear polynomials of the form ax+by+c
     930             with integers a, b and a rational number c representing
    931931             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, 
     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,
    935935             two variables and up to one parameter!
    936 RETURN:      list, each entry i=1,...,size(l)-1 corresponds to a vertex 
     936RETURN:      list, each entry i=1,...,size(l)-1 corresponds to a vertex
    937937                   in the tropical plane curve defined by tp
    938938                   l[i][1] = x-coordinate of the ith vertex
    939939                   l[i][2] = y-coordinate of the ith vertex
    940                    l[i][3] = intmat, if j is an entry in the first row 
     940                   l[i][3] = intmat, if j is an entry in the first row
    941941                             of intmat then the ith vertex of
    942                              the tropical curve is connected to the 
     942                             the tropical curve is connected to the
    943943                             jth vertex with multiplicity given
    944944                             by the corresponding entry in the second row
    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 
     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
    949949                             the list is the multiplicity of the unbounded edge
    950                    l[i][5] = a polynomial whose monomials mark the vertices 
     950                   l[i][5] = a polynomial whose monomials mark the vertices
    951951                             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, 
     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,
    955955                             then each monomial has to be shifted by
    956956                             the values in l[size(l)][3]
    957                    l[size(l)][1] = list, the entries describe the boundary 
     957                   l[size(l)][1] = list, the entries describe the boundary
    958958                                         points of the Newton subdivision
    959                    l[size(l)][2] = list, the entries are pairs of integer 
     959                   l[size(l)][2] = list, the entries are pairs of integer
    960960                                         vectors defining an interior
    961961                                         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 
     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
    965965                                           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] 
     966NOTE:        here the tropical polynomial is supposed to be the MINIMUM
     967             of the linear forms in tp, unless the optional input #[1]
    968968             is the string 'max'
    969969EXAMPLE:     example tropicalCurve;   shows an example"
     
    978978    ERROR("The basering should have a global monomial ordering, e.g. ring r=(0,t),(x,y),dp;");
    979979  }
    980   // if you insert a single polynomial instead of an ideal 
     980  // if you insert a single polynomial instead of an ideal
    981981  // representing a tropicalised polynomial,
    982   // then we compute first the tropicalisation of this polynomial 
     982  // then we compute first the tropicalisation of this polynomial
    983983  // -- this feature is not documented in the above help string
    984984  if (typeof(tp)=="poly")
    985985  {
    986     // exclude the case that the basering has not precisely 
     986    // exclude the case that the basering has not precisely
    987987    // one parameter and two indeterminates
    988988    if ((npars(basering)!=1) or (nvars(basering)!=2))
    989989    {
    990       ERROR("The basering should have precisely one parameter and two indeterminates!");     
     990      ERROR("The basering should have precisely one parameter and two indeterminates!");
    991991    }
    992992    poly f=tp;
     
    997997  if (nvars(basering) != 2)
    998998  {
    999     ERROR("The basering should have precisely two indeterminates!");     
    1000   }
    1001   // -1) Exclude the pathological case that the defining 
     999    ERROR("The basering should have precisely two indeterminates!");
     1000  }
     1001  // -1) Exclude the pathological case that the defining
    10021002  //     tropical polynomial has only one term,
    10031003  //     so that the tropical variety is not defined.
     
    10071007    intmat M[2][1]=0,0;
    10081008    return(list(list(0,0,M,list(),detropicalise(tp[1])),list(list(leadexp(detropicalise(tp[1]))),list())));
    1009   }   
    1010   // 0) If the input was a list of linear polynomials, 
     1009  }
     1010  // 0) If the input was a list of linear polynomials,
    10111011  //    then some coefficient of x or y can be negative,
    1012   //    i.e. the input corresponds to the tropical curve 
     1012  //    i.e. the input corresponds to the tropical curve
    10131013  //    of a Laurent polynomial. In that case we should
    1014   //    add some ax+by, so that all coefficients are positive. 
     1014  //    add some ax+by, so that all coefficients are positive.
    10151015  //    This does not change the tropical curve.
    1016   //    however, we have to save (a,b), since the Newton 
     1016  //    however, we have to save (a,b), since the Newton
    10171017  //    polygone has to be shifted by (-a,-b).
    10181018  poly aa,bb; // koeffizienten
     
    10261026    {
    10271027      bb=koeffizienten(tp[i],2);
    1028     }   
     1028    }
    10291029  }
    10301030  if ((aa!=0) or (bb!=0))
     
    10351035    }
    10361036  }
    1037   // 1) compute the vertices of the tropical curve 
     1037  // 1) compute the vertices of the tropical curve
    10381038  //    defined by tp and the Newton subdivision
    10391039  list vtp=verticesTropicalCurve(tp,#);
    1040   //    if vtp is empty, then the Newton polygone is just 
     1040  //    if vtp is empty, then the Newton polygone is just
    10411041  //    a line segment and constitutes a bunch of lines
    10421042  //    which can be computed by bunchOfLines
     
    10451045    return(bunchOfLines(tp));
    10461046  }
    1047   // 2) store all vertices belonging to the ith part of the 
     1047  // 2) store all vertices belonging to the ith part of the
    10481048  //    Newton subdivision in the list vtp[i] as 4th entry,
    10491049  //    and store those, which are not corners of the ith subdivision polygon
    10501050  //    in vtp[i][6]
    1051   poly nwt; 
     1051  poly nwt;
    10521052  list boundaryNSD;  // stores the boundary of a Newton subdivision
    1053   intmat zwsp[2][1]; // used for intermediate storage   
     1053  intmat zwsp[2][1]; // used for intermediate storage
    10541054  for (i=1;i<=size(vtp);i++)
    10551055  {
    10561056    k=1;
    1057     nwt=vtp[i][3]; // the polynomial representing the 
     1057    nwt=vtp[i][3]; // the polynomial representing the
    10581058    // ith part of the Newton subdivision
    1059     // store the vertices of the ith part of the 
     1059    // store the vertices of the ith part of the
    10601060    // Newton subdivision in the list newton
    1061     list newton; 
     1061    list newton;
    10621062    while (nwt!=0)
    10631063    {
     
    10661066      k++;
    10671067    }
    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 
     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
    10721072                                             // clockwise)
    10731073    vtp[i][4]=boundaryNSD[1];
    10741074    vtp[i][5]=boundaryNSD[2];
    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 
     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
    10781078                    //with which multiplicity
    10791079    kill newton; // we kill the superflous list
    10801080  }
    1081   // 3) Next we build for each part of the Newton 
     1081  // 3) Next we build for each part of the Newton
    10821082  //    subdivision the list of all pairs of vertices on the
    10831083  //    boundary, which are involved, including those which are not corners
     
    10961096    kill ipairs;
    10971097  }
    1098   // 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
    10991099  //    occur in two different parts of the Newton subdivision
    1100   int deleted; // if a pair occurs in two NSD, it can be removed 
     1100  int deleted; // if a pair occurs in two NSD, it can be removed
    11011101               // from both - deleted is then set to 1
    1102   list inneredges; // contains the list of all pairs contained in two NSD 
     1102  list inneredges; // contains the list of all pairs contained in two NSD
    11031103                   // - these are inner the edges of NSD
    11041104  int ggt;
    11051105  d=1;  // counts the inner edges
    11061106  for (i=1;i<=size(pairs)-1;i++)
    1107   { 
     1107  {
    11081108    for (j=i+1;j<=size(pairs);j++)
    11091109    {
     
    11121112        deleted=0;
    11131113        for (l=size(pairs[j]);l>=1 and deleted==0;l--)
    1114         { 
     1114        {
    11151115          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])))
    11161116          {
     
    11181118            d++;
    11191119            ggt=abs(gcd(pairs[i][k][1][1]-pairs[i][k][2][1],pairs[i][k][1][2]-pairs[i][k][2][2]));
    1120             zwsp=j,ggt;   // and it is recorded that the ith and jth 
     1120            zwsp=j,ggt;   // and it is recorded that the ith and jth
    11211121                          // vertex should be connected with mult ggt
    11221122            vtp[i][6]=intmatconcat(vtp[i][6],zwsp);
    11231123            zwsp=i,ggt;
    11241124            vtp[j][6]=intmatconcat(vtp[j][6],zwsp);
    1125             pairs[i]=delete(pairs[i],k);  // finally the pair is deleted 
     1125            pairs[i]=delete(pairs[i],k);  // finally the pair is deleted
    11261126                                          // from both sets of pairs
    11271127            pairs[j]=delete(pairs[j],l);
     
    11631163    }
    11641164  }
    1165   // 6.3) Order the vertices such that passing from one to the next we 
     1165  // 6.3) Order the vertices such that passing from one to the next we
    11661166  //      travel along the boundary of the Newton polytope clock wise.
    11671167  boundaryNSD=findOrientedBoundary(vertices);
    11681168  list orderedvertices=boundaryNSD[1];
    11691169  // 7) Find the unbounded edges emerging from a vertex in the tropical curve.
    1170   //    For this we check the remaining pairs for the ith NSD. 
     1170  //    For this we check the remaining pairs for the ith NSD.
    11711171  //    Each pair is ordered according
    1172   //    to the order in which the vertices occur in orderedvertices. 
     1172  //    to the order in which the vertices occur in orderedvertices.
    11731173  //    The direction of the
    1174   //    unbounded edge is then the outward pointing primitive normal 
     1174  //    unbounded edge is then the outward pointing primitive normal
    11751175  //    vector to the vector
    11761176  //    pointing from the first vertex in a pair to the second one.
     
    11821182  for (i=1;i<=size(pairs);i++)
    11831183  {
    1184     list ubedges; // stores the unbounded edges 
     1184    list ubedges; // stores the unbounded edges
    11851185    k=1; // counts the unbounded edges
    11861186    for (j=1;j<=size(pairs[i]);j++)
    11871187    {
    11881188      // computes the position of the vertices in the
    1189       pos1=positionInList(orderedvertices,pairs[i][j][1]); 
     1189      pos1=positionInList(orderedvertices,pairs[i][j][1]);
    11901190      // pair in the list orderedvertices
    1191       pos2=positionInList(orderedvertices,pairs[i][j][2]); 
     1191      pos2=positionInList(orderedvertices,pairs[i][j][2]);
    11921192      if (((pos1>pos2) and !((pos1==size(orderedvertices)) and (pos2==1))) or ((pos2==size(orderedvertices)) and (pos1==1)))  // reorders them if necessary
    11931193      {
     
    11971197      }
    11981198      // the vector pointing from vertex 1 in the pair to vertex2
    1199       normalvector=pairs[i][j][2]-pairs[i][j][1]; 
     1199      normalvector=pairs[i][j][2]-pairs[i][j][1];
    12001200      ggt=gcd(normalvector[1],normalvector[2]);   // the gcd of the entries
    12011201      zw=normalvector[2];    // create the outward pointing normal vector
     
    12291229    kill ubedges;
    12301230  }
    1231   // 8) Store the computed information for the ith part 
     1231  // 8) Store the computed information for the ith part
    12321232  //    of the NSD in the list graph[i].
    12331233  list graph,gr;
     
    12351235  {
    12361236    // the first coordinate of the ith vertex of the tropical curve
    1237     gr[1]=vtp[i][1]; 
     1237    gr[1]=vtp[i][1];
    12381238    // the second coordinate of the ith vertex of the tropical curve
    1239     gr[2]=vtp[i][2]; 
     1239    gr[2]=vtp[i][2];
    12401240    // 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 
     1241    gr[3]=vtp[i][6];
     1242    // the directions unbounded edges emerging from the ith
    12431243    // 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]; 
     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];
    12471247    graph[i]=gr;
    12481248  }
     
    12631263    }
    12641264  }
    1265   // 10) Finally store the boundary vertices and 
     1265  // 10) Finally store the boundary vertices and
    12661266  //     the inner edges as last entry in the list graph.
    12671267  //     This represents the NSD.
     
    12801280// the coordinates of the first vertex are graph[1][1],graph[1][2];
    12811281   graph[1][1],graph[1][2];
    1282 // the first vertex is connected to the vertices 
     1282// the first vertex is connected to the vertices
    12831283//     graph[1][3][1,1..ncols(graph[1][3])]
    12841284   intmat M=graph[1][3];
    12851285   M[1,1..ncols(graph[1][3])];
    1286 // the weights of the edges to these vertices are 
     1286// the weights of the edges to these vertices are
    12871287//     graph[1][3][2,1..ncols(graph[1][3])]
    12881288   M[2,1..ncols(graph[1][3])];
    12891289// from the first vertex emerge size(graph[1][4]) unbounded edges
    12901290   size(graph[1][4]);
    1291 // the primitive integral direction vector of the first unbounded edge 
     1291// the primitive integral direction vector of the first unbounded edge
    12921292//     of the first vertex
    12931293   graph[1][4][1][1];
    12941294// the weight of the first unbounded edge of the first vertex
    12951295   graph[1][4][1][2];
    1296 // 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
    12971297   graph[1][5];
    1298 // connecting the points in graph[size(graph)][1] we get 
     1298// connecting the points in graph[size(graph)][1] we get
    12991299//     the boundary of the Newton polytope
    13001300   graph[size(graph)][1];
    1301 // 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
    13021302//     in the Newton polytope bounding an inner edge
    13031303   graph[size(graph)][2][1];
     
    13081308proc drawTropicalCurve (def f,list #)
    13091309"USAGE:      drawTropicalCurve(f[,#]); f poly or list, # optional list
    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 
     1310ASSUME:      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
    13121312             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 
     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
    13161316             variables and up to one parameter!
    13171317RETURN:      NONE
    1318 NOTE:        - the procedure creates the files /tmp/tropicalcurveNUMBER.tex and 
    1319                /tmp/tropicalcurveNUMBER.ps, where NUMBER is a random four 
    1320                digit integer; 
     1318NOTE:        - the procedure creates the files /tmp/tropicalcurveNUMBER.tex and
     1319               /tmp/tropicalcurveNUMBER.ps, where NUMBER is a random four
     1320               digit integer;
    13211321               moreover it displays the tropical curve via kghostview;
    1322                if you wish to remove all these files from /tmp, 
     1322               if you wish to remove all these files from /tmp,
    13231323               call the procedure cleanTmp
    13241324@*           - edges with multiplicity greater than one carry this multiplicity
    13251325@*           - 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 
     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
    13291329               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, 
     1330@*           - note that lattice points in the Newton subdivision which are
     1331               black correspond to markings of the marked subdivision,
    13321332               while lattice points in grey are not marked
    13331333EXAMPLE:     example drawTropicalCurve  shows an example"
     
    13471347  if (typeof(f)=="poly")
    13481348  {
    1349     // exclude the case that the basering has not precisely 
     1349    // exclude the case that the basering has not precisely
    13501350    // one parameter and two indeterminates
    13511351    if ((npars(basering)!=1) or (nvars(basering)!=2))
    13521352    {
    1353       ERROR("The basering should have precisely one parameter and two indeterminates!");     
     1353      ERROR("The basering should have precisely one parameter and two indeterminates!");
    13541354    }
    13551355    texf=texPolynomial(f); // write the polynomial over Q(t)
     
    13621362      texf="\\mbox{\\tt The defining equation was not handed over!}";
    13631363      list graph=f;
    1364     }   
     1364    }
    13651365    else
    13661366    { // write the tropical polynomial defined by f
    13671367      if (size(#)==0)
    1368       {     
     1368      {
    13691369        texf="\\min\\{";
    13701370      }
     
    13751375      for (j=1;j<=size(f);j++)
    13761376      {
    1377         texf=texf+texPolynomial(f[j]);   
     1377        texf=texf+texPolynomial(f[j]);
    13781378        if (j<size(f))
    13791379        {
     
    13841384          texf=texf+"\\}";
    13851385        }
    1386       }   
     1386      }
    13871387      list graph=tropicalCurve(f,#); // the graph of the tropical polynomial f
    13881388    }
     
    14021402\\addtolength{\\topmargin}{-\\headheight}
    14031403\\addtolength{\\topmargin}{-\\topskip}
    1404 \\setlength{\\textheight}{267mm} 
     1404\\setlength{\\textheight}{267mm}
    14051405\\addtolength{\\textheight}{\\topskip}
    14061406\\addtolength{\\textheight}{-\\footskip}
    14071407\\addtolength{\\textheight}{-30pt}
    1408 \\setlength{\\oddsidemargin}{-1in} 
     1408\\setlength{\\oddsidemargin}{-1in}
    14091409\\addtolength{\\oddsidemargin}{20mm}
    14101410\\setlength{\\evensidemargin}{\\oddsidemargin}
    1411 \\setlength{\\textwidth}{170mm} 
     1411\\setlength{\\textwidth}{170mm}
    14121412
    14131413\\begin{document}
    14141414   \\parindent0cm
    14151415   \\begin{center}
    1416       \\large\\bf The Tropicalisation of 
     1416      \\large\\bf The Tropicalisation of
    14171417
    14181418      \\bigskip
     
    14381438
    14391439   \\begin{center}
    1440        "+texDrawNewtonSubdivision(graph,#)+" 
     1440       "+texDrawNewtonSubdivision(graph,#)+"
    14411441   \\end{center}
    14421442\\end{document}";
     
    14451445    int rdnum=random(1000,9999);
    14461446    write(":w /tmp/tropicalcurve"+string(rdnum)+".tex",TEXBILD);
    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 &"); 
     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 &");
    14481448  }
    14491449  else
     
    14721472proc drawNewtonSubdivision (def f,list #)
    14731473"USAGE:   drawTropicalCurve(f[,#]); f poly, # optional list
    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 
     1474ASSUME:   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
    14761476          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 
     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
    14801480          and up to one parameter!
    14811481RETURN:   NONE
    1482 NOTE:     - the procedure creates the files /tmp/newtonsubdivisionNUMBER.tex, 
    1483             and /tmp/newtonsubdivisionNUMBER.ps, where NUMBER is a random 
    1484             four digit integer; 
     1482NOTE:     - the procedure creates the files /tmp/newtonsubdivisionNUMBER.tex,
     1483            and /tmp/newtonsubdivisionNUMBER.ps, where NUMBER is a random
     1484            four digit integer;
    14851485            moreover it desplays the tropical curve defined by f via kghostview;
    1486             if you wish to remove all these files from /tmp, call the procedure 
     1486            if you wish to remove all these files from /tmp, call the procedure
    14871487            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 
     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
    14921492            points in grey are not marked
    14931493EXAMPLE:     example drawNewtonSubdivision;   shows an example"
     
    15031503  { // write the tropical polynomial defined by f
    15041504    if (size(#)==0)
    1505     {     
     1505    {
    15061506      texf="\\min\\{";
    15071507    }
     
    15121512    for (j=1;j<=size(f);j++)
    15131513    {
    1514       texf=texf+texPolynomial(f[j]);   
     1514      texf=texf+texPolynomial(f[j]);
    15151515      if (j<size(f))
    15161516      {
     
    15211521        texf=texf+"\\}";
    15221522      }
    1523     }   
     1523    }
    15241524    list graph=tropicalCurve(f,#); // the graph of the tropical polynomial f
    15251525  }
     
    15291529   \\parindent0cm
    15301530   \\begin{center}
    1531       \\large\\bf The Newtonsubdivison of 
     1531      \\large\\bf The Newtonsubdivison of
    15321532      \\begin{displaymath}
    15331533          f="+texf+"
     
    15371537
    15381538   \\begin{center}
    1539 "+texDrawNewtonSubdivision(graph)+ 
     1539"+texDrawNewtonSubdivision(graph)+
    15401540"   \\end{center}
    15411541
     
    15431543  int rdnum=random(1000,9999);
    15441544  write(":w /tmp/newtonsubdivision"+string(rdnum)+".tex",TEXBILD);
    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 &"); 
     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 &");
    15461546//  return(TEXBILD);
    15471547}
     
    15681568proc tropicalJInvariant (def f,list #)
    15691569"USAGE:      tropicalJInvariant(f[,#]); f poly or list, # optional list
    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 
     1570ASSUME:      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
    15721572             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 
     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
    15761576             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, 
     1577RETURN:      number, if the graph underlying the tropical curve has precisely
     1578                     one loop then its weighted lattice length is returned,
    15791579                     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 
     1580NOTE:        - if the tropical curve is elliptic and its embedded graph has
     1581               precisely one loop, then the weigthed lattice length of
    15821582               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 
     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
    15901590               the j-invariant
    15911591@*           - 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 
     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
    15961596               of a cubic tropical plane curve.
    15971597EXAMPLE:     example tropicalJInvariant;   shows an example"
     
    16071607    {
    16081608      if (typeof(f[1])=="list")
    1609       {       
     1609      {
    16101610        list graph=f;
    16111611      }
     
    16191619        {
    16201620          ERROR("This is no valid input.");
    1621         }       
     1621        }
    16221622      }
    16231623    }
     
    16361636  genus=-genus/2; // we have counted each bounded edge twice
    16371637  genus=genus+size(graph); // the genus is 1-#bounded_edges+#vertices
    1638   // 3) if the embedded graph has not genus one, 
     1638  // 3) if the embedded graph has not genus one,
    16391639  //    we cannot compute the j-invariant
    16401640  if(genus!=1)
     
    16481648  else
    16491649  {
    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, 
     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,
    16531653    //    otherwise the number of the vertex in the list graph
    1654     int nonloopvertex=findNonLoopVertex(graph);   
     1654    int nonloopvertex=findNonLoopVertex(graph);
    16551655    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 
     1656    intmat delvert; // takes for a moment graph[i][3] of the vertex
    16571657                    // to which nonloopvertex is connected
    1658     // 5) delete successively vertices in the graph which 
     1658    // 5) delete successively vertices in the graph which
    16591659    //    have only one bounded edge
    16601660    while (nonloopvertex>0)
    16611661    {
    1662       // find the only vertex to which the nonloopvertex 
     1662      // find the only vertex to which the nonloopvertex
    16631663      // is connected, when it is found
    16641664      // delete the connection in graph[i][3] and set dv=1
     
    16731673            {
    16741674              delvert=graph[i][3];
    1675               delvert=intmatcoldelete(delvert,j); // delete the connection (note 
     1675              delvert=intmatcoldelete(delvert,j); // delete the connection (note
    16761676                                                  // there must have been two!)
    16771677              dv=1;
     
    16811681        }
    16821682      }
    1683       graph[nonloopvertex][3]=nullmat; // the only connection of nonloopvertex 
     1683      graph[nonloopvertex][3]=nullmat; // the only connection of nonloopvertex
    16841684                                       // is killed
    1685       nonloopvertex=findNonLoopVertex(graph); // find the next vertex 
     1685      nonloopvertex=findNonLoopVertex(graph); // find the next vertex
    16861686                                              // which has only one edge
    16871687    }
     
    16891689    intvec loop,weights; // encodes the loop and the edges
    16901690    i=1;
    1691     //    start by finding some vertex which belongs to the loop 
    1692     while (loop==0) 
     1691    //    start by finding some vertex which belongs to the loop
     1692    while (loop==0)
    16931693    {
    16941694      // if graph[i][3] of a vertex in the loop has 2 columns, all others have 1
    1695       if (ncols(graph[i][3])==1) 
     1695      if (ncols(graph[i][3])==1)
    16961696      {
    16971697        i++;
     
    16991699      else
    17001700      {
    1701         loop[1]=i; // a starting vertex is found 
    1702         loop[2]=graph[i][3][1,1]; // it is connected to vertex with this number 
     1701        loop[1]=i; // a starting vertex is found
     1702        loop[2]=graph[i][3][1,1]; // it is connected to vertex with this number
    17031703        weights[2]=graph[i][3][2,1]; // and the edge has this weight
    17041704      }
     
    17081708    while (j!=i)  // the loop ends with the same vertex with which it starts
    17091709    {
    1710       // the first row of graph[j][3] has two entries 
     1710      // the first row of graph[j][3] has two entries
    17111711      // corresponding to the two vertices
    1712       // to which the active vertex j is connected; 
     1712      // to which the active vertex j is connected;
    17131713      // one is loop[k-1], i.e. the one which
    17141714      // precedes j in the loop; we have to choose the other one
    1715       if (graph[j][3][1,1]==loop[k-1]) 
     1715      if (graph[j][3][1,1]==loop[k-1])
    17161716      {
    17171717        loop[k+1]=graph[j][3][1,2];
     
    17241724      }
    17251725      j=loop[k+1]; // set loop[k+1] the new active vertex
    1726       k++; 
    1727     }   
     1726      k++;
     1727    }
    17281728    // 7) compute for each edge in the loop the lattice length
    1729     poly xcomp,ycomp; // the x- and y-components of the vectors 
     1729    poly xcomp,ycomp; // the x- and y-components of the vectors
    17301730                      // connecting two vertices of the loop
    1731     number nenner;    // the product of the denominators of 
     1731    number nenner;    // the product of the denominators of
    17321732                      // the x- and y-components
    17331733    number jinvariant;  // the j-invariant
    1734     int eins,zwei,ggt; 
     1734    int eins,zwei,ggt;
    17351735    for (i=1;i<=size(loop)-1;i++) // compute the lattice length for each edge
    17361736    {
    1737       xcomp=graph[loop[i]][1]-graph[loop[i+1]][1]; 
    1738       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];
    17391739      nenner=denominator(leadcoef(xcomp))*denominator(leadcoef(ycomp));
    1740       execute("eins="+string(numerator(leadcoef(nenner*xcomp)))+";"); 
    1741       execute("zwei="+string(numerator(leadcoef(nenner*ycomp)))+";"); 
     1740      execute("eins="+string(numerator(leadcoef(nenner*xcomp)))+";");
     1741      execute("zwei="+string(numerator(leadcoef(nenner*ycomp)))+";");
    17421742      ggt=gcd(eins,zwei); // the lattice length is the "gcd"
    17431743                          // of the x-component and the y-component
    1744       jinvariant=jinvariant+ggt/(nenner*weights[i+1]); // divided by the 
     1744      jinvariant=jinvariant+ggt/(nenner*weights[i+1]); // divided by the
    17451745                                                       // weight of the edge
    17461746    }
    1747     return(jinvariant);   
     1747    return(jinvariant);
    17481748  }
    17491749}
     
    17591759// the curve can have arbitrary degree
    17601760   tropicalJInvariant(t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2);
    1761 // 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
    17621762//     curve has a loop that can be resolved
    17631763   tropicalJInvariant(1+x+y+xy+tx2y+txy2);
    17641764// but it does realise, if the curve has no loop at all ...
    17651765   tropicalJInvariant(x+y+1);
    1766 // 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
    17671767//     cannot be resolved
    17681768   tropicalJInvariant(1+x+y+xy+tx2y+txy2+t3x5+t3y5+tx2y2+t2xy4+t2yx4);
     
    17731773proc weierstrassForm (poly f,list #)
    17741774"USAGE:      weierstrassForm(wf[,#]); wf poly, # list
    1775 ASSUME:      wf is a a polynomial whose Newton polygon has precisely one 
    1776              interior lattice point, so that it defines an elliptic curve 
     1775ASSUME:      wf is a a polynomial whose Newton polygon has precisely one
     1776             interior lattice point, so that it defines an elliptic curve
    17771777             on the toric surface corresponding to the Newton polygon
    17781778RETURN:      poly, the Weierstrass normal form of the polynomial
     
    17801780               to Fernando Rodriguez Villegas, villegas@math.utexas.edu
    17811781@*           - the characteristic of the base field should not be 2 or 3
    1782 @*           - if an additional argument # is given, a simplified Weierstrass 
     1782@*           - if an additional argument # is given, a simplified Weierstrass
    17831783               form is computed
    17841784EXAMPLE:     example weierstrassForm;   shows an example"
     
    18411841
    18421842proc jInvariant (poly f,list #)
    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 
     1843"USAGE:      jInvariant(f[,#]); f poly, # list
     1844ASSUME:      - f is a a polynomial whose Newton polygon has precisely one
     1845               interior lattice point, so that it defines an elliptic curve
    18461846               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 
     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
    18491849               strings:
    1850 @*             'ord'   : then the return value is of type integer, 
     1850@*             'ord'   : then the return value is of type integer,
    18511851                         namely the order of the j-invariant
    1852 @*             'split' : then the return value is a list of two polynomials, 
     1852@*             'split' : then the return value is a list of two polynomials,
    18531853                         such that the quotient of these two is the j-invariant
    18541854RETURN:      poly, the j-invariant of the elliptic curve defined by poly
    1855 NOTE:        the characteristic of the base field should not be 2 or 3, 
     1855NOTE:        the characteristic of the base field should not be 2 or 3,
    18561856             unless the input is a plane cubic
    18571857EXAMPLE:     example jInvariant;   shows an example"
     
    18791879   echo=2;
    18801880   ring r=(0,t),(x,y),dp;
    1881 // jInvariant computes the j-invariant of a cubic 
     1881// jInvariant computes the j-invariant of a cubic
    18821882   jInvariant(x+y+x2y+y3+1/t*xy);
    1883 // 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
    18841884//    compute the order of the j-invariant
    18851885   jInvariant(x+y+x2y+y3+1/t*xy,"ord");
     
    18891889   poly h=x22y11+x19y10+x17y9+x16y9+x12y7+x9y6+x7y5+x2y3+x14y8;
    18901890// its j-invariant is
    1891    jInvariant(h); 
     1891   jInvariant(h);
    18921892}
    18931893
     
    19081908@*                 l[6] = a list containing the vertices of the tropical conic f
    19091909@*                 l[7] = a list containing lists with vertices of the tangents
    1910 @*                 l[8] = a string which contains the latex-code to draw the 
     1910@*                 l[8] = a string which contains the latex-code to draw the
    19111911                          tropical conic and its tropicalised tangents
    19121912@*                 l[9] = if # is non-empty, this is the same data for the dual
     
    19321932  ring LINRING=(0,t),(x,y,a(1..6)),lp;
    19331933  list points=imap(BASERING,points);
    1934   ideal I; // the ideal will contain the linear equations given by the conic 
     1934  ideal I; // the ideal will contain the linear equations given by the conic
    19351935           // and the points
    19361936  for (i=1;i<=5;i++)
     
    19531953  ring tRING=0,t,ls;
    19541954  list pointdenom=imap(BASERING,pointdenom);
    1955   list pointnum=imap(BASERING,pointnum); 
     1955  list pointnum=imap(BASERING,pointnum);
    19561956  intvec pointcoordinates;
    19571957  for (i=1;i<=size(pointdenom);i++)
     
    20292029   We consider the concic through the following five points:
    20302030   \\begin{displaymath}
    2031 "; 
     2031";
    20322032  string texf=texDrawTropical(graphf,list("",scalefactor));
    20332033  for (i=1;i<=size(points);i++)
     
    20672067\\end{document}";
    20682068  setring BASERING;
    2069   // If # non-empty, compute the dual conic and the tangents 
    2070   // through the dual points 
     2069  // If # non-empty, compute the dual conic and the tangents
     2070  // through the dual points
    20712071  // corresponding to the tangents of the given conic.
    20722072  if (size(#)>0)
    20732073  {
    20742074    list dualpoints;
    2075     for (i=1;i<=size(points);i++) 
     2075    for (i=1;i<=size(points);i++)
    20762076    {
    20772077      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));
     
    20972097// conic[2] is the equation of the conic f passing through the five points
    20982098   conic[2];
    2099 // conic[3] is a list containing the equations of the tangents 
     2099// conic[3] is a list containing the equations of the tangents
    21002100//          through the five points
    21012101   conic[3];
    21022102// conic[4] is an ideal representing the tropicalisation of the conic f
    21032103   conic[4];
    2104 // conic[5] is a list containing the tropicalisation 
     2104// conic[5] is a list containing the tropicalisation
    21052105//          of the five tangents in conic[3]
    21062106   conic[5];
    2107 // 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
    21082108   conic[6];
    21092109// conic[7] is a list containing the vertices of the five tangents
    21102110   conic[7];
    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; 
     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;
    21162116            kghostview conic.ps &");
    2117 // 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
    21182118//         and saved in conic[9]
    21192119   conic=conicWithTangents(points,1);
    21202120   conic[9][2]; // the equation of the dual conic
    21212121}
    2122  
     2122
    21232123///////////////////////////////////////////////////////////////////////////////
    21242124/// Procedures concerned with tropicalisation
     
    21292129ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n]
    21302130RETURN:      list, the linear forms of the tropicalisation of f
    2131 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 
     2131NOTE:        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
    21342134             computed linear forms, the former that we consider their minimum
    21352135EXAMPLE:     example tropicalise;   shows an example"
     
    21542154    {
    21552155      tropicalf[i]=tropicalf[i]+exp[j]*var(j);
    2156     }   
     2156    }
    21572157    f=f-lead(f);
    21582158  }
     
    21942194/////////////////////////////////////////////////////////////////////////
    21952195
    2196 proc tInitialForm (poly f, intvec w) 
     2196proc tInitialForm (poly f, intvec w)
    21972197"USAGE:      tInitialForm(f,w); f a polynomial, w an integer vector
    21982198ASSUME:      f is a polynomial in Q[t,x_1,...,x_n] and w=(w_0,w_1,...,w_n)
    21992199RETURN:      poly, the t-initialform of f(t,x) w.r.t. w evaluated at t=1
    2200 NOTE:        the t-initialform is the sum of the terms with MAXIMAL 
     2200NOTE:        the t-initialform is the sum of the terms with MAXIMAL
    22012201             weighted order w.r.t. w
    22022202EXAMPLE:     example tInitialForm;   shows an example"
     
    22082208  // do the same for the remaining part of f and compare the results
    22092209  // keep only the smallest ones
    2210   int vglgewicht; 
    2211   f=f-lead(f); 
     2210  int vglgewicht;
     2211  f=f-lead(f);
    22122212  while (f!=0)
    22132213  {
     
    22242224        initialf=initialf+lead(f);
    22252225      }
    2226     }   
     2226    }
    22272227    f=f-lead(f);
    22282228  }
     
    22442244proc tInitialIdeal (ideal i,intvec w,list #)
    22452245"USAGE:      tInitialIdeal(i,w); i ideal, w intvec
    2246 ASSUME:      i is an ideal in Q[t,x_1,...,x_n] and w=(w_0,...,w_n) 
     2246ASSUME:      i is an ideal in Q[t,x_1,...,x_n] and w=(w_0,...,w_n)
    22472247RETURN:      ideal ini, the t-initial ideal of i with respect to w"
    22482248{
    22492249  // THE PROCEDURE WILL BE CALLED FROM OTHER PROCEDURES INSIDE THIS LIBRARY;
    2250   // IN THIS CASE THE VARIABLE t WILL INDEED BE THE LAST VARIABLE INSTEAD OF 
     2250  // IN THIS CASE THE VARIABLE t WILL INDEED BE THE LAST VARIABLE INSTEAD OF
    22512251  // THE FIRST,
    22522252  // AND WE THEREFORE HAVE TO MOVE IT BACK TO THE FRONT!
     
    22722272  // ... and compute a standard basis with
    22732273  // respect to the homogenised ordering defined by w. Since the generators
    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 
     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
    22782278                              // strictly positive for all j
    22792279  intvec whomog=M;
     
    22832283  }
    22842284  execute("ring WEIGHTRING=("+charstr(basering)+"),("+varstr(basering)+"),(wp("+string(whomog)+"));");
    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 
     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
    22872287  // initial forms of the generators generate the initial ideal
    22882288  ideal i=subst(groebner(imap(HOMOGRING,i)),@s,1);
     
    25382538proc texDrawBasic (list texdraw)
    25392539"USAGE:      texDrawBasic(texdraw); list texdraw
    2540 ASSUME:      texdraw is a list of strings representing texdraw commands 
    2541              (as produced by texDrawTropical) which should be embedded into 
     2540ASSUME:      texdraw is a list of strings representing texdraw commands
     2541             (as produced by texDrawTropical) which should be embedded into
    25422542             a texdraw environment
    25432543RETURN:      string, a texdraw environment enclosing the input
     
    25592559    \\end{texdraw}";
    25602560  return(texdrawtp);
    2561 } 
     2561}
    25622562example
    25632563{
     
    25762576ASSUME:  graph is the output of tropicalCurve
    25772577RETURN:  string, the texdraw code of the tropical plane curve encoded by graph
    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 
     2578NOTE:    - 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
    25822582           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 
     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
    25882588           by a second optional entry of type poly
    25892589@*       - the list # is optional and may as well be empty
     
    25912591{
    25922592  int i,j;
    2593   // deal first with the pathological case that 
     2593  // deal first with the pathological case that
    25942594  // the input polynomial was a monomial
    2595   // and does therefore not define a tropical curve, 
    2596   // and check if the Newton polytope is 
     2595  // and does therefore not define a tropical curve,
     2596  // and check if the Newton polytope is
    25972597  // a line segment so that the curve defines a bunch of lines
    25982598  int bunchoflines;
    25992599  // if the boundary of the Newton polytope consists of a single point
    2600   if (size(graph[size(graph)][1])==1) 
     2600  if (size(graph[size(graph)][1])==1)
    26012601  {
    26022602    return(string());
     
    26112611    }
    26122612    // then the Newton polytope is a line segment
    2613     if ((size(graph[size(graph)][1])-size(syz(M)))==1) 
     2613    if ((size(graph[size(graph)][1])-size(syz(M)))==1)
    26142614    {
    26152615      bunchoflines=1;
     
    26182618  // go on with the case that a tropical curve is defined
    26192619  if (size(#)==0)
    2620   {   
     2620  {
    26212621     string texdrawtp="
    26222622
     
    26262626  {
    26272627    if ((#[1]!="max") and (#[1]!=""))
    2628     {     
     2628    {
    26292629      string texdrawtp=#[1];
    26302630    }
     
    26742674        nachkomma++;
    26752675      }
    2676     }   
    2677     // if the scalefactor is < 1/100, then we should rather scale the 
     2676    }
     2677    // if the scalefactor is < 1/100, then we should rather scale the
    26782678    // coordinates directly, since otherwise texdraw gets into trouble
    26792679    if (nachkomma > 2)
     
    26842684        sf=sf*10;
    26852685      }
    2686     }   
     2686    }
    26872687    texdrawtp=texdrawtp+"
    26882688       \\relunitscale "+ decimal(scalefactor,nachkomma);
     
    26972697  {
    26982698    // if the curve is a bunch of lines no vertex has to be drawn
    2699     if (bunchoflines==0) 
     2699    if (bunchoflines==0)
    27002700    {
    27012701      texdrawtp=texdrawtp+"
     
    27032703    }
    27042704    // draw the bounded edges emerging from the ith vertex
    2705     for (j=1;j<=ncols(graph[i][3]);j++) 
    2706     {
    2707       // don't draw it twice - and if there is only one vertex 
     2705    for (j=1;j<=ncols(graph[i][3]);j++)
     2706    {
     2707      // don't draw it twice - and if there is only one vertex
    27082708      //                       and graph[i][3][1,1] is thus 0, nothing is done
    2709       if (i<graph[i][3][1,j]) 
    2710       {                       
     2709      if (i<graph[i][3][1,j])
     2710      {
    27112711        texdrawtp=texdrawtp+"
    27122712       \\move ("+decimal((graph[i][1]-centerx)/sf)+" "+decimal((graph[i][2]-centery)/sf)+") \\lvec ("+decimal((graph[graph[i][3][1,j]][1]-centerx)/sf)+" "+decimal((graph[graph[i][3][1,j]][2]-centery)/sf)+")";
    27132713        // if the multiplicity is more than one, denote it in the picture
    2714         if (graph[i][3][2,j]>1) 
     2714        if (graph[i][3][2,j]>1)
    27152715        {
    27162716          texdrawtp=texdrawtp+"
     
    27212721    // draw the unbounded edges emerging from the ith vertex
    27222722    // they should not be too long
    2723     for (j=1;j<=size(graph[i][4]);j++) 
    2724     {     
     2723    for (j=1;j<=size(graph[i][4]);j++)
     2724    {
    27252725      relxy=shorten(list(decimal((3*graph[i][4][j][1][1]/scalefactor)*sf),decimal((3*graph[i][4][j][1][2]/scalefactor)*sf),string(5*sf/2)));
    27262726      texdrawtp=texdrawtp+"
    27272727       \\move ("+decimal((graph[i][1]-centerx)/sf)+" "+decimal((graph[i][2]-centery)/sf)+") \\rlvec ("+relxy[1]+" "+relxy[2]+")";
    27282728      // if the multiplicity is more than one, denote it in the picture
    2729       if (graph[i][4][j][2]>1) 
     2729      if (graph[i][4][j][2]>1)
    27302730      {
    27312731        texdrawtp=texdrawtp+"
     
    28052805  poly scalefactor=minOfPolys(list(12/leadcoef(maxx),12/leadcoef(maxy)));
    28062806  if (scalefactor<1)
    2807   {   
     2807  {
    28082808    subdivision=subdivision+"
    28092809       \\relunitscale"+ decimal(scalefactor);
     
    28132813  {
    28142814    subdivision=subdivision+"
    2815         \\move ("+string(boundary[i][1])+" "+string(boundary[i][2])+")       
     2815        \\move ("+string(boundary[i][1])+" "+string(boundary[i][2])+")
    28162816        \\lvec ("+string(boundary[i+1][1])+" "+string(boundary[i+1][2])+")";
    2817   } 
     2817  }
    28182818  subdivision=subdivision+"
    2819         \\move ("+string(boundary[size(boundary)][1])+" "+string(boundary[size(boundary)][2])+")       
     2819        \\move ("+string(boundary[size(boundary)][1])+" "+string(boundary[size(boundary)][2])+")
    28202820        \\lvec ("+string(boundary[1][1])+" "+string(boundary[1][2])+")
    28212821
     
    28242824  {
    28252825    subdivision=subdivision+"
    2826         \\move ("+string(inneredges[i][1][1])+" "+string(inneredges[i][1][2])+")       
     2826        \\move ("+string(inneredges[i][1][1])+" "+string(inneredges[i][1][2])+")
    28272827        \\lvec ("+string(inneredges[i][2][1])+" "+string(inneredges[i][2][2])+")";
    28282828  }
     
    28442844    }
    28452845  }
    2846   // deal with the pathological cases 
     2846  // deal with the pathological cases
    28472847  if (size(boundary)==1) // then the Newton polytope is a point
    28482848  {
     
    28992899  {
    29002900    subdivision=subdivision+"
    2901        \\move ("+string(markings[i][1])+" "+string(markings[i][2])+") 
     2901       \\move ("+string(markings[i][1])+" "+string(markings[i][2])+")
    29022902       \\fcir f:0 r:"+decimal(2/(8*scalefactor),size(string(int(scalefactor)))+1);
    29032903  }
    29042904  // enclose subdivision in the texdraw environment
    2905   string texsubdivision="     
     2905  string texsubdivision="
    29062906    \\begin{texdraw}
    2907        \\drawdim cm  \\relunitscale 1 
     2907       \\drawdim cm  \\relunitscale 1
    29082908       \\linewd 0.05"
    29092909    +subdivision+"
     
    29192919   poly f=x+y+x2y+xy2+1/t*xy;
    29202920   list graph=tropicalCurve(f);
    2921 // compute the texdraw code of the Newton subdivision of the tropical curve 
     2921// compute the texdraw code of the Newton subdivision of the tropical curve
    29222922   texDrawNewtonSubdivision(graph);
    29232923}
     
    29272927proc texDrawTriangulation (list triang,list polygon)
    29282928"USAGE:      texDrawTriangulation(triang,polygon);  triang,polygon list
    2929 ASSUME:      polygon is a list of integer vectors describing the 
     2929ASSUME:      polygon is a list of integer vectors describing the
    29302930             lattice points of a marked polygon;
    2931              triang is a list of integer vectors describing a 
     2931             triang is a list of integer vectors describing a
    29322932             triangulation of the marked polygon
    2933              in the sense that an integer vector of the form (i,j,k) describes 
     2933             in the sense that an integer vector of the form (i,j,k) describes
    29342934             the triangle formed by polygon[i], polygon[j] and polygon[k]
    2935 RETURN:      string, a texdraw code for the triangulation described 
     2935RETURN:      string, a texdraw code for the triangulation described
    29362936                     by triang without the texdraw environment
    29372937EXAMPLE:     example texDrawTriangulation;   shows an example"
     
    29422942   ";
    29432943  int i,j; // indices
    2944   list pairs,markings; // stores edges of the triangulation, respecively 
    2945   // the marked points for each triangle store the edges and marked 
     2944  list pairs,markings; // stores edges of the triangulation, respecively
     2945  // the marked points for each triangle store the edges and marked
    29462946  // points of the triangle
    29472947  for (i=1;i<=size(triang);i++)
     
    29522952    markings[3*i-2]=triang[i][1];
    29532953    markings[3*i-1]=triang[i][2];
    2954     markings[3*i]=triang[i][3];   
     2954    markings[3*i]=triang[i][3];
    29552955  }
    29562956  // delete redundant pairs which occur more than once
     
    29852985  {
    29862986    latex=latex+"
    2987         \\move ("+string(polygon[markings[i]][1])+" "+string(polygon[markings[i]][2])+")       
     2987        \\move ("+string(polygon[markings[i]][1])+" "+string(polygon[markings[i]][2])+")
    29882988        \\fcir f:0 r:0.08";
    29892989  }
     
    29922992  {
    29932993    latex=latex+"
    2994         \\move ("+string(polygon[pairs[i][1]][1])+" "+string(polygon[pairs[i][1]][2])+")       
     2994        \\move ("+string(polygon[pairs[i][1]][1])+" "+string(polygon[pairs[i][1]][2])+")
    29952995        \\lvec ("+string(polygon[pairs[i][2]][1])+" "+string(polygon[pairs[i][2]][2])+")";
    29962996  }
     
    29992999  {
    30003000    latex=latex+"
    3001         \\move ("+string(polygon[i][1])+" "+string(polygon[i][2])+")       
     3001        \\move ("+string(polygon[i][1])+" "+string(polygon[i][2])+")
    30023002        \\fcir f:0.7 r:0.04";
    30033003  }
     
    30083008   "EXAMPLE:";
    30093009   echo=2;
    3010    // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 
     3010   // the lattice polygon spanned by the points (0,0), (3,0) and (0,3)
    30113011   // with all integer points as markings
    30123012   list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),intvec(0,0),
    30133013                intvec(2,1),intvec(0,1),intvec(1,2),intvec(0,2),intvec(0,3);
    3014    // define a triangulation by connecting the only interior point 
     3014   // define a triangulation by connecting the only interior point
    30153015   //        with the vertices
    30163016   list triang=intvec(1,2,5),intvec(1,5,10),intvec(1,2,10);
     
    30203020
    30213021///////////////////////////////////////////////////////////////////////////////
    3022 /// Auxilary Procedures 
     3022/// Auxilary Procedures
    30233023///////////////////////////////////////////////////////////////////////////////
    30243024
     
    30263026"USAGE:  radicalMemberShip (f,i); f poly, i ideal
    30273027RETURN:  int, 1 if f is in the radical of i, 0 else
    3028 EXAMPLE:     example radicalMemberShip;   shows an example" 
     3028EXAMPLE:     example radicalMemberShip;   shows an example"
    30293029{
    30303030  def BASERING=basering;
     
    30663066{
    30673067  // compute first the t-order of the leading coefficient of f (leitkoef[1]) and
    3068   // the rational constant corresponding to this order in leadkoef(f) 
     3068  // the rational constant corresponding to this order in leadkoef(f)
    30693069  // (leitkoef[2])
    30703070  list leitkoef=simplifyToOrder(f);
     
    30763076  // do the same for the remaining part of f and compare the results
    30773077  // keep only the smallest ones
    3078   int vglgewicht; 
    3079   f=f-lead(f); 
     3078  int vglgewicht;
     3079  f=f-lead(f);
    30803080  while (f!=0)
    30813081  {
    3082     leitkoef=simplifyToOrder(f);   
     3082    leitkoef=simplifyToOrder(f);
    30833083    vglgewicht=leitkoef[1]+scalarproduct(w,leadexp(f));
    30843084    if (vglgewicht<gewicht)
     
    30953095        initialf=initialf+koef*leadmonom(f);
    30963096      }
    3097     }   
     3097    }
    30983098    f=f-lead(f);
    30993099  }
     
    31203120{
    31213121  // compute first the t-order of the leading coefficient of f (leitkoef[1]) and
    3122   // the rational constant corresponding to this order in leadkoef(f) 
     3122  // the rational constant corresponding to this order in leadkoef(f)
    31233123  // (leitkoef[2])
    3124   list leitkoef=simplifyToOrder(f); 
     3124  list leitkoef=simplifyToOrder(f);
    31253125  execute("poly koef="+leitkoef[2]+";");
    31263126  // take in lead(f) only the term of lowest t-order and set t=1
     
    31313131  // keep only the largest ones
    31323132  int vglgewicht;
    3133   f=f-lead(f); 
     3133  f=f-lead(f);
    31343134  while (f!=0)
    31353135  {
     
    31493149        initialf=initialf+koef*leadmonom(f);
    31503150      }
    3151     }   
     3151    }
    31523152    f=f-lead(f);
    31533153  }
     
    31683168proc solveTInitialFormPar (ideal i)
    31693169"USAGE:      solveTInitialFormPar(i); i ideal
    3170 ASSUME:      i is a zero-dimensional ideal in Q(t)[x_1,...,x_n] generated 
    3171              by the (1,w)-homogeneous elements for some integer vector w 
     3170ASSUME:      i is a zero-dimensional ideal in Q(t)[x_1,...,x_n] generated
     3171             by the (1,w)-homogeneous elements for some integer vector w
    31723172             - i.e. by the (1,w)-initialforms of polynomials
    31733173RETURN:      none
    3174 NOTE:        the procedure just displays complex approximations 
     3174NOTE:        the procedure just displays complex approximations
    31753175             of the solution set of i
    31763176EXAMPLE:     example solveTInitialFormPar;   shows an example"
     
    31973197/////////////////////////////////////////////////////////////////////////
    31983198
    3199 proc detropicalise (poly p) 
     3199proc detropicalise (poly p)
    32003200"USAGE:   detropicalise(f); f poly
    32013201ASSUME:   f is a linear polynomial with an arbitrary constant term and
    32023202          positive integer coefficients as further coefficients;
    32033203RETURN:   poly, the detropicalisation of (the non-constant part of) f
    3204 NOTE:     the output will be a monomial and the constant coefficient 
     3204NOTE:     the output will be a monomial and the constant coefficient
    32053205          has been ignored
    32063206EXAMPLE:  example detropicalise;   shows an example"
     
    32103210  {
    32113211    if (leadmonom(p)!=1)
    3212     { 
     3212    {
    32133213      dtp=dtp*leadmonom(p)^int(leadcoef(p));
    32143214    }
     
    32633263proc parameterSubstitute (poly f,int N)
    32643264"USAGE:   parameterSubstitute(f,N); f poly, N int
    3265 ASSUME:   f is a polynomial in Q(t)[x_1,...,x_n] describing 
     3265ASSUME:   f is a polynomial in Q(t)[x_1,...,x_n] describing
    32663266          a plane curve over Q(t)
    32673267RETURN:   poly f with t replaced by t^N
     
    33173317   poly f=t2x+1/t*y-1;
    33183318   tropicalSubst(f,2,x,x+t,y,tx+y+t2);
    3319    // The procedure can be used to study the effect of a transformation of 
     3319   // The procedure can be used to study the effect of a transformation of
    33203320   // the form x -> x+t^b, with b a rational number, on the tropicalisation and
    33213321   // the j-invariant of a cubic over the Puiseux series.
    33223322   f=t7*y3+t3*y2+t*(x3+xy2+y+1)+xy;
    3323    // - the j-invariant, and hence its valuation, 
     3323   // - the j-invariant, and hence its valuation,
    33243324   //   does not change under the transformation
    33253325   jInvariant(f,"ord");
    3326    // - b=3/2, then the cycle length of the tropical cubic equals -val(j-inv)   
    3327    list g32=tropicalSubst(f,2,x,x+t3,y,y); 
     3326   // - b=3/2, then the cycle length of the tropical cubic equals -val(j-inv)
     3327   list g32=tropicalSubst(f,2,x,x+t3,y,y);
    33283328   tropicalJInvariant(g32);
    33293329   // - b=1, then it is still true, but only just ...
     
    33383338
    33393339proc randomPoly (int d,int ug, int og, list #)
    3340 "USAGE:      randomPoly(d,ug,og[,#]);   d, ug, og int, # list 
     3340"USAGE:      randomPoly(d,ug,og[,#]);   d, ug, og int, # list
    33413341ASSUME:      the basering has a parameter t
    3342 RETURN:      poly, a polynomial of degree d where the coefficients are 
     3342RETURN:      poly, a polynomial of degree d where the coefficients are
    33433343                   of the form t^j with j a random integer between ug and og
    3344 NOTE:        if an optional argument # is given, then the coefficients are 
    3345              instead either of the form t^j as above or they are zero, 
     3344NOTE:        if an optional argument # is given, then the coefficients are
     3345             instead either of the form t^j as above or they are zero,
    33463346             and this is chosen randomly
    33473347EXAMPLE:     example randomPoly;   shows an example"
     
    33593359  {
    33603360    if (size(#)!=0)
    3361     {     
     3361    {
    33623362      k=random(0,1);
    33633363    }
    33643364    if (k==0)
    3365     {     
     3365    {
    33663366      j=random(ug,og);
    33673367      randomPolynomial=randomPolynomial+t^j*m[i];
     
    33933393RETURN:  none"
    33943394{
    3395   system("sh","cd /tmp; /bin/rm -f tropicalcurve*; /bin/rm -f tropicalnewtonsubdivision*"); 
     3395  system("sh","cd /tmp; /bin/rm -f tropicalcurve*; /bin/rm -f tropicalnewtonsubdivision*");
    33963396}
    33973397
     
    34503450static proc cutdown (ideal jideal,intvec wvec,int dimension,list #)
    34513451"USAGE:      cutdown(i,w,d); i ideal, w intvec, d int, # list
    3452 ASSUME:      i an ideal in Q[t,x_1,...,x_n], (w_1,...,w_n) is in the tropical 
    3453              variety of jideal and d=dim(i)>0, in Q(t)[x]; the optional 
    3454              parameter # can contain the string 'isPrime' to indicate that 
    3455              the input ideal is prime and no minimal associated primes have 
     3452ASSUME:      i an ideal in Q[t,x_1,...,x_n], (w_1,...,w_n) is in the tropical
     3453             variety of jideal and d=dim(i)>0, in Q(t)[x]; the optional
     3454             parameter # can contain the string 'isPrime' to indicate that
     3455             the input ideal is prime and no minimal associated primes have
    34563456             to be computed
    3457 RETURN:      list, the first entry is a ring, namely the basering where some 
    3458                    variables have been eliminated, and the ring contains 
     3457RETURN:      list, the first entry is a ring, namely the basering where some
     3458                   variables have been eliminated, and the ring contains
    34593459                   the ideal i (with the same variables eliminated),
    3460                    the t-initial ideal ini of i (w.r.t. the weight vector 
    3461                    where the entries corresponding to the deleted variables 
    3462                    have been eliminated) and a list repl where for each 
     3460                   the t-initial ideal ini of i (w.r.t. the weight vector
     3461                   where the entries corresponding to the deleted variables
     3462                   have been eliminated) and a list repl where for each
    34633463                   eliminated variable there is one entry, namely a polynomial
    3464                    in the remaining variables and t that explains how 
    3465                    resubstitution of a solution for the new i gives a solution 
     3464                   in the remaining variables and t that explains how
     3465                   resubstitution of a solution for the new i gives a solution
    34663466                   for the old i; the second entry is the weight vector
    3467                    wvec with the components corresponding to the eliminated 
     3467                   wvec with the components corresponding to the eliminated
    34683468                   variables removed
    3469 NOTE:        needs the libraries random.lib and primdec.lib; 
     3469NOTE:        needs the libraries random.lib and primdec.lib;
    34703470             is called from tropicalLifting"
    3471 { 
    3472   // IDEA: i is an ideal of dimension d; we want to cut it with d random linear 
     3471{
     3472  // IDEA: i is an ideal of dimension d; we want to cut it with d random linear
    34733473  //       forms in such a way that the resulting
    34743474  //       ideal is 0-dim and still contains w in the tropical variety
    3475   // NOTE: t is the last variable in the basering 
     3475  // NOTE: t is the last variable in the basering
    34763476  ideal pideal;  //this is the ideal we want to return
    34773477  ideal cutideal;
     
    34913491  for (j1=1;j1<=nvars(basering)-1;j1++)
    34923492  {
    3493     variablen=variablen+var(j1); // read the set of variables 
     3493    variablen=variablen+var(j1); // read the set of variables
    34943494                                 // (needed to make the quotring later)
    3495     product=product*var(j1); // make product of all variables 
     3495    product=product*var(j1); // make product of all variables
    34963496                             // (needed for the initial-monomial-check later
    3497   }   
     3497  }
    34983498  execute("ring QUOTRING=("+charstr(basering)+",t),("+string(variablen)+"),dp;");
    34993499  setring BASERING;
     
    35023502  {
    35033503    setring QUOTRING;
    3504     ideal jideal=imap(BASERING,jideal); 
    3505     list primp=minAssGTZ(jideal); //compute the primary decomposition 
     3504    ideal jideal=imap(BASERING,jideal);
     3505    list primp=minAssGTZ(jideal); //compute the primary decomposition
    35063506    for (j1=1;j1<=size(primp);j1++)
    3507     {     
     3507    {
    35083508      for(j2=1;j2<=size(primp[j1]);j2++)
    35093509      {
    35103510        // clear all denominators
    35113511        primp[j1][j2]=primp[j1][j2]/content(primp[j1][j2]);
    3512       }       
     3512      }
    35133513    }
    35143514    setring BASERING;
    35153515    list primp=imap(QUOTRING,primp);
    35163516    // if i is not primary itself
    3517     // go through the list of min. ass. primes and find the first 
     3517    // go through the list of min. ass. primes and find the first
    35183518    // one which has w in its tropical variety
    3519     if (size(primp)>1) 
     3519    if (size(primp)>1)
    35203520    {
    35213521      j1=1;
     
    35243524        //compute the t-initial of the associated prime
    35253525        // - the last entry 1 only means that t is the last variable in the ring
    3526         primini=tInitialIdeal(primp[j1],wvec,1); 
    3527         // check if it contains a monomial (resp if the product of var 
     3526        primini=tInitialIdeal(primp[j1],wvec,1);
     3527        // check if it contains a monomial (resp if the product of var
    35283528        // is in the radical)
    3529         if (radicalMemberShip(product,primini)==0) 
    3530         { 
     3529        if (radicalMemberShip(product,primini)==0)
     3530        {
    35313531          // if w is in the tropical variety of the prime, we take that
    35323532          jideal=primp[j1];
     
    35353535          setring BASERING;
    35363536          winprim=1; // and stop the checking
    3537         } 
     3537        }
    35383538        j1=j1+1;  //else we look at the next associated prime
    35393539      }
     
    35423542    {
    35433543      jideal=primp[1]; //if i is primary itself we take its prime instead
    3544     } 
     3544    }
    35453545  }
    35463546  // now we start as a first try to intersect with a hyperplane parallel to
    35473547  // coordinate axes, because this would make our further computations
    3548   // a lot easier. 
    3549   // We choose a subset of our n variables of size d=dim(ideal). 
     3548  // a lot easier.
     3549  // We choose a subset of our n variables of size d=dim(ideal).
    35503550  // For each of these
    3551   // variables, we want to fix a value: x_i= a_i*t^-w_i. 
     3551  // variables, we want to fix a value: x_i= a_i*t^-w_i.
    35523552  // This will only work if the
    3553   // projection of the d-dim variety to the other n-d variables 
     3553  // projection of the d-dim variety to the other n-d variables
    35543554  // is the whole n-d plane.
    3555   // Then a general choice for a_i will intersect the variety 
     3555  // Then a general choice for a_i will intersect the variety
    35563556  // in finitely many points.
    3557   // If the projection is not the whole n-d plane, 
     3557  // If the projection is not the whole n-d plane,
    35583558  // then a general choice will not work.
    3559   // We could determine if we picked a good 
     3559  // We could determine if we picked a good
    35603560  // d-subset of variables using elimination
    3561   // (NOTE, there EXIST d variables such that 
     3561  // (NOTE, there EXIST d variables such that
    35623562  // a random choice of a_i's would work!).
    3563   // But since this involves many computations, 
     3563  // But since this involves many computations,
    35643564  // we prefer to choose randomly and just
    3565   // try in the end if our intersected ideal 
    3566   // satisfies our requirements. If this does not 
     3565  // try in the end if our intersected ideal
     3566  // satisfies our requirements. If this does not
    35673567  // work, we give up this try and use our second intersection idea, which
    35683568  // will work for a Zariksi-open subset (i.e. almost always).
    35693569  //
    3570   // As random subset of d variables we choose 
     3570  // As random subset of d variables we choose
    35713571  // those for which the absolute value of the
    3572   // wvec-coordinate is smallest, because this will 
     3572  // wvec-coordinate is smallest, because this will
    35733573  // give us the smallest powers of t and hence
    3574   // less effort in following computations. 
     3574  // less effort in following computations.
    35753575  // Note that the smallest absolute value have those
    3576   // which are biggest, because wvec is negative. 
     3576  // which are biggest, because wvec is negative.
    35773577  //print("first try");
    35783578  intvec wminust=intvecdelete(wvec,1);
     
    35813581  A[1,1..size(wminust)]=-wminust;
    35823582  A[2,1..size(wminust)]=1..size(wminust);
    3583   // sort this matrix in order to get 
     3583  // sort this matrix in order to get
    35843584  // the d biggest entries and their position in wvec
    3585   A=sortintmat(A); 
    3586   // we construct a vector which has 1 at entry j if j belongs to the list 
     3585  A=sortintmat(A);
     3586  // we construct a vector which has 1 at entry j if j belongs to the list
    35873587  // of the d biggest entries of wvec and a 0 else
    35883588  for (j1=1;j1<=nvars(basering)-1;j1++) //go through the variables
     
    35933593      {
    35943594        setvec[j1]=1;//put a 1
    3595       }       
    3596     } 
    3597   }
    3598   // using this 0/1-vector we produce 
    3599   // a random constant (i.e. coeff in Q times something in t) 
    3600   // for each of the biggest variables, 
     3595      }
     3596    }
     3597  }
     3598  // using this 0/1-vector we produce
     3599  // a random constant (i.e. coeff in Q times something in t)
     3600  // for each of the biggest variables,
    36013601  // we add the forms x_i-random constant to the ideal
    3602   // and we save the constant at the i-th place of 
     3602  // and we save the constant at the i-th place of
    36033603  // a list we want to return for later computations
    36043604  j3=0;
     
    36113611    {
    36123612      if(setvec[j1]==1)//if x_i belongs to the biggest variables
    3613       {     
     3613      {
    36143614        if ((j3==1) and ((char(basering)==0) or (char(basering)>3)))
    3615         {       
     3615        {
    36163616          randomp1=random(1,3);
    3617           randomp=t^(A[1,j2])*randomp1;// make a random constant 
     3617          randomp=t^(A[1,j2])*randomp1;// make a random constant
    36183618                                       // --- first we try small numbers
    3619         }   
     3619        }
    36203620        if ((j3==2) and ((char(basering)==0) or (char(basering)>100)))
    36213621        {
    36223622          randomp1=random(1,100);
    3623           randomp=t^(A[1,j2])*randomp1;// make a random constant 
     3623          randomp=t^(A[1,j2])*randomp1;// make a random constant
    36243624                                       // --- next we try bigger numbers
    3625         }   
     3625        }
    36263626        else
    36273627        {
     
    36353635      else
    36363636      {
    3637         ergl[j1]=0; //if the variable is not among the d biggest ones, 
     3637        ergl[j1]=0; //if the variable is not among the d biggest ones,
    36383638                    //save 0 in the list
    36393639        erglini[j1]=0;
    3640       }       
     3640      }
    36413641    }
    36423642      // print(ergl);print(pideal);
    3643       // now we check if we made a good choice of pideal, i.e. if dim=0 and 
     3643      // now we check if we made a good choice of pideal, i.e. if dim=0 and
    36443644      // wvec is still in the tropical variety
    36453645      // change to quotring where we compute dimension
     
    36483648    {
    36493649      if(setvec[j1]==1)
    3650       {     
    3651         cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
    3652       }     
     3650      {
     3651        cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
     3652      }
    36533653    }
    36543654    setring QUOTRING;
     
    36623662    {
    36633663      // compute the t-initial of the associated prime
    3664       // - the last 1 just means that the variable t is 
     3664      // - the last 1 just means that the variable t is
    36653665      //   the last variable in the ring
    36663666      pini=tInitialIdeal(cutideal,wvec ,1);
    36673667      //print("initial");
    36683668      //print(pini);
    3669       // and if the initial w.r.t. t contains no monomial 
     3669      // and if the initial w.r.t. t contains no monomial
    36703670      // as we want (checked with
    36713671      // radical-membership of the product of all variables)
    3672       if (radicalMemberShip(product,pini)==0) 
    3673       {
    3674         // we made the right choice and now 
    3675         // we substitute the variables in the ideal   
     3672      if (radicalMemberShip(product,pini)==0)
     3673      {
     3674        // we made the right choice and now
     3675        // we substitute the variables in the ideal
    36763676        // to get an ideal in less variables
    3677         // also we make a projected vector 
     3677        // also we make a projected vector
    36783678        // from wvec only the components of the remaining variables
    36793679        wvecp=wvec;
    3680         variablen=0;   
     3680        variablen=0;
    36813681        j2=0;
    36823682        for(j1=1;j1<=nvars(basering)-1;j1++)
     
    36913691          else
    36923692          {
    3693             variablen=variablen+var(j1); // read the set of remaining variables 
     3693            variablen=variablen+var(j1); // read the set of remaining variables
    36943694                                         // (needed to make quotring later)
    3695           }   
    3696         }     
     3695          }
     3696        }
    36973697        // return pideal, the initial and the list ergl which tells us
    36983698        // which variables we replaced by which form
     
    37043704        export(ini);
    37053705        export(repl);
    3706         return(list(BASERINGLESS1,wvecp)); 
     3706        return(list(BASERINGLESS1,wvecp));
    37073707      }
    37083708    }
    37093709  }
    37103710  // this is our second try to cut down, which we only use if the first try
    3711   // didn't work out. We intersect with d general hyperplanes 
     3711  // didn't work out. We intersect with d general hyperplanes
    37123712  // (i.e. we don't choose
    37133713  // them to be parallel to coordinate hyperplanes anymore. This works out with
    37143714  // probability 1.
    37153715  //
    3716   // We choose general hyperplanes, i.e. linear forms which involve all x_i. 
    3717   // Each x_i has to be multiplied bz t^(w_i) in order 
    3718   // to get the same weight (namely 0) 
     3716  // We choose general hyperplanes, i.e. linear forms which involve all x_i.
     3717  // Each x_i has to be multiplied bz t^(w_i) in order
     3718  // to get the same weight (namely 0)
    37193719  // for each term. As we cannot have negative exponents, we multiply
    3720   // the whole form by t^minimumw. Notice that then in the first form, 
     3720  // the whole form by t^minimumw. Notice that then in the first form,
    37213721  // there is one term without t- the term of the variable
    37223722  // x_i such that w_i is minimal. That is, we can solve for this variable.
    3723   // In the second form, we can replace that variable, 
    3724   // and divide by t as much as possible. 
    3725   // Then there is again one term wihtout t - 
    3726   // the term of the variable with second least w. 
     3723  // In the second form, we can replace that variable,
     3724  // and divide by t as much as possible.
     3725  // Then there is again one term wihtout t -
     3726  // the term of the variable with second least w.
    37273727  // So we can solve for this one again and also replace it in the first form.
    3728   // Since all our coefficients are chosen randomly, 
    3729   // we can also from the beginning on 
    3730   // choose the set of variables which belong to the d smallest entries of wvec 
    3731   // (t not counting) and pick random forms g_i(t,x') 
    3732   // (where x' is the set of remaining variables) 
    3733   // and set x_i=g_i(t,x'). 
     3728  // Since all our coefficients are chosen randomly,
     3729  // we can also from the beginning on
     3730  // choose the set of variables which belong to the d smallest entries of wvec
     3731  // (t not counting) and pick random forms g_i(t,x')
     3732  // (where x' is the set of remaining variables)
     3733  // and set x_i=g_i(t,x').
    37343734  //
    37353735  // make a matrix with first row wvec (without t) and second row 1..n
    37363736  //print("second try");
    37373737  setring BASERING;
    3738   A[1,1..size(wminust)]=wminust; 
     3738  A[1,1..size(wminust)]=wminust;
    37393739  A[2,1..size(wminust)]=1..size(wminust);
    3740   // sort this matrix in otder to get the d smallest entries 
     3740  // sort this matrix in otder to get the d smallest entries
    37413741  // (without counting the t-entry)
    37423742  A=sortintmat(A);
     
    37443744  setvec=0;
    37453745  setvec[nvars(basering)-1]=0;
    3746   // we construct a vector which has 1 at entry j if j belongs to the list of 
     3746  // we construct a vector which has 1 at entry j if j belongs to the list of
    37473747  // the d smallest entries of wvec and a 0 else
    37483748  for (j1=1;j1<=nvars(basering)-1;j1++) //go through the variables
     
    37643764    {
    37653765      j2=j2+1;
    3766       wvecp=intvecdelete(wvecp,j1+2-j2);// delete the components 
     3766      wvecp=intvecdelete(wvecp,j1+2-j2);// delete the components
    37673767                                        // we substitute from wvec
    37683768    }
    37693769    else
    37703770    {
    3771       variablen=variablen+var(j1); // read the set of remaining variables 
     3771      variablen=variablen+var(j1); // read the set of remaining variables
    37723772                                   // (needed to make the quotring later)
    37733773    }
    3774   } 
     3774  }
    37753775  setring BASERING;
    37763776  execute("ring BASERINGLESS2=("+charstr(BASERING)+"),("+string(variablen)+",t),(dp("+string(ncols(variablen))+"),lp(1));");
    3777   // using the 0/1-vector which tells us which variables belong 
     3777  // using the 0/1-vector which tells us which variables belong
    37783778  // to the set of smallest entries of wvec
    3779   // we construct a set of d random linear 
    3780   // polynomials of the form x_i=g_i(t,x'), 
     3779  // we construct a set of d random linear
     3780  // polynomials of the form x_i=g_i(t,x'),
    37813781  // where the set of all x_i is the set of
    3782   // all variables which are in the list of smallest 
     3782  // all variables which are in the list of smallest
    37833783  // entries in wvec, and x' are the other variables.
    3784   // We add these d random linear polynomials to 
    3785   // the ideal pideal, i.e. we intersect 
     3784  // We add these d random linear polynomials to
     3785  // the ideal pideal, i.e. we intersect
    37863786  // with these and hope to get something
    3787   // 0-dim which still contains wvec in its 
    3788   // tropical variety. Also, we produce a list ergl 
     3787  // 0-dim which still contains wvec in its
     3788  // tropical variety. Also, we produce a list ergl
    37893789  // with g_i at the i-th position.
    37903790  // This is a list we want to return.
     
    37923792  setring BASERING;
    37933793  pideal=jideal;
    3794   for(j1=1;j1<=dimension;j1++)//go through the list of variables 
     3794  for(j1=1;j1<=dimension;j1++)//go through the list of variables
    37953795  { // corres to the d smallest in wvec
    37963796    if ((char(basering)==0) or (char(basering)>3))
    3797     { 
     3797    {
    37983798      randomp1=random(1,3);
    37993799      randomp=randomp1*t^(-A[1,j1]);
     
    38083808      if(setvec[j2]==0)//if x_j belongs to the set x'
    38093809      {
    3810         // add a random term with the suitable power 
     3810        // add a random term with the suitable power
    38113811        // of t to the random linear form
    38123812        if ((char(basering)==0) or (char(basering)>3))
     
    38333833    }
    38343834  //print(ergl);
    3835   // Again, we have to test if we made a good choice 
    3836   // to intersect,i.e. we have to check whether 
     3835  // Again, we have to test if we made a good choice
     3836  // to intersect,i.e. we have to check whether
    38373837  // pideal is 0-dim and contains wvec in the tropical variety.
    38383838  cutideal=pideal;
     
    38413841    if(setvec[j1]==1)
    38423842    {
    3843       cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
    3844     }   
     3843      cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
     3844    }
    38453845  }
    38463846  setring QUOTRING;
     
    38543854  {
    38553855    // compute the t-initial of the associated prime
    3856     // - the last 1 just means that the variable t 
     3856    // - the last 1 just means that the variable t
    38573857    // is the last variable in the ring
    38583858    pini=tInitialIdeal(cutideal,wvec ,1);
     
    38613861    // and if the initial w.r.t. t contains no monomial as we want (checked with
    38623862    // radical-membership of the product of all variables)
    3863     if (radicalMemberShip(product,pini)==0) 
     3863    if (radicalMemberShip(product,pini)==0)
    38643864    {
    38653865      // we want to replace the variables x_i by the forms -g_i in
    3866       // our ideal in order to return an ideal with less variables 
     3866      // our ideal in order to return an ideal with less variables
    38673867      // first we substitute the chosen variables
    38683868      for(j1=1;j1<=nvars(basering)-1;j1++)
     
    38813881      export(ini);
    38823882      export(repl);
    3883       return(list(BASERINGLESS2,wvecp)); 
     3883      return(list(BASERINGLESS2,wvecp));
    38843884    }
    38853885  }
    38863886  // now we try bigger numbers
    3887   while (1) //a never-ending loop which will stop with prob. 1 
     3887  while (1) //a never-ending loop which will stop with prob. 1
    38883888  { // as we find a suitable ideal with that prob
    38893889    setring BASERING;
    38903890    pideal=jideal;
    3891     for(j1=1;j1<=dimension;j1++)//go through the list of variables 
     3891    for(j1=1;j1<=dimension;j1++)//go through the list of variables
    38923892    { // corres to the d smallest in wvec
    38933893      randomp1=random(1,100);
    38943894      randomp=randomp1*t^(-A[1,j1]);
    38953895      for(j2=1;j2<=nvars(basering)-1;j2++)//go through all variables
    3896       { 
     3896      {
    38973897        if(setvec[j2]==0)//if x_j belongs to the set x'
    38983898        {
    3899           // add a random term with the suitable power 
     3899          // add a random term with the suitable power
    39003900          // of t to the random linear form
    39013901          if ((char(basering)==0) or (char(basering)>100))
    3902           { 
     3902          {
    39033903            randomp2=random(1,100);
    39043904            randomp1=randomp1+randomp2*var(j2);
     
    39213921      }
    39223922    //print(ergl);
    3923     // Again, we have to test if we made a good choice to 
    3924     // intersect,i.e. we have to check whether 
     3923    // Again, we have to test if we made a good choice to
     3924    // intersect,i.e. we have to check whether
    39253925    // pideal is 0-dim and contains wvec in the tropical variety.
    39263926    cutideal=pideal;
     
    39293929      if(setvec[j1]==1)
    39303930      {
    3931         cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
    3932       }     
     3931        cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
     3932      }
    39333933    }
    39343934    setring QUOTRING;
     
    39383938    //print(dimp);
    39393939    kill cutideal;
    3940     setring BASERING; 
     3940    setring BASERING;
    39413941    if (dimp==0) // if it is 0 as we want
    39423942    {
    39433943      // compute the t-initial of the associated prime
    3944       // - the last 1 just means that the variable t 
     3944      // - the last 1 just means that the variable t
    39453945      // is the last variable in the ring
    39463946      pini=tInitialIdeal(cutideal,wvec ,1);
    39473947      //print("initial");
    39483948      //print(pini);
    3949       // and if the initial w.r.t. t contains no monomial 
     3949      // and if the initial w.r.t. t contains no monomial
    39503950      // as we want (checked with
    39513951      // radical-membership of the product of all variables)
    3952       if (radicalMemberShip(product,pini)==0) 
     3952      if (radicalMemberShip(product,pini)==0)
    39533953      {
    39543954        // we want to replace the variables x_i by the forms -g_i in
     
    39613961            pideal=subst(pideal,var(j1),ergl[j1]);//substitute it
    39623962            pini=subst(pini,var(j1),erglini[j1]);
    3963           }   
    3964         }   
     3963          }
     3964        }
    39653965        // return pideal and the list ergl which tells us
    39663966        // which variables we replaced by which form
     
    39723972        export(ini);
    39733973        export(repl);
    3974         return(list(BASERINGLESS2,wvecp)); 
     3974        return(list(BASERINGLESS2,wvecp));
    39753975      }
    39763976    }
     
    39833983static proc tropicalparametriseNoabs (ideal i,intvec ww,int ordnung,int gfanold,int nogfan,list #)
    39843984"USAGE:  tropicalparametriseNoabs(i,tw,ord,gf,ng[,#]); i ideal, tw intvec, ord int, gf,ng int, # opt. list
    3985 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], 
    3986            tw=(w_0,w_1,...,w_n,0,...,0) and (w_0,...,w_n,0,...,0) is in 
    3987            the tropical variety of i, and ord is the order up to which a point 
    3988            in V(i) over C((t)) lying over w shall be computed; 
     3985ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k],
     3986           tw=(w_0,w_1,...,w_n,0,...,0) and (w_0,...,w_n,0,...,0) is in
     3987           the tropical variety of i, and ord is the order up to which a point
     3988           in V(i) over C((t)) lying over w shall be computed;
    39893989         - moreover, k should be zero if the procedure is not called recursively;
    3990          - the point in the tropical variety is supposed to lie in the NEGATIVE 
     3990         - the point in the tropical variety is supposed to lie in the NEGATIVE
    39913991           orthant;
    3992          - the ideal is zero-dimensional when considered 
     3992         - the ideal is zero-dimensional when considered
    39933993           in (Q(t)[X_1,...,X_k]/m)[x_1,...,x_n],
    3994            where m=#[2] is a maximal ideal in Q(t)[X_1,...,X_k]; 
     3994           where m=#[2] is a maximal ideal in Q(t)[X_1,...,X_k];
    39953995         - gf is 0 if version 2.2 or larger is used and it is 1 else
    3996          - ng is 1 if gfan should not be executed 
     3996         - ng is 1 if gfan should not be executed
    39973997RETURN:  list, l[1] = ring Q(0,X_1,...,X_r)[[t]]
    39983998               l[2] = int
    39993999               l[3] = string
    40004000NOTE:    - the procedure is also called recursively by itself, and
    4001            if it is called in the first recursion, the list # is empty, 
    4002            otherwise #[1] is an integer, one more than the number 
     4001           if it is called in the first recursion, the list # is empty,
     4002           otherwise #[1] is an integer, one more than the number
    40034003           of true variables x_1,...,x_n,
    40044004           and #[2] will contain the maximal ideal m in the variables X_1,...X_k
     
    40064006           work correctly in K[t,x_1,...,x_n] where K=Q[X_1,...,X_k]/m is a field
    40074007           extension of Q;
    4008          - the ring l[1] contains an ideal PARA, which contains the 
    4009            parametrisation of a point in V(i) lying over w up to the 
     4008         - the ring l[1] contains an ideal PARA, which contains the
     4009           parametrisation of a point in V(i) lying over w up to the
    40104010           first ord terms;
    4011          - the string m=l[3] contains the code of the maximal ideal m, 
    4012            by which we have to divide Q[X_1,...,X_r] in order to have 
     4011         - the string m=l[3] contains the code of the maximal ideal m,
     4012           by which we have to divide Q[X_1,...,X_r] in order to have
    40134013           the appropriate field extension over which the parametrisation lives;
    4014          - and if the integer l[2] is N then t has to be replaced by t^1/N in 
    4015            the parametrisation, or alternatively replace t by t^N in the 
     4014         - and if the integer l[2] is N then t has to be replaced by t^1/N in
     4015           the parametrisation, or alternatively replace t by t^N in the
    40164016           defining ideal
    4017          - the procedure REQUIRES that the program GFAN is installed on 
     4017         - the procedure REQUIRES that the program GFAN is installed on
    40184018           your computer"
    40194019{
     
    40234023  if (size(#)==2) // this means the precedure has been called recursively
    40244024  {
    4025     // how many variables are true variables, and how many come 
     4025    // how many variables are true variables, and how many come
    40264026    // from the field extension
    40274027    // only true variables have to be transformed
     
    40294029    ideal gesamt_m=std(#[2]); // stores all maxideals used for field extensions
    40304030    // find the zeros of the w-initial ideal and transform the ideal i;
    4031     // findzeros and basictransformideal need to know how 
     4031    // findzeros and basictransformideal need to know how
    40324032    // many of the variables are true variables
    40334033    list m_ring=findzeros(i,ww,anzahlvariablen);
     
    40364036  else // the procedure has been called by tropicalLifting
    40374037  {
    4038     // how many variables are true variables, and how many come from 
     4038    // how many variables are true variables, and how many come from
    40394039    // the field extension only true variables have to be transformed
    40404040    int anzahlvariablen=nvars(basering);
     
    40434043    ideal ini=#[1];
    40444044    // find the zeros of the w-initial ideal and transform the ideal i;
    4045     // we should hand the t-initial ideal ine to findzeros, 
     4045    // we should hand the t-initial ideal ine to findzeros,
    40464046    // since we know it already
    40474047    list m_ring=findzeros(i,ww,ini);
     
    40654065    list a=btr[2];
    40664066    ideal m=btr[3];
    4067     gesamt_m=gesamt_m+m; // add the newly found maximal 
     4067    gesamt_m=gesamt_m+m; // add the newly found maximal
    40684068                         // ideal to the previous ones
    40694069  }
    40704070  // check if there is a solution which has the n-th component zero,
    4071   // if so, then eliminate the n-th variable from sat(i+x_n,t), 
     4071  // if so, then eliminate the n-th variable from sat(i+x_n,t),
    40724072  // otherwise leave i as it is;
    4073   // then check if the (remaining) ideal has as solution 
     4073  // then check if the (remaining) ideal has as solution
    40744074  // where the n-1st component is zero,
    40754075  // and procede as before; do the same for the remaining variables;
    4076   // this way we make sure that the remaining ideal has 
     4076  // this way we make sure that the remaining ideal has
    40774077  // a solution which has no component zero;
    40784078  intvec deletedvariables;    // the jth entry is set 1, if we eliminate x_j
    40794079  int numberdeletedvariables; // the number of eliminated variables
    40804080  ideal variablen;  // will contain the variables which are not eliminated
    4081   intvec tw=ww;     // in case some variables are deleted, 
     4081  intvec tw=ww;     // in case some variables are deleted,
    40824082                    // we have to store the old weight vector
    40834083  deletedvariables[anzahlvariablen]=0;
    4084   ideal I,LI; 
     4084  ideal I,LI;
    40854085  i=i+m; // if a field extension was necessary, then i has to be extended by m
    40864086  for (jj=anzahlvariablen-1;jj>=1;jj--)  // the variable t is the last one !!!
     
    40894089    LI=subst(I,var(nvars(basering)),0);
    40904090    //size(deletedvariables)=anzahlvariablen(before elim.)
    4091     for (kk=1;kk<=size(deletedvariables)-1;kk++) 
     4091    for (kk=1;kk<=size(deletedvariables)-1;kk++)
    40924092    {
    40934093      LI=subst(LI,var(kk),0);
    40944094    }
    4095     if (size(LI)==0) // if no power of t is in lead(I) 
     4095    if (size(LI)==0) // if no power of t is in lead(I)
    40964096    { // (where the X(i) are considered as field elements)
    4097       // get rid of var(jj)   
     4097      // get rid of var(jj)
    40984098      i=eliminate(I,var(jj));
    40994099      deletedvariables[jj]=1;
    4100       anzahlvariablen--; // if a variable is eliminated, 
     4100      anzahlvariablen--; // if a variable is eliminated,
    41014101                         // then the number of true variables drops
    41024102      numberdeletedvariables++;
     
    41084108  }
    41094109  variablen=invertorder(variablen);
    4110   // store also the additional variables and t, 
     4110  // store also the additional variables and t,
    41114111  // since they for sure have not been eliminated
    41124112  for (jj=anzahlvariablen+numberdeletedvariables-1;jj<=nvars(basering);jj++)
     
    41144114    variablen=variablen+var(jj);
    41154115  }
    4116   // if some variables have been eliminated, 
     4116  // if some variables have been eliminated,
    41174117  // then pass to a new ring which has less variables,
    41184118  // but if no variables are left, then we are done
    41194119  def BASERING=basering;
    4120   if ((numberdeletedvariables>0) and (anzahlvariablen>1)) // if only t remains, 
     4120  if ((numberdeletedvariables>0) and (anzahlvariablen>1)) // if only t remains,
    41214121  { // all true variables are gone
    41224122    execute("ring NEURING=("+charstr(basering)+"),("+string(variablen)+"),(dp("+string(size(variablen)-1)+"),lp(1));");
    41234123    ideal i=imap(BASERING,i);
    4124     ideal gesamt_m=imap(BASERING,gesamt_m);   
    4125   }
    4126   // now we have to compute a point ww on the tropical variety 
     4124    ideal gesamt_m=imap(BASERING,gesamt_m);
     4125  }
     4126  // now we have to compute a point ww on the tropical variety
    41274127  // of the transformed ideal i;
    4128   // of course, we only have to do so, if we have not yet 
     4128  // of course, we only have to do so, if we have not yet
    41294129  // reached the order up to which we
    41304130  // were supposed to do our computations
    4131   if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains, 
     4131  if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains,
    41324132  { // all true variables are gone
    41334133    def PREGFANRING=basering;
    41344134    if (nogfan!=1)
    4135     {     
     4135    {
    41364136      // pass to a ring which has variables which are suitable for gfan
    41374137      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;");
    4138       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; 
     4138      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;
    41394139      phiideal[nvars(PREGFANRING)]=a; // map t to a
    4140       map phi=PREGFANRING,phiideal; 
     4140      map phi=PREGFANRING,phiideal;
    41414141      ideal i=phi(i);
    4142       // homogenise the ideal i with the first not yet 
    4143       // used variable in our ring, since gfan 
    4144       // only handles homogenous ideals; in principle 
     4142      // homogenise the ideal i with the first not yet
     4143      // used variable in our ring, since gfan
     4144      // only handles homogenous ideals; in principle
    41454145      // for this one has first to compute a
    4146       // standard basis of i and homogenise that, 
    4147       // but for the tropical variety (says Anders) 
     4146      // standard basis of i and homogenise that,
     4147      // but for the tropical variety (says Anders)
    41484148      // it suffices to homogenise an arbitrary system of generators
    4149       // i=groebner(i); 
     4149      // i=groebner(i);
    41504150      i=homog(i,maxideal(1)[nvars(PREGFANRING)+1]);
    41514151      // if gfan version >= 0.3.0 is used and the characteristic
     
    41594159        write(":a /tmp/gfaninput","{"+string(i)+"}");
    41604160      }
    4161       else 
     4161      else
    41624162      {
    41634163        // write the ideal to a file which gfan takes as input and call gfan
     
    41804180        string trop=read("/tmp/gfanoutput");
    41814181        setring PREGFANRING;
    4182         intvec wneu=-1;    // this integer vector will store 
     4182        intvec wneu=-1;    // this integer vector will store
    41834183                           // the point on the tropical variety
    41844184        wneu[nvars(basering)]=0;
     
    41934193        "IF YOU WANT wneu TO BE TESTED, THEN SET goon=0;";
    41944194        ~
    4195           // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE 
     4195          // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE
    41964196          // TROPICAL PREVARIETY
    4197           // test, if wneu really is in the tropical variety   
     4197          // test, if wneu really is in the tropical variety
    41984198        while (goon==0)
    41994199        {
     
    42124212      {
    42134213        system("sh","gfan_tropicallifting -n "+string(anzahlvariablen)+" --noMult -c < /tmp/gfaninput > /tmp/gfanoutput");
    4214         // read the result from gfan and store it to a string, 
     4214        // read the result from gfan and store it to a string,
    42154215        // which in a later version
    42164216        // should be interpreded by Singular
     
    42254225    }
    42264226  }
    4227   // if we have not yet computed our parametrisation 
     4227  // if we have not yet computed our parametrisation
    42284228  // up to the required order and
    4229   // zero is not yet a solution, then we have 
     4229  // zero is not yet a solution, then we have
    42304230  // to go on by calling the procedure recursively;
    42314231  // if all variables were deleted, then i=0 and thus anzahlvariablen==0
    42324232  if ((ordnung>1) and (anzahlvariablen>1))
    4233   {   
    4234     // we call the procedure with the transformed ideal i, 
     4233  {
     4234    // we call the procedure with the transformed ideal i,
    42354235    // the new weight vector, with the
    4236     // required order lowered by one, and with 
     4236    // required order lowered by one, and with
    42374237    // additional parameters, namely the number of
    4238     // true variables and the maximal ideal that 
     4238    // true variables and the maximal ideal that
    42394239    // was computed so far to describe the field extension
    42404240    list PARALIST=tropicalparametriseNoabs(i,wneu,ordnung-1,gfanold,nogfan,anzahlvariablen,gesamt_m);
    4241     // the output will be a ring, in which the 
     4241    // the output will be a ring, in which the
    42424242    // parametrisation lives, and a string, which contains
    42434243    // the maximal ideal that describes the necessary field extension
     
    42464246    string PARAm=PARALIST[3];
    42474247    setring PARARing;
    4248     // if some variables have been eliminated in before, 
    4249     // then we have to insert zeros 
     4248    // if some variables have been eliminated in before,
     4249    // then we have to insert zeros
    42504250    // into the parametrisation for those variables
    42514251    if (numberdeletedvariables>0)
     
    42534253      ideal PARAneu=PARA;
    42544254      int k;
    4255       for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++) // t admits 
     4255      for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++) // t admits
    42564256      { // no parametrisation
    42574257        if (deletedvariables[jj]!=1)
     
    42674267    }
    42684268  }
    4269   // otherwise we are done and we can start to compute 
     4269  // otherwise we are done and we can start to compute
    42704270  // the last step of the parametrisation
    42714271  else
     
    42734273    // we store the information on m in a string
    42744274    string PARAm=string(gesamt_m);
    4275     // we define the weight of t, i.e. in the parametrisation t 
     4275    // we define the weight of t, i.e. in the parametrisation t
    42764276    // has to be replaced by t^1/tweight
    42774277    int tweight=-tw[1];
    4278     // if additional variables were necessary, 
     4278    // if additional variables were necessary,
    42794279    // we introduce them now as parameters;
    4280     // in any case the parametrisation ring will 
    4281     // have only one variable, namely t, 
    4282     // and its order will be local, so that it 
     4280    // in any case the parametrisation ring will
     4281    // have only one variable, namely t,
     4282    // and its order will be local, so that it
    42834283    // displays the lowest term in t first
    42844284    if (anzahlvariablen+numberdeletedvariables<nvars(basering))
     
    42914291    }
    42924292    ideal PARA; // will contain the parametrisation
    4293     // we start by initialising the entries to be zero; 
     4293    // we start by initialising the entries to be zero;
    42944294    // one entry for each true variable
    4295     // here we also have to consider the variables 
     4295    // here we also have to consider the variables
    42964296    // that we have eliminated in before
    42974297    for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++)
     
    43004300    }
    43014301  }
    4302   // we now have to change the parametrisation by 
     4302  // we now have to change the parametrisation by
    43034303  // reverting the transformations that we have done
    43044304  list a=imap(BASERING,a);
    4305   if (defined(wneu)==0) // when tropicalparametriseNoabs is called for the 
    4306   { // last time, it does not enter the part, where wneu is defined and the 
     4305  if (defined(wneu)==0) // when tropicalparametriseNoabs is called for the
     4306  { // last time, it does not enter the part, where wneu is defined and the
    43074307    intvec wneu=-1;     // variable t should have weight -1
    43084308  }
     
    43114311    PARA[jj]=(PARA[jj]+a[jj+1])*t^(tw[jj+1]*tweight/ww[1]);
    43124312  }
    4313   // if we have reached the stop-level, i.e. either 
     4313  // if we have reached the stop-level, i.e. either
    43144314  // we had only to compute up to order 1
    4315   // or zero was a solution of the ideal, then we have 
     4315  // or zero was a solution of the ideal, then we have
    43164316  // to export the computed parametrisation
    43174317  // otherwise it has already been exported before
    43184318  // note, if all variables were deleted, then i==0 and thus testaufnull==0
    43194319  if ((ordnung==1) or (anzahlvariablen==1))
    4320   {   
     4320  {
    43214321    export(PARA);
    43224322  }
    43234323  // kill the gfan files in /tmp
    4324   system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput"); 
    4325   // we return a list which contains the 
     4324  system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput");
     4325  // we return a list which contains the
    43264326  // parametrisation ring (with the parametrisation ideal)
    4327   // and the string representing the maximal ideal 
     4327  // and the string representing the maximal ideal
    43284328  // describing the necessary field extension
    43294329  return(list(PARARing,tweight,PARAm));
     
    43344334static proc findzeros (ideal i,intvec w,list #)
    43354335"USAGE:      findzeros(i,w[,#]); i ideal, w intvec, # an optional list
    4336 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_n+1,...,X_m] and 
     4336ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_n+1,...,X_m] and
    43374337             w=(w_0,...,w_n,0,...,0) is in the tropical variety of i
    4338 RETURN:      list, l[1] = is polynomial ring containing an associated maximal 
    4339                           ideal m of the w-initial ideal of i which does not 
     4338RETURN:      list, l[1] = is polynomial ring containing an associated maximal
     4339                          ideal m of the w-initial ideal of i which does not
    43404340                          contain any monomial and where the variables
    4341                           which do not lead to a field extension have already 
    4342                           been eliminated, and containing a list a such that 
    4343                           the non-zero entries of a correspond to the values 
     4341                          which do not lead to a field extension have already
     4342                          been eliminated, and containing a list a such that
     4343                          the non-zero entries of a correspond to the values
    43444344                          of the zero of the associated maximal ideal for the
    43454345                          eliminated variables
    43464346                   l[2] = number of variables which have not been eliminated
    4347                    l[3] = intvec, if the entry is one then the corresponding 
     4347                   l[3] = intvec, if the entry is one then the corresponding
    43484348                                  variable has not been eliminated
    4349 NOTE:        the procedure is called from inside the recursive procedure 
     4349NOTE:        the procedure is called from inside the recursive procedure
    43504350             tropicalparametriseNoabs;
    4351              if it is called in the first recursion, the list #[1] contains 
    4352              the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer, 
     4351             if it is called in the first recursion, the list #[1] contains
     4352             the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer,
    43534353             one more than the number of true variables x_1,...,x_n"
    43544354{
    4355   def BASERING=basering; 
     4355  def BASERING=basering;
    43564356  // set anzahlvariablen to the number of true variables
    43574357  if (typeof(#[1])=="int")
     
    43594359    int anzahlvariablen=#[1];
    43604360    // compute the initial ideal of i
    4361     // - the last 1 just means that the variable t is the last 
     4361    // - the last 1 just means that the variable t is the last
    43624362    //   variable in the ring
    43634363    ideal ini=tInitialIdeal(i,w,1);
     
    43664366  {
    43674367    int anzahlvariablen=nvars(basering);
    4368     ideal ini=#[1]; // the t-initial ideal has been computed 
     4368    ideal ini=#[1]; // the t-initial ideal has been computed
    43694369                    // in before and was handed over
    43704370  }
    4371   // move to a polynomial ring with global monomial ordering 
     4371  // move to a polynomial ring with global monomial ordering
    43724372  // - the variable t is superflous
    43734373  ideal variablen;
    43744374  for (int j=1;j<=nvars(basering)-1;j++)
    4375   {   
     4375  {
    43764376    variablen=variablen+var(j);
    43774377  }
     
    43794379  ideal ini=imap(BASERING,ini);
    43804380  // compute the associated primes of the initialideal
    4381   // ordering the maximal ideals shall help to avoid 
     4381  // ordering the maximal ideals shall help to avoid
    43824382  // unneccessary field extensions
    43834383  list maximalideals=ordermaximalidealsNoabs(minAssGTZ(std(ini)),anzahlvariablen);
    43844384  ideal m=maximalideals[1][1];              // the first associated maximal ideal
    43854385  int neuvar=maximalideals[1][2];           // the number of new variables needed
    4386   intvec neuevariablen=maximalideals[1][3]; // the information which variable 
     4386  intvec neuevariablen=maximalideals[1][3]; // the information which variable
    43874387                                            // leads to a new one
    4388   list a=maximalideals[1][4];               // a_k is the kth component of a 
     4388  list a=maximalideals[1][4];               // a_k is the kth component of a
    43894389                                            // zero of m, if it is not zero
    4390   // eliminate from m the superflous variables, that is those ones, 
     4390  // eliminate from m the superflous variables, that is those ones,
    43914391  // which do not lead to a new variable
    43924392  poly elimvars=1;
     
    43984398    }
    43994399  }
    4400   m=eliminate(m,elimvars); 
    4401   export(a); 
     4400  m=eliminate(m,elimvars);
     4401  export(a);
    44024402  export(m);
    44034403  list m_ring=INITIALRING,neuvar,neuevariablen;
     
    44114411static proc basictransformideal (ideal i,intvec w,list m_ring,list #)
    44124412"USAGE:  basictransformideal(i,w,m_ring[,#]); i ideal, w intvec, m_ring list, # an optional list
    4413 ASSUME:  i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], 
    4414          w=(w_0,...,w_n,0,...,0) is in the tropical variety of i, and 
     4413ASSUME:  i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k],
     4414         w=(w_0,...,w_n,0,...,0) is in the tropical variety of i, and
    44154415         m_ring contains a ring containing a maximal ideal m needed
    4416          to describe the field extension over which a corresponding 
    4417          associated maximal ideal of the initialideal of i, considered 
    4418          in (Q[X_1,...,X_k]/m_alt)(t)[x_1,...,x_n], has a zero, and 
     4416         to describe the field extension over which a corresponding
     4417         associated maximal ideal of the initialideal of i, considered
     4418         in (Q[X_1,...,X_k]/m_alt)(t)[x_1,...,x_n], has a zero, and
    44194419         containing a list a describing the zero of m, and m_ring contains
    44204420         the information how many new variables are needed for m
     
    44234423                      l[3] = ideal, the maximal ideal m
    44244424               or l[1] = ring which contains the ideals i and m, and the list a
    4425 NOTE:    the procedure is called from inside the recursive procedure 
     4425NOTE:    the procedure is called from inside the recursive procedure
    44264426         tropicalparametriseNoabs;
    4427          if it is called in the first recursion, the list # is empty, 
     4427         if it is called in the first recursion, the list # is empty,
    44284428         otherwise #[1] is an integer, the number of true variables x_1,...,x_n;
    4429          during the procedure we check if a field extension is necessary 
    4430          to express a zero (a_1,...,a_n) of m; if so, we have to introduce 
    4431          new variables and a list containing a ring is returned, otherwise 
    4432          the list containing i, a and m is returned; 
    4433          the ideal m will be changed during the procedure since all variables 
     4429         during the procedure we check if a field extension is necessary
     4430         to express a zero (a_1,...,a_n) of m; if so, we have to introduce
     4431         new variables and a list containing a ring is returned, otherwise
     4432         the list containing i, a and m is returned;
     4433         the ideal m will be changed during the procedure since all variables
    44344434         which reduce to a polynomial in X_1,...,X_k modulo m will be eliminated,
    44354435         while the others are replaced by new variables X_k+1,...,X_k'"
     
    44434443    wdegs[j]=deg(i[j],intvec(w[2..size(w)],w[1]));
    44444444  }
    4445   // how many variables are true variables, 
     4445  // how many variables are true variables,
    44464446  // and how many come from the field extension
    44474447  // only real variables have to be transformed
     
    44584458  // get the information if any new variables are needed from m_ring
    44594459  int neuvar=m_ring[2];  // number of variables which have to be added
    4460   intvec neuevariablen=m_ring[3];  // [i]=1, if for the ith comp. 
     4460  intvec neuevariablen=m_ring[3];  // [i]=1, if for the ith comp.
    44614461                                   // of a zero of m a new variable is needed
    44624462  def MRING=m_ring[1];   // MRING contains a and m
    4463   list a=imap(MRING,a);  // (a_1,...,a_n)=(a[2],...,a[n+1]) will be 
     4463  list a=imap(MRING,a);  // (a_1,...,a_n)=(a[2],...,a[n+1]) will be
    44644464                         // a common zero of the ideal m
    4465   ideal m=std(imap(MRING,m)); // m is zero, if neuvar==0, 
     4465  ideal m=std(imap(MRING,m)); // m is zero, if neuvar==0,
    44664466                              // otherwise we change the ring anyway
    4467   // if a field extension is needed, then extend the polynomial 
     4467  // if a field extension is needed, then extend the polynomial
    44684468  // ring by new variables X_k+1,...,X_k';
    44694469  if (neuvar>0)
    44704470  {
    4471     // change to a ring where for each variable needed 
     4471    // change to a ring where for each variable needed
    44724472    // in m a new variable has been introduced
    44734473    ideal variablen;
     
    44804480    // map i into the new ring
    44814481    ideal i=imap(BASERING,i);
    4482     // define a map phi which maps the true variables, which are not 
     4482    // define a map phi which maps the true variables, which are not
    44834483    // reduced to polynomials in the additional variables modulo m, to
    4484     // the corresponding newly introduced variables, and which maps 
     4484    // the corresponding newly introduced variables, and which maps
    44854485    // the old additional variables to themselves
    44864486    ideal phiideal;
    44874487    k=1;
    4488     for (j=2;j<=size(neuevariablen);j++)  // starting with 2, since the 
     4488    for (j=2;j<=size(neuevariablen);j++)  // starting with 2, since the
    44894489    { // first entry corresponds to t
    44904490      if(neuevariablen[j]==1)
     
    44954495      else
    44964496      {
    4497         phiideal[j-1]=0; 
     4497        phiideal[j-1]=0;
    44984498      }
    44994499    }
     
    45024502      phiideal=phiideal,X(1..nvars(BASERING)-anzahlvariablen);
    45034503    }
    4504     map phi=MRING,phiideal; 
    4505     // map m and a to the new ring via phi, so that the true variables 
     4504    map phi=MRING,phiideal;
     4505    // map m and a to the new ring via phi, so that the true variables
    45064506    // in m and a are replaced by
    45074507    // the corresponding newly introduced variables
     
    45094509    list a=phi(a);
    45104510  }
    4511   // replace now the zeros among the a_j by the corresponding 
     4511  // replace now the zeros among the a_j by the corresponding
    45124512  // newly introduced variables;
    4513   // note that no component of a can be zero 
     4513  // note that no component of a can be zero
    45144514  // since the maximal ideal m contains no variable!
    4515   // moreover, substitute right away in the ideal i 
     4515  // moreover, substitute right away in the ideal i
    45164516  // the true variable x_j by (a_j+x_j)*t^w_j
    45174517  zaehler=nvars(BASERING)-anzahlvariablen+1;
    4518   for (j=1;j<=anzahlvariablen;j++) 
     4518  for (j=1;j<=anzahlvariablen;j++)
    45194519  {
    45204520    if ((a[j]==0) and (j!=1))  // a[1]=0, since t->t^w_0
    4521     {       
     4521    {
    45224522      a[j]=X(zaehler);
    45234523      zaehler++;
     
    45264526    {
    45274527      if (j!=1) // corresponds to  x_(j-1) --  note t is the last variable
    4528       {       
     4528      {
    45294529        i[k]=substitute(i[k],var(j-1),(a[j]+var(j-1))*t^(-w[j]));
    45304530      }
     
    45384538  for (j=1;j<=ncols(i);j++)
    45394539  {
    4540     if (wdegs[j]<0) // if wdegs[j]==0 there is no need to divide, and 
     4540    if (wdegs[j]<0) // if wdegs[j]==0 there is no need to divide, and
    45414541    { // we made sure that it is no positive
    45424542      i[j]=i[j]/t^(-wdegs[j]);
    45434543    }
    45444544  }
    4545   // since we want to consider i now in the ring 
     4545  // since we want to consider i now in the ring
    45464546  // (Q[X_1,...,X_k']/m)[t,x_1,...,x_n]
    4547   // we can  reduce i modulo m, so that "constant terms" 
     4547  // we can  reduce i modulo m, so that "constant terms"
    45484548  // which are "zero" since they
    45494549  // are in m will disappear; simplify(...,2) then really removes them
    45504550  i=simplify(reduce(i,m),2);
    4551   // if new variables have been introduced, we have 
     4551  // if new variables have been introduced, we have
    45524552  // to return the ring containing i, a and m
    45534553  // otherwise we can simply return a list containing i, a and m
     
    45704570static proc testw (ideal i,intvec w,int anzahlvariablen,list #)
    45714571"USAGE:      testw(i,w,n); i ideal, w intvec, n number
    4572 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k] and 
    4573              w=(w_0,...,w_n,0,...,0)           
    4574 RETURN:      int b, 0 if the t-initial ideal of i considered in 
     4572ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k] and
     4573             w=(w_0,...,w_n,0,...,0)
     4574RETURN:      int b, 0 if the t-initial ideal of i considered in
    45754575                    Q(X_1,...,X_k)[t,x_1,...,x_n] is monomial free, 1 else
    45764576NOTE:        the procedure is called by tinitialform"
     
    45864586    ideal tin=tInitialIdeal(i,w,1);
    45874587  }
    4588  
     4588
    45894589  int j;
    45904590  ideal variablen;
     
    46184618  def BASERING=basering;
    46194619  if (anzahlvariablen<nvars(basering))
    4620   {   
     4620  {
    46214621    execute("ring TINRING=("+charstr(basering)+","+string(Parameter)+"),("+string(variablen)+"),dp;");
    46224622  }
     
    46284628  poly monom=imap(BASERING,monom);
    46294629  return(radicalMemberShip(monom,tin));
    4630 } 
     4630}
    46314631
    46324632/////////////////////////////////////////////////////////////////////////
     
    46344634static proc simplifyToOrder (poly f)
    46354635"USAGE:      simplifyToOrder(f); f a polynomial
    4636 ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n] 
     4636ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n]
    46374637RETURN:      list, l[1] = t-order of leading term of f
    46384638                   l[2] = the rational coefficient of the term of lowest t-order
     
    46574657static proc scalarproduct (intvec w,intvec v)
    46584658"USAGE:      scalarproduct(w,v); w,v intvec
    4659 ASSUME:      w and v are integer vectors of the same length 
     4659ASSUME:      w and v are integer vectors of the same length
    46604660RETURN:      int, the scalarproduct of v and w
    46614661NOTE:        the procedure is called by tropicalparametriseNoabs"
     
    47154715"USAGE:      ordermaximalidealsNoabs(minassi); minassi list
    47164716ASSUME:      minassi is a list of maximal ideals
    4717 RETURN:      list, the procedure orders the maximal ideals in minassi according 
    4718                    to how many new variables are needed to describe the zeros 
     4717RETURN:      list, the procedure orders the maximal ideals in minassi according
     4718                   to how many new variables are needed to describe the zeros
    47194719                   of the ideal
    47204720                   l[j][1] = jth maximal ideal
    47214721                   l[j][2] = the number of variables needed
    4722                    l[j][3] = intvec, if for the kth variable a new variable is 
    4723                                      needed to define the corresponding zero of 
     4722                   l[j][3] = intvec, if for the kth variable a new variable is
     4723                                     needed to define the corresponding zero of
    47244724                                     l[j][1], then the k+1st entry is one
    4725                    l[j][4] = list, if for the kth variable no new variable is 
    4726                                    needed to define the corresponding zero of 
     4725                   l[j][4] = list, if for the kth variable no new variable is
     4726                                   needed to define the corresponding zero of
    47274727                                   l[j][1], then its value is the k+1st entry
    47284728NOTE:        if a maximal ideal contains a variable, it is removed from the list;
     
    47334733  int pruefer;       // is set one if a maximal ideal contains a variable
    47344734  list minassisort;  // will contain the output
    4735   for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort 
     4735  for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort
    47364736                                                    // to fix its initial length
    47374737  list zwischen;     // needed for reordering
    47384738  list a;// (a_1,...,a_n)=(a[2],...,a[n+1]) will be a common zero of the ideal m
    47394739  poly nf;           // normalform of a variable w.r.t. m
    4740   intvec neuevariablen; // ith entry is 1, if for the ith component of a zero 
     4740  intvec neuevariablen; // ith entry is 1, if for the ith component of a zero
    47414741                        // of m a new variable is needed
    47424742  intvec testvariablen; // integer vector of length n=number of variables
    4743   // compute for each maximal ideal the number of new variables, 
     4743  // compute for each maximal ideal the number of new variables,
    47444744  // which are needed to describe
    4745   // its zeros -- note, a new variable is needed if modulo 
    4746   // the maximal ideal it does not reduce 
     4745  // its zeros -- note, a new variable is needed if modulo
     4746  // the maximal ideal it does not reduce
    47474747  // to something which only depends on the following variables;
    4748   // if no new variable is needed, then store the value 
    4749   // a variable reduces to in the list a; 
     4748  // if no new variable is needed, then store the value
     4749  // a variable reduces to in the list a;
    47504750  for (j=size(minassi);j>=1;j--)
    47514751  {
    4752     a[1]=poly(0);         // the first entry in a and in neuevariablen 
     4752    a[1]=poly(0);         // the first entry in a and in neuevariablen
    47534753                          // corresponds to the variable t,
    47544754    neuevariablen[1]=0;   // which is not present in the INITIALRING
     
    47584758    {
    47594759      nf=reduce(var(k),minassi[j]);
    4760       // if a variable reduces to zero, then the maximal ideal 
     4760      // if a variable reduces to zero, then the maximal ideal
    47614761      // contains a variable and we can delete it
    47624762      if (nf==0)
     
    47644764        pruefer=1;
    47654765      }
    4766       // set the entries of testvariablen corresponding to the first 
     4766      // set the entries of testvariablen corresponding to the first
    47674767      // k variables to 1, and the others to 0
    47684768      for (l=1;l<=nvars(basering);l++)
    47694769      {
    47704770        if (l<=k)
    4771         {         
     4771        {
    47724772          testvariablen[l]=1;
    47734773        }
     
    47774777        }
    47784778      }
    4779       // if the variable x_j reduces to a polynomial 
     4779      // if the variable x_j reduces to a polynomial
    47804780      // in x_j+1,...,x_n,X_1,...,X_k modulo m
    4781       // then we can eliminate x_j from the maximal ideal 
     4781      // then we can eliminate x_j from the maximal ideal
    47824782      // (since we do not need any
    4783       // further field extension to express a_j) and a_j 
     4783      // further field extension to express a_j) and a_j
    47844784      // will just be this normalform,
    47854785      // otherwise we have to introduce a new variable in order to express a_j;
     
    47884788        a[k+1]=nf; // a_k is the normal form of the kth variable modulo m
    47894789        neuevariablen[k+1]=0;  // no new variable is needed
    4790       }   
     4790      }
    47914791      else
    47924792      {
    4793         a[k+1]=poly(0); // a_k is set to zero until we have 
     4793        a[k+1]=poly(0); // a_k is set to zero until we have
    47944794                        // introduced the new variable
    47954795        neuevariablen[k+1]=1;
     
    47994799    // if the maximal ideal contains a variable, we simply delete it
    48004800    if (pruefer==0)
    4801     {     
     4801    {
    48024802      minassisort[j]=list(minassi[j],neuvar,neuevariablen,a);
    48034803    }
    4804     // otherwise we store the information on a, 
     4804    // otherwise we store the information on a,
    48054805    // neuevariablen and neuvar together with the ideal
    48064806    else
     
    48114811    }
    48124812  }
    4813   // sort the maximal ideals ascendingly according to 
     4813  // sort the maximal ideals ascendingly according to
    48144814  // the number of new variables needed to
    48154815  // express the zero of the maximal ideal
     
    48184818    l=j;
    48194819    for (k=j-1;k>=1;k--)
    4820     {     
     4820    {
    48214821      if (minassisort[l][2]<minassisort[k][2])
    48224822      {
     
    48364836"USAGE:  displaypoly(p,N,wj,w1); p poly, N, wj, w1 int
    48374837ASSUME:  p is a polynomial in r=(0,X(1..k)),t,ls
    4838 RETURN:  string, the string of t^-wj/w1*p(t^1/N) 
     4838RETURN:  string, the string of t^-wj/w1*p(t^1/N)
    48394839NOTE:    the procedure is called from displayTropicalLifting"
    48404840{
     
    48544854  {
    48554855    if (koeffizienten[j-ord(p)+1]!=0)
    4856     {     
     4856    {
    48574857      if ((j-(N*wj)/w1)==0)
    48584858      {
     
    49044904static proc displaycoef (poly p)
    49054905"USAGE:      displaycoef(p); p poly
    4906 RETURN:      string, the string of p where brackets around 
     4906RETURN:      string, the string of p where brackets around
    49074907                     have been added if they were missing
    49084908NOTE:        the procedure is called from displaypoly"
     
    49764976static proc tropicalliftingresubstitute (ideal i,list liftring,int N,list #)
    49774977"USAGE:   tropicalliftingresubstitute(i,L,N[,#]); i ideal, L list, N int, # string
    4978 ASSUME:   i is an ideal and L[1] is a ring which contains the lifting of a 
    4979           point in the tropical variety of i computed with tropicalLifting; 
    4980           t has to be replaced by t^1/N in the lifting; #[1]=m is the string 
    4981           of the maximal ideal defining the necessary field extension as 
     4978ASSUME:   i is an ideal and L[1] is a ring which contains the lifting of a
     4979          point in the tropical variety of i computed with tropicalLifting;
     4980          t has to be replaced by t^1/N in the lifting; #[1]=m is the string
     4981          of the maximal ideal defining the necessary field extension as
    49824982          computed by tropicalLifting, if #[1] is present
    49834983RETURN:   string, the lifting has been substituted into i
     
    50025002      ideal i=imap(BASERING,i);
    50035003    }
    5004   } 
     5004  }
    50055005  else
    50065006  {
     
    50155015  }
    50165016  // map the resulting i back to LIFTRing;
    5017   // if noAbs, then reduce i modulo the maximal ideal 
     5017  // if noAbs, then reduce i modulo the maximal ideal
    50185018  // before going back to LIFTRing
    50195019  if ((size(parstr(LIFTRing))!=0) and size(#)>0)
     
    50325032  for (j=1;j<=ncols(i);j++)
    50335033  {
    5034     SUBSTTEST[j]=displaypoly(i[j],N,0,1); 
     5034    SUBSTTEST[j]=displaypoly(i[j],N,0,1);
    50355035  }
    50365036  return(SUBSTTEST);
     
    50425042/// - eliminatecomponents
    50435043/// - findzerosAndBasictransform
    5044 /// - ordermaximalideals 
     5044/// - ordermaximalideals
    50455045///////////////////////////////////////////////////////////////////////////////
    50465046
    50475047static proc tropicalparametrise (ideal i,intvec ww,int ordnung,int gfanold,int findall,int nogfan,list #)
    50485048"USAGE:  tropicalparametrise(i,tw,ord,gf,fa,ng[,#]); i ideal, tw intvec, ord int, gf,fa,ng int, # opt. list
    5049 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,@a], tw=(w_0,w_1,...,w_n,0) 
    5050            and (w_0,...,w_n,0) is in the tropical variety of i, 
    5051            and ord is the order up to which a point in V(i) 
    5052            over K{{t}} lying over w shall be computed; 
    5053          - moreover, @a should be not be there if the procedure is not 
     5049ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,@a], tw=(w_0,w_1,...,w_n,0)
     5050           and (w_0,...,w_n,0) is in the tropical variety of i,
     5051           and ord is the order up to which a point in V(i)
     5052           over K{{t}} lying over w shall be computed;
     5053         - moreover, @a should be not be there if the procedure is not
    50545054           called recursively;
    50555055         - the point in the tropical variety is supposed to lie in the
    50565056           NEGATIVE orthant;
    5057          - the ideal is zero-dimensional when considered in 
    5058            (K(t)[@a]/m)[x_1,...,x_n], where m=#[2] is a maximal ideal in K[@a]; 
     5057         - the ideal is zero-dimensional when considered in
     5058           (K(t)[@a]/m)[x_1,...,x_n], where m=#[2] is a maximal ideal in K[@a];
    50595059         - gf is 0 if version 2.2 or larger is used and it is 1 else
    50605060         - fa is 1 if all solutions should be found
     
    50635063               l[2] = int
    50645064NOTE:    - the procedure is also called recursively by itself, and
    5065            if it is called in the first recursion, the list # is empty, 
    5066            otherwise #[1] is an integer, one more than the number of 
    5067            true variables x_1,...,x_n, and #[2] will contain the maximal 
    5068            ideal m in the variable @a by which the ring K[t,x_1,...,x_n,@a] 
    5069            should be divided to work correctly in L[t,x_1,...,x_n] where 
     5065           if it is called in the first recursion, the list # is empty,
     5066           otherwise #[1] is an integer, one more than the number of
     5067           true variables x_1,...,x_n, and #[2] will contain the maximal
     5068           ideal m in the variable @a by which the ring K[t,x_1,...,x_n,@a]
     5069           should be divided to work correctly in L[t,x_1,...,x_n] where
    50705070           L=Q[@a]/m is a field extension of K
    5071          - the ring l[1] contains an ideal PARA, which contains the 
    5072            parametrisation of a point in V(i) lying over w up to the first 
     5071         - the ring l[1] contains an ideal PARA, which contains the
     5072           parametrisation of a point in V(i) lying over w up to the first
    50735073           ord terms;
    5074          - the string m contains the code of the maximal ideal m, by which we 
     5074         - the string m contains the code of the maximal ideal m, by which we
    50755075           have to divide K[@a] in order to have the appropriate field extension
    50765076           over which the parametrisation lives;
    50775077         - and if the integer l[3] is N then t has to be replaced by t^1/N in the
    5078            parametrisation, or alternatively replace t by t^N in the defining 
     5078           parametrisation, or alternatively replace t by t^N in the defining
    50795079           ideal
    5080          - the procedure REQUIRES that the program GFAN is installed 
     5080         - the procedure REQUIRES that the program GFAN is installed
    50815081           on your computer"
    50825082{
     
    50845084  int recursively; // is set 1 if the procedure is called recursively by itself
    50855085  int ii,jj,kk,ll,jjj,kkk,lll;
    5086   if (typeof(#[1])=="int") // this means the precedure has been 
     5086  if (typeof(#[1])=="int") // this means the precedure has been
    50875087  { // called recursively
    5088     // how many variables are true variables, and how many come 
     5088    // how many variables are true variables, and how many come
    50895089    // from the field extension
    50905090    // only true variables have to be transformed
    50915091    int anzahlvariablen=#[1];
    50925092    // find the zeros of the w-initial ideal and transform the ideal i;
    5093     // findzeros and basictransformideal need to know 
     5093    // findzeros and basictransformideal need to know
    50945094    // how many of the variables are true variables
    50955095    // and do the basic transformation as well
     
    50995099  else // the procedure has been called by tropicalLifting
    51005100  {
    5101     // how many variables are true variables, and 
     5101    // how many variables are true variables, and
    51025102    // how many come from the field extension
    51035103    // only true variables have to be transformed
    51045104    int anzahlvariablen=nvars(basering);
    5105     list zerolist; // will carry the zeros which are 
    5106     //computed in the recursion steps   
     5105    list zerolist; // will carry the zeros which are
     5106    //computed in the recursion steps
    51075107    // the initial ideal of i has been handed over as #[1]
    51085108    ideal ini=#[1];
    51095109    // find the zeros of the w-initial ideal and transform the ideal i;
    5110     // we should hand the t-initial ideal ine to findzeros, 
     5110    // we should hand the t-initial ideal ine to findzeros,
    51115111    // since we know it already;
    51125112    // and do the basic transformation as well
     
    51145114  }
    51155115  list wneulist; // carries all newly computed weight vector
    5116   intvec wneu;   // carries the newly computed weight vector 
     5116  intvec wneu;   // carries the newly computed weight vector
    51175117  int tweight;   // carries the weight of t
    5118   list PARALIST; // carries the result when tropicalparametrise 
     5118  list PARALIST; // carries the result when tropicalparametrise
    51195119                 // is recursively called
    51205120  list eliminaterings;     // carries the result of eliminatecomponents
     
    51255125  list liftings,partliftings;  // the computed liftings (all resp. partly)
    51265126  // consider each ring which has been returned when computing the zeros of the
    5127   // the t-initial ideal, equivalently, consider 
     5127  // the t-initial ideal, equivalently, consider
    51285128  // each zero which has been returned
    51295129  for (jj=1;jj<=size(trring);jj++)
     
    51315131    def TRRING=trring[jj];
    51325132    setring TRRING;
    5133     // check if a certain number of components lead to suitable 
     5133    // check if a certain number of components lead to suitable
    51345134    // solutions with zero components;
    51355135    // compute them all if findall==1
    51365136    eliminaterings=eliminatecomponents(i,m,oldanzahlvariablen,findall,oldanzahlvariablen-1,deletedvariables);
    5137     // consider each of the rings returned by eliminaterings ... 
     5137    // consider each of the rings returned by eliminaterings ...
    51385138    // there is at least one !!!
    51395139    for (ii=1;ii<=size(eliminaterings);ii++)
    51405140    {
    51415141      // #variables which have been eliminated
    5142       numberdeletedvariables=oldanzahlvariablen-eliminaterings[ii][2]; 
     5142      numberdeletedvariables=oldanzahlvariablen-eliminaterings[ii][2];
    51435143      // #true variables which remain (including t)
    5144       anzahlvariablen=eliminaterings[ii][2]; 
     5144      anzahlvariablen=eliminaterings[ii][2];
    51455145      // a 1 in this vector says that variable was eliminated
    5146       deletedvariables=eliminaterings[ii][3]; 
     5146      deletedvariables=eliminaterings[ii][3];
    51475147      setring TRRING; // set TRRING - this is important for the loop
    51485148      // pass the ring computed by eliminatecomponents
    5149       def PREGFANRING=eliminaterings[ii][1]; 
     5149      def PREGFANRING=eliminaterings[ii][1];
    51505150      setring PREGFANRING;
    51515151      poly m=imap(TRRING,m);        // map the maximal ideal to this ring
    51525152      list zero=imap(TRRING,zero);  // map the vector of zeros to this ring
    5153       // now we have to compute a point ww on the tropical 
     5153      // now we have to compute a point ww on the tropical
    51545154      // variety of the transformed ideal i;
    5155       // of course, we only have to do so, if we have 
     5155      // of course, we only have to do so, if we have
    51565156      // not yet reached the order up to which we
    51575157      // were supposed to do our computations
    5158       if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains, 
     5158      if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains,
    51595159      { // all true variables are gone
    51605160        if (nogfan!=1)
    5161         {         
     5161        {
    51625162          // pass to a ring which has variables which are suitable for gfan
    51635163          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;");
    5164           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; 
     5164          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;
    51655165          phiideal[nvars(PREGFANRING)]=a; // map t to a
    5166           map phi=PREGFANRING,phiideal; 
     5166          map phi=PREGFANRING,phiideal;
    51675167          ideal II=phi(i);
    5168           // homogenise the ideal II with the first not yet 
    5169           // used variable in our ring, since gfan 
    5170           // only handles homogenous ideals; in principle for this 
     5168          // homogenise the ideal II with the first not yet
     5169          // used variable in our ring, since gfan
     5170          // only handles homogenous ideals; in principle for this
    51715171          // one has first to compute a
    5172           // standard basis of II and homogenise that, 
    5173           // but for the tropical variety (says Anders) 
     5172          // standard basis of II and homogenise that,
     5173          // but for the tropical variety (says Anders)
    51745174          // it suffices to homogenise an arbitrary system of generators
    5175           // II=groebner(II); 
     5175          // II=groebner(II);
    51765176          II=homog(II,maxideal(1)[nvars(PREGFANRING)+1]);
    51775177          // if gfan version >= 0.3.0 is used and the characteristic
     
    52115211            int goon=1;
    52125212            trop;
    5213             "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY"; 
     5213            "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY";
    52145214            "NON-POSITIVE ENTRIES AND STARTS WITH A NEGATIVE ONE,";
    52155215            "E.G. (-3,-4,-1,-5,0,0,0) - the last entry will always be 0 -";
     
    52185218            "IF YOU WANT wneu TO BE TESTED, THEN SET goon=0;";
    52195219            ~
    5220             // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY 
     5220            // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY
    52215221            // THE TROPICAL PREVARIETY
    5222             // test, if wneu really is in the tropical variety   
     5222            // test, if wneu really is in the tropical variety
    52235223            while (goon==0)
    52245224            {
     
    52385238          {
    52395239            system("sh","gfan_tropicallifting -n "+string(anzahlvariablen)+" --noMult -c < /tmp/gfaninput > /tmp/gfanoutput");
    5240             // read the result from gfan and store it to a string, 
     5240            // read the result from gfan and store it to a string,
    52415241            // which in a later version
    52425242            // should be interpreded by Singular
     
    52615261        }
    52625262      }
    5263       // if we have not yet computed our parametrisation up to 
     5263      // if we have not yet computed our parametrisation up to
    52645264      // the required order and
    5265       // zero is not yet a solution, then we have to go on 
     5265      // zero is not yet a solution, then we have to go on
    52665266      // by calling the procedure recursively;
    52675267      // if all variables were deleted, then i=0 and thus anzahlvariablen==0
    52685268      lll=0;
    52695269      if ((ordnung>1) and (anzahlvariablen>1))
    5270       { 
     5270      {
    52715271        partliftings=list(); // initialise partliftings
    5272         // we call the procedure with the transformed 
     5272        // we call the procedure with the transformed
    52735273        // ideal i, the new weight vector, with the
    5274         // required order lowered by one, and with 
     5274        // required order lowered by one, and with
    52755275        // additional parameters, namely the number of
    5276         // true variables and the maximal ideal that 
     5276        // true variables and the maximal ideal that
    52775277        // was computed so far to describe the field extension
    52785278        for (kk=1;kk<=size(wneulist);kk++)
     
    52805280          wneu=wneulist[kk];
    52815281          PARALIST=tropicalparametrise(i,wneu,ordnung-1,gfanold,findall,nogfan,anzahlvariablen,zero);
    5282           // the output will be a ring, in which the 
     5282          // the output will be a ring, in which the
    52835283          // parametrisation lives, and a string, which contains
    52845284          // the maximal ideal that describes the necessary field extension
    52855285          for (ll=1;ll<=size(PARALIST);ll++)
    5286           { 
     5286          {
    52875287            def PARARing=PARALIST[ll][1];
    52885288            tweight=-ww[1]*PARALIST[ll][2];
    52895289            setring PARARing;
    5290             // if some variables have been eliminated 
    5291             // in before, then we have to insert zeros 
     5290            // if some variables have been eliminated
     5291            // in before, then we have to insert zeros
    52925292            // into the parametrisation for those variables
    52935293            if (numberdeletedvariables>0)
     
    52955295              ideal PARAneu=PARA;
    52965296              kkk=0;
    5297               for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++) 
     5297              for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++)
    52985298              { // t admits no parametrisation
    52995299                if (deletedvariables[jjj]!=1)
     
    53155315        }
    53165316      }
    5317       // otherwise we are done and we can start 
     5317      // otherwise we are done and we can start
    53185318      // to compute the last step of the parametrisation
    53195319      else
    53205320      {
    5321         // we define the weight of t, i.e. in the 
     5321        // we define the weight of t, i.e. in the
    53225322        // parametrisation t has to be replaced by t^1/tweight
    53235323        tweight=-ww[1];
    5324         // if additional variables were necessary, 
     5324        // if additional variables were necessary,
    53255325        // we introduce them now as parameters;
    5326         // in any case the parametrisation ring will 
    5327         // have only one variable, namely t, 
    5328         // and its order will be local, so that it 
     5326        // in any case the parametrisation ring will
     5327        // have only one variable, namely t,
     5328        // and its order will be local, so that it
    53295329        // displays the lowest term in t first
    53305330        if (anzahlvariablen<nvars(basering))
     
    53385338        }
    53395339        ideal PARA; // will contain the parametrisation
    5340         // we start by initialising the entries to be zero; 
     5340        // we start by initialising the entries to be zero;
    53415341        // one entry for each true variable
    5342         // here we also have to consider the variables 
     5342        // here we also have to consider the variables
    53435343        // that we have eliminated in before
    53445344        for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++)
     
    53525352        kill PARARing;
    53535353      }
    5354       // we now have to change the parametrisation by 
     5354      // we now have to change the parametrisation by
    53555355      // reverting the transformations that we have done
    53565356      for (lll=1;lll<=size(partliftings);lll++)
    53575357      {
    5358         if (size(partliftings[lll])==2) // when tropicalparametrise is called 
    5359         { // for the last time, it does not enter the part, where wneu is 
     5358        if (size(partliftings[lll])==2) // when tropicalparametrise is called
     5359        { // for the last time, it does not enter the part, where wneu is
    53605360          wneu=-1;     // defined and the variable t should have weight -1
    53615361        }
     
    53725372          PARA[jjj]=(PARA[jjj]+zeros[size(zeros)][jjj+1])*t^(ww[jjj+1]*tweight/ww[1]);
    53735373        }
    5374         // delete the last entry in zero, since that one has 
     5374        // delete the last entry in zero, since that one has
    53755375        // been used for the transformation
    53765376        zeros=delete(zeros,size(zeros));
    5377         // in order to avoid redefining commands an empty 
     5377        // in order to avoid redefining commands an empty
    53785378        // zeros list should be removed
    53795379        if (size(zeros)==0)
     
    53915391  }
    53925392  // kill the gfan files in /tmp
    5393   system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput"); 
    5394   // we return a list which contains lists of the parametrisation 
     5393  system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput");
     5394  // we return a list which contains lists of the parametrisation
    53955395  // rings (with the parametrisation ideal)
    53965396  // and an integer N such that t should be replaced by t^1/N
     
    54025402static proc eliminatecomponents (ideal i,ideal m,int anzahlvariablen,int findall,int lastvar,intvec deletedvariables)
    54035403"USAGE:  eliminatecomponents(i,m,n,a,v,d); i,m ideal, n,a,v int, d intvec
    5404 ASSUME:  i is an ideal in Q[x_1,...,x_n,@a,t] and w=(-w_1/w_0,...,-w_n/w_0) 
    5405          is in the tropical variety of i considered in 
    5406          Q[@a]/m{{t}}[x_1,...,x_n]; 
    5407          considered in this ring i is zero-dimensional; @a need not be present 
     5404ASSUME:  i is an ideal in Q[x_1,...,x_n,@a,t] and w=(-w_1/w_0,...,-w_n/w_0)
     5405         is in the tropical variety of i considered in
     5406         Q[@a]/m{{t}}[x_1,...,x_n];
     5407         considered in this ring i is zero-dimensional; @a need not be present
    54085408         in which case m is zero; 1<=v<=n
    54095409RETURN:  list, L of lists
     
    54115411               L[j][2] = an integer anzahlvariablen
    54125412               L[j][3] = an intvec deletedvariables
    5413 NOTE:    - the procedure is called from inside the recursive 
     5413NOTE:    - the procedure is called from inside the recursive
    54145414           procedure tropicalparametrise
    5415          - the procedure checks for solutions which have certain 
    5416            components zero; these are separated from the rest by 
    5417            elimination and saturation; the integer deletedvariables 
    5418            records which variables have been eliminated; 
    5419            the integer anzahlvariablen records how many true variables remain 
     5415         - the procedure checks for solutions which have certain
     5416           components zero; these are separated from the rest by
     5417           elimination and saturation; the integer deletedvariables
     5418           records which variables have been eliminated;
     5419           the integer anzahlvariablen records how many true variables remain
    54205420           after the elimination
    5421          - if the integer a is one then all zeros of the ideal i are 
    5422            considered and found, otherwise only one is considered, so that L 
     5421         - if the integer a is one then all zeros of the ideal i are
     5422           considered and found, otherwise only one is considered, so that L
    54235423           has length one"
    54245424{
     
    54285428  // if all solutions have to be found
    54295429  if (findall==1)
    5430   {   
     5430  {
    54315431    list saturatelist,eliminatelist; // carry the solution of the two tests
    5432     // we test first if there is a solution which has the component 
    5433     // lastvar zero and 
     5432    // we test first if there is a solution which has the component
     5433    // lastvar zero and
    54345434    // where the order of each component is strictly positive;
    5435     // if so, we add this variable to the ideal and 
     5435    // if so, we add this variable to the ideal and
    54365436    // eliminate it - which amounts to
    5437     // to projecting the solutions with this component 
     5437    // to projecting the solutions with this component
    54385438    // zero to the hyperplane without this component;
    5439     // for the test we compute the saturation with 
     5439    // for the test we compute the saturation with
    54405440    // respect to t and replace each variable
    5441     // x_i and also t by zero -- if the result is zero, 
    5442     // then 1 is not in I:t^infty 
     5441    // x_i and also t by zero -- if the result is zero,
     5442    // then 1 is not in I:t^infty
    54435443    // (i.e. there is a solution which has the component lastvar zero) and
    5444     // the result lives in the maximal 
    5445     // ideal <t,x_1,...,[no x_lastvar],...,x_n> so that 
     5444    // the result lives in the maximal
     5445    // ideal <t,x_1,...,[no x_lastvar],...,x_n> so that
    54465446    // there is a solution which has strictly positive valuation
    54475447/*
    54485448    // DER NACHFOLGENDE TEIL IST MUELL UND WIRD NICHT MEHR GAMACHT
    5449     // for the test we simply compute the leading ideal 
     5449    // for the test we simply compute the leading ideal
    54505450    // and set all true variables zero;
    5451     // since the ordering was an elimination ordering 
     5451    // since the ordering was an elimination ordering
    54525452    // with respect to (@a if present and) t
    5453     // there remains something not equal to zero 
     5453    // there remains something not equal to zero
    54545454    // if and only if there is polynomial which only
    5455     // depends on t (and @a if present), but that is 
     5455    // depends on t (and @a if present), but that is
    54565456    // a unit in K{{t}}, which would show that there
    54575457    // is no solution with the component lastvar zero;
    5458     // however, we also have to ensure that if there 
     5458    // however, we also have to ensure that if there
    54595459    // exists a solution with the component lastvar
    5460     // equal to zero then this component has a 
     5460    // equal to zero then this component has a
    54615461    // valuation with all strictly positive values!!!!;
    5462     // for this we can either saturate the ideal 
     5462    // for this we can either saturate the ideal
    54635463    // after elimination with respect to <t,x_1,...,x_n>
    5464     // and see if the saturated ideal is contained in <t,x_1,...x_n>+m, 
    5465     // or ALTERNATIVELY we can pass to the 
     5464    // and see if the saturated ideal is contained in <t,x_1,...x_n>+m,
     5465    // or ALTERNATIVELY we can pass to the
    54665466    // ring 0,(t,x_1,...,x_n,@a),(ds(n+1),dp(1)),
    5467     // compute a standard basis of the elimination 
     5467    // compute a standard basis of the elimination
    54685468    // ideal (plus m) there and check if the dimension 1
    5469     // (since we have not omitted the variable lastvar, 
     5469    // (since we have not omitted the variable lastvar,
    54705470    // this means that we have the ideal
    5471     // generated by t,x_1,...,[no x_lastvar],...,x_n 
     5471    // generated by t,x_1,...,[no x_lastvar],...,x_n
    54725472    // and this defines NO curve after omitting x_lastvar)
    54735473    I=std(ideal(var(lastvar)+i));
     
    54755475    LI=lead(reduce(I,std(m)));
    54765476    //size(deletedvariables)=anzahlvariablen(before elimination)
    5477     for (j=1;j<=anzahlvariablen-1;j++) 
     5477    for (j=1;j<=anzahlvariablen-1;j++)
    54785478    {
    54795479      LI=subst(LI,var(j),0);
     
    54815481    if (size(LI)==0) // if no power of t is in lead(I) (where @a is considered as a field element)
    54825482*/
    5483     I=reduce(sat(ideal(var(lastvar)+i),t)[1],std(m)); // get rid of the minimal 
     5483    I=reduce(sat(ideal(var(lastvar)+i),t)[1],std(m)); // get rid of the minimal
    54845484                                                      // polynomial for the test
    54855485    LI=subst(I,var(nvars(basering)),0);
    54865486    //size(deletedvariables)=anzahlvariablen(before elimination)
    5487     for (j=1;j<=anzahlvariablen-1;j++) 
     5487    for (j=1;j<=anzahlvariablen-1;j++)
    54885488    {
    54895489      LI=subst(LI,var(j),0);
    54905490    }
    5491     if (size(LI)==0) // the saturation lives in the maximal 
     5491    if (size(LI)==0) // the saturation lives in the maximal
    54925492    { // ideal generated by t and the x_i
    54935493      // get rid of var(lastvar)
     
    55045504      {
    55055505        string elring="ring ELIMINATERING=("+charstr(basering)+"),("+string(simplify(reduce(maxideal(1),std(var(lastvar))),2))+"),(";
    5506       }   
    5507       if (anzahlvariablen<nvars(basering)) // if @a was present, the 
     5506      }
     5507      if (anzahlvariablen<nvars(basering)) // if @a was present, the
    55085508      { // ordersting needs an additional entry
    55095509        elring=elring+"dp(1),";
    55105510      }
    55115511      elring=elring+"lp(1));";
    5512       execute(elring);     
     5512      execute(elring);
    55135513      ideal i=imap(BASERING,I); // move the ideal I to the new ring
    5514       // if not yet all variables have been checked, 
     5514      // if not yet all variables have been checked,
    55155515      // then go on with the next smaller variable,
    5516       // else prepare the elimination ring and the neccessary 
     5516      // else prepare the elimination ring and the neccessary
    55175517      // information for return
    55185518      if (lastvar>1)
     
    55275527      setring BASERING;
    55285528    }
    5529     // next we have to test if there is also a solution 
     5529    // next we have to test if there is also a solution
    55305530    // which has the variable lastvar non-zero;
    5531     // to do so, we saturate with respect to this variable; 
    5532     // since when considered over K{{t}} 
    5533     // the ideal is zero dimensional, this really removes 
     5531    // to do so, we saturate with respect to this variable;
     5532    // since when considered over K{{t}}
     5533    // the ideal is zero dimensional, this really removes
    55345534    // all solutions with that component zero;
    55355535    // the checking is then done as above
    55365536    i=std(sat(i,var(lastvar))[1]);
    55375537    I=reduce(i,std(m)); // "remove" m from i
    5538     // test first, if i still is in the ideal <t,x_1,...,x_n> -- if not, then 
    5539     // we know that i has no longer a point in the tropical 
     5538    // test first, if i still is in the ideal <t,x_1,...,x_n> -- if not, then
     5539    // we know that i has no longer a point in the tropical
    55405540    // variety with all components negative
    55415541    LI=subst(I,var(nvars(basering)),0);
    5542     for (j=1;j<=anzahlvariablen-1;j++) // set all variables 
     5542    for (j=1;j<=anzahlvariablen-1;j++) // set all variables
    55435543    { // t,x_1,...,x_n equal to zero
    55445544      LI=subst(LI,var(j),0);
    55455545    }
    55465546    if (size(LI)==0) // the entries of i have not constant part
    5547     {     
    5548       // check now, if the leading ideal of i contains an element 
     5547    {
     5548      // check now, if the leading ideal of i contains an element
    55495549      // which only depends on t
    55505550      LI=lead(I);
    55515551      //size(deletedvariables)=anzahlvariablen(before elimination)
    5552       for (j=1;j<=anzahlvariablen-1;j++) 
     5552      for (j=1;j<=anzahlvariablen-1;j++)
    55535553      {
    55545554        LI=subst(LI,var(j),0);
    55555555      }
    5556       if (size(LI)==0) // if no power of t is in lead(i) 
     5556      if (size(LI)==0) // if no power of t is in lead(i)
    55575557      { // (where @a is considered as a field element)
    5558         // if not yet all variables have been tested, go on with the 
     5558        // if not yet all variables have been tested, go on with the
    55595559        // next smaller variable
    55605560        // else prepare the neccessary information for return
     
    55645564        }
    55655565        else
    5566         {   
     5566        {
    55675567          execute("ring SATURATERING=("+charstr(basering)+"),("+varstr(basering)+"),("+ordstr(basering)+");");
    55685568          ideal i=imap(BASERING,i);
     
    55755575    return(eliminatelist+saturatelist);
    55765576  }
    5577   else // only one solution is searched for, we can do a simplified 
     5577  else // only one solution is searched for, we can do a simplified
    55785578  { // version of the above
    5579     // check if there is a solution which has the n-th component 
     5579    // check if there is a solution which has the n-th component
    55805580    // zero and with positive valuation,
    5581     // if so, then eliminate the n-th variable from 
     5581    // if so, then eliminate the n-th variable from
    55825582    // sat(i+x_n,t), otherwise leave i as it is;
    5583     // then check if the (remaining) ideal has as 
     5583    // then check if the (remaining) ideal has as
    55845584    // solution where the n-1st component is zero ...,
    55855585    // and procede as before; do the same for the remaining variables;
    5586     // this way we make sure that the remaining ideal has 
     5586    // this way we make sure that the remaining ideal has
    55875587    // a solution which has no component zero;
    55885588    ideal variablen; // will contain the variables which are not eliminated
     
    55925592      LI=subst(I,var(nvars(basering)),0);
    55935593      //size(deletedvariables)=anzahlvariablen-1(before elimination)
    5594       for (k=1;k<=size(deletedvariables);k++) 
     5594      for (k=1;k<=size(deletedvariables);k++)
    55955595      {
    55965596        LI=subst(LI,var(k),0);
    55975597      }
    5598       if (size(LI)==0) // if no power of t is in lead(I) 
     5598      if (size(LI)==0) // if no power of t is in lead(I)
    55995599      { // (where the X(i) are considered as field elements)
    5600         // get rid of var(j)   
     5600        // get rid of var(j)
    56015601        i=eliminate(I,var(j));
    56025602        deletedvariables[j]=1;
    5603         anzahlvariablen--; // if a variable is eliminated, 
     5603        anzahlvariablen--; // if a variable is eliminated,
    56045604                           // then the number of true variables drops
    56055605      }
     
    56105610    }
    56115611    variablen=invertorder(variablen);
    5612     // store also the additional variable and t, 
     5612    // store also the additional variable and t,
    56135613    // since they for sure have not been eliminated
    56145614    for (j=size(deletedvariables)+1;j<=nvars(basering);j++)
     
    56165616      variablen=variablen+var(j);
    56175617    }
    5618     // if there are variables left, then pass to a ring which 
    5619     // only realises these variables else we are done 
     5618    // if there are variables left, then pass to a ring which
     5619    // only realises these variables else we are done
    56205620    if (anzahlvariablen>1)
    56215621    {
     
    56255625    {
    56265626      string elring="ring ELIMINATERING=("+charstr(basering)+"),("+string(variablen)+"),(";
    5627     }   
    5628     if (size(deletedvariables)+1<nvars(basering)) // if @a was present, 
     5627    }
     5628    if (size(deletedvariables)+1<nvars(basering)) // if @a was present,
    56295629    { // the ordersting needs an additional entry
    56305630      elring=elring+"dp(1),";
    56315631    }
    56325632    elring=elring+"lp(1));";
    5633     execute(elring);     
     5633    execute(elring);
    56345634    ideal i=imap(BASERING,i);
    56355635    ideal m=imap(BASERING,m);
     
    56445644static proc findzerosAndBasictransform (ideal i,intvec w,list zerolist,int findall,list #)
    56455645"USAGE:  findzerosAndBasictransform(i,w,z,f[,#]); i ideal, w intvec, z list, f int,# an optional list
    5646 ASSUME:  i is an ideal in Q[t,x_1,...,x_n,@a] and w=(w_0,...,w_n,0) 
     5646ASSUME:  i is an ideal in Q[t,x_1,...,x_n,@a] and w=(w_0,...,w_n,0)
    56475647         is in the tropical variety of i; @a need not be present;
    56485648         the list 'zero' contains the zeros computed in previous recursion steps;
    5649          if 'f' is one then all zeros should be found and returned, 
     5649         if 'f' is one then all zeros should be found and returned,
    56505650         otherwise only one
    5651 RETURN:  list, each entry is a ring corresponding to one conjugacy class of 
    5652                zeros of the t-initial ideal inside the torus; each of the rings 
     5651RETURN:  list, each entry is a ring corresponding to one conjugacy class of
     5652               zeros of the t-initial ideal inside the torus; each of the rings
    56535653               contains the following objects
    56545654               ideal i    = the ideal i, where the variable @a (if present) has
    5655                             possibly been transformed according to the new 
    5656                             minimal polynomial, and where itself has been 
    5657                             submitted to the basic transform of the algorithm 
     5655                            possibly been transformed according to the new
     5656                            minimal polynomial, and where itself has been
     5657                            submitted to the basic transform of the algorithm
    56585658                            given by the jth zero found for the t-initial ideal;
    5659                             note that the new minimal polynomial has already 
     5659                            note that the new minimal polynomial has already
    56605660                            been added
    5661                poly m     = the new minimal polynomial for @a 
     5661               poly m     = the new minimal polynomial for @a
    56625662                            (it is zero if no @a is present)
    5663                list zero  = zero[k+1] is the kth component of a zero 
     5663               list zero  = zero[k+1] is the kth component of a zero
    56645664                            the t-initial ideal of i
    5665 NOTE:     -  the procedure is called from inside the recursive procedure 
     5665NOTE:     -  the procedure is called from inside the recursive procedure
    56665666             tropicalparametrise;
    5667              if it is called in the first recursion, the list #[1] contains 
    5668              the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer, 
     5667             if it is called in the first recursion, the list #[1] contains
     5668             the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer,
    56695669             one more than the number of true variables x_1,...,x_n
    5670           -  if #[2] is present, then it is an integer which tells whether 
     5670          -  if #[2] is present, then it is an integer which tells whether
    56715671             ALL zeros should be found or not"
    56725672{
     
    56865686    int anzahlvariablen=#[1];
    56875687    // compute the initial ideal of i
    5688     // - the last 1 just means that the variable t is the last 
     5688    // - the last 1 just means that the variable t is the last
    56895689    //   variable in the ring
    56905690    ideal ini=tInitialIdeal(i,w,1);
     
    56945694    int recursive=0;
    56955695    int anzahlvariablen=nvars(basering);
    5696     ideal ini=#[1]; // the t-initial ideal has been computed 
     5696    ideal ini=#[1]; // the t-initial ideal has been computed
    56975697                    // in before and was handed over
    5698   } 
     5698  }
    56995699  // collect the true variables x_1,...,x_n plus @a, if it is defined in BASERING
    57005700  ideal variablen;
    57015701  for (j=1;j<=nvars(basering)-1;j++)
    5702   {   
     5702  {
    57035703    variablen=variablen+var(j);
    57045704  }
    5705   // move to a polynomial ring with global monomial ordering 
     5705  // move to a polynomial ring with global monomial ordering
    57065706  // - the variable t is superflous,
    57075707  // the variable @a is not if it was already present
    57085708  execute("ring INITIALRING=("+charstr(basering)+"),("+string(variablen)+"),dp;");
    57095709  ideal ini=imap(BASERING,ini);
    5710   // compute the minimal associated primes of the 
     5710  // compute the minimal associated primes of the
    57115711  // initialideal over the algebraic closure;
    5712   // ordering the maximal ideals shall help to 
     5712  // ordering the maximal ideals shall help to
    57135713  // avoid unneccessary field extensions
    57145714  list absminass=absPrimdecGTZ(ini);
    5715   def ABSRING=absminass[1]; // the ring in which the minimal 
     5715  def ABSRING=absminass[1]; // the ring in which the minimal
    57165716                            // associated primes live
    57175717  setring ABSRING;
     
    57265726    // check fort the jth maximal ideal a field extension is necessary;
    57275727    // the latter condition says that @a is not in BASERING;
    5728     // if some of the maximal ideals needs a field extension, 
     5728    // if some of the maximal ideals needs a field extension,
    57295729    // then everything will live in this ring
    57305730    if ((maximalideals[j][1]!=0) and (nvars(BASERING)==anzahlvariablen))
    57315731    {
    5732       // define the extension ring which contains 
     5732      // define the extension ring which contains
    57335733      // the new variable @a, if it is not yet present
    57345734      execute("ring EXTENSIONRING=("+charstr(BASERING)+"),("+string(imap(BASERING,variablen))+",@a,"+tvar+"),(dp("+string(anzahlvariablen-1)+"),dp(1),lp(1));");
    5735       // phi maps x_i to x_i, @a to @a (if present in the ring), 
     5735      // phi maps x_i to x_i, @a to @a (if present in the ring),
    57365736      // and the additional variable
    5737       // for the field extension is mapped to @a as well 
     5737      // for the field extension is mapped to @a as well
    57385738      // -- note that we only apply phi
    5739       // to the list a, and in this list no @a is present; 
     5739      // to the list a, and in this list no @a is present;
    57405740      // therefore, it does not matter where this is mapped to
    57415741      map phi=ABSRING,imap(BASERING,variablen),@a;
    57425742    }
    5743     else // @a was already present in the BASERING or no 
     5743    else // @a was already present in the BASERING or no
    57445744    { // field extension is necessary
    57455745      execute("ring EXTENSIONRING=("+charstr(BASERING)+"),("+varstr(BASERING)+"),("+ordstr(BASERING)+");");
    5746       // phi maps x_i to x_i, @a to @a (if present in the ring), 
     5746      // phi maps x_i to x_i, @a to @a (if present in the ring),
    57475747      // and the additional variable
    5748       // for the field extension is mapped to @a as well respectively to 0, 
     5748      // for the field extension is mapped to @a as well respectively to 0,
    57495749      // if no @a is present;
    5750       // note that we only apply phi to the list a and to 
     5750      // note that we only apply phi to the list a and to
    57515751      // the replacement rule for
    5752       // the old variable @a, and in this list resp. 
    5753       // replacement rule no @a is present; 
     5752      // the old variable @a, and in this list resp.
     5753      // replacement rule no @a is present;
    57545754      // therefore, it does not matter where this is mapped to;
    57555755      if (anzahlvariablen<nvars(EXTENSIONRING)) // @a is in EXTENSIONRING
    5756       {     
     5756      {
    57575757        // additional variable is mapped to @a
    5758         map phi=ABSRING,imap(BASERING,variablen),@a; 
     5758        map phi=ABSRING,imap(BASERING,variablen),@a;
    57595759      }
    57605760      else
    57615761      {
    57625762        // additional variable is mapped to 0
    5763         map phi=ABSRING,imap(BASERING,variablen),0; 
     5763        map phi=ABSRING,imap(BASERING,variablen),0;
    57645764      }
    57655765    }
     
    57685768    poly m=maximalideals[j][1];    // extract m
    57695769    list zeroneu=maximalideals[j][2]; // extract the new zero
    5770     poly repl=maximalideals[j][3]; // extract the replacement rule   
    5771     // the list zero may very well exist as an EMPTY global list 
     5770    poly repl=maximalideals[j][3]; // extract the replacement rule
     5771    // the list zero may very well exist as an EMPTY global list
    57725772    // - in this case we have to remove it
    57735773    // in order to avoid a redefining warning
    5774     if (defined(zero)!=0) 
     5774    if (defined(zero)!=0)
    57755775    {
    57765776      if (size(zero)==0)
     
    57835783    {
    57845784      ideal i=imap(BASERING,i);
    5785       if (defined(zerolist)==0) // if zerolist is empty, it does not 
     5785      if (defined(zerolist)==0) // if zerolist is empty, it does not
    57865786      { // depend on BASERING !
    57875787        list zero=imap(BASERING,zerolist);
    57885788      }
    5789       else 
     5789      else
    57905790      {
    57915791        list zero=zerolist;
    57925792      }
    57935793    }
    5794     else // in BASERING was @a present 
     5794    else // in BASERING was @a present
    57955795    {
    57965796      ideal variablen=imap(BASERING,variablen);
    5797       // map i and zerolist to EXTENSIONRING replacing @a 
     5797      // map i and zerolist to EXTENSIONRING replacing @a
    57985798      // by the replacement rule repl
    57995799      map psi=BASERING,variablen[1..size(variablen)-1],repl,var(nvars(basering));
     
    58055805    zero[size(zero)+1]=zeroneu;
    58065806    // do now the basic transformation sending x_l -> t^-w_l*(zero_l+x_l)
    5807     for (l=1;l<=anzahlvariablen;l++) 
     5807    for (l=1;l<=anzahlvariablen;l++)
    58085808    {
    58095809      for (k=1;k<=size(i);k++)
    58105810      {
    58115811        if (l!=1) // corresponds to  x_(l-1) --  note t is the last variable
    5812         {       
     5812        {
    58135813          i[k]=substitute(i[k],var(l-1),(zeroneu[l]+var(l-1))*t^(-w[l]));
    58145814        }
     
    58225822    for (l=1;l<=ncols(i);l++)
    58235823    {
    5824       if (wdegs[l]<0) // if wdegs[l]==0 there is no need to divide, 
     5824      if (wdegs[l]<0) // if wdegs[l]==0 there is no need to divide,
    58255825      { // and we made sure that it is no positive
    58265826        i[l]=i[l]/t^(-wdegs[l]);
     
    58285828    }
    58295829    // since we want to consider i now in the ring (Q[@a]/m)[t,x_1,...,x_n]
    5830     // we can  reduce i modulo m, so that "constant terms" 
     5830    // we can  reduce i modulo m, so that "constant terms"
    58315831    // which are "zero" since they
    58325832    // are in m will disappear; simplify(...,2) then really removes them;
     
    58355835    export(i);
    58365836    export(m);
    5837     export(zero);   
     5837    export(zero);
    58385838    extensionringlist[j]=EXTENSIONRING;
    58395839    kill EXTENSIONRING;
     
    58475847static proc ordermaximalideals (list minassi,int anzahlvariablen)
    58485848"USAGE:      ordermaximalideals(minassi); minassi list
    5849 ASSUME:      minassi is a list of maximal ideals (together with the information 
    5850              how many conjugates it has), where the first polynomial is the 
    5851              minimal polynomial of the last variable in the ring which is 
     5849ASSUME:      minassi is a list of maximal ideals (together with the information
     5850             how many conjugates it has), where the first polynomial is the
     5851             minimal polynomial of the last variable in the ring which is
    58525852             considered as a parameter
    5853 RETURN:      list, the procedure orders the maximal ideals in minassi according 
    5854                    to how many new variables are needed (namely none or one) to 
    5855                    describe the zeros of the ideal, and accordingly to the 
     5853RETURN:      list, the procedure orders the maximal ideals in minassi according
     5854                   to how many new variables are needed (namely none or one) to
     5855                   describe the zeros of the ideal, and accordingly to the
    58565856                   degree of the corresponding minimal polynomial
    58575857                   l[j][1] = the minimal polynomial for the jth maximal ideal
    5858                    l[j][2] = list, the k+1st entry is the kth coordinate of the 
    5859                                    zero described by the maximal ideal in terms 
     5858                   l[j][2] = list, the k+1st entry is the kth coordinate of the
     5859                                   zero described by the maximal ideal in terms
    58605860                                   of the last variable
    5861                    l[j][3] = poly, the replacement for the old variable @a 
     5861                   l[j][3] = poly, the replacement for the old variable @a
    58625862NOTE:        if a maximal ideal contains a variable, it is removed from the list;
    58635863             the procedure is called by findzerosAndBasictransform"
     
    58665866  int pruefer;       // is set one if a maximal ideal contains a variable
    58675867  list minassisort;  // will contain the output
    5868   for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort 
     5868  for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort
    58695869                                                    // to fix its initial length
    58705870  list zwischen;     // needed for reordering
    5871   list zero;         // (a_1,...,a_n)=(zero[2],...,zero[n+1]) will be 
     5871  list zero;         // (a_1,...,a_n)=(zero[2],...,zero[n+1]) will be
    58725872                     // a common zero of the ideal m
    58735873  poly nf;           // normalform of a variable w.r.t. m
    5874   poly minimalpolynomial;  // minimal polynomial for the field extension 
     5874  poly minimalpolynomial;  // minimal polynomial for the field extension
    58755875  poly parrep;  // the old variable @a possibly has to be replaced by a new one
    5876   // compute for each maximal ideal the number of new variables, which are 
    5877   // needed to describe its zeros -- note, a new variable is needed 
     5876  // compute for each maximal ideal the number of new variables, which are
     5877  // needed to describe its zeros -- note, a new variable is needed
    58785878  // if the first entry of minassi[j][1] is not the last variable
    5879   // store the value a variable reduces to in the list a; 
     5879  // store the value a variable reduces to in the list a;
    58805880  for (j=size(minassi);j>=1;j--)
    58815881  {
     
    58855885      minimalpolynomial=0;
    58865886    }
    5887     zero[1]=poly(0);         // the first entry in zero and in 
     5887    zero[1]=poly(0);         // the first entry in zero and in
    58885888                             // neuevariablen corresponds to the variable t,
    58895889    minassi[j][1]=std(minassi[j][1]);
     
    58915891    {
    58925892      // zero_k+1 is the normal form of the kth variable modulo m
    5893       zero[k+1]=reduce(var(k),minassi[j][1]); 
    5894       // if a variable reduces to zero, then the maximal 
     5893      zero[k+1]=reduce(var(k),minassi[j][1]);
     5894      // if a variable reduces to zero, then the maximal
    58955895      // ideal contains a variable and we can delete it
    58965896      if (zero[k+1]==0)
     
    58995899      }
    59005900    }
    5901     // if anzahlvariablen<nvars(basering), then the old ring 
     5901    // if anzahlvariablen<nvars(basering), then the old ring
    59025902    // had already an additional variable;
    59035903    // the old parameter @a then has to be replaced by parrep
     
    59085908    // if the maximal ideal contains a variable, we simply delete it
    59095909    if (pruefer==0)
    5910     {     
     5910    {
    59115911      minassisort[j]=list(minimalpolynomial,zero,parrep);
    59125912    }
    5913     // otherwise we store the information on a, neuevariablen 
     5913    // otherwise we store the information on a, neuevariablen
    59145914    // and neuvar together with the ideal
    59155915    else
     
    59205920    }
    59215921  }
    5922   // sort the maximal ideals ascendingly according to the 
     5922  // sort the maximal ideals ascendingly according to the
    59235923  // number of new variables needed to
    59245924  // express the zero of the maximal ideal
     
    59275927    l=j;
    59285928    for (k=j-1;k>=1;k--)
    5929     {     
     5929    {
    59305930      if (deg(minassisort[l][1])<deg(minassisort[k][1]))
    59315931      {
     
    59625962static proc verticesTropicalCurve (def tp,list #)
    59635963"USAGE:      verticesTropicalCurve(tp[,#]); tp list, # optional list
    5964 ASSUME:      tp is represents an ideal in Z[x,y] representing a tropical 
     5964ASSUME:      tp is represents an ideal in Z[x,y] representing a tropical
    59655965             polynomial (in the form of the output of the procedure tropicalise)
    59665966             defining a tropical plane curve
    5967 RETURN:      list, each entry corresponds to a vertex in the tropical plane 
     5967RETURN:      list, each entry corresponds to a vertex in the tropical plane
    59685968                   curve defined by tp
    59695969                   l[i][1] = x-coordinate of the ith vertex
    59705970                   l[i][2] = y-coordinate of the ith vertex
    5971                    l[i][3] = a polynomial whose monimials mark the vertices in 
    5972                              the Newton polygon corresponding to the entries in 
     5971                   l[i][3] = a polynomial whose monimials mark the vertices in
     5972                             the Newton polygon corresponding to the entries in
    59735973                             tp which take the common minimum at the ith vertex
    59745974NOTE:      - the information in l[i][3] represents the subdivision of the Newton
    5975              polygon of tp (respectively a polynomial which defines tp); 
    5976            - if # is non-empty and #[1] is the string 'max', then in the 
    5977              computations minimum and maximum are exchanged; 
    5978            - if # is non-empty and the #[1] is not a string, only the vertices 
     5975             polygon of tp (respectively a polynomial which defines tp);
     5976           - if # is non-empty and #[1] is the string 'max', then in the
     5977             computations minimum and maximum are exchanged;
     5978           - if # is non-empty and the #[1] is not a string, only the vertices
    59795979             will be computed and the information on the Newton subdivision will
    59805980             be omitted;
    5981            - here the tropical polynomial is supposed to be the MINIMUM of the 
    5982              linear forms in tp, unless the optional input #[1] is the 
     5981           - here the tropical polynomial is supposed to be the MINIMUM of the
     5982             linear forms in tp, unless the optional input #[1] is the
    59835983             string 'max'
    5984            - the procedure is called from tropicalCurve and from 
     5984           - the procedure is called from tropicalCurve and from
    59855985             conicWithTangents"
    59865986{
    5987   // if you insert a single polynomial instead of an ideal representing 
     5987  // if you insert a single polynomial instead of an ideal representing
    59885988  // a tropicalised polynomial,
    5989   // then we compute first the tropicalisation of this polynomial 
     5989  // then we compute first the tropicalisation of this polynomial
    59905990  // -- this feature is not documented in the above help string
    59915991  if (typeof(tp)=="poly")
     
    59965996  }
    59975997  int i,j,k,l,z; // indices
    5998   // make sure that no constant entry of tp has type int since that 
     5998  // make sure that no constant entry of tp has type int since that
    59995999  // would lead to trouble
    60006000  // when using the procedure substitute
     
    60146014  int e=1;
    60156015  option(redSB);
    6016   // for each triple (i,j,k) of entries in tp check if they have a 
    6017   // point in common and if they attain at this point the minimal 
     6016  // for each triple (i,j,k) of entries in tp check if they have a
     6017  // point in common and if they attain at this point the minimal
    60186018  // possible value for all linear forms in tp
    60196019  for (i=1;i<=size(tp)-2;i++)
     
    60686068            e++;
    60696069          }
    6070         }         
     6070        }
    60716071      }
    60726072    }
     
    60916091static proc bunchOfLines (def tp,list #)
    60926092"USAGE:      bunchOfLines(tp[,#]); tp list, # optional list
    6093 ASSUME:      tp is represents an ideal in Q[x,y] representing a tropical 
     6093ASSUME:      tp is represents an ideal in Q[x,y] representing a tropical
    60946094             polynomial (in the form of the output of the procedure tropicalise)
    60956095             defining a bunch of ordinary lines in the plane,
    60966096             i.e. the Newton polygone is a line segment
    6097 RETURN:      list, see the procedure tropicalCurve for an explanation of 
     6097RETURN:      list, see the procedure tropicalCurve for an explanation of
    60986098                   the syntax of this list
    6099 NOTE:      - the tropical curve defined by tp will consist of a bunch of 
    6100              parallel lines and throughout the procedure a list with the 
    6101              name bunchoflines is computed, which represents these lines and 
     6099NOTE:      - the tropical curve defined by tp will consist of a bunch of
     6100             parallel lines and throughout the procedure a list with the
     6101             name bunchoflines is computed, which represents these lines and
    61026102             has the following interpretation:
    6103              list, each entry corresponds to a vertex in the tropical plane 
     6103             list, each entry corresponds to a vertex in the tropical plane
    61046104                   curve defined by tp
    61056105                   l[i][1] = the equation of the ith line in the tropical curve
    6106                    l[i][2] = a polynomial whose monimials mark the vertices in 
    6107                              the Newton polygon corresponding to the entries in 
     6106                   l[i][2] = a polynomial whose monimials mark the vertices in
     6107                             the Newton polygon corresponding to the entries in
    61086108                             tp which take the common minimum at the ith vertex
    61096109           - the information in l[i][2] represents the subdivision of the Newton
    6110              polygon of tp (respectively a polynomial which defines tp); 
    6111            - if # is non-empty and #[1] is the string 'max', then in the 
    6112              computations minimum and maximum are exchanged; 
    6113            - if # is non-empty and the #[1] is not a string, only the vertices 
    6114              will be computed and the information on the Newton subdivision 
     6110             polygon of tp (respectively a polynomial which defines tp);
     6111           - if # is non-empty and #[1] is the string 'max', then in the
     6112             computations minimum and maximum are exchanged;
     6113           - if # is non-empty and the #[1] is not a string, only the vertices
     6114             will be computed and the information on the Newton subdivision
    61156115             will be omitted;
    6116            - here the tropical polynomial is supposed to be the MINIMUM of the 
    6117              linear forms in tp, unless the optional input #[1] is the 
     6116           - here the tropical polynomial is supposed to be the MINIMUM of the
     6117             linear forms in tp, unless the optional input #[1] is the
    61186118             string 'max'
    61196119           - the procedure is called from tropicalCurve"
     
    61326132  intvec direction=leadexp(detropicalise(tp[1]))-leadexp(detropicalise(tp[2]));
    61336133  direction=direction/gcd(direction[1],direction[2]);
    6134   // change the coordinates in such a way, that the Newton polygon 
     6134  // change the coordinates in such a way, that the Newton polygon
    61356135  // lies on the x-axis
    6136   if (direction[1]==0) // there is no x-term - exchange x and y 
     6136  if (direction[1]==0) // there is no x-term - exchange x and y
    61376137  { // and get rid of the new y part
    61386138    for (i=1;i<=size(tp);i++)
     
    61486148    }
    61496149  }
    6150   // For all tuples (i,j) of entries in tp check if they attain 
     6150  // For all tuples (i,j) of entries in tp check if they attain
    61516151  // at their point of intersection
    61526152  // the minimal possible value for all linear forms in tp
     
    61646164      {
    61656165        vergleich=substitute(tp[l],var(1),px);
    6166         if (vergleich==wert) 
     6166        if (vergleich==wert)
    61676167        {
    61686168          newton=newton+detropicalise(oldtp[l]);
     
    61756175        e++;
    61766176      }
    6177     }         
     6177    }
    61786178  }
    61796179  // if a vertex appears several times, only its first occurence will be kept
     
    61826182    for (j=i-1;j>=1;j--)
    61836183    {
    6184       if (bunchoflines[i][1]==bunchoflines[j][1]) 
     6184      if (bunchoflines[i][1]==bunchoflines[j][1])
    61856185      {
    61866186        bunchoflines=delete(bunchoflines,i);
     
    61896189    }
    61906190  }
    6191   // sort the lines in an descending way according to the leading 
     6191  // sort the lines in an descending way according to the leading
    61926192  // exponent of the polynomial
    61936193  // defining the Newton polygone
     
    62296229      gr[2]=0;
    62306230    }
    6231     else // if there is no point with y-coordinate zero, then 
     6231    else // if there is no point with y-coordinate zero, then
    62326232    { // there is point with x-coordinate zero
    62336233      gr[1]=0;
     
    62466246
    62476247static proc clearintmat (intmat vv)
    6248 "USAGE:      clearintmat(vv); vv intmat 
    6249 ASSUME:      all entries of the first column of vv are non-negative, 
     6248"USAGE:      clearintmat(vv); vv intmat
     6249ASSUME:      all entries of the first column of vv are non-negative,
    62506250             not all entries are zero unless vv has only one column
    6251 RETURN:      intmat, vv has been ordered in an ascending way by the entries 
    6252                      of the first row; 
    6253                      if an entry in the first row occurs several times, the 
    6254                      entries in the second row have been added and only one 
     6251RETURN:      intmat, vv has been ordered in an ascending way by the entries
     6252                     of the first row;
     6253                     if an entry in the first row occurs several times, the
     6254                     entries in the second row have been added and only one
    62556255                     row has been kept;
    6256                      colums with a zero in the first row have been removed 
     6256                     colums with a zero in the first row have been removed
    62576257                     unless vv has only one column
    62586258NOTE:        called by tropicalCurve"
     
    62616261  for (int i=ncols(vv)-1;i>=1;i--)
    62626262  {
    6263     if (vv[1,i]==vv[1,i+1]) 
     6263    if (vv[1,i]==vv[1,i+1])
    62646264    {
    62656265      vv[2,i]=vv[2,i]+vv[2,i+1];
     
    62936293        k++;
    62946294      }
    6295       else 
     6295      else
    62966296      {
    62976297        stop=1;
     
    63216321static proc sortintmat (intmat vv)
    63226322"USAGE:      sortintmat(vv); vv intmat
    6323 RETURN:      intmat, the columns of vv have been ordered in an ascending 
     6323RETURN:      intmat, the columns of vv have been ordered in an ascending
    63246324                     way by the first entry
    63256325NOTE:        called by clearintmat"
     
    63756375  {
    63766376    int m=nrows(M);
    6377    
     6377
    63786378  }
    63796379  else
     
    63916391static proc minInIntvec (intvec v)
    63926392"USAGE:      minInIntvec(v); v intvec
    6393 RETURN:      list, first entry is the minimal value in v, second entry 
     6393RETURN:      list, first entry is the minimal value in v, second entry
    63946394                   is its position in v
    63956395NOTE:        called by sortintmat"
     
    64286428static proc sortlist (list v,int pos)
    64296429"USAGE:      sortlist(v,pos); v list, pos int
    6430 RETURN:      list, the list L ordered in an ascending way according 
     6430RETURN:      list, the list L ordered in an ascending way according
    64316431                   to the pos-th entries
    64326432NOTE:        called by tropicalCurve"
     
    64676467static proc vergleiche (poly wert,poly vglwert,list #)
    64686468"USAGE:      vergleiche(wert,vglwert,liste), wert, vglwert poly, liste list
    6469 RETURN:      int, if list contains a string as first entry then 1 
    6470                   is returned if wert is at most vglwert and 0 if wert is 
     6469RETURN:      int, if list contains a string as first entry then 1
     6470                  is returned if wert is at most vglwert and 0 if wert is
    64716471                  larger than vglwert, if liste is anything else 1 is returned if
    64726472                  wert is at least vglwert and 0 if wert s less than vglwert"
     
    65006500static proc koeffizienten (poly f,int k)
    65016501"USAGE:      koeffizienten(f,k)  f poly, k int
    6502 ASSUME:      f=a*x+b*y+c is a linear polynomial in two variables, 
     6502ASSUME:      f=a*x+b*y+c is a linear polynomial in two variables,
    65036503             k is either 0, 1 or 2
    65046504RETURN:      poly, one of the coefficients of f, depending on the value of k:
     
    65136513    return(c);
    65146514  }
    6515   f=f-c; 
     6515  f=f-c;
    65166516  if (k==1)
    65176517  {
    65186518    return(substitute(f,var(1),1,var(2),0));
    6519   }   
     6519  }
    65206520  else
    65216521  {
    65226522    return(substitute(f,var(1),0,var(2),1));
    6523   }   
     6523  }
    65246524}
    65256525
     
    65596559ASSUME:      AA has three entries representing decimal numbers a, b and c
    65606560RETURN:      list, containing strings representing the numbers a and b scaled
    6561                    down so that the absolute maximum of the two is no 
     6561                   down so that the absolute maximum of the two is no
    65626562                   larger than c
    65636563NOTE:        the procedure is called by texDrawTropical"
     
    66126612static proc decimal (poly n,list #)
    66136613"USAGE:      decimal(f[,#]); f poly, # list
    6614 ASSUME:      f is a polynomial in Q[x_1,...,x_n], and # is either empty 
     6614ASSUME:      f is a polynomial in Q[x_1,...,x_n], and # is either empty
    66156615             or #[1] is a positive integer
    6616 RETURN:      string, a decimal expansion of the leading coefficient of f up 
     6616RETURN:      string, a decimal expansion of the leading coefficient of f up
    66176617                     to order two respectively #[1]
    6618 NOTE:        the procedure is called by texDrawTropical and conicWithTangents 
     6618NOTE:        the procedure is called by texDrawTropical and conicWithTangents
    66196619             and f will actually be a number"
    66206620{
     
    66436643      }
    66446644      for (j=i;j<=i+nachkomma;j++)
    6645       {       
     6645      {
    66466646        news=news+s[j];
    66476647      }
     
    66756675  }
    66766676  return(0);
    6677 }     
     6677}
    66786678
    66796679/////////////////////////////////////////////////////////////////////////
     
    66916691  {
    66926692    return("");
    6693    
     6693
    66946694  }
    66956695  if (i==1)
     
    67506750      k=j+2;
    67516751      while (k<=size(F) and ((F[k]=="0") or (F[k]=="1") or (F[k]=="2") or (F[k]=="3") or
    6752                                 (F[k]=="4") or (F[k]=="5") or (F[k]=="6") or (F[k]=="7") or (F[k]=="8") 
     6752                                (F[k]=="4") or (F[k]=="5") or (F[k]=="6") or (F[k]=="7") or (F[k]=="8")
    67536753                             or (F[k]=="9")))
    67546754      {
     
    67646764      k=j+2;
    67656765      while (k<=size(F) and ((F[k]=="0") or (F[k]=="1") or (F[k]=="2") or (F[k]=="3") or
    6766                                 (F[k]=="4") or (F[k]=="5") or (F[k]=="6") or (F[k]=="7") or (F[k]=="8") 
     6766                                (F[k]=="4") or (F[k]=="5") or (F[k]=="6") or (F[k]=="7") or (F[k]=="8")
    67676767                             or (F[k]=="9")))
    67686768      {
     
    67776777      F=stringdelete(F,j);
    67786778      j--;
    6779     }     
     6779    }
    67806780  }
    67816781  short=altshort;
    67826782  return(F);
    67836783}
    6784  
     6784
    67856785/////////////////////////////////////////////////////////////////////////
    67866786
    67876787static proc texcoefficient (poly f,list #)
    67886788"USAGE:      texcoefficient(f[,#]); f poly, # optional list
    6789 RETURN:      string, the tex command representing the leading coefficient 
     6789RETURN:      string, the tex command representing the leading coefficient
    67906790                     of f using \frac as coefficient
    6791 NOTE:        if # is non-empty, then the cdot at the end is omitted; 
     6791NOTE:        if # is non-empty, then the cdot at the end is omitted;
    67926792             this is needed for the constant term"
    67936793{
     
    68216821  }
    68226822  if (size(koeffizient)>5)
    6823   {   
     6823  {
    68246824    string tfractest=koeffizient[2..6];
    68256825    if (tfractest=="tfrac")
     
    69086908static proc coordinatechange (poly f,intmat A,intvec v)
    69096909"USAGE:   coordinatechange(f,A,v);  f poly, A intmat, v intvec
    6910 ASSUME:   f is a polynomial in two variables, A is a 2x2 
     6910ASSUME:   f is a polynomial in two variables, A is a 2x2
    69116911          integer matrix, and v is an integer vector with 2 entries
    69126912RETURN:   poly, the polynomial transformed by (x,y)->A*(x,y)+v
     
    69306930"USAGE:      weierstrassFormOfACubic(wf[,#]); wf poly, # list
    69316931ASSUME:      poly is a cubic polynomial
    6932 RETURN:      poly, the Weierstrass normal form of the cubic, 0 if poly is 
     6932RETURN:      poly, the Weierstrass normal form of the cubic, 0 if poly is
    69336933                   not a cubic
    69346934NOTE:        - the algorithm for the coefficients of the Weierstrass form is due
    69356935               to Fernando Rodriguez Villegas, villegas@math.utexas.edu
    6936              - if an additional argument # is given, the simplified Weierstrass 
     6936             - if an additional argument # is given, the simplified Weierstrass
    69376937               form is computed
    69386938             - the procedure is called by weierstrassForm
    6939              - the characteristic of the base field should not be 2 or 3 
     6939             - the characteristic of the base field should not be 2 or 3
    69406940               if # is non-empty"
    69416941{
     
    69516951    return (f);
    69526952  }
    6953   // compute the coefficients a1,a2,a3,a4, and a6 of the Weierstrass 
     6953  // compute the coefficients a1,a2,a3,a4, and a6 of the Weierstrass
    69546954  // form y^2+a1xy+a3y=x^3+a2x^2+a4x+a6
    69556955  poly a1=r1;
     
    69586958  poly a4=((-3*t0*r0+s0^2)*q1+(-3*s1*s0*q0+s1*r0^2))*q3
    69596959    +(t0*r0*q2^2+(s1*s0*q1+((-3*t0*r2+s1^2)*q0+s0*r0*r2))*q2
    6960       +(t0*r2*q1^2+s1*r0*r2*q1+s0*r2^2*q0)); 
     6960      +(t0*r2*q1^2+s1*r0*r2*q1+s0*r2^2*q0));
    69616961  poly a6=(-27*t0^2*q0^2+(9*t0*s0*r0-s0^3)*q0-t0*r0^3)*q3^2+
    69626962        (((9*t0^2*q0-t0*s0*r0)*q1+((-3*t0*s0*r1+(3*t0*s1*r0+
     
    70237023        i.e. a polynomial of the form a+bx+cx2+dy+exy+fx2y+gy2+hxy2+ix2y2
    70247024RETURN: poly, a Weierstrass form of the elliptic curve defined by poly
    7025 NOTE:   - the algorithm is based on the paper Sang Yook An, Seog Young Kim, 
    7026           David C. Marshall, Susan H. Marshall, William G. McCallum and 
    7027           Alexander R. Perlis: Jacobians of Genus One Curves. Journal of Number 
     7025NOTE:   - the algorithm is based on the paper Sang Yook An, Seog Young Kim,
     7026          David C. Marshall, Susan H. Marshall, William G. McCallum and
     7027          Alexander R. Perlis: Jacobians of Genus One Curves. Journal of Number
    70287028          Theory 90,2 (2001), 304-315.
    70297029        - the procedure is called by weierstrassForm
     
    70347034  // define P1xP1 as quadric in P3
    70357035  matrix A[4][4]=0,0,0,1/2,0,0,1/2,0,0,1/2,0,0,1/2,0,0,0;
    7036   // define the image of the (2,2)-curve under the Segre embedding 
     7036  // define the image of the (2,2)-curve under the Segre embedding
    70377037  // as quadric which should be
    70387038  // intersected with the image of P1xP1
    70397039  matrix B[4][4]=A00,A10/2,A01/2,0,A10/2,A20,A11/2,A21/2,A01/2,A11/2,A02,A12/2,0,A21/2,A12/2,A22;
    7040   // compute the coefficients of the Weierstrass form of 
     7040  // compute the coefficients of the Weierstrass form of
    70417041  // the input polynomial and its j-invariant
    70427042  poly a=det(x*A+B);
     
    70517051
    70527052static proc jInvariantOfACubic (poly f,list #)
    7053 "USAGE:      jInvariantOfACubic(f[,#]); f poly, # list 
     7053"USAGE:      jInvariantOfACubic(f[,#]); f poly, # list
    70547054ASSUME:      poly is a cubic polynomial defining an elliptic curve
    70557055RETURN:      poly, the j-invariant of the elliptic curve defined by poly
    70567056NOTE:        - if the base field is Q(t) an optional argument # may be given;
    7057                then the algorithm only computes the negative of the order 
     7057               then the algorithm only computes the negative of the order
    70587058               of the j-invariant"
    70597059{
     
    70627062    ERROR("The input polynomial is not a cubic!");
    70637063  }
    7064   // compute first the Weierstrass form of the cubic 
     7064  // compute first the Weierstrass form of the cubic
    70657065  // - this does not change the j-invariant
    70667066  f=weierstrassFormOfACubic(f);
     
    70807080    ERROR("The input is a rational curve and has no j-invariant!");
    70817081  }
    7082   if (size(#)>0) // if the optional argument is given, then only the 
     7082  if (size(#)>0) // if the optional argument is given, then only the
    70837083  { // negative of the order is computed
    70847084    int zaehler=3*simplifyToOrder(c4)[1];
     
    70967096
    70977097static proc jInvariantOfA2x2Curve (poly f,list #)
    7098 "USAGE: jInvariantOfA2x2Curve(f[,#]); f poly, # list 
     7098"USAGE: jInvariantOfA2x2Curve(f[,#]); f poly, # list
    70997099ASSUME: poly, is a polynomial defining an elliptic curve of type (2,2) on P^1xP^1
    71007100             i.e. a polynomial of the form a+bx+cx2+dy+exy+fx2y+gy2+hxy2+ix2y2
    71017101RETURN: poly, the j-invariant of the elliptic curve defined by poly
    71027102NOTE:   - if the base field is Q(t) an optional argument # may be given;
    7103           then the algorithm only computes the negative of the order of the 
     7103          then the algorithm only computes the negative of the order of the
    71047104          j-invariant
    71057105        - the characteristic should not be 2 or 3
     
    71147114  // intersected with the image of P1xP1
    71157115  matrix B[4][4]=A00,A10/2,A01/2,0,A10/2,A20,A11/2,A21/2,A01/2,A11/2,A02,A12/2,0,A21/2,A12/2,A22;
    7116   // compute the coefficients of the Weierstrass form of 
     7116  // compute the coefficients of the Weierstrass form of
    71177117  // the input polynomial and its j-invariant
    71187118  poly a=det(var(1)*A+B);
     
    71307130    ERROR("The input is a rational curve and has no j-invariant!");
    71317131  }
    7132   if (size(#)>0) // if the optional argument is given, 
     7132  if (size(#)>0) // if the optional argument is given,
    71337133  { // then only the negative of the order is computed
    71347134    int zaehler=simplifyToOrder(jinvnum)[1];
     
    71467146
    71477147static proc jInvariantOfA4x2Curve (poly f,list #)
    7148 "USAGE:      jInvariantOfA4x2Curve(f[,#]); f poly, # list 
     7148"USAGE:      jInvariantOfA4x2Curve(f[,#]); f poly, # list
    71497149ASSUME:      poly, is a polynomial defining an elliptic curve of type (4,2),
    71507150             i.e. a polynomial of the form a+bx+cx2+dx3+ex4+fy+gxy+hx2y+iy2
    71517151RETURN:      poly, the j-invariant of the elliptic curve defined by poly
    71527152NOTE:        - if the base field is Q(t) an optional argument # may be given;
    7153                then the algorithm only computes the negative of the order 
     7153               then the algorithm only computes the negative of the order
    71547154               of the j-invariant
    71557155             - the characteristic should not be 2 or 3
    7156              - the procedure is not called at all, it is just stored 
     7156             - the procedure is not called at all, it is just stored
    71577157               for the purpose of comparison"
    71587158{
     
    71747174  poly c4cube=c4^3;
    71757175  poly jdenom=c4cube-c6^2;
    7176   if (size(#)>0) // if the optional argument is given, 
     7176  if (size(#)>0) // if the optional argument is given,
    71777177  { // then only the negative of the order is computed
    71787178    int zaehler=3*simplifyToOrder(c4)[1];
     
    71897189
    71907190static proc jInvariantOfAPuiseuxCubic (poly f,list #)
    7191 "USAGE:  jInvariantOfAPuiseuxCubic(f[,#]); f poly, # list 
    7192 ASSUME:  poly is a cubic polynomial over Q(t) defining an elliptic curve 
     7191"USAGE:  jInvariantOfAPuiseuxCubic(f[,#]); f poly, # list
     7192ASSUME:  poly is a cubic polynomial over Q(t) defining an elliptic curve
    71937193         and # is empty
    7194 RETURN:  list, containing two polynomials whose ratio is the j-invariant 
     7194RETURN:  list, containing two polynomials whose ratio is the j-invariant
    71957195               of the  elliptic curve defined by poly
    7196 ASSUME:  poly is a cubic polynomial over Q(t) defining an elliptic curve 
     7196ASSUME:  poly is a cubic polynomial over Q(t) defining an elliptic curve
    71977197         and # is non-empty
    71987198RETURN:  int, the order of the j-invariant of the elliptic curve defined by poly
     
    72037203    ERROR("The input polynomial is not a cubic!");
    72047204  }
    7205   // compute first the Weierstrass form of the cubic 
     7205  // compute first the Weierstrass form of the cubic
    72067206  // - this does not change the j-invariant
    72077207  f=weierstrassFormOfACubic(f);
     
    72287228    ERROR("The input is a rational curve and has no j-invariant!");
    72297229  }
    7230   if (size(#)>0) // if the optional argument is given, 
     7230  if (size(#)>0) // if the optional argument is given,
    72317231  { // then only the negative of the order is computed
    72327232    int zaehler=3*simplifyToOrder(c4)[1];
     
    72717271/*
    72727272
    7273 /// Note, only the following procedures need further examples 
     7273/// Note, only the following procedures need further examples
    72747274/// (the others are too simple):
    72757275/// A) tropicalLifting (best tested via displayTropicalLifting)
     
    73027302// Example 3 - the ideal is not zero dimensional
    73037303// --------------------------------------------------------
    7304 ring r1=0,(t,x,y),dp; 
     7304ring r1=0,(t,x,y),dp;
    73057305poly f=(9t27-12t26-5t25+21t24+35t23-51t22-40t21+87t20+56t19-94t18-62t17+92t16+56t15-70t14-42t13+38t12+28t11+18t10-50t9-48t8+40t7+36t6-16t5-12t4+4t2)*x2+(-9t24+12t23-4t22-42t20+28t19+30t18-20t17-54t16+16t15+48t14-16t12+8t11-18t10-26t9+30t8+20t7-24t6+4t5+28t4-8t3-16t2+4)*xy+(6t16-10t15-2t14+16t13+4t12-18t11-10t10+24t9+6t8-20t7+8t6+8t5-20t4-4t3+12t2+4t-4)*y2+(-9t28+3t27+8t26-4t25-45t24-6t23+42t22+30t21-94t20-40t19+68t18+82t17-38t16-60t15+26t14+36t13-22t12-20t11+4t10+4t9+12t8+8t7-8t6-8t5+4t4)*x+(9t27-21t26+16t25+14t24+12t23-61t22+27t21+80t20-19t19-100t18+26t17+96t16-24t15-84t14+44t12-2t11-18t10+2t9+40t8+4t7-32t6-12t5+4t3+12t2-4)*y+(9t27-12t26+4t25+36t23-18t22-28t21-2t20+54t19+14t18-52t17-44t16+24t15+40t14-4t13-12t12+4t11-4t10-4t9+4t8);
    73067306f;
     
    74887488poly f=t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2;
    74897489list graph=tropicalCurve(f);
    7490 graph; 
     7490graph;
    74917491size(graph)-1;
    74927492drawTropicalCurve(graph);
Note: See TracChangeset for help on using the changeset viewer.