Changeset d8217b in git


Ignore:
Timestamp:
Oct 15, 2008, 10:53:18 AM (15 years ago)
Author:
Thomas Markwig <keilen@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
Children:
28f88cb738f9da7f460746ac9e08014e14065286
Parents:
5c9d99573bf1433cfce050d20faf365415f0e341
Message:
Fehler in weierstrassFormOfACubic behoben.


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/tropical.lib

    r5c9d99 rd8217b  
    1 version="$Id: tropical.lib,v 1.8 2008-10-09 09:31:58 Singular Exp $";
     1version="$Id: tropical.lib,v 1.9 2008-10-15 08:53:18 keilen Exp $";
    22category="Tropical Geometry";
    33info="
     
    88@*               Thomas Markwig,  email: keilen@mathematik.uni-kl.de
    99
    10 WARNING:
     10WARNING: 
    1111     - tropicalLifting will only work under LINUX and if in addition gfan is installed.
    1212@*   - drawTropicalCurve and drawTropicalNewtonSubdivision will only display the tropical
     
    2020     the torus is embedded via the map sending a point x in (K*)^n to the point (x^v0,...,x^vm).
    2121     The generic hyperplane sections are just the images of the hypersurfaces in (K*)^n defined by
    22      the polynomials f=a0*x^v0+...+am*x^vm=0. Some properties of these hypersurfaces can be studied
    23      via tropicalisation.
    24 
    25      For this we suppose that K=C{{t}} is the field of Puiseux series over the field of complex
     22     the polynomials f=a0*x^v0+...+am*x^vm=0. Some properties of these hypersurfaces can be studied 
     23     via tropicalisation. 
     24
     25     For this we suppose that K=C{{t}} is the field of Puiseux series over the field of complex 
    2626     numbers (or any other field with a valuation into the real numbers). One associates to the
    2727     hypersurface given by f=a0*x^v0+...+am*x^vm the tropical hypersurface defined by the tropicalisation
     
    2929     of the integer vector v in Z^n with the vector x=(x1,...,xn) of variables, so that trop(f) is
    3030     a piecewise linear function on R^n. The corner locus of this function (i.e. the points at which
    31      the minimum is attained a least twice) is the tropical hypersurface defined by trop(f).
     31     the minimum is attained a least twice) is the tropical hypersurface defined by trop(f). 
    3232     The theorem of Newton-Kapranov states that this tropical hypersurface is the same as if one
    3333     computes pointwise the valuation of the hypersurface given by f. The analogue holds true if one
    34      replaces one equation f by an ideal I. A constructive proof of the theorem is given by an adapted
     34     replaces one equation f by an ideal I. A constructive proof of the theorem is given by an adapted 
    3535     version of the Newton-Puiseux algorithm. The hard part is to find a point in the variety over
    3636     C{{t}} which corresponds to a given point in the tropical variety.
     
    3939     Of course we cannot represent the field of Puiseux series over C in its full strength, however,
    4040     in order to compute interesting examples it will be sufficient to replace the complex numbers C
    41      by the rational numbers Q and to replace Puiseux series in t by rational functions in t,
    42      i.e. we replace C{{t}} by Q(t), or sometimes even by Q[t]. Note, that this in particular
     41     by the rational numbers Q and to replace Puiseux series in t by rational functions in t, 
     42     i.e. we replace C{{t}} by Q(t), or sometimes even by Q[t]. Note, that this in particular 
    4343     forbits rational exponents for the t's.
    4444
     
    4848     If, however, for some reason you prefer to work with general vi, then you have to pass right away to
    4949     the tropicalisation of the equations, whereever this is allowed -- these are linear polynomials
    50      where the constant coefficient correspond to the valuation of the original coefficient and where
     50     where the constant coefficient correspond to the valuation of the original coefficient and where 
    5151     the non-constant coefficient correspond to the exponents of the monomials, thus they may be rational
    52      numbers respectively negative numbers:
     52     numbers respectively negative numbers: 
    5353     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}.
    5454
     
    5959                          I have to be in the polynomial ring Q[t,x1,...,xn] considered as a subring of
    6060                          C{{t}}[x1,...,xn]; a solution will be constructed up to given order; note that
    61                           several field extensions of Q might be necessary thoughout the intermediate
     61                          several field extensions of Q might be necessary thoughout the intermediate 
    6262                          computations; the procedures uses the external program gfan
    6363@*   - drawTropicalCurve  visualises a tropical plane curve either given by a polynomial in Q(t)[x,y]
     
    6666@*   - tropicalJInvariant computes the tropical j-invaiant of a tropical elliptic curve
    6767@*   - jInvariant         computes the j-invariant of an elliptic curve
    68 @*   - weierstrassFom     computes the Weierstrass form of an elliptic curve
     68@*   - weierstrassFom     computes the Weierstrass form of an elliptic curve     
    6969
    7070PROCEDURES CONCERNED WITH TROPICAL LIFTING:
     
    9393PROCEDURES CONCERNED WITH THE LATEX CONVERSION:
    9494     texNumber(poly)                  outputs the texcommand for the leading coefficient of poly
    95      texPolynomial(poly)              outputs the texcommand for the polynomial poly
     95     texPolynomial(poly)              outputs the texcommand for the polynomial poly 
    9696     texMatrix(matrix)                outputs the texcommand for the matrix
    9797     texDrawBasic(list)               embeds the output of texDrawTropical in a texdraw environment
    9898     texDrawTropical(list)            computes the texdraw commands for a tropical curve
    99      texDrawNewtonSubdivision(list)   computes the texdraw commands for a Newton subdivision
    100      texDrawTriangulation(list,list)  computes the texdraw commands for a triangulation
     99     texDrawNewtonSubdivision(list)   computes the texdraw commands for a Newton subdivision 
     100     texDrawTriangulation(list,list)  computes the texdraw commands for a triangulation     
    101101
    102102AUXILARY PROCEDURES:
     
    108108     dualConic(poly)                  computes the dual of the affine plane conic defined by poly
    109109     parameterSubstitute(poly,int)    substitutes in the poly the parameter t by t^N
    110      tropcialSubst(poly,int,list)     computes the tropical polynomial of poly with certain substitutions
     110     tropcialSubst(poly,int,list)     computes the tropical polynomial of poly with certain substitutions 
    111111     randomPoly(int,int,int)          computes a polynomial with random coefficients
    112112     cleanTmp()                       removes the latex and ps files from /tmp created by other procedures
     
    137137/// - eliminatecomponents
    138138/// - findzerosAndBasictransform
    139 /// - ordermaximalideals
     139/// - ordermaximalideals 
    140140/// - verticesTropicalCurve
    141141/// - bunchOfLines
     
    186186
    187187////////////////////////////////////////////////////////////////////////////////////
    188 /// Procedures concerned with tropical parametrisation
    189 ///////////////////////////////////////////////////////////////////////////////////
     188/// Procedures concerned with tropical parametrisation 
     189/////////////////////////////////////////////////////////////////////////////////// 
    190190
    191191proc tropicalLifting (ideal i,intvec w,int ordnung,list #)
    192192"USAGE:  tropicalLifting(i,w,ord[,opt]); i ideal, w intvec, ord int, opt string
    193 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n], w=(w_0,w_1,...,w_n)
    194            and (w_1/w_0,...,w_n/w_0) is in the tropical variety of i,
    195            and ord is the order up to which a point in V(i) over Q{{t}} lying over
     193ASSUME:  - i is an ideal in Q[t,x_1,...,x_n], w=(w_0,w_1,...,w_n) 
     194           and (w_1/w_0,...,w_n/w_0) is in the tropical variety of i, 
     195           and ord is the order up to which a point in V(i) over Q{{t}} lying over 
    196196           (w_1/w_0,...,w_n/w_0) shall be computed; w_0 may NOT be ZERO
    197 @*       - the basering should not have any parameters on its own
     197@*       - the basering should not have any parameters on its own 
    198198           and it should have a global monomial ordering, e.g. ring r=0,(t,x(1..n)),dp;
    199 @*       - the first variable of the basering will be treated as the parameter t
     199@*       - the first variable of the basering will be treated as the parameter t 
    200200           in the Puiseux series field !!!!
    201201@*       - the optional parameter opt should be one or more strings among the following:
     
    203203@*         'isPrime'            : the ideal is prime over Q(t)[x_1,...,x_n]  (not to be checked);
    204204@*         'isInTrop'           : (w_1/w_0,...,w_n/w_0) is in the tropical variety (not to be checked);
    205 @*         'oldGfan'            : uses gfan version 0.2.1 or less
     205@*         'oldGfan'            : uses gfan version 0.2.1 or less 
    206206@*         'findAll'            : find all solutions of a zero-dimensional ideal over (w_1/w_0,...,w_n/w_0)
    207207@*         'noAbs'              : do NOT use absolute primary decomposition
     
    226226               in the tropical variety of i to a point in V(i) over Puiseux series field up to
    227227               the first ord terms, if the ideal is zero-dimensional over Q{{t}};
    228                more precisely, each entry of the list is a list l as computed if
     228               more precisely, each entry of the list is a list l as computed if 
    229229               'find_all' was NOT set
    230230@*       WE NOW DESCRIBE THE LIST ENTRIES IF 'findAll' WAS NOT SET:
    231 @*       - the ring l[1] contains an ideal LIFT, which contains
     231@*       - the ring l[1] contains an ideal LIFT, which contains 
    232232           a point in V(i) lying over w up to the first ord terms;
    233233@*       - and if the integer l[2] is N then t has to be replaced by t^1/N in the
     
    235235@*       - if the k+1st entry of l[3] is  non-zero, then the kth component of LIFT has to
    236236           be multiplied t^(-l[3][k]/l[3][1]) AFTER substituting t by t^1/N
    237 @*       - unless the option 'noResubst' was set, the kth entry of list l[4]
     237@*       - unless the option 'noResubst' was set, the kth entry of list l[4] 
    238238           is a string which represents the kth generator of
    239239           the ideal i where the coordinates have been replaced by the result of the lift;
     
    246246@*       - if the parameter 'findAll' is set AND the ideal i is zero-dimensional in Q{{t}}[x_1,...,x_n]
    247247           then ALL points in V(i) lying over w are computed up to order ord; if the ideal
    248            is not-zero dimenisonal, then only all points in the ideal after cutting down
     248           is not-zero dimenisonal, then only all points in the ideal after cutting down 
    249249           to dimension zero will be computed
    250250@*       - the procedure REQUIRES that the program GFAN is installed on your computer;
     
    263263             and thus there may not exist a point in V(i) over the Puiseux series field
    264264             with the desired valuation; so there is no chance that the procedure produced
    265              a sensible output - e.g. if i=tx^p-tx-1
    266 @*         + if the dimension of i over Z/pZ(t) is not zero the process of reduction to
     265             a sensible output - e.g. if i=tx^p-tx-1 
     266@*         + if the dimension of i over Z/pZ(t) is not zero the process of reduction to 
    267267             zero might not work if the characteristic is small and you are unlucky
    268 @*         + the option 'noAbs' has to be used since absolute primary decomposition in
     268@*         + the option 'noAbs' has to be used since absolute primary decomposition in 
    269269             Singular only works in characteristic zero
    270 @*       - the basefield should either be Q or Z/pZ for some prime p; field extensions
     270@*       - the basefield should either be Q or Z/pZ for some prime p; field extensions 
    271271           will be computed where necessary; if you need parameters or field extensions
    272272           from the beginning they should rather be simulated as variables possibly adding
     
    346346  {
    347347    Error("The first coordinate of your input w must be NON-ZERO, since it is a DENOMINATOR!");
    348   }
     348  } 
    349349  // if w_0<0, then replace w by -w, so that the "denominator" w_0 is positive
    350350  if (w[1]<0)
     
    362362    w[1]=-1;
    363363  }
    364   // if some entry of w is positive, we have to make a transformation,
     364  // if some entry of w is positive, we have to make a transformation, 
    365365  // which moves it to something non-positive
    366366  for (j=2;j<=nvars(basering);j++)
     
    387387  {
    388388    variablen=variablen+var(j);
    389   }
     389  }   
    390390  map GRUNDPHI=BASERING,t,variablen;
    391391  ideal i=GRUNDPHI(i);
    392   // compute the initial ideal of i and test if w is in the tropical variety of i
     392  // compute the initial ideal of i and test if w is in the tropical variety of i 
    393393  // - the last entry 1 only means that t is the last variable in the ring
    394394  ideal ini=tInitialIdeal(i,w,1);
    395395  if (isintrop==0) // test if w is in trop(i) only if isInTrop has not been set
    396   {
     396  {   
    397397    poly product=1;
    398398    for (j=1;j<=nvars(basering)-1;j++)
     
    418418      // the procedurce cutdown computes a new ring, in which there lives a zero-dimensional
    419419      // ideal which has been computed by cutting down the input with generic linear forms
    420       // of the type x_i1-p_1,...,x_id-p_d for some polynomials p_1,...,p_d not depending
     420      // of the type x_i1-p_1,...,x_id-p_d for some polynomials p_1,...,p_d not depending 
    421421      // on the variables x_i1,...,x_id; that way we have reduced the number of variables by dd !!!
    422422      // the new zero-dimensional ideal is called i, its t-initial ideal (with respect to
    423       // the new w=CUTDOWN[2]) is ini, and finally there is a list repl in the ring
     423      // the new w=CUTDOWN[2]) is ini, and finally there is a list repl in the ring 
    424424      // which contains at the polynomial p_j at position i_j and a zero otherwise;
    425425      if (isprime==0) // the minimal associated primes of i are computed
     
    461461    for (jj=1;jj<=size(TP);jj++)
    462462    {
    463       // the list TP contains as a first entry the ring over which the tropical parametrisation
     463      // the list TP contains as a first entry the ring over which the tropical parametrisation 
    464464      // of the (possibly cutdown ideal) i lives
    465465      def LIFTRING=TP[jj][1];
     
    493493        }
    494494        setring LIFTRING;
    495         ideal LIFT=imap(REPLACEMENTRING,LIFT);
    496         // test now if the LIFT has the correct valuation !!!
     495        ideal LIFT=imap(REPLACEMENTRING,LIFT);   
     496        // test now if the LIFT has the correct valuation !!!     
    497497        // note: it may happen, that when resubstituting PARA into the replacement rules
    498498        //       there occured some unexpected cancellation; we only know that for SOME
    499         //       solution of the zero-dimensional reduction NO canellation will occur,
     499        //       solution of the zero-dimensional reduction NO canellation will occur, 
    500500        //       but for others this may very well happen; this in particular means that
    501501        //       we possibly MUST compute all zero-dimensional solutions when cutting down!
     
    548548          // replace @a by a in minpoly and in LIFT
    549549          map phi=INTERRING,t,a,a;
    550           mp=phi(mp);
     550          mp=phi(mp);     
    551551          LIFT=phi(LIFT);
    552552          // pass now to a ring whithout @a and with a as parameter
     
    555555          ideal LIFT=imap(INTERRING,LIFT);
    556556          kill INTERRING;
    557         }
     557        }   
    558558        // then export LIFT
    559         export(LIFT);
     559        export(LIFT); 
    560560        // test the  result by resubstitution
    561         setring GRUNDRING;
     561        setring GRUNDRING; 
    562562        list resubst;
    563563        if (noresubst==0)
     
    568568          }
    569569          else
    570           {
     570          {     
    571571            resubst=tropicalliftingresubstitute(substitute(i,t,t^(TP[jj][2])),list(LIFTRING),N*TP[jj][2]);
    572572          }
    573573        }
    574574        setring BASERING;
    575         // Finally, if t has been replaced by t^N, then we have to change the
     575        // Finally, if t has been replaced by t^N, then we have to change the 
    576576        // third entry of TP by multiplying by N.
    577577        if (noabs==1)
     
    598598      "The procedure will be restarted with the option 'findAll'.";
    599599      "Go on by hitting RETURN!";
    600       findall=1;
     600      findall=1;   
    601601      noabs=0;
    602602      setring CUTDOWNRING;
     
    604604      "i";i;
    605605      "ini";tInitialIdeal(i,w,1);
    606 
     606     
    607607/*
    608608      setring GRUNDRING;
     
    630630  if (voice+printlevel>=2)
    631631  {
    632 
     632     
    633633      "The procedure has created a list of lists. The jth entry of this list
    634634contains a ring, an integer and an intvec.
    635635In this ring lives an ideal representing the wanted lifting,
    636636if the integer is N then in the parametrisation t has to be replaced by t^1/N,
    637 and if the ith component of the intvec is w[i] then the ith component in LIFT
     637and if the ith component of the intvec is w[i] then the ith component in LIFT 
    638638should be multiplied by t^-w[i]/N in order to get the parametrisation.
    639 
     639   
    640640Suppose your list has the name L, then you can access the 1st ring via:
    641641";
    642642    if (findall==1)
    643643    {
    644       "def LIFTRing=L[1][1]; setring LIFTRing; LIFT;
     644      "def LIFTRing=L[1][1]; setring LIFTRing; LIFT; 
    645645";
    646646    }
    647647    else
    648648    {
    649       "def LIFTRing=L[1]; setring LIFTRing; LIFT;
     649      "def LIFTRing=L[1]; setring LIFTRing; LIFT; 
    650650";
    651     }
     651    } 
    652652  }
    653653  if (findall==1) // if all solutions have been computed, return a list of lists
     
    674674   def LIFTRing=LIST[1];
    675675   setring LIFTRing;
    676    // LIFT contains the first 4 terms of a point in the variety of i
     676   // LIFT contains the first 4 terms of a point in the variety of i 
    677677   // over the Puiseux series field C{{t}} whose order is -w[1]/w[0]=1
    678678   LIFT;
     
    702702   // NOTE: since the last component of v is positive, the lifting
    703703   //       must start with a negative power of t, which in Singular
    704    //       is not allowed for a variable.
     704   //       is not allowed for a variable. 
    705705   def LIFTRing3=LIST[1];
    706706   setring LIFTRing3;
     
    756756    }
    757757    if (size(troplift)==4) // this means that tropicalLifting was called with absolute primary decomposition
    758     {
     758    {     
    759759      setring LIFTRing;
    760760      "The lifting of the point in the tropical variety lives in the ring";
    761761      if ((size(LIFTpar)==0) and (N==1))
    762762      {
    763         Kstring+"[[t]]";
     763        Kstring+"[[t]]"; 
    764764      }
    765765      if ((size(LIFTpar)==0) and (N!=1))
    766766      {
    767         Kstring+"[[t^(1/"+string(N)+")]]";
     767        Kstring+"[[t^(1/"+string(N)+")]]"; 
    768768      }
    769769      if ((size(LIFTpar)!=0) and (N!=1))
    770       {
    771         Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]";
     770      {   
     771        Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]"; 
    772772      }
    773773      if ((size(LIFTpar)!=0) and (N==1))
    774       {
    775         Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]";
     774      {   
     775        Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]"; 
    776776      }
    777777    }
     
    790790      }
    791791      if ((size(LIFTpar)!=0) and (N!=1))
    792       {
    793         Kstring+"["+LIFTpar+"]/M[[t^(1/"+string(N)+")]]";
     792      {   
     793        Kstring+"["+LIFTpar+"]/M[[t^(1/"+string(N)+")]]"; 
    794794        "where M is the maximal ideal";
    795795        "M=<"+m+">";
    796796      }
    797797      if ((size(LIFTpar)!=0) and (N==1))
    798       {
    799         Kstring+"["+LIFTpar+"]/M[[t]]";
     798      {   
     799        Kstring+"["+LIFTpar+"]/M[[t]]"; 
    800800        "where M is the maximal ideal";
    801801        "M=<"+m+">";
    802       }
     802      }     
    803803    }
    804804    "";
     
    827827      }
    828828    }
    829   }
     829  }     
    830830}
    831831example
     
    841841
    842842////////////////////////////////////////////////////////////////////////////////////
    843 /// Procedures concerned with drawing a tropical curve or a Newton subdivision
     843/// Procedures concerned with drawing a tropical curve or a Newton subdivision 
    844844////////////////////////////////////////////////////////////////////////////////////
    845845proc tropicalCurve (def tp,list #)
    846846"USAGE:      tropicalCurve(tp[,#]); tp list, # optional list
    847 ASSUME:      tp is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c
     847ASSUME:      tp is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c 
    848848             representing a tropical Laurent polynomial defining a tropical plane curve;
    849849             alternatively tp can be a polynomial in Q(t)[x,y] defining a tropical plane curve
    850              via the valuation map;
     850             via the valuation map; 
    851851             the basering must have a global monomial ordering, two variables and up to one parameter!
    852 RETURN:      list, each entry i=1,...,size(l)-1 corresponds to a vertex in the tropical plane
     852RETURN:      list, each entry i=1,...,size(l)-1 corresponds to a vertex in the tropical plane 
    853853                   curve defined by tp
    854854                   l[i][1] = x-coordinate of the ith vertex
     
    857857                             the tropical curve is connected to the jth vertex with multiplicity given
    858858                             by the corresponding entry in the second row
    859                    l[i][4] = list of lists, the first entry of a list is a primitive integer vector
    860                              defining the direction of an unbounded edge emerging from the ith vertex
     859                   l[i][4] = list of lists, the first entry of a list is a primitive integer vector 
     860                             defining the direction of an unbounded edge emerging from the ith vertex 
    861861                             of the graph, the corresponding second entry in the list is the multiplicity
    862862                             of the unbounded edge
    863863                   l[i][5] = a polynomial whose monomials mark the vertices in the Newton polygon
    864                              corresponding to the entries in tp which take the common minimum
     864                             corresponding to the entries in tp which take the common minimum 
    865865                             at the ith vertex -- if some coefficient a or b of the linear polynomials
    866866                             in the input was negative, then each monomial has to be shifted by
     
    885885  }
    886886  // if you insert a single polynomial instead of an ideal representing a tropicalised polynomial,
    887   // then we compute first the tropicalisation of this polynomial -- this feature is not
     887  // then we compute first the tropicalisation of this polynomial -- this feature is not 
    888888  // documented in the above help string
    889889  if (typeof(tp)=="poly")
     
    892892    if ((npars(basering)!=1) or (nvars(basering)!=2))
    893893    {
    894       ERROR("The basering should have precisely one parameter and two indeterminates!");
     894      ERROR("The basering should have precisely one parameter and two indeterminates!");     
    895895    }
    896896    poly f=tp;
     
    901901  if (nvars(basering) != 2)
    902902  {
    903     ERROR("The basering should have precisely two indeterminates!");
     903    ERROR("The basering should have precisely two indeterminates!");     
    904904  }
    905905  // -1) Exclude the pathological case that the defining tropical polynomial has only one term,
     
    910910    intmat M[2][1]=0,0;
    911911    return(list(list(0,0,M,list(),detropicalise(tp[1])),list(list(leadexp(detropicalise(tp[1]))),list())));
    912   }
     912  }   
    913913  // 0) If the input was a list of linear polynomials, then some coefficient of x or y can be negative,
    914914  //    i.e. the input corresponds to the tropical curve of a Laurent polynomial. In that case we should
     
    925925    {
    926926      bb=koeffizienten(tp[i],2);
    927     }
     927    }   
    928928  }
    929929  if ((aa!=0) or (bb!=0))
     
    942942    return(bunchOfLines(tp));
    943943  }
    944   // 2) store all vertices belonging to the ith part of the
     944  // 2) store all vertices belonging to the ith part of the 
    945945  //    Newton subdivision in the list vtp[i] as 4th entry,
    946946  //    and store those, which are not corners of the ith subdivision polygon
    947947  //    in vtp[i][6]
    948   poly nwt;
     948  poly nwt; 
    949949  list boundaryNSD;  // stores the boundary of a Newton subdivision
    950   intmat zwsp[2][1]; // used for intermediate storage
     950  intmat zwsp[2][1]; // used for intermediate storage   
    951951  for (i=1;i<=size(vtp);i++)
    952952  {
     
    954954    nwt=vtp[i][3]; // the polynomial representing the ith part of the Newton subdivision
    955955    // store the vertices of the ith part of the Newton subdivision in the list newton
    956     list newton;
     956    list newton; 
    957957    while (nwt!=0)
    958958    {
     
    964964    vtp[i][4]=boundaryNSD[1];
    965965    vtp[i][5]=boundaryNSD[2];
    966     vtp[i][6]=zwsp; // the entries of the first row will denote to which vertex the ith one is connected
     966    vtp[i][6]=zwsp; // the entries of the first row will denote to which vertex the ith one is connected 
    967967                 // and the entries of the second row will denote with which multiplicity
    968968    kill newton; // we kill the superflous list
     
    984984    kill ipairs;
    985985  }
    986   // 4) Check for all pairs of verticies in the Newton diagram if they
     986  // 4) Check for all pairs of verticies in the Newton diagram if they 
    987987  //    occur in two different parts of the Newton subdivision
    988988  int deleted; // if a pair occurs in two NSD, it can be removed from both - deleted is then set to 1
     
    991991  d=1;  // counts the inner edges
    992992  for (i=1;i<=size(pairs)-1;i++)
    993   {
     993  { 
    994994    for (j=i+1;j<=size(pairs);j++)
    995995    {
     
    998998        deleted=0;
    999999        for (l=size(pairs[j]);l>=1 and deleted==0;l--)
    1000         {
     1000        { 
    10011001          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])))
    10021002          {
     
    10621062  for (i=1;i<=size(pairs);i++)
    10631063  {
    1064     list ubedges; // stores the unbounded edges
     1064    list ubedges; // stores the unbounded edges 
    10651065    k=1; // counts the unbounded edges
    10661066    for (j=1;j<=size(pairs[i]);j++)
     
    11141114    gr[3]=vtp[i][6];  // to which vertices is the ith vertex of the tropical curve connected
    11151115    gr[4]=vtp[i][7];  // the directions unbounded edges emerging from the ith vertex of the trop. curve
    1116     gr[5]=vtp[i][3];  // the vertices of the boundary of the ith part of the NSD
     1116    gr[5]=vtp[i][3];  // the vertices of the boundary of the ith part of the NSD 
    11171117    graph[i]=gr;
    11181118  }
     
    11491149// the coordinates of the first vertex are graph[1][1],graph[1][2];
    11501150   graph[1][1],graph[1][2];
    1151 // the first vertex is connected to the vertices
     1151// the first vertex is connected to the vertices 
    11521152//     graph[1][3][1,1..ncols(graph[1][3])]
    11531153   intmat M=graph[1][3];
    11541154   M[1,1..ncols(graph[1][3])];
    1155 // the weights of the edges to these vertices are
     1155// the weights of the edges to these vertices are 
    11561156//     graph[1][3][2,1..ncols(graph[1][3])]
    11571157   M[2,1..ncols(graph[1][3])];
    11581158// from the first vertex emerge size(graph[1][4]) unbounded edges
    11591159   size(graph[1][4]);
    1160 // the primitive integral direction vector of the first unbounded edge
     1160// the primitive integral direction vector of the first unbounded edge 
    11611161//     of the first vertex
    11621162   graph[1][4][1][1];
    11631163// the weight of the first unbounded edge of the first vertex
    11641164   graph[1][4][1][2];
    1165 // the monomials which are part of the Newton subdivision of the first vertex
     1165// the monomials which are part of the Newton subdivision of the first vertex 
    11661166   graph[1][5];
    1167 // connecting the points in graph[size(graph)][1] we get
     1167// connecting the points in graph[size(graph)][1] we get 
    11681168//     the boundary of the Newton polytope
    11691169   graph[size(graph)][1];
    1170 // an entry in graph[size(graph)][2] is a pair of points
     1170// an entry in graph[size(graph)][2] is a pair of points 
    11711171//     in the Newton polytope bounding an inner edge
    11721172   graph[size(graph)][2][1];
     
    11751175proc drawTropicalCurve (def f,list #)
    11761176"USAGE:      drawTropicalCurve(f[,#]); f poly or list, # optional list
    1177 ASSUME:      f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c
     1177ASSUME:      f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c 
    11781178             representing a tropical Laurent polynomial defining a tropical plane curve;
    11791179             alternatively f can be a polynomial in Q(t)[x,y] defining a tropical plane curve
    1180              via the valuation map;
     1180             via the valuation map; 
    11811181             the basering must have a global monomial ordering, two variables and up to one parameter!
    11821182RETURN:      NONE
    1183 NOTE:        - the procedure produces the files /tmp/tropicalcurveNUMBER.tex and
    1184                /tmp/tropicalcurveNUMBER.ps, where NUMBER is a random four digit integer;
     1183NOTE:        - the procedure produces the files /tmp/tropicalcurveNUMBER.tex and 
     1184               /tmp/tropicalcurveNUMBER.ps, where NUMBER is a random four digit integer; 
    11851185               moreover it displays the tropical curve defined by f via kghostview;
    11861186               if you wish to remove all these files from /tmp, call the procedure cleanTmp
    11871187@*           - edges with multiplicity greater than one carry this multiplicity
    11881188@*           - if # is empty, then the tropical curve is computed w.r.t. minimum, if #[1] is the
    1189                string 'max', then it is computed w.r.t. maximum
     1189               string 'max', then it is computed w.r.t. maximum 
    11901190@*           - if the last optional argument is 'onlytexfile' then only the latex file
    11911191               is produced; this option should be used if kghostview is not installed on
     
    12121212    if ((npars(basering)!=1) or (nvars(basering)!=2))
    12131213    {
    1214       ERROR("The basering should have precisely one parameter and two indeterminates!");
     1214      ERROR("The basering should have precisely one parameter and two indeterminates!");     
    12151215    }
    12161216    texf=texPolynomial(f); // write the polynomial over Q(t)
     
    12231223      texf="\\mbox{\\tt The defining equation was not handed over!}";
    12241224      list graph=f;
    1225     }
     1225    }   
    12261226    else
    12271227    { // write the tropical polynomial defined by f
    12281228      if (size(#)==0)
    1229       {
     1229      {     
    12301230        texf="\\min\\{";
    12311231      }
     
    12361236      for (j=1;j<=size(f);j++)
    12371237      {
    1238         texf=texf+texPolynomial(f[j]);
     1238        texf=texf+texPolynomial(f[j]);   
    12391239        if (j<size(f))
    12401240        {
     
    12451245          texf=texf+"\\}";
    12461246        }
    1247       }
     1247      }   
    12481248      list graph=tropicalCurve(f,#); // the graph of the tropical polynomial f
    12491249    }
     
    12631263\\addtolength{\\topmargin}{-\\headheight}
    12641264\\addtolength{\\topmargin}{-\\topskip}
    1265 \\setlength{\\textheight}{267mm}
     1265\\setlength{\\textheight}{267mm} 
    12661266\\addtolength{\\textheight}{\\topskip}
    12671267\\addtolength{\\textheight}{-\\footskip}
    12681268\\addtolength{\\textheight}{-30pt}
    1269 \\setlength{\\oddsidemargin}{-1in}
     1269\\setlength{\\oddsidemargin}{-1in} 
    12701270\\addtolength{\\oddsidemargin}{20mm}
    12711271\\setlength{\\evensidemargin}{\\oddsidemargin}
    1272 \\setlength{\\textwidth}{170mm}
     1272\\setlength{\\textwidth}{170mm} 
    12731273
    12741274\\begin{document}
    12751275   \\parindent0cm
    12761276   \\begin{center}
    1277       \\large\\bf The Tropicalisation of
     1277      \\large\\bf The Tropicalisation of 
    12781278
    12791279      \\bigskip
     
    12991299
    13001300   \\begin{center}
    1301        "+texDrawNewtonSubdivision(graph,#)+"
     1301       "+texDrawNewtonSubdivision(graph,#)+" 
    13021302   \\end{center}
    13031303\\end{document}";
     
    13061306    int rdnum=random(1000,9999);
    13071307    write(":w /tmp/tropicalcurve"+string(rdnum)+".tex",TEXBILD);
    1308     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 &");
     1308    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 &"); 
    13091309  }
    13101310  else
     
    13221322// given by f and displays a post script image, provided you have kghostview
    13231323   drawTropicalCurve(f);
    1324 // we can instead apply the procedure to a tropical polynomial
     1324// we can instead apply the procedure to a tropical polynomial and use "maximum"
    13251325   poly g=t3*(x7+y7+1)+1/t3*(x4+y4+x2+y2+x3y+xy3)+1/t21*x2y2;
    13261326   list tropical_g=tropicalise(g);
    13271327   tropical_g;
    1328    drawTropicalCurve(tropical_g);
     1328   drawTropicalCurve(tropical_g,"max");
    13291329}
    13301330
    13311331proc drawNewtonSubdivision (def f,list #)
    13321332"USAGE:   drawTropicalCurve(f[,#]); f poly, # optional list
    1333 ASSUME:   f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c
     1333ASSUME:   f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c 
    13341334          representing a tropical Laurent polynomial defining a tropical plane curve;
    13351335          alternatively f can be a polynomial in Q(t)[x,y] defining a tropical plane curve
    1336           via the valuation map;
     1336          via the valuation map; 
    13371337          the basering must have a global monomial ordering, two variables and up to one parameter!
    13381338RETURN:   NONE
    1339 NOTE:     - the procedure produces the files /tmp/newtonsubdivisionNUMBER.tex,
    1340             and /tmp/newtonsubdivisionNUMBER.ps, where NUMBER is a random four digit integer;
     1339NOTE:     - the procedure produces the files /tmp/newtonsubdivisionNUMBER.tex, 
     1340            and /tmp/newtonsubdivisionNUMBER.ps, where NUMBER is a random four digit integer; 
    13411341            moreover it desplays the tropical curve defined by f via kghostview;
    13421342            if you wish to remove all these files from /tmp, call the procedure cleanTmp
    13431343@*          if # is empty, then the tropical curve is computed w.r.t. minimum, if #[1] is the
    1344             string 'max', then it is computed w.r.t. maximum
     1344            string 'max', then it is computed w.r.t. maximum 
    13451345@*        - note that lattice points in the Newton subdivision which are black correspond to markings
    13461346            of the marked subdivision, while lattice points in grey are not marked
     
    13571357  { // write the tropical polynomial defined by f
    13581358    if (size(#)==0)
    1359     {
     1359    {     
    13601360      texf="\\min\\{";
    13611361    }
     
    13661366    for (j=1;j<=size(f);j++)
    13671367    {
    1368       texf=texf+texPolynomial(f[j]);
     1368      texf=texf+texPolynomial(f[j]);   
    13691369      if (j<size(f))
    13701370      {
     
    13751375        texf=texf+"\\}";
    13761376      }
    1377     }
     1377    }   
    13781378    list graph=tropicalCurve(f,#); // the graph of the tropical polynomial f
    13791379  }
     
    13831383   \\parindent0cm
    13841384   \\begin{center}
    1385       \\large\\bf The Newtonsubdivison of
     1385      \\large\\bf The Newtonsubdivison of 
    13861386      \\begin{displaymath}
    13871387          f="+texf+"
     
    13911391
    13921392   \\begin{center}
    1393 "+texDrawNewtonSubdivision(graph)+
     1393"+texDrawNewtonSubdivision(graph)+ 
    13941394"   \\end{center}
    13951395
     
    13971397  int rdnum=random(1000,9999);
    13981398  write(":w /tmp/newtonsubdivision"+string(rdnum)+".tex",TEXBILD);
    1399   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 &");
     1399  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 &"); 
    14001400//  return(TEXBILD);
    14011401}
     
    14221422proc tropicalJInvariant (def f,list #)
    14231423"USAGE:      tropicalJInvariant(f[,#]); f poly or list, # optional list
    1424 ASSUME:      f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c
     1424ASSUME:      f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c 
    14251425             representing a tropical Laurent polynomial defining a tropical plane curve;
    14261426             alternatively f can be a polynomial in Q(t)[x,y] defining a tropical plane curve
    1427              via the valuation map;
     1427             via the valuation map; 
    14281428@*           the basering must have a global monomial ordering, two variables and up to one parameter!
    14291429RETURN:      number, if the graph underlying the tropical curve has precisely one loop then its weighted
    14301430                     lattice length is returned, otherwise the result will be -1
    1431 NOTE:        - if the tropical curve is elliptic and its embedded graph has precisely one loop,
     1431NOTE:        - if the tropical curve is elliptic and its embedded graph has precisely one loop, 
    14321432               then the weigthed lattice length of the loop is its tropical j-invariant
    1433 @*           - the procedure checks if the embedded graph of the tropical curve has genus one,
    1434                but it does NOT check if the loop can be resolved, so that the curve is not
    1435                a proper tropical elliptic curve
     1433@*           - the procedure checks if the embedded graph of the tropical curve has genus one, 
     1434               but it does NOT check if the loop can be resolved, so that the curve is not 
     1435               a proper tropical elliptic curve 
    14361436@*           - if the embedded graph of a tropical elliptic curve has more than one loop, then
    14371437               all but one can be resolved, but this is not observed by this procedure, so it
    14381438               will not compute the j-invariant
    14391439@*           - if # is empty, then the tropical curve is computed w.r.t. minimum, if #[1] is the
    1440                string 'max', then it is computed w.r.t. maximum
     1440               string 'max', then it is computed w.r.t. maximum 
    14411441@*           - the tropicalJInvariant of a plane tropical cubic is the 'cycle length' of the
    1442                cubic as introduced in the paper:
     1442               cubic as introduced in the paper: 
    14431443               Erik Katz, Hannah Markwig, Thomas Markwig: The j-invariant of a cubic tropical plane curve.
    14441444EXAMPLE:     example tropicalJInvariant;   shows an example"
     
    14541454    {
    14551455      if (typeof(f[1])=="list")
    1456       {
     1456      {       
    14571457        list graph=f;
    14581458      }
     
    14661466        {
    14671467          ERROR("This is no valid input.");
    1468         }
     1468        }       
    14691469      }
    14701470    }
     
    14941494  else
    14951495  {
    1496     intmat nullmat[2][1];  // used to set
    1497     // 4) find a vertex which has only one bounded edge, if none exists zero is returned,
     1496    intmat nullmat[2][1];  // used to set 
     1497    // 4) find a vertex which has only one bounded edge, if none exists zero is returned, 
    14981498    //    otherwise the number of the vertex in the list graph
    14991499    int nonloopvertex=findNonLoopVertex(graph);
     
    15281528    intvec loop,weights; // encodes the loop and the edges
    15291529    i=1;
    1530     //    start by finding some vertex which belongs to the loop
    1531     while (loop==0)
     1530    //    start by finding some vertex which belongs to the loop 
     1531    while (loop==0) 
    15321532    {
    15331533      if (ncols(graph[i][3])==1) // the graph[i][3] of a vertex in the loop has 2 columns, all others have 1
     
    15371537      else
    15381538      {
    1539         loop[1]=i; // a starting vertex is found
    1540         loop[2]=graph[i][3][1,1]; // it is connected to the vertex with this number
     1539        loop[1]=i; // a starting vertex is found 
     1540        loop[2]=graph[i][3][1,1]; // it is connected to the vertex with this number 
    15411541        weights[2]=graph[i][3][2,1]; // and the edge has this weight
    15421542      }
     
    15491549      // to which the active vertex j is connected; one is loop[k-1], i.e. the one which
    15501550      // precedes j in the loop; we have to choose the other one
    1551       if (graph[j][3][1,1]==loop[k-1])
     1551      if (graph[j][3][1,1]==loop[k-1]) 
    15521552      {
    15531553        loop[k+1]=graph[j][3][1,2];
     
    15601560      }
    15611561      j=loop[k+1]; // set loop[k+1] the new active vertex
    1562       k++;
    1563     }
     1562      k++; 
     1563    }   
    15641564    // 7) compute for each edge in the loop the lattice length
    15651565    poly xcomp,ycomp; // the x- and y-components of the vectors connecting two vertices of the loop
    15661566    number nenner;    // the product of the denominators of the x- and y-components
    15671567    number jinvariant;  // the j-invariant
    1568     int eins,zwei,ggt;
     1568    int eins,zwei,ggt; 
    15691569    for (i=1;i<=size(loop)-1;i++) // compute the lattice length for each edge
    15701570    {
    1571       xcomp=graph[loop[i]][1]-graph[loop[i+1]][1];
    1572       ycomp=graph[loop[i]][2]-graph[loop[i+1]][2];
     1571      xcomp=graph[loop[i]][1]-graph[loop[i+1]][1]; 
     1572      ycomp=graph[loop[i]][2]-graph[loop[i+1]][2]; 
    15731573      nenner=denominator(leadcoef(xcomp))*denominator(leadcoef(ycomp));
    1574       execute("eins="+string(numerator(leadcoef(nenner*xcomp)))+";");
    1575       execute("zwei="+string(numerator(leadcoef(nenner*ycomp)))+";");
     1574      execute("eins="+string(numerator(leadcoef(nenner*xcomp)))+";"); 
     1575      execute("zwei="+string(numerator(leadcoef(nenner*ycomp)))+";"); 
    15761576      ggt=gcd(eins,zwei); // the lattice length is the "gcd" of the x-component and the y-component
    15771577      jinvariant=jinvariant+ggt/(nenner*weights[i+1]); // divided by the weight of the edge
    15781578    }
    1579     return(jinvariant);
     1579    return(jinvariant);   
    15801580  }
    15811581}
     
    15911591// the curve can have arbitrary degree
    15921592   tropicalJInvariant(t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2);
    1593 // the procedure does not realise, if the embedded graph of the tropical
     1593// the procedure does not realise, if the embedded graph of the tropical 
    15941594//     curve has a loop that can be resolved
    15951595   tropicalJInvariant(1+x+y+xy+tx2y+txy2);
    15961596// but it does realise, if the curve has no loop at all ...
    15971597   tropicalJInvariant(x+y+1);
    1598 // or if the embedded graph has more than one loop - even if only one
     1598// or if the embedded graph has more than one loop - even if only one 
    15991599//     cannot be resolved
    16001600   tropicalJInvariant(1+x+y+xy+tx2y+txy2+t3x5+t3y5+tx2y2+t2xy4+t2yx4);
     
    16031603proc weierstrassForm (poly f,list #)
    16041604"USAGE:      weierstrassFormOfACubic(wf[,#]); wf poly, # list
    1605 ASSUME:      wf is a polynomial whose Newton polygon has precisely one interior lattice
     1605ASSUME:      wf is a a polynomial whose Newton polygon has precisely one interior lattice
    16061606             point, so that it defines an elliptic curve on the toric surface corresponding
    16071607             to the Newton polygon
    16081608RETURN:      poly, the Weierstrass normal form of the polygon
    1609 NOTE:        - the algorithm for the coefficients of the Weierstrass form is due to
     1609NOTE:        - the algorithm for the coefficients of the Weierstrass form is due to 
    16101610               Fernando Rodriguez Villegas, villegas@math.utexas.edu
    16111611@*           - the characteristic of the base field should not be 2 or 3
     
    16691669
    16701670proc jInvariant (poly f,list #)
    1671 "USAGE:      jInvariant(f[,#]); f poly, # list
    1672 ASSUME:      - f is a polynomial whose Newton polygon has precisely one interior lattice
     1671"USAGE:      jInvariant(f[,#]); f poly, # list 
     1672ASSUME:      - f is a a polynomial whose Newton polygon has precisely one interior lattice
    16731673               point, so that it defines an elliptic curve on the toric surface corresponding
    16741674               to the Newton polygon
    1675 @*           - it the optional argument # is present the base field should be Q(t) and
     1675@*           - it the optional argument # is present the base field should be Q(t) and 
    16761676               the optional argument should be one of the following strings:
    16771677@*             'ord'   : then the return value is of type integer, namely the order of the j-invariant
     
    17041704   echo=2;
    17051705   ring r=(0,t),(x,y),dp;
    1706 // jInvariant computes the j-invariant of a cubic
     1706// jInvariant computes the j-invariant of a cubic 
    17071707   jInvariant(x+y+x2y+y3+1/t*xy);
    1708 // if the ground field has one parameter t, then we can instead
     1708// if the ground field has one parameter t, then we can instead 
    17091709//    compute the order of the j-invariant
    17101710   jInvariant(x+y+x2y+y3+1/t*xy,"ord");
     
    17141714   poly h=x22y11+x19y10+x17y9+x16y9+x12y7+x9y6+x7y5+x2y3+x14y8;
    17151715// its j-invariant is
    1716    jInvariant(h);
     1716   jInvariant(h); 
    17171717}
    17181718
     
    17771777  ring tRING=0,t,ls;
    17781778  list pointdenom=imap(BASERING,pointdenom);
    1779   list pointnum=imap(BASERING,pointnum);
     1779  list pointnum=imap(BASERING,pointnum); 
    17801780  intvec pointcoordinates;
    17811781  for (i=1;i<=size(pointdenom);i++)
     
    18531853   We consider the concic through the following five points:
    18541854   \\begin{displaymath}
    1855 ";
     1855"; 
    18561856  string texf=texDrawTropical(graphf,list("",scalefactor));
    18571857  for (i=1;i<=size(points);i++)
     
    18911891\\end{document}";
    18921892  setring BASERING;
    1893   // If # non-empty, compute the dual conic and the tangents through the dual points
     1893  // If # non-empty, compute the dual conic and the tangents through the dual points 
    18941894  // corresponding to the tangents of the given conic.
    18951895  if (size(#)>0)
    18961896  {
    18971897    list dualpoints;
    1898     for (i=1;i<=size(points);i++)
     1898    for (i=1;i<=size(points);i++) 
    18991899    {
    19001900      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));
     
    19201920// conic[2] is the equation of the conic f passing through the five points
    19211921   conic[2];
    1922 // conic[3] is a list containing the equations of the tangents
     1922// conic[3] is a list containing the equations of the tangents 
    19231923//          through the five points
    19241924   conic[3];
    19251925// conic[4] is an ideal representing the tropicalisation of the conic f
    19261926   conic[4];
    1927 // conic[5] is a list containing the tropicalisation
     1927// conic[5] is a list containing the tropicalisation 
    19281928//          of the five tangents in conic[3]
    19291929   conic[5];
    1930 // conic[6] is a list containing the vertices of the tropical conic
     1930// conic[6] is a list containing the vertices of the tropical conic 
    19311931   conic[6];
    19321932// conic[7] is a list containing the vertices of the five tangents
    19331933   conic[7];
    1934 // conic[8] contains the latex code to draw the tropical conic and
    1935 //          its tropicalised tangents; it can written in a file, processed and
    1936 //          displayed via kghostview
    1937    write(":w /tmp/conic.tex",conic[8]);
    1938    system("sh","cd /tmp; latex /tmp/conic.tex; dvips /tmp/conic.dvi -o;
     1934// conic[8] contains the latex code to draw the tropical conic and 
     1935//          its tropicalised tangents; it can written in a file, processed and 
     1936//          displayed via kghostview 
     1937   write(":w /tmp/conic.tex",conic[8]);   
     1938   system("sh","cd /tmp; latex /tmp/conic.tex; dvips /tmp/conic.dvi -o; 
    19391939            kghostview conic.ps &");
    1940 // with an optional argument the same information for the dual conic is computed
     1940// with an optional argument the same information for the dual conic is computed 
    19411941//         and saved in conic[9]
    19421942   conic=conicWithTangents(points,1);
    19431943   conic[9][2]; // the equation of the dual conic
    19441944}
    1945 
     1945 
    19461946////////////////////////////////////////////////////////////////////////////////////
    19471947/// Procedures concerned with tropicalisation
     
    19521952ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n]
    19531953RETURN:      list, the linear forms of the tropicalisation of f
    1954 NOTE:        if # is empty, then the valuation of t will be 1,
    1955 @*           if # is the string 'max' it will be -1;
    1956 @*           the latter supposes that we consider the maximum of the computed
     1954NOTE:        if # is empty, then the valuation of t will be 1, 
     1955@*           if # is the string 'max' it will be -1; 
     1956@*           the latter supposes that we consider the maximum of the the computed
    19571957             linear forms, the former that we consider their minimum
    19581958EXAMPLE:     example tropicalise;   shows an example"
     
    19771977    {
    19781978      tropicalf[i]=tropicalf[i]+exp[j]*var(j);
    1979     }
     1979    }   
    19801980    f=f-lead(f);
    19811981  }
     
    20132013}
    20142014
    2015 proc tInitialForm (poly f, intvec w)
     2015proc tInitialForm (poly f, intvec w) 
    20162016"USAGE:      tInitialForm(f,w); f a polynomial, w an integer vector
    20172017ASSUME:      f is a polynomial in Q[t,x_1,...,x_n] and w=(w_0,w_1,...,w_n)
     
    20262026  // do the same for the remaining part of f and compare the results
    20272027  // keep only the smallest ones
    2028   int vglgewicht;
    2029   f=f-lead(f);
     2028  int vglgewicht; 
     2029  f=f-lead(f); 
    20302030  while (f!=0)
    20312031  {
     
    20422042        initialf=initialf+lead(f);
    20432043      }
    2044     }
     2044    }   
    20452045    f=f-lead(f);
    20462046  }
     
    20582058}
    20592059
    2060 proc tInitialIdeal (ideal i,intvec w,list #)
     2060proc tInitialIdeal (ideal i,intvec w,list #) 
    20612061"USAGE:      tInitialIdeal(i,w); i ideal, w intvec
    2062 ASSUME:      i is an ideal in Q[t,x_1,...,x_n] and w=(w_0,...,w_n)
     2062ASSUME:      i is an ideal in Q[t,x_1,...,x_n] and w=(w_0,...,w_n) 
    20632063RETURN:      ideal ini, the t-initial ideal of i with respect to w"
    20642064{
     
    20872087  // ... and compute a standard basis with
    20882088  // respect to the homogenised ordering defined by w. Since the generators
    2089   // of i will be homogeneous it we can instead take the ordering wp
    2090   // with the weightvector (0,w) replaced by (M,...,M)+(0,w) for some
    2091   // large M, so that all entries are positive
     2089  // of i will be homogeneous it we can instead take the ordering wp 
     2090  // with the weightvector (0,w) replaced by (M,...,M)+(0,w) for some 
     2091  // large M, so that all entries are positive 
    20922092  int M=-minInIntvec(w)[1]+1; // find M such that w[j]+M is strictly positive for all j
    20932093  intvec whomog=M+1;
     
    20972097  }
    20982098  execute("ring WEIGHTRING=("+charstr(basering)+"),("+varstr(basering)+"),(wp("+string(whomog)+"));");
    2099   // map i to the new ring and compute a GB of i, then dehomogenise i,
    2100   // so that we can be sure, that the
     2099  // map i to the new ring and compute a GB of i, then dehomogenise i, 
     2100  // so that we can be sure, that the 
    21012101  // initial forms of the generators generate the initial ideal
    21022102  ideal i=subst(groebner(imap(HOMOGRING,i)),@s,1);
     
    23432343proc texDrawBasic (list texdraw)
    23442344"USAGE:      texDrawBasic(texdraw); list texdraw
    2345 ASSUME:      texdraw is a list of strings representing texdraw commands (as produced by
     2345ASSUME:      texdraw is a list of strings representing texdraw commands (as produced by 
    23462346             texDrawTropical) which should be embedded into a texdraw environment
    23472347RETURN:      string, a texdraw environment enclosing the input
     
    23632363    \\end{texdraw}";
    23642364  return(texdrawtp);
    2365 }
     2365} 
    23662366example
    23672367{
     
    23782378ASSUME:  graph is the output of tropicalCurve
    23792379RETURN:  string, the texdraw code of the tropical plane curve encoded by graph
    2380 NOTE:    - if the list # is non-empty, the first entry should be a string; if this string is 'max',
     2380NOTE:    - if the list # is non-empty, the first entry should be a string; if this string is 'max', 
    23812381           then the tropical curve is considered with respect to the maximum; otherwise the curve
    2382            is considered with respect to the minimum and the string can be used to
     2382           is considered with respect to the minimum and the string can be used to 
    23832383           insert further texdraw commands (e.g. to have a lighter image as when called
    2384            from inside conicWithTangents);
     2384           from inside conicWithTangents); 
    23852385@*       - the procedure computes a scalefactor for the texdraw command which should
    23862386           help to display the curve in the right way; this may, however, be a bad idea
     
    23922392  int i,j;
    23932393  // deal first with the pathological case that the input polynomial was a monomial
    2394   // and does therefore not define a tropical curve, and check if the Newton polytope is
     2394  // and does therefore not define a tropical curve, and check if the Newton polytope is 
    23952395  // a line segment so that the curve defines a bunch of lines
    23962396  int bunchoflines;
     
    24142414  // go on with the case that a tropical curve is defined
    24152415  if (size(#)==0)
    2416   {
     2416  {   
    24172417     string texdrawtp="
    24182418
     
    24222422  {
    24232423    if ((#[1]!="max") and (#[1]!=""))
    2424     {
     2424    {     
    24252425      string texdrawtp=#[1];
    24262426    }
     
    25452545NOTE:        - the list # should contain as only entry a string; if this string is 'max', then
    25462546               the tropical curve is considered with respect to the maximum; otherwise the curve
    2547                is considered with respect to the minimum and the string can be used to
     2547               is considered with respect to the minimum and the string can be used to 
    25482548               insert further texdraw commands (e.g. to have a lighter image as when called
    25492549               from inside conicWithTangents); the list # is optional and may as well be empty
     
    25542554  int i,j,k,l;
    25552555  list boundary=graph[size(graph)][1];
    2556   list inneredges=graph[size(graph)][2];
     2556  list inneredges=graph[size(graph)][2]; 
    25572557  intvec shiftvector=graph[size(graph)][3];
    25582558  string subdivision;
     
    25662566  poly scalefactor=minOfPolys(list(12/leadcoef(maxx),12/leadcoef(maxy)));
    25672567  if (scalefactor<1)
    2568   {
     2568  {   
    25692569    subdivision=subdivision+"
    25702570       \\relunitscale"+ decimal(scalefactor);
     
    25742574  {
    25752575    subdivision=subdivision+"
    2576         \\move ("+string(boundary[i][1])+" "+string(boundary[i][2])+")
     2576        \\move ("+string(boundary[i][1])+" "+string(boundary[i][2])+")       
    25772577        \\lvec ("+string(boundary[i+1][1])+" "+string(boundary[i+1][2])+")";
    2578   }
     2578  } 
    25792579  subdivision=subdivision+"
    2580         \\move ("+string(boundary[size(boundary)][1])+" "+string(boundary[size(boundary)][2])+")
     2580        \\move ("+string(boundary[size(boundary)][1])+" "+string(boundary[size(boundary)][2])+")       
    25812581        \\lvec ("+string(boundary[1][1])+" "+string(boundary[1][2])+")
    25822582
     
    25852585  {
    25862586    subdivision=subdivision+"
    2587         \\move ("+string(inneredges[i][1][1])+" "+string(inneredges[i][1][2])+")
     2587        \\move ("+string(inneredges[i][1][1])+" "+string(inneredges[i][1][2])+")       
    25882588        \\lvec ("+string(inneredges[i][2][1])+" "+string(inneredges[i][2][2])+")";
    25892589  }
     
    26052605    }
    26062606  }
    2607   // deal with the pathological cases
     2607  // deal with the pathological cases 
    26082608  if (size(boundary)==1) // then the Newton polytope is a point
    26092609  {
     
    26602660  {
    26612661    subdivision=subdivision+"
    2662        \\move ("+string(markings[i][1])+" "+string(markings[i][2])+")
     2662       \\move ("+string(markings[i][1])+" "+string(markings[i][2])+") 
    26632663       \\fcir f:0 r:"+decimal(2/(8*scalefactor),size(string(int(scalefactor)))+1);
    26642664  }
    26652665  // enclose subdivision in the texdraw environment
    2666   string texsubdivision="
     2666  string texsubdivision="     
    26672667    \\begin{texdraw}
    2668        \\drawdim cm  \\relunitscale 1
     2668       \\drawdim cm  \\relunitscale 1 
    26692669       \\linewd 0.05"
    26702670    +subdivision+"
     
    26802680   poly f=x+y+x2y+xy2+1/t*xy;
    26812681   list graph=tropicalCurve(f);
    2682 // compute the texdraw code of the Newton subdivision of the tropical curve
     2682// compute the texdraw code of the Newton subdivision of the tropical curve 
    26832683   texDrawNewtonSubdivision(graph);
    26842684}
     
    27072707    markings[3*i-2]=triang[i][1];
    27082708    markings[3*i-1]=triang[i][2];
    2709     markings[3*i]=triang[i][3];
     2709    markings[3*i]=triang[i][3];   
    27102710  }
    27112711  // delete redundant pairs which occur more than once
     
    27402740  {
    27412741    latex=latex+"
    2742         \\move ("+string(polygon[markings[i]][1])+" "+string(polygon[markings[i]][2])+")
     2742        \\move ("+string(polygon[markings[i]][1])+" "+string(polygon[markings[i]][2])+")       
    27432743        \\fcir f:0 r:0.08";
    27442744  }
     
    27472747  {
    27482748    latex=latex+"
    2749         \\move ("+string(polygon[pairs[i][1]][1])+" "+string(polygon[pairs[i][1]][2])+")
     2749        \\move ("+string(polygon[pairs[i][1]][1])+" "+string(polygon[pairs[i][1]][2])+")       
    27502750        \\lvec ("+string(polygon[pairs[i][2]][1])+" "+string(polygon[pairs[i][2]][2])+")";
    27512751  }
     
    27542754  {
    27552755    latex=latex+"
    2756         \\move ("+string(polygon[i][1])+" "+string(polygon[i][2])+")
     2756        \\move ("+string(polygon[i][1])+" "+string(polygon[i][2])+")       
    27572757        \\fcir f:0.7 r:0.04";
    27582758  }
     
    27632763   "EXAMPLE:";
    27642764   echo=2;
    2765    // the lattice polygon spanned by the points (0,0), (3,0) and (0,3)
     2765   // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 
    27662766   // with all integer points as markings
    27672767   list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),intvec(0,0),
    27682768                intvec(2,1),intvec(0,1),intvec(1,2),intvec(0,2),intvec(0,3);
    2769    // define a triangulation by connecting the only interior point
     2769   // define a triangulation by connecting the only interior point 
    27702770   //        with the vertices
    27712771   list triang=intvec(1,2,5),intvec(1,5,10),intvec(1,2,10);
     
    27752775
    27762776////////////////////////////////////////////////////////////////////////////////////
    2777 /// Auxilary Procedures
     2777/// Auxilary Procedures 
    27782778////////////////////////////////////////////////////////////////////////////////////
    27792779
     
    28292829  // do the same for the remaining part of f and compare the results
    28302830  // keep only the smallest ones
    2831   int vglgewicht;
    2832   f=f-lead(f);
     2831  int vglgewicht; 
     2832  f=f-lead(f); 
    28332833  while (f!=0)
    28342834  {
    2835     leitkoef=simplifyToOrder(f);
     2835    leitkoef=simplifyToOrder(f);   
    28362836    vglgewicht=leitkoef[1]+scalarproduct(w,leadexp(f));
    28372837    if (vglgewicht<gewicht)
     
    28482848        initialf=initialf+koef*leadmonom(f);
    28492849      }
    2850     }
     2850    }   
    28512851    f=f-lead(f);
    28522852  }
     
    28722872  // compute first the t-order of the leading coefficient of f (leitkoef[1]) and
    28732873  // the rational constant corresponding to this order in leadkoef(f) (leitkoef[2])
    2874   list leitkoef=simplifyToOrder(f);
     2874  list leitkoef=simplifyToOrder(f); 
    28752875  execute("poly koef="+leitkoef[2]+";");
    28762876  // take in lead(f) only the term of lowest t-order and set t=1
     
    28812881  // keep only the largest ones
    28822882  int vglgewicht;
    2883   f=f-lead(f);
     2883  f=f-lead(f); 
    28842884  while (f!=0)
    28852885  {
     
    28992899        initialf=initialf+koef*leadmonom(f);
    29002900      }
    2901     }
     2901    }   
    29022902    f=f-lead(f);
    29032903  }
     
    29162916proc solveTInitialFormPar (ideal i)
    29172917"USAGE:      solveTInitialFormPar(i); i ideal
    2918 ASSUME:      i is a zero-dimensional ideal in Q(t)[x_1,...,x_n] generated by the (1,w)-homogeneous
     2918ASSUME:      i is a zero-dimensional ideal in Q(t)[x_1,...,x_n] generated by the (1,w)-homogeneous 
    29192919             elements for some integer vector w - i.e. by the (1,w)-initialforms of polynomials
    29202920RETURN:      none
     
    29412941}
    29422942
    2943 proc detropicalise (poly p)
     2943proc detropicalise (poly p) 
    29442944"USAGE:      detropicalise(f); f poly
    29452945ASSUME:      f is a linear polynomial with an arbitrary constant term and
     
    29532953  {
    29542954    if (leadmonom(p)!=1)
    2955     {
     2955    { 
    29562956      dtp=dtp*leadmonom(p)^int(leadcoef(p));
    29572957    }
     
    30573057   poly f=t2x+1/t*y-1;
    30583058   tropicalSubst(f,2,x,x+t,y,tx+y+t2);
    3059    // The procedure can be used to study the effect of a transformation of
     3059   // The procedure can be used to study the effect of a transformation of 
    30603060   // the form x -> x+t^b, with b a rational number, on the tropicalisation and
    30613061   // the j-invariant of a cubic over the Puiseux series.
     
    30633063   // - the j-invariant, and hence its valuation, does not change under the transformation
    30643064   jInvariant(f,"ord");
    3065    // - b=3/2, then the cycle length of the tropical cubic equals -val(j-inv)
    3066    list g32=tropicalSubst(f,2,x,x+t3,y,y);
     3065   // - b=3/2, then the cycle length of the tropical cubic equals -val(j-inv)   
     3066   list g32=tropicalSubst(f,2,x,x+t3,y,y); 
    30673067   tropicalJInvariant(g32);
    30683068   // - b=1, then it is still true, but only just ...
     
    30753075
    30763076proc randomPoly (int d,int ug, int og, list #)
    3077 "USAGE:      randomPoly(d,ug,og[,#]);   d, ug, og int, # list
     3077"USAGE:      randomPoly(d,ug,og[,#]);   d, ug, og int, # list 
    30783078ASSUME:      the basering has a parameter t
    30793079RETURN:      poly, a polynomial of degree d where the coefficients are of the form t^j with
    30803080                   j a random integer between ug and og
    3081 NOTE:        if an optional argument # is given, then the coefficients are instead either of the
     3081NOTE:        if an optional argument # is given, then the coefficients are instead either of the 
    30823082             form t^j as above or they are zero, and this is chosen randomly
    30833083EXAMPLE:     example randomPoly;   shows an example"
     
    30953095  {
    30963096    if (size(#)!=0)
    3097     {
     3097    {     
    30983098      k=random(0,1);
    30993099    }
    31003100    if (k==0)
    3101     {
     3101    {     
    31023102      j=random(ug,og);
    31033103      randomPolynomial=randomPolynomial+t^j*m[i];
     
    31273127RETURN:  none"
    31283128{
    3129   system("sh","cd /tmp; /bin/rm -f tropicalcurve*; /bin/rm -f tropicalnewtonsubdivision*");
     3129  system("sh","cd /tmp; /bin/rm -f tropicalcurve*; /bin/rm -f tropicalnewtonsubdivision*"); 
    31303130}
    31313131
     
    31823182static proc cutdown (ideal jideal,intvec wvec,int dimension,list #)
    31833183"USAGE:      cutdown(i,w,d); i ideal, w intvec, d int, # list
    3184 ASSUME:      i an ideal in Q[t,x_1,...,x_n], (w_1,...,w_n) is in the tropical variety of jideal
     3184ASSUME:      i an ideal in Q[t,x_1,...,x_n], (w_1,...,w_n) is in the tropical variety of jideal 
    31853185             and d=dim(i)>0, in Q(t)[x]; the optional parameter # can contain the string 'isPrime'
    3186              to indicate that the input ideal is prime and no minimal associated primes have
     3186             to indicate that the input ideal is prime and no minimal associated primes have 
    31873187             to be computed
    31883188RETURN:      list, the first entry is a ring, namely the basering where some variables have been
     
    31953195                   wvec with the components corresponding to the eliminated variables removed
    31963196NOTE:        needs the libraries random.lib and primdec.lib; is called from tropicalLifting"
    3197 {
    3198   // IDEA: i is an ideal of dimension d; we want to cut it with d random linear
     3197{ 
     3198  // IDEA: i is an ideal of dimension d; we want to cut it with d random linear 
    31993199  //       forms in such a way that the resulting
    32003200  //       ideal is 0-dim and still contains w in the tropical variety
    3201   // NOTE: t is the last variable in the basering
     3201  // NOTE: t is the last variable in the basering 
    32023202  ideal pideal;  //this is the ideal we want to return
    32033203  ideal cutideal;
     
    32193219    variablen=variablen+var(j1); //read the set of variables (needed to make the quotring later)
    32203220    product=product*var(j1); //make product of all variables (needed for the initial-monomial-check later
    3221   }
     3221  }   
    32223222  execute("ring QUOTRING=("+charstr(basering)+",t),("+string(variablen)+"),dp;");
    32233223  setring BASERING;
     
    32263226  {
    32273227    setring QUOTRING;
    3228     ideal jideal=imap(BASERING,jideal);
    3229     list primp=minAssGTZ(jideal); //compute the primary decomposition
     3228    ideal jideal=imap(BASERING,jideal); 
     3229    list primp=minAssGTZ(jideal); //compute the primary decomposition 
    32303230    for (j1=1;j1<=size(primp);j1++)
    3231     {
     3231    {     
    32323232      for(j2=1;j2<=size(primp[j1]);j2++)
    32333233      {
    32343234        primp[j1][j2]=primp[j1][j2]/content(primp[j1][j2]);// clear all denominators
    3235       }
     3235      }       
    32363236    }
    32373237    setring BASERING;
     
    32393239    // if i is not primary itself
    32403240    // go through the list of min. ass. primes and find the first one which has w in its tropical variety
    3241     if (size(primp)>1)
     3241    if (size(primp)>1) 
    32423242    {
    32433243      j1=1;
     
    32463246        //compute the t-initial of the associated prime
    32473247        // - the last entry 1 only means that t is the last variable in the ring
    3248         primini=tInitialIdeal(primp[j1],wvec,1);
     3248        primini=tInitialIdeal(primp[j1],wvec,1); 
    32493249        // check if it contains a monomial (resp if the product of var is in the radical)
    3250         if (radicalMemberShip(product,primini)==0)
    3251         {
     3250        if (radicalMemberShip(product,primini)==0) 
     3251        { 
    32523252          jideal=primp[j1];// if w is in the tropical variety of the prime, we take that
    32533253          setring QUOTRING;
     
    32553255          setring BASERING;
    32563256          winprim=1; // and stop the checking
    3257         }
     3257        } 
    32583258        j1=j1+1;  //else we look at the next associated prime
    32593259      }
     
    32623262    {
    32633263      jideal=primp[1]; //if i is primary itself we take its prime instead
    3264     }
     3264    } 
    32653265  }
    32663266  // now we start as a first try to intersect with a hyperplane parallel to
    32673267  // coordinate axes, because this would make our further computations
    3268   // a lot easier.
     3268  // a lot easier. 
    32693269  // We choose a subset of our n variables of size d=dim(ideal). For each of these
    32703270  // variables, we want to fix a value: x_i= a_i*t^-w_i. This will only work if the
     
    32753275  // (NOTE, there EXIST d variables such that a random choice of a_i's would work!).
    32763276  // But since this involves many computations, we prefer to choose randomly and just
    3277   // try in the end if our intersected ideal satisfies our requirements. If this does not
     3277  // try in the end if our intersected ideal satisfies our requirements. If this does not 
    32783278  // work, we give up this try and use our second intersection idea, which
    32793279  // will work for a Zariksi-open subset (i.e. almost always).
     
    32823282  // wvec-coordinate is smallest, because this will give us the smallest powers of t and hence
    32833283  // less effort in following computations. Note that the smallest absolute value have those
    3284   // which are biggest, because wvec is negative.
     3284  // which are biggest, because wvec is negative. 
    32853285  //print("first try");
    32863286  intvec wminust=intvecdelete(wvec,1);
     
    32903290  A[2,1..size(wminust)]=1..size(wminust);
    32913291  // sort this matrix in order to get the d biggest entries and their position in wvec
    3292   A=sortintmat(A);
    3293   // we construct a vector which has 1 at entry j if j belongs to the list
     3292  A=sortintmat(A); 
     3293  // we construct a vector which has 1 at entry j if j belongs to the list 
    32943294  // of the d biggest entries of wvec and a 0 else
    32953295  for (j1=1;j1<=nvars(basering)-1;j1++) //go through the variables
     
    33003300      {
    33013301        setvec[j1]=1;//put a 1
    3302       }
    3303     }
    3304   }
    3305   // using this 0/1-vector we produce a random constant (i.e. coeff in Q times something in t)
     3302      }       
     3303    } 
     3304  }
     3305  // using this 0/1-vector we produce a random constant (i.e. coeff in Q times something in t) 
    33063306  // for each of the biggest variables, we add the forms x_i-random constant to the ideal
    33073307  // and we save the constant at the i-th place of a list we want to return for later computations
     
    33153315    {
    33163316      if(setvec[j1]==1)//if x_i belongs to the biggest variables
    3317       {
     3317      {     
    33183318        if ((j3==1) and ((char(basering)==0) or (char(basering)>3)))
    3319         {
     3319        {       
    33203320          randomp1=random(1,3);
    33213321          randomp=t^(A[1,j2])*randomp1;//make a random constant --- first we try small numbers
    3322         }
     3322        }   
    33233323        if ((j3==2) and ((char(basering)==0) or (char(basering)>100)))
    33243324        {
    33253325          randomp1=random(1,100);
    33263326          randomp=t^(A[1,j2])*randomp1;//make a random constant --- next we try bigger numbers
    3327         }
     3327        }   
    33283328        else
    33293329        {
     
    33373337      else
    33383338      {
    3339         ergl[j1]=0; //if the variable belongs not the d biggest ones, save 0 in the list
     3339        ergl[j1]=0; //if the variable belongs not the the d biggest ones, save 0 in the list
    33403340        erglini[j1]=0;
    3341       }
     3341      }       
    33423342    }
    33433343      // print(ergl);print(pideal);
    3344       // now we check if we made a good choice of pideal, i.e. if dim=0 and
     3344      // now we check if we made a good choice of pideal, i.e. if dim=0 and 
    33453345      // wvec is still in the tropical variety
    33463346      //change to quotring where we compute dimension
     
    33493349    {
    33503350      if(setvec[j1]==1)
    3351       {
    3352         cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
    3353       }
     3351      {     
     3352        cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
     3353      }     
    33543354    }
    33553355    setring QUOTRING;
     
    33693369      // and if the initial w.r.t. t contains no monomial as we want (checked with
    33703370      // radical-membership of the product of all variables)
    3371       if (radicalMemberShip(product,pini)==0)
    3372       {
    3373         // we made the right choice and now we substitute the variables in the ideal
     3371      if (radicalMemberShip(product,pini)==0) 
     3372      {
     3373        // we made the right choice and now we substitute the variables in the ideal   
    33743374        //to get an ideal in less variables
    33753375        // also we make a projected vector from wvec only the components of the remaining variables
    33763376        wvecp=wvec;
    3377         variablen=0;
     3377        variablen=0;   
    33783378        j2=0;
    33793379        for(j1=1;j1<=nvars(basering)-1;j1++)
     
    33893389          {
    33903390            variablen=variablen+var(j1); //read the set of remaining variables (needed to make quotring later)
    3391           }
    3392         }
     3391          }   
     3392        }     
    33933393        // return pideal, the initial and the list ergl which tells us
    33943394        // which variables we replaced by which form
     
    34003400        export(ini);
    34013401        export(repl);
    3402         return(list(BASERINGLESS1,wvecp));
     3402        return(list(BASERINGLESS1,wvecp)); 
    34033403      }
    34043404    }
     
    34093409  // probability 1.
    34103410  //
    3411   // We choose general hyperplanes, i.e. linear forms which involve all x_i.
    3412   // Each x_i has to be multiplied bz t^(w_i) in order to get the same weight (namely 0)
     3411  // We choose general hyperplanes, i.e. linear forms which involve all x_i. 
     3412  // Each x_i has to be multiplied bz t^(w_i) in order to get the same weight (namely 0) 
    34133413  // for each term. As we cannot have negative exponents, we multiply
    3414   // the whole form by t^minimumw. Notice that then in the first form,
     3414  // the whole form by t^minimumw. Notice that then in the first form, 
    34153415  // there is one term without t- the term of the variable
    34163416  // x_i such that w_i is minimal. That is, we can solve for this variable.
    3417   // In the second form, we can replace that variable, and divide by t as much as possible.
    3418   // Then there is again one term wihtout t - the term of the variable with second least w.
     3417  // In the second form, we can replace that variable, and divide by t as much as possible. 
     3418  // Then there is again one term wihtout t - the term of the variable with second least w. 
    34193419  // So we can solve for this one again and also replace it in the first form.
    3420   // Since all our coefficients are chosen randomly, we can also from the beginning on
    3421   // choose the set of variables which belong to the d smallest entries of wvec
    3422   // (t not counting) and pick random forms g_i(t,x') (where x' is the set of remaining variables)
    3423   // and set x_i=g_i(t,x').
     3420  // Since all our coefficients are chosen randomly, we can also from the beginning on 
     3421  // choose the set of variables which belong to the d smallest entries of wvec 
     3422  // (t not counting) and pick random forms g_i(t,x') (where x' is the set of remaining variables) 
     3423  // and set x_i=g_i(t,x'). 
    34243424  //
    34253425  // make a matrix with first row wvec (without t) and second row 1..n
    34263426  //print("second try");
    34273427  setring BASERING;
    3428   A[1,1..size(wminust)]=wminust;
     3428  A[1,1..size(wminust)]=wminust; 
    34293429  A[2,1..size(wminust)]=1..size(wminust);
    34303430  // sort this matrix in otder to get the d smallest entries (without counting the t-entry)
     
    34333433  setvec=0;
    34343434  setvec[nvars(basering)-1]=0;
    3435   // we construct a vector which has 1 at entry j if j belongs to the list of
     3435  // we construct a vector which has 1 at entry j if j belongs to the list of 
    34363436  // the d smallest entries of wvec and a 0 else
    34373437  for (j1=1;j1<=nvars(basering)-1;j1++) //go through the variables
     
    34593459      variablen=variablen+var(j1); //read the set of remaining variables (needed to make the quotring later)
    34603460    }
    3461   }
     3461  } 
    34623462  setring BASERING;
    34633463  execute("ring BASERINGLESS2=("+charstr(BASERING)+"),("+string(variablen)+",t),(dp("+string(ncols(variablen))+"),lp(1));");
    34643464  // using the 0/1-vector which tells us which variables belong to the set of smallest entries of wvec
    3465   // we construct a set of d random linear polynomials of the form x_i=g_i(t,x'),
     3465  // we construct a set of d random linear polynomials of the form x_i=g_i(t,x'), 
    34663466  // where the set of all x_i is the set of
    34673467  // all variables which are in the list of smallest entries in wvec, and x' are the other variables.
    3468   // We add these d random linear polynomials to the indeal pideal, i.e. we intersect
     3468  // We add these d random linear polynomials to the indeal pideal, i.e. we intersect 
    34693469  // with these and hope to get something
    3470   // 0-dim which still contains wvec in its tropical variety. Also, we produce a list ergl
     3470  // 0-dim which still contains wvec in its tropical variety. Also, we produce a list ergl 
    34713471  // with g_i at the i-th position.
    34723472  // This is a list we want to return.
     
    34773477  {
    34783478    if ((char(basering)==0) or (char(basering)>3))
    3479     {
     3479    { 
    34803480      randomp1=random(1,3);
    34813481      randomp=randomp1*t^(-A[1,j1]);
     
    35143514    }
    35153515  //print(ergl);
    3516   // Again, we have to test if we made a good choice to intersect,i.e. we have to check whether
     3516  // Again, we have to test if we made a good choice to intersect,i.e. we have to check whether 
    35173517  // pideal is 0-dim and contains wvec in the tropical variety.
    35183518  cutideal=pideal;
     
    35213521    if(setvec[j1]==1)
    35223522    {
    3523       cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
    3524     }
     3523      cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
     3524    }   
    35253525  }
    35263526  setring QUOTRING;
     
    35403540    // and if the initial w.r.t. t contains no monomial as we want (checked with
    35413541    // radical-membership of the product of all variables)
    3542     if (radicalMemberShip(product,pini)==0)
     3542    if (radicalMemberShip(product,pini)==0) 
    35433543    {
    35443544      // we want to replace the variables x_i by the forms -g_i in
    3545       // our ideal in order to return an ideal with less variables
     3545      // our ideal in order to return an ideal with less variables 
    35463546      // first we substitute the chosen variables
    35473547      for(j1=1;j1<=nvars(basering)-1;j1++)
     
    35603560      export(ini);
    35613561      export(repl);
    3562       return(list(BASERINGLESS2,wvecp));
     3562      return(list(BASERINGLESS2,wvecp)); 
    35633563    }
    35643564  }
     
    35733573      randomp=randomp1*t^(-A[1,j1]);
    35743574      for(j2=1;j2<=nvars(basering)-1;j2++)//go through all variables
    3575       {
     3575      { 
    35763576        if(setvec[j2]==0)//if x_j belongs to the set x'
    35773577        {
    35783578          // add a random term with the suitable power of t to the random linear form
    35793579          if ((char(basering)==0) or (char(basering)>100))
    3580           {
     3580          { 
    35813581            randomp2=random(1,100);
    35823582            randomp1=randomp1+randomp2*var(j2);
     
    35993599      }
    36003600    //print(ergl);
    3601     // Again, we have to test if we made a good choice to intersect,i.e. we have to check whether
     3601    // Again, we have to test if we made a good choice to intersect,i.e. we have to check whether 
    36023602    // pideal is 0-dim and contains wvec in the tropical variety.
    36033603    cutideal=pideal;
     
    36063606      if(setvec[j1]==1)
    36073607      {
    3608         cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
    3609       }
     3608        cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
     3609      }     
    36103610    }
    36113611    setring QUOTRING;
     
    36153615    //print(dimp);
    36163616    kill cutideal;
    3617     setring BASERING;
     3617    setring BASERING; 
    36183618    if (dimp==0) // if it is 0 as we want
    36193619    {
     
    36253625      // and if the initial w.r.t. t contains no monomial as we want (checked with
    36263626      // radical-membership of the product of all variables)
    3627       if (radicalMemberShip(product,pini)==0)
     3627      if (radicalMemberShip(product,pini)==0) 
    36283628      {
    36293629        // we want to replace the variables x_i by the forms -g_i in
     
    36363636            pideal=subst(pideal,var(j1),ergl[j1]);//substitute it
    36373637            pini=subst(pini,var(j1),erglini[j1]);
    3638           }
    3639         }
     3638          }   
     3639        }   
    36403640        // return pideal and the list ergl which tells us
    36413641        // which variables we replaced by which form
     
    36473647        export(ini);
    36483648        export(repl);
    3649         return(list(BASERINGLESS2,wvecp));
     3649        return(list(BASERINGLESS2,wvecp)); 
    36503650      }
    36513651    }
     
    36563656static proc tropicalparametriseNoabs (ideal i,intvec ww,int ordnung,int gfanold,int nogfan,list #)
    36573657  "USAGE:  tropicalparametriseNoabs(i,tw,ord,gf,ng[,#]); i ideal, tw intvec, ord int, gf,ng int, # opt. list
    3658 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], tw=(w_0,w_1,...,w_n,0,...,0)
    3659            and (w_0,...,w_n,0,...,0) is in the tropical variety of i,
    3660            and ord is the order up to which a point in V(i) over C((t)) lying over w shall be computed;
     3658ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], tw=(w_0,w_1,...,w_n,0,...,0) 
     3659           and (w_0,...,w_n,0,...,0) is in the tropical variety of i, 
     3660           and ord is the order up to which a point in V(i) over C((t)) lying over w shall be computed; 
    36613661         - moreover, k should be zero if the procedure is not called recursively;
    36623662         - the point in the tropical variety is supposed to lie in the NEGATIVE orthant;
    36633663         - the ideal is zero-dimensional when considered in (Q(t)[X_1,...,X_k]/m)[x_1,...,x_n],
    3664            where m=#[2] is a maximal ideal in Q(t)[X_1,...,X_k];
     3664           where m=#[2] is a maximal ideal in Q(t)[X_1,...,X_k]; 
    36653665         - gf is 0 if version 2.2 or larger is used and it is 1 else
    3666          - ng is 1 if gfan should not be executed
     3666         - ng is 1 if gfan should not be executed 
    36673667RETURN:  list, l[1] = ring Q(0,X_1,...,X_r)[[t]]
    36683668               l[2] = int
    36693669               l[3] = string
    36703670NOTE:    - the procedure is also called recursively by itself, and
    3671            if it is called in the first recursion, the list # is empty,
     3671           if it is called in the first recursion, the list # is empty, 
    36723672           otherwise #[1] is an integer, one more than the number of true variables x_1,...,x_n,
    36733673           and #[2] will contain the maximal ideal m in the variables X_1,...X_k
     
    37393739  intvec tw=ww; // in case some variables are deleted, we have to store the old weight vector
    37403740  deletedvariables[anzahlvariablen]=0;
    3741   ideal I,LI;
     3741  ideal I,LI; 
    37423742  i=i+m; // if a field extension was necessary, then i has to be extended by m
    37433743  for (jj=anzahlvariablen-1;jj>=1;jj--)  // the variable t is the last one !!!
     
    37513751    if (size(LI)==0) // if no power of t is in lead(I) (where the X(i) are considered as field elements)
    37523752    {
    3753       // get rid of var(jj)
     3753      // get rid of var(jj)   
    37543754      i=eliminate(I,var(jj));
    37553755      deletedvariables[jj]=1;
     
    37753775    execute("ring NEURING=("+charstr(basering)+"),("+string(variablen)+"),(dp("+string(size(variablen)-1)+"),lp(1));");
    37763776    ideal i=imap(BASERING,i);
    3777     ideal gesamt_m=imap(BASERING,gesamt_m);
     3777    ideal gesamt_m=imap(BASERING,gesamt_m);   
    37783778  }
    37793779  // now we have to compute a point ww on the tropical variety of the transformed ideal i;
     
    37843784    def PREGFANRING=basering;
    37853785    if (nogfan!=1)
    3786     {
     3786    {     
    37873787      // pass to a ring which has variables which are suitable for gfan
    37883788      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;");
    3789       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;
     3789      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; 
    37903790      phiideal[nvars(PREGFANRING)]=a; // map t to a
    3791       map phi=PREGFANRING,phiideal;
     3791      map phi=PREGFANRING,phiideal; 
    37923792      ideal i=phi(i);
    3793       // homogenise the ideal i with the first not yet used variable in our ring, since gfan
     3793      // homogenise the ideal i with the first not yet used variable in our ring, since gfan 
    37943794      // only handles homogenous ideals; in principle for this one has first to compute a
    3795       // standard basis of i and homogenise that, but for the tropical variety (says Anders)
     3795      // standard basis of i and homogenise that, but for the tropical variety (says Anders) 
    37963796      // it suffices to homogenise an arbitrary system of generators
    3797       // i=groebner(i);
     3797      // i=groebner(i); 
    37983798      i=homog(i,maxideal(1)[nvars(PREGFANRING)+1]);
    37993799      // if gfan version >= 0.3.0 is used and the characteristic
     
    38043804        ringvariablen=ringvariablen[1..2*nvars(PREGFANRING)+1];
    38053805        write(":w /tmp/gfaninput","Z/"+string(char(GFANRING))+"Z["+ringvariablen+"]");
    3806         // write the ideal to a file which gfan takes as input and call gfan
     3806        // write the ideal to a file which gfan takes as input and call gfan     
    38073807        write(":a /tmp/gfaninput","{"+string(i)+"}");
    38083808      }
    3809       else
    3810       {
    3811         // write the ideal to a file which gfan takes as input and call gfan
     3809      else 
     3810      {
     3811        // write the ideal to a file which gfan takes as input and call gfan     
    38123812        write(":w /tmp/gfaninput","{"+string(i)+"}");
    38133813      }
     
    38403840        ~
    38413841          // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE TROPICAL PREVARIETY
    3842           // test, if wneu really is in the tropical variety
     3842          // test, if wneu really is in the tropical variety   
    38433843          while (goon==0)
    38443844        {
     
    38733873  // if all variables were deleted, then i=0 and thus anzahlvariablen==0
    38743874  if ((ordnung>1) and (anzahlvariablen>1))
    3875   {
     3875  {   
    38763876    // we call the procedure with the transformed ideal i, the new weight vector, with the
    38773877    // required order lowered by one, and with additional parameters, namely the number of
     
    38843884    string PARAm=PARALIST[3];
    38853885    setring PARARing;
    3886     // if some variables have been eliminated in before, then we have to insert zeros
     3886    // if some variables have been eliminated in before, then we have to insert zeros 
    38873887    // into the parametrisation for those variables
    38883888    if (numberdeletedvariables>0)
     
    39123912    int tweight=-tw[1];
    39133913    // if additional variables were necessary, we introduce them now as parameters;
    3914     // in any case the parametrisation ring will have only one variable, namely t,
     3914    // in any case the parametrisation ring will have only one variable, namely t, 
    39153915    // and its order will be local, so that it displays the lowest term in t first
    39163916    if (anzahlvariablen+numberdeletedvariables<nvars(basering))
     
    39333933  list a=imap(BASERING,a);
    39343934  if (defined(wneu)==0) // when tropicalparametriseNoabs is called for the last time, it does not
    3935   {                     // enter the part, where wneu is defined and the variable t should have
     3935  {                     // enter the part, where wneu is defined and the variable t should have 
    39363936    intvec wneu=-1;     // weight -1
    39373937  }
     
    39453945  // note, if all variables were deleted, then i==0 and thus testaufnull==0
    39463946  if ((ordnung==1) or (anzahlvariablen==1))
    3947   {
     3947  {   
    39483948    export(PARA);
    39493949  }
    39503950  // kill the gfan files in /tmp
    3951   system("sh","cd /tmp; /bin/rm gfaninput; /bin/rm gfanoutput");
     3951  system("sh","cd /tmp; /bin/rm gfaninput; /bin/rm gfanoutput"); 
    39523952  // we return a list which contains the parametrisation ring (with the parametrisation ideal)
    39533953  // and the string representing the maximal ideal describing the necessary field extension
     
    39573957static proc findzeros (ideal i,intvec w,list #)
    39583958  "USAGE:      findzeros(i,w[,#]); i ideal, w intvec, # an optional list
    3959 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_n+1,...,X_m] and w=(w_0,...,w_n,0,...,0)
     3959ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_n+1,...,X_m] and w=(w_0,...,w_n,0,...,0) 
    39603960             is in the tropical variety of i
    3961 RETURN:      list, l[1] = is polynomial ring containing an associated maximal ideal m of the w-initial
     3961RETURN:      list, l[1] = is polynomial ring containing an associated maximal ideal m of the w-initial 
    39623962                          ideal of i which does not contain any monomial and where the variables
    39633963                          which do not lead to a field extension have already been eliminated,
     
    39693969                          been eliminated
    39703970NOTE:        the procedure is called from inside the recursive procedure tropicalparametriseNoabs;
    3971              if it is called in the first recursion, the list #[1] contains the t-initial ideal
    3972              of i w.r.t. w, otherwise #[1] is an integer, one more than the number of true
     3971             if it is called in the first recursion, the list #[1] contains the t-initial ideal 
     3972             of i w.r.t. w, otherwise #[1] is an integer, one more than the number of true 
    39733973             variables x_1,...,x_n"
    39743974{
    3975   def BASERING=basering;
     3975  def BASERING=basering; 
    39763976  // set anzahlvariablen to the number of true variables
    39773977  if (typeof(#[1])=="int")
     
    39903990  ideal variablen;
    39913991  for (int j=1;j<=nvars(basering)-1;j++)
    3992   {
     3992  {   
    39933993    variablen=variablen+var(j);
    39943994  }
     
    40024002  intvec neuevariablen=maximalideals[1][3]; // the information which variable leads to a new one
    40034003  list a=maximalideals[1][4];               // a_k is the kth component of a zero of m, if it is not zero
    4004   // eliminate from m the superflous variables, that is those ones, which do not lead to
     4004  // eliminate from m the superflous variables, that is those ones, which do not lead to 
    40054005  // a new variable
    40064006  poly elimvars=1;
     
    40124012    }
    40134013  }
    4014   m=eliminate(m,elimvars);
    4015   export(a);
     4014  m=eliminate(m,elimvars); 
     4015  export(a); 
    40164016  export(m);
    40174017  list m_ring=INITIALRING,neuvar,neuevariablen;
     
    40234023static proc basictransformideal (ideal i,intvec w,list m_ring,list #)
    40244024  "USAGE:      basictransformideal(i,w,m_ring[,#]); i ideal, w intvec, m_ring list, # an optional list
    4025 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], w=(w_0,...,w_n,0,...,0)
     4025ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], w=(w_0,...,w_n,0,...,0) 
    40264026             is in the tropical variety of i, and m_ring contains a ring containing a maximal ideal m needed
    40274027             to describe the field extension over which a corresponding associated maximal ideal of the
     
    40344034                   or l[1] = ring which contains the ideals i and m, and the list a
    40354035NOTE:        the procedure is called from inside the recursive procedure tropicalparametriseNoabs;
    4036              if it is called in the first recursion, the list # is empty,
     4036             if it is called in the first recursion, the list # is empty, 
    40374037             otherwise #[1] is an integer, the number of true variables x_1,...,x_n;
    40384038             during the procedure we check if a field extension is necessary to express
    40394039             a zero (a_1,...,a_n) of m; if so, we have to introduce new variables and
    40404040             a list containing a ring is returned, otherwise the list containing i, a and m
    4041              is returned;
     4041             is returned; 
    40424042             the ideal m will be changed during the procedure since all variables which reduce
    40434043             to a polynomial in X_1,...,X_k modulo m will be eliminated, while the others are
     
    40834083    // map i into the new ring
    40844084    ideal i=imap(BASERING,i);
    4085     // define a map phi which maps the true variables, which are not
     4085    // define a map phi which maps the true variables, which are not 
    40864086    // reduced to polynomials in the additional variables modulo m, to
    4087     // the corresponding newly introduced variables, and which maps
     4087    // the corresponding newly introduced variables, and which maps 
    40884088    // the old additional variables to themselves
    40894089    ideal phiideal;
     
    40984098      else
    40994099      {
    4100         phiideal[j-1]=0;
     4100        phiideal[j-1]=0; 
    41014101      }
    41024102    }
     
    41054105      phiideal=phiideal,X(1..nvars(BASERING)-anzahlvariablen);
    41064106    }
    4107     map phi=MRING,phiideal;
     4107    map phi=MRING,phiideal; 
    41084108    // map m and a to the new ring via phi, so that the true variables in m and a are replaced by
    41094109    // the corresponding newly introduced variables
     
    41154115  // moreover, substitute right away in the ideal i the true variable x_j by (a_j+x_j)*t^w_j
    41164116  zaehler=nvars(BASERING)-anzahlvariablen+1;
    4117   for (j=1;j<=anzahlvariablen;j++)
     4117  for (j=1;j<=anzahlvariablen;j++) 
    41184118  {
    41194119    if ((a[j]==0) and (j!=1))  // a[1]=0, since t->t^w_0
    4120     {
     4120    {       
    41214121      a[j]=X(zaehler);
    41224122      zaehler++;
     
    41254125    {
    41264126      if (j!=1) // corresponds to  x_(j-1) --  note t is the last variable
    4127       {
     4127      {       
    41284128        i[k]=substitute(i[k],var(j-1),(a[j]+var(j-1))*t^(-w[j]));
    41294129      }
     
    41384138  {
    41394139    if (wdegs[j]<0) // if wdegs[j]==0 there is no need to divide, and we made sure that it is no positive
    4140     {
     4140    {     
    41414141      i[j]=i[j]/t^(-wdegs[j]);
    41424142    }
     
    41644164static proc testw (ideal i,intvec w,int anzahlvariablen,list #)
    41654165"USAGE:      testw(i,w,n); i ideal, w intvec, n number
    4166 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k] and w=(w_0,...,w_n,0,...,0)
     4166ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k] and w=(w_0,...,w_n,0,...,0)           
    41674167RETURN:      int b, 0 if the t-initial ideal of i considered in Q(X_1,...,X_k)[t,x_1,...,x_n]
    41684168                    is monomial free, 1 else
     
    41794179    ideal tin=tInitialIdeal(i,w,1);
    41804180  }
    4181 
     4181 
    41824182  int j;
    41834183  ideal variablen;
     
    42114211  def BASERING=basering;
    42124212  if (anzahlvariablen<nvars(basering))
    4213   {
     4213  {   
    42144214    execute("ring TINRING=("+charstr(basering)+","+string(Parameter)+"),("+string(variablen)+"),dp;");
    42154215  }
     
    42214221  poly monom=imap(BASERING,monom);
    42224222  return(radicalMemberShip(monom,tin));
    4223 }
     4223} 
    42244224
    42254225static proc simplifyToOrder (poly f)
    42264226"USAGE:      simplifyToOrder(f); f a polynomial
    4227 ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n]
     4227ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n] 
    42284228RETURN:      list, l[1] = t-order of leading term of f
    42294229                   l[2] = the rational coefficient of the term of lowest t-order
     
    42464246static proc scalarproduct (intvec w,intvec v)
    42474247"USAGE:      scalarproduct(w,v); w,v intvec
    4248 ASSUME:      w and v are integer vectors of the same length
     4248ASSUME:      w and v are integer vectors of the same length 
    42494249RETURN:      int, the scalarproduct of v and w
    42504250NOTE:        the procedure is called by tropicalparametriseNoabs"
     
    43044304                   l[j][3] = intvec, if for the kth variable a new variable is needed to
    43054305                             define the corresponding zero of l[j][1], then the k+1st entry is one
    4306                    l[j][4] = list, if for the kth variable no new variable is needed to
     4306                   l[j][4] = list, if for the kth variable no new variable is needed to 
    43074307                             define the corresponding zero of l[j][1], then its value is the k+1st entry
    43084308NOTE:        if a maximal ideal contains a variable, it is removed from the list;
     
    43204320  intvec testvariablen; // integer vector of length n=number of variables
    43214321  // compute for each maximal ideal the number of new variables, which are needed to describe
    4322   // its zeros -- note, a new variable is needed if modulo the maximal ideal it does not reduce
     4322  // its zeros -- note, a new variable is needed if modulo the maximal ideal it does not reduce 
    43234323  // to something which only depends on the following variables;
    4324   // if no new variable is needed, then store the value a variable reduces to in the list a;
     4324  // if no new variable is needed, then store the value a variable reduces to in the list a; 
    43254325  for (j=size(minassi);j>=1;j--)
    43264326  {
     
    43414341      {
    43424342        if (l<=k)
    4343         {
     4343        {         
    43444344          testvariablen[l]=1;
    43454345        }
     
    43574357        a[k+1]=nf;             // a_k is the normal form of the kth variable modulo m
    43584358        neuevariablen[k+1]=0;  // no new variable is needed
    4359       }
     4359      }   
    43604360      else
    43614361      {
     
    43674367    // if the maximal ideal contains a variable, we simply delete it
    43684368    if (pruefer==0)
    4369     {
     4369    {     
    43704370      minassisort[j]=list(minassi[j],neuvar,neuevariablen,a);
    43714371    }
     
    43844384    l=j;
    43854385    for (k=j-1;k>=1;k--)
    4386     {
     4386    {     
    43874387      if (minassisort[l][2]<minassisort[k][2])
    43884388      {
     
    44004400"USAGE:  displaypoly(p,N,wj,w1); p poly, N, wj, w1 int
    44014401ASSUME:  p is a polynomial in r=(0,X(1..k)),t,ls
    4402 RETURN:  string, the string of t^-wj/w1*p(t^1/N)
     4402RETURN:  string, the string of t^-wj/w1*p(t^1/N) 
    44034403NOTE:    the procedure is called from displayTropicalLifting"
    44044404{
     
    44184418  {
    44194419    if (koeffizienten[j-ord(p)+1]!=0)
    4420     {
     4420    {     
    44214421      if ((j-(N*wj)/w1)==0)
    44224422      {
     
    45344534"USAGE:   tropicalliftingresubstitute(i,L,N[,#]); i ideal, L list, N int, # string
    45354535ASSUME:   i is an ideal and L[1] is a ring which contains the lifting of a point in the
    4536           tropical variety of i computed with tropicalLifting;
    4537           t has to be replaced by t^1/N in the lifting; #[1]=m is the string of the maximal
     4536          tropical variety of i computed with tropicalLifting; 
     4537          t has to be replaced by t^1/N in the lifting; #[1]=m is the string of the maximal 
    45384538          ideal defining the necessary field extension as computed by tropicalLifting,
    45394539          if #[1] is present
     
    45594559      ideal i=imap(BASERING,i);
    45604560    }
    4561   }
     4561  } 
    45624562  else
    45634563  {
     
    45884588  for (j=1;j<=ncols(i);j++)
    45894589  {
    4590     SUBSTTEST[j]=displaypoly(i[j],N,0,1);
     4590    SUBSTTEST[j]=displaypoly(i[j],N,0,1); 
    45914591  }
    45924592  return(SUBSTTEST);
     
    45984598/// - eliminatecomponents
    45994599/// - findzerosAndBasictransform
    4600 /// - ordermaximalideals
     4600/// - ordermaximalideals 
    46014601////////////////////////////////////////////////////////////////////////////////////
    46024602
    46034603static proc tropicalparametrise (ideal i,intvec ww,int ordnung,int gfanold,int findall,int nogfan,list #)
    46044604"USAGE:  tropicalparametrise(i,tw,ord,gf,fa,ng[,#]); i ideal, tw intvec, ord int, gf,fa,ng int, # opt. list
    4605 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,@a], tw=(w_0,w_1,...,w_n,0)
    4606            and (w_0,...,w_n,0) is in the tropical variety of i,
    4607            and ord is the order up to which a point in V(i) over K{{t}} lying over w shall be computed;
     4605ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,@a], tw=(w_0,w_1,...,w_n,0) 
     4606           and (w_0,...,w_n,0) is in the tropical variety of i, 
     4607           and ord is the order up to which a point in V(i) over K{{t}} lying over w shall be computed; 
    46084608         - moreover, @a should be not be there if the procedure is not called recursively;
    46094609         - the point in the tropical variety is supposed to lie in the NEGATIVE orthant;
    46104610         - the ideal is zero-dimensional when considered in (K(t)[@a]/m)[x_1,...,x_n],
    4611            where m=#[2] is a maximal ideal in K[@a];
     4611           where m=#[2] is a maximal ideal in K[@a]; 
    46124612         - gf is 0 if version 2.2 or larger is used and it is 1 else
    46134613         - fa is 1 if all solutions should be found
     
    46164616               l[2] = int
    46174617NOTE:    - the procedure is also called recursively by itself, and
    4618            if it is called in the first recursion, the list # is empty,
     4618           if it is called in the first recursion, the list # is empty, 
    46194619           otherwise #[1] is an integer, one more than the number of true variables x_1,...,x_n,
    46204620           and #[2] will contain the maximal ideal m in the variable @a
     
    46514651    int anzahlvariablen=nvars(basering);
    46524652    list zerolist; // will carry the zeros which are computed in the recursion steps
    4653 
     4653   
    46544654    // the initial ideal of i has been handed over as #[1]
    46554655    ideal ini=#[1];
     
    46604660  }
    46614661  list wneulist; // carries all newly computed weight vector
    4662   intvec wneu;   // carries the newly computed weight vector
     4662  intvec wneu;   // carries the newly computed weight vector 
    46634663  int tweight;   // carries the weight of t
    46644664  list PARALIST; // carries the result when tropicalparametrise is recursively called
     
    46954695      {
    46964696        if (nogfan!=1)
    4697         {
     4697        {         
    46984698          // pass to a ring which has variables which are suitable for gfan
    46994699          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;");
    4700           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;
     4700          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; 
    47014701          phiideal[nvars(PREGFANRING)]=a; // map t to a
    4702           map phi=PREGFANRING,phiideal;
     4702          map phi=PREGFANRING,phiideal; 
    47034703          ideal II=phi(i);
    4704           // homogenise the ideal II with the first not yet used variable in our ring, since gfan
     4704          // homogenise the ideal II with the first not yet used variable in our ring, since gfan 
    47054705          // only handles homogenous ideals; in principle for this one has first to compute a
    4706           // standard basis of II and homogenise that, but for the tropical variety (says Anders)
     4706          // standard basis of II and homogenise that, but for the tropical variety (says Anders) 
    47074707          // it suffices to homogenise an arbitrary system of generators
    4708           // II=groebner(II);
     4708          // II=groebner(II); 
    47094709          II=homog(II,maxideal(1)[nvars(PREGFANRING)+1]);
    47104710          // if gfan version >= 0.3.0 is used and the characteristic
     
    47514751            ~
    47524752            // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE TROPICAL PREVARIETY
    4753             // test, if wneu really is in the tropical variety
     4753            // test, if wneu really is in the tropical variety   
    47544754            while (goon==0)
    47554755            {
     
    47964796      lll=0;
    47974797      if ((ordnung>1) and (anzahlvariablen>1))
    4798       {
     4798      { 
    47994799        partliftings=list(); // initialise partliftings
    48004800        // we call the procedure with the transformed ideal i, the new weight vector, with the
     
    48084808          // the maximal ideal that describes the necessary field extension
    48094809          for (ll=1;ll<=size(PARALIST);ll++)
    4810           {
     4810          { 
    48114811            def PARARing=PARALIST[ll][1];
    48124812            tweight=-ww[1]*PARALIST[ll][2];
    48134813            setring PARARing;
    4814             // if some variables have been eliminated in before, then we have to insert zeros
     4814            // if some variables have been eliminated in before, then we have to insert zeros 
    48154815            // into the parametrisation for those variables
    48164816            if (numberdeletedvariables>0)
     
    48444844        tweight=-ww[1];
    48454845        // if additional variables were necessary, we introduce them now as parameters;
    4846         // in any case the parametrisation ring will have only one variable, namely t,
     4846        // in any case the parametrisation ring will have only one variable, namely t, 
    48474847        // and its order will be local, so that it displays the lowest term in t first
    48484848        if (anzahlvariablen<nvars(basering))
     
    48724872      {
    48734873        if (size(partliftings[lll])==2) // when tropicalparametrise is called for the last time, it does not
    4874         {                     // enter the part, where wneu is defined and the variable t should have
     4874        {                     // enter the part, where wneu is defined and the variable t should have 
    48754875          wneu=-1;     // weight -1
    48764876        }
     
    49044904  }
    49054905  // kill the gfan files in /tmp
    4906   system("sh","cd /tmp; /bin/rm gfaninput; /bin/rm gfanoutput");
     4906  system("sh","cd /tmp; /bin/rm gfaninput; /bin/rm gfanoutput"); 
    49074907  // we return a list which contains lists of the parametrisation rings (with the parametrisation ideal)
    49084908  // and an integer N such that t should be replaced by t^1/N
     
    49124912static proc eliminatecomponents (ideal i,ideal m,int anzahlvariablen,int findall,int lastvar,intvec deletedvariables)
    49134913"USAGE:  eliminatecomponents(i,m,n,a,v,d); i,m ideal, n,a,v int, d intvec
    4914 ASSUME:  i is an ideal in Q[x_1,...,x_n,@a,t] and w=(-w_1/w_0,...,-w_n/w_0)
    4915          is in the tropical variety of i considered in Q[@a]/m{{t}}[x_1,...,x_n];
    4916          considered in this ring i is zero-dimensional; @a need not be present
     4914ASSUME:  i is an ideal in Q[x_1,...,x_n,@a,t] and w=(-w_1/w_0,...,-w_n/w_0) 
     4915         is in the tropical variety of i considered in Q[@a]/m{{t}}[x_1,...,x_n]; 
     4916         considered in this ring i is zero-dimensional; @a need not be present 
    49174917         in which case m is zero; 1<=v<=n
    49184918RETURN:  list, L of lists
     
    49224922NOTE:    - the procedure is called from inside the recursive procedure tropicalparametrise
    49234923         - the procedure checks for solutions which have certain components zero; these are
    4924            separated from the rest by elimination and saturation; the integer deletedvariables
     4924           separated from the rest by elimination and saturation; the integer deletedvariables 
    49254925           records which variables have been eliminated; the integer anzahlvariablen records how
    49264926           many true variables remain after the elimination
     
    49334933  // if all solutions have to be found
    49344934  if (findall==1)
    4935   {
     4935  {   
    49364936    list saturatelist,eliminatelist; // carry the solution of the two tests
    4937     // we test first if there is a solution which has the component lastvar zero and
     4937    // we test first if there is a solution which has the component lastvar zero and 
    49384938    // where the order of each component is strictly positive;
    49394939    // if so, we add this variable to the ideal and eliminate it - which amounts to
    49404940    // to projecting the solutions with this component zero to the hyperplane without this component;
    49414941    // for the test we compute the saturation with respect to t and replace each variable
    4942     // x_i and also t by zero -- if the result is zero, then 1 is not in I:t^infty
     4942    // x_i and also t by zero -- if the result is zero, then 1 is not in I:t^infty 
    49434943    // (i.e. there is a solution which has the component lastvar zero) and
    4944     // the result lives in the maximal ideal <t,x_1,...,[no x_lastvar],...,x_n> so that
     4944    // the result lives in the maximal ideal <t,x_1,...,[no x_lastvar],...,x_n> so that 
    49454945    // there is a solution which has strictly positive valuation
    49464946/*
     
    49544954    // equal to zero then this component has a valuation with all strictly positive values!!!!;
    49554955    // for this we can either saturate the ideal after elimination with respect to <t,x_1,...,x_n>
    4956     // and see if the saturated ideal is contained in <t,x_1,...x_n>+m,
     4956    // and see if the saturated ideal is contained in <t,x_1,...x_n>+m, 
    49574957    // or ALTERNATIVELY we can pass to the ring 0,(t,x_1,...,x_n,@a),(ds(n+1),dp(1)),
    49584958    // compute a standard basis of the elimination ideal (plus m) there and check if the dimension 1
     
    49894989      {
    49904990        string elring="ring ELIMINATERING=("+charstr(basering)+"),("+string(simplify(reduce(maxideal(1),std(var(lastvar))),2))+"),(";
    4991       }
     4991      }   
    49924992      if (anzahlvariablen<nvars(basering)) // if @a was present, the ordersting needs an additional entry
    49934993      {
     
    49954995      }
    49964996      elring=elring+"lp(1));";
    4997       execute(elring);
     4997      execute(elring);     
    49984998      ideal i=imap(BASERING,I); // move the ideal I to the new ring
    49994999      // if not yet all variables have been checked, then go on with the next smaller variable,
     
    50115011    }
    50125012    // next we have to test if there is also a solution which has the variable lastvar non-zero;
    5013     // to do so, we saturate with respect to this variable; since when considered over K{{t}}
     5013    // to do so, we saturate with respect to this variable; since when considered over K{{t}} 
    50145014    // the ideal is zero dimensional, this really removes  all solutions with that component zero;
    50155015    // the checking is then done as above
    50165016    i=std(sat(i,var(lastvar))[1]);
    50175017    I=reduce(i,std(m)); // "remove" m from i
    5018     // test first, if i still is in the ideal <t,x_1,...,x_n> -- if not, then
     5018    // test first, if i still is in the ideal <t,x_1,...,x_n> -- if not, then 
    50195019    // we know that i has no longer a point in the tropical variety with all components negative
    50205020    LI=subst(I,var(nvars(basering)),0);
     
    50245024    }
    50255025    if (size(LI)==0) // the entries of i have not constant part
    5026     {
     5026    {     
    50275027      // check now, if the leading ideal of i contains an element which only depends on t
    50285028      LI=lead(I);
     
    50405040        }
    50415041        else
    5042         {
     5042        {   
    50435043          execute("ring SATURATERING=("+charstr(basering)+"),("+varstr(basering)+"),("+ordstr(basering)+");");
    50445044          ideal i=imap(BASERING,i);
     
    50695069      if (size(LI)==0) // if no power of t is in lead(I) (where the X(i) are considered as field elements)
    50705070      {
    5071         // get rid of var(j)
     5071        // get rid of var(j)   
    50725072        i=eliminate(I,var(j));
    50735073        deletedvariables[j]=1;
     
    50865086    }
    50875087    // if there are variables left, then pass to a ring which only realises these variables
    5088     // else we are done
     5088    // else we are done 
    50895089    if (anzahlvariablen>1)
    50905090    {
     
    50945094    {
    50955095      string elring="ring ELIMINATERING=("+charstr(basering)+"),("+string(variablen)+"),(";
    5096     }
     5096    }   
    50975097    if (size(deletedvariables)+1<nvars(basering)) // if @a was present, the ordersting needs an additional entry
    50985098    {
     
    51005100    }
    51015101    elring=elring+"lp(1));";
    5102     execute(elring);
     5102    execute(elring);     
    51035103    ideal i=imap(BASERING,i);
    51045104    ideal m=imap(BASERING,m);
     
    51115111static proc findzerosAndBasictransform (ideal i,intvec w,list zerolist,int findall,list #)
    51125112"USAGE:      findzerosAndBasictransform(i,w,z,f[,#]); i ideal, w intvec, z list, f int,# an optional list
    5113 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,@a] and w=(w_0,...,w_n,0)
     5113ASSUME:      i is an ideal in Q[t,x_1,...,x_n,@a] and w=(w_0,...,w_n,0) 
    51145114             is in the tropical variety of i; @a need not be present;
    51155115             the list 'zero' contains the zeros computed in previous recursion steps;
     
    51255125                   list zero  = zero[k+1] is the kth component of a zero the t-initial ideal of i
    51265126NOTE:     -  the procedure is called from inside the recursive procedure tropicalparametrise;
    5127              if it is called in the first recursion, the list #[1] contains the t-initial ideal
    5128              of i w.r.t. w, otherwise #[1] is an integer, one more than the number of true
     5127             if it is called in the first recursion, the list #[1] contains the t-initial ideal 
     5128             of i w.r.t. w, otherwise #[1] is an integer, one more than the number of true 
    51295129             variables x_1,...,x_n
    51305130          -  if #[2] is present, then it is an integer which tells whether ALL zeros should be
     
    51545154    int anzahlvariablen=nvars(basering);
    51555155    ideal ini=#[1]; // the t-initial ideal has been computed in before and was handed over
    5156   }
     5156  } 
    51575157  // collect the true variables x_1,...,x_n plus @a, if it is defined in BASERING
    51585158  ideal variablen;
    51595159  for (j=1;j<=nvars(basering)-1;j++)
    5160   {
     5160  {   
    51615161    variablen=variablen+var(j);
    51625162  }
     
    51875187      // phi maps x_i to x_i, @a to @a (if present in the ring), and the additional variable
    51885188      // for the field extension is mapped to @a as well -- note that we only apply phi
    5189       // to the list a, and in this list no @a is present; therefore, it does not matter
     5189      // to the list a, and in this list no @a is present; therefore, it does not matter 
    51905190      // where this is mapped to
    51915191      map phi=ABSRING,imap(BASERING,variablen),@a;
     
    51975197      // for the field extension is mapped to @a as well respectively to 0, if no @a is present;
    51985198      // note that we only apply phi to the list a and to the replacement rule for
    5199       // the old variable @a, and in this list resp. replacement rule no @a is present;
     5199      // the old variable @a, and in this list resp. replacement rule no @a is present; 
    52005200      // therefore, it does not matter where this is mapped to;
    52015201      if (anzahlvariablen<nvars(EXTENSIONRING)) // @a is in EXTENSIONRING
    5202       {
     5202      {     
    52035203        map phi=ABSRING,imap(BASERING,variablen),@a; // additional variable is mapped to @a
    52045204      }
     
    52125212    poly m=maximalideals[j][1];    // extract m
    52135213    list zeroneu=maximalideals[j][2]; // extract the new zero
    5214     poly repl=maximalideals[j][3]; // extract the replacement rule
     5214    poly repl=maximalideals[j][3]; // extract the replacement rule   
    52155215    // the list zero may very well exist as an EMPTY global list - in this case we have to remove it
    52165216    // in order to avoid a redefining warning
    5217     if (defined(zero)!=0)
     5217    if (defined(zero)!=0) 
    52185218    {
    52195219      if (size(zero)==0)
     
    52275227      ideal i=imap(BASERING,i);
    52285228      if (defined(zerolist)==0) // if zerolist is empty, it does not depend on BASERING !
    5229       {
     5229      {       
    52305230        list zero=imap(BASERING,zerolist);
    52315231      }
    5232       else
     5232      else 
    52335233      {
    52345234        list zero=zerolist;
    52355235      }
    52365236    }
    5237     else // in BASERING was @a present
     5237    else // in BASERING was @a present 
    52385238    {
    52395239      ideal variablen=imap(BASERING,variablen);
     
    52475247    zero[size(zero)+1]=zeroneu;
    52485248    // do now the basic transformation sending x_l -> t^-w_l*(zero_l+x_l)
    5249     for (l=1;l<=anzahlvariablen;l++)
     5249    for (l=1;l<=anzahlvariablen;l++) 
    52505250    {
    52515251      for (k=1;k<=size(i);k++)
    52525252      {
    52535253        if (l!=1) // corresponds to  x_(l-1) --  note t is the last variable
    5254         {
     5254        {       
    52555255          i[k]=substitute(i[k],var(l-1),(zeroneu[l]+var(l-1))*t^(-w[l]));
    52565256        }
     
    52655265    {
    52665266      if (wdegs[l]<0) // if wdegs[l]==0 there is no need to divide, and we made sure that it is no positive
    5267       {
     5267      {     
    52685268        i[l]=i[l]/t^(-wdegs[l]);
    52695269      }
     
    52765276    export(i);
    52775277    export(m);
    5278     export(zero);
     5278    export(zero);   
    52795279    extensionringlist[j]=EXTENSIONRING;
    52805280    kill EXTENSIONRING;
     
    52905290             polynomial of the last variable in the ring which is considered as a parameter
    52915291RETURN:      list, the procedure orders the maximal ideals in minassi according to how many new
    5292                    variables are needed (namely none or one) to describe the zeros of the ideal,
     5292                   variables are needed (namely none or one) to describe the zeros of the ideal, 
    52935293                   and accordingly to the degree of the corresponding minimal polynomial
    52945294                   l[j][1] = the minimal polynomial for the jth maximal ideal
    5295                    l[j][2] = list, the k+1st entry is the kth coordinate of the zero
     5295                   l[j][2] = list, the k+1st entry is the kth coordinate of the zero 
    52965296                                   described by the maximal ideal in terms of the last variable
    5297                    l[j][3] = poly, the replacement for the old variable @a
     5297                   l[j][3] = poly, the replacement for the old variable @a 
    52985298NOTE:        if a maximal ideal contains a variable, it is removed from the list;
    52995299             the procedure is called by findzerosAndBasictransform"
     
    53065306  list zero;         // (a_1,...,a_n)=(zero[2],...,zero[n+1]) will be a common zero of the ideal m
    53075307  poly nf;           // normalform of a variable w.r.t. m
    5308   poly minimalpolynomial;  // minimal polynomial for the field extension
     5308  poly minimalpolynomial;  // minimal polynomial for the field extension 
    53095309  poly parrep;       // the old variable @a possibly has to be replaced by a new one
    53105310  // compute for each maximal ideal the number of new variables, which are needed to describe
    53115311  // its zeros -- note, a new variable is needed if the first entry of minassi[j][1] is not the last variable
    5312   // store the value a variable reduces to in the list a;
     5312  // store the value a variable reduces to in the list a; 
    53135313  for (j=size(minassi);j>=1;j--)
    53145314  {
     
    53375337    // if the maximal ideal contains a variable, we simply delete it
    53385338    if (pruefer==0)
    5339     {
     5339    {     
    53405340      minassisort[j]=list(minimalpolynomial,zero,parrep);
    53415341    }
     
    53545354    l=j;
    53555355    for (k=j-1;k>=1;k--)
    5356     {
     5356    {     
    53575357      if (deg(minassisort[l][1])<deg(minassisort[k][1]))
    53585358      {
     
    53935393                   l[i][2] = y-coordinate of the ith vertex
    53945394                   l[i][3] = a polynomial whose monimials mark the vertices in the Newton polygon
    5395                              corresponding to the entries in tp which take the common minimum
     5395                             corresponding to the entries in tp which take the common minimum 
    53965396                             at the ith vertex
    5397 NOTE:      - the information in l[i][3] represents the subdivision of the Newton polygon of tp
    5398              (respectively a polynomial which defines tp);
    5399            - if # is non-empty and #[1] is the string 'max', then in the computations minimum and
    5400              maximum are exchanged;
    5401            - if # is non-empty and the #[1] is not a string, only the vertices will be computed
     5397NOTE:      - the information in l[i][3] represents the subdivision of the Newton polygon of tp 
     5398             (respectively a polynomial which defines tp); 
     5399           - if # is non-empty and #[1] is the string 'max', then in the computations minimum and 
     5400             maximum are exchanged; 
     5401           - if # is non-empty and the #[1] is not a string, only the vertices will be computed 
    54025402             and the information on the Newton subdivision will be omitted;
    54035403           - here the tropical polynomial is supposed to be the MINIMUM of the linear forms in tp,
     
    54065406{
    54075407  // if you insert a single polynomial instead of an ideal representing a tropicalised polynomial,
    5408   // then we compute first the tropicalisation of this polynomial -- this feature is not
     5408  // then we compute first the tropicalisation of this polynomial -- this feature is not 
    54095409  // documented in the above help string
    54105410  if (typeof(tp)=="poly")
     
    54855485            e++;
    54865486          }
    5487         }
     5487        }         
    54885488      }
    54895489    }
     
    55115511RETURN:      list, see the procedure tropicalCurve for an explanation of the syntax of this list
    55125512NOTE:      - the tropical curve defined by tp will consist of a bunch of parallel lines and
    5513              throughout the procedure a list with the name bunchoflines is computed, which
     5513             throughout the procedure a list with the name bunchoflines is computed, which 
    55145514             represents these lines and has the following interpretation:
    55155515             list, each entry corresponds to a vertex in the tropical plane curve defined by tp
    55165516                   l[i][1] = the equation of the ith line in the tropical curve
    55175517                   l[i][2] = a polynomial whose monimials mark the vertices in the Newton polygon
    5518                              corresponding to the entries in tp which take the common minimum
     5518                             corresponding to the entries in tp which take the common minimum 
    55195519                             at the ith vertex
    5520            - the information in l[i][2] represents the subdivision of the Newton polygon of tp
    5521              (respectively a polynomial which defines tp);
    5522            - if # is non-empty and #[1] is the string 'max', then in the computations minimum and
    5523              maximum are exchanged;
    5524            - if # is non-empty and the #[1] is not a string, only the vertices will be computed
     5520           - the information in l[i][2] represents the subdivision of the Newton polygon of tp 
     5521             (respectively a polynomial which defines tp); 
     5522           - if # is non-empty and #[1] is the string 'max', then in the computations minimum and 
     5523             maximum are exchanged; 
     5524           - if # is non-empty and the #[1] is not a string, only the vertices will be computed 
    55255525             and the information on the Newton subdivision will be omitted;
    55265526           - here the tropical polynomial is supposed to be the MINIMUM of the linear forms in tp,
     
    55715571      {
    55725572        vergleich=substitute(tp[l],var(1),px);
    5573         if (vergleich==wert)
     5573        if (vergleich==wert) 
    55745574        {
    55755575          newton=newton+detropicalise(oldtp[l]);
     
    55825582        e++;
    55835583      }
    5584     }
     5584    }         
    55855585  }
    55865586  // if a vertex appears several times, only its first occurence will be kept
     
    55895589    for (j=i-1;j>=1;j--)
    55905590    {
    5591       if (bunchoflines[i][1]==bunchoflines[j][1])
     5591      if (bunchoflines[i][1]==bunchoflines[j][1]) 
    55925592      {
    55935593        bunchoflines=delete(bunchoflines,i);
     
    56305630    xc=substitute(bunchoflines[i][1]-cc,var(2),0,var(1),1);
    56315631    yc=substitute(bunchoflines[i][1]-cc,var(2),1,var(1),0);
    5632         if (xc!=0) // then there is a point on the line with y-coordinate zero
     5632        if (xc!=0) // then there is a point on the line with y-coordinate zero
    56335633    {
    56345634      gr[1]=-cc/leadcoef(xc);
     
    56505650
    56515651static proc clearintmat (intmat vv)
    5652 "USAGE:      clearintmat(vv); vv intmat
     5652"USAGE:      clearintmat(vv); vv intmat 
    56535653ASSUME:      all entries of the first column of vv are non-negative, not all entries are zero
    56545654             unless vv has only one column
    5655 RETURN:      intmat, vv has been ordered in an ascending way by the entries of the first row;
    5656                      if an entry in the first row occurs several times, the entries in the
     5655RETURN:      intmat, vv has been ordered in an ascending way by the entries of the first row; 
     5656                     if an entry in the first row occurs several times, the entries in the 
    56575657                     second row have been added and only one row has been kept;
    56585658                     colums with a zero in the first row have been removed unless vv has only one
     
    56635663  for (int i=ncols(vv)-1;i>=1;i--)
    56645664  {
    5665     if (vv[1,i]==vv[1,i+1])
     5665    if (vv[1,i]==vv[1,i+1]) 
    56665666    {
    56675667      vv[2,i]=vv[2,i]+vv[2,i+1];
     
    56935693        k++;
    56945694      }
    5695       else
     5695      else 
    56965696      {
    56975697        stop=1;
     
    57685768  {
    57695769    int m=nrows(M);
    5770 
     5770   
    57715771  }
    57725772  else
     
    58905890    return(c);
    58915891  }
    5892   f=f-c;
     5892  f=f-c; 
    58935893  if (k==1)
    58945894  {
    58955895    return(substitute(f,var(1),1,var(2),0));
    5896   }
     5896  }   
    58975897  else
    58985898  {
    58995899    return(substitute(f,var(1),0,var(2),1));
    5900   }
     5900  }   
    59015901}
    59025902
     
    59835983ASSUME:      f is a polynomial in Q[x_1,...,x_n], and # is either empty or #[1] is a positive integer
    59845984RETURN:      string, a decimal expansion of the leading coefficient of f up to order two respectively #[1]
    5985 NOTE:        the procedure is called by texDrawTropical and conicWithTangents and
     5985NOTE:        the procedure is called by texDrawTropical and conicWithTangents and 
    59865986             f will actually be a number"
    59875987{
     
    60106010      }
    60116011      for (j=i;j<=i+nachkomma;j++)
    6012       {
     6012      {       
    60136013        news=news+s[j];
    60146014      }
     
    60406040  }
    60416041  return(0);
    6042 }
     6042}     
    60436043
    60446044static proc stringdelete (string w,int i)
     
    60546054  {
    60556055    return("");
    6056 
     6056   
    60576057  }
    60586058  if (i==1)
     
    61096109      k=j+2;
    61106110      while (k<=size(F) and ((F[k]=="0") or (F[k]=="1") or (F[k]=="2") or (F[k]=="3") or
    6111                                 (F[k]=="4") or (F[k]=="5") or (F[k]=="6") or (F[k]=="7") or (F[k]=="8")
     6111                                (F[k]=="4") or (F[k]=="5") or (F[k]=="6") or (F[k]=="7") or (F[k]=="8") 
    61126112                             or (F[k]=="9")))
    61136113      {
     
    61236123      k=j+2;
    61246124      while (k<=size(F) and ((F[k]=="0") or (F[k]=="1") or (F[k]=="2") or (F[k]=="3") or
    6125                                 (F[k]=="4") or (F[k]=="5") or (F[k]=="6") or (F[k]=="7") or (F[k]=="8")
     6125                                (F[k]=="4") or (F[k]=="5") or (F[k]=="6") or (F[k]=="7") or (F[k]=="8") 
    61266126                             or (F[k]=="9")))
    61276127      {
     
    61366136      F=stringdelete(F,j);
    61376137      j--;
    6138     }
     6138    }     
    61396139  }
    61406140  short=altshort;
    61416141  return(F);
    61426142}
    6143 
     6143 
    61446144static proc texcoefficient (poly f,list #)
    61456145"USAGE:      texcoefficient(f[,#]); f poly, # optional list
     
    61766176  }
    61776177  if (size(koeffizient)>5)
    6178   {
     6178  {   
    61796179    string tfractest=koeffizient[2..6];
    61806180    if (tfractest=="tfrac")
     
    62596259static proc coordinatechange (poly f,intmat A,intvec v)
    62606260"USAGE:   coordinatechange(f,A,v);  f poly, A intmat, v intvec
    6261 ASSUME:   f is a polynomial in two variables, A is a 2x2
     6261ASSUME:   f is a polynomial in two variables, A is a 2x2 
    62626262          integer matrix, and v is an integer vector with 2 entries
    62636263RETURN:   poly, the polynomial transformed by (x,y)->A*(x,y)+v
     
    62806280ASSUME:      poly is a cubic polynomial
    62816281RETURN:      poly, the Weierstrass normal form of the cubic, 0 if poly is not a cubic
    6282 NOTE:        - the algorithm for the coefficients of the Weierstrass form is due to
     6282NOTE:        - the algorithm for the coefficients of the Weierstrass form is due to 
    62836283               Fernando Rodriguez Villegas, villegas@math.utexas.edu
    62846284             - if an additional argument # is given, the simplified Weierstrass form
     
    62946294  poly t0,s1,s0,r2,r1,r0,q3,q2,q1,q0=flatten(coeffs(f,ideal(var(2)^3,var(2)^2,var(2)^2*var(1),var(2),var(2)*var(1),var(2)*var(1)^2,1,var(1),var(1)^2,var(1)^3)));
    62956295  // test, if f is already in Weierstrass form
    6296   if ((t0==0) and (s1==1) and (s0==0) and (r0==0) and (q0==-1))
     6296  if ((t0==0) and (s1==1) and (s0==0) and (r0==0) and (q0==-1) and (size(#)==0))
    62976297  {
    62986298    return (f);
     
    63046304  poly a4=((-3*t0*r0+s0^2)*q1+(-3*s1*s0*q0+s1*r0^2))*q3
    63056305    +(t0*r0*q2^2+(s1*s0*q1+((-3*t0*r2+s1^2)*q0+s0*r0*r2))*q2
    6306       +(t0*r2*q1^2+s1*r0*r2*q1+s0*r2^2*q0));
     6306      +(t0*r2*q1^2+s1*r0*r2*q1+s0*r2^2*q0)); 
    63076307  poly a6=(-27*t0^2*q0^2+(9*t0*s0*r0-s0^3)*q0-t0*r0^3)*q3^2+
    6308         (((9*t0^2*q0-t0*s0*r0)*q1+((-3*t0*s0*r1+(3*t0*s1*r0+
    6309         2*s1*s0^2))*q0+(t0*r0^2*r1-s1*s0*r0^2)))*q2+(-t0^2*q1^3
    6310         +(t0*s0*r1+(2*t0*s1*r0-s1*s0^2))*q1^2+((3*t0*s0*r2+
    6311         (-3*t0*s1*r1+2*s1^2*s0))*q0+((2*t0*r0^2-s0^2*r0)*r2+
    6312         (-t0*r0*r1^2+s1*s0*r0*r1-s1^2*r0^2)))*q1+((9*t0*s1*r2-
    6313         s1^3)*q0^2+(((-3*t0*r0+s0^2)*r1-s1*s0*r0)*r2+(t0*r1^3
    6314         -s1*s0*r1^2+s1^2*r0*r1))*q0)))*q3+(-t0^2*q0*q2^3+
    6315         (-t0*s1*r0*q1+((2*t0*s0*r2+(t0*s1*r1-s1^2*s0))*q0-
    6316         t0*r0^2*r2))*q2^2+(-t0*s0*r2*q1^2+(-t0*s1*r2*q0+
    6317         (t0*r0*r1-s1*s0*r0)*r2)*q1+((2*t0*r0-s0^2)*r2^2+
    6318         (-t0*r1^2+s1*s0*r1-s1^2*r0)*r2)*q0)*q2+
    6319         (-t0*r0*r2^2*q1^2+(t0*r1-s1*s0)*r2^2*q0*q1-
     6308        (((9*t0^2*q0-t0*s0*r0)*q1+((-3*t0*s0*r1+(3*t0*s1*r0+
     6309        2*s1*s0^2))*q0+(t0*r0^2*r1-s1*s0*r0^2)))*q2+(-t0^2*q1^3
     6310        +(t0*s0*r1+(2*t0*s1*r0-s1*s0^2))*q1^2+((3*t0*s0*r2+
     6311        (-3*t0*s1*r1+2*s1^2*s0))*q0+((2*t0*r0^2-s0^2*r0)*r2+
     6312        (-t0*r0*r1^2+s1*s0*r0*r1-s1^2*r0^2)))*q1+((9*t0*s1*r2-
     6313        s1^3)*q0^2+(((-3*t0*r0+s0^2)*r1-s1*s0*r0)*r2+(t0*r1^3
     6314        -s1*s0*r1^2+s1^2*r0*r1))*q0)))*q3+(-t0^2*q0*q2^3+
     6315        (-t0*s1*r0*q1+((2*t0*s0*r2+(t0*s1*r1-s1^2*s0))*q0-
     6316        t0*r0^2*r2))*q2^2+(-t0*s0*r2*q1^2+(-t0*s1*r2*q0+
     6317        (t0*r0*r1-s1*s0*r0)*r2)*q1+((2*t0*r0-s0^2)*r2^2+
     6318        (-t0*r1^2+s1*s0*r1-s1^2*r0)*r2)*q0)*q2+
     6319        (-t0*r0*r2^2*q1^2+(t0*r1-s1*s0)*r2^2*q0*q1-
    63206320     t0*r2^3*q0^2));
    63216321  poly b2=a1^2+4*a2;
     
    63656365             i.e. a polynomial of the form a+bx+cx2+dy+exy+fx2y+gy2+hxy2+ix2y2
    63666366RETURN:      poly, a Weierstrass form of the elliptic curve defined by poly
    6367 NOTE:        - the algorithm is based on the paper Sang Yook An, Seog Young Kim,
     6367NOTE:        - the algorithm is based on the paper Sang Yook An, Seog Young Kim, 
    63686368               David C. Marshall, Susan H. Marshall, William G. McCallum and Alexander R. Perlis:
    63696369               Jacobians of Genus One Curves. Journal of Number Theory 90,2 (2001), 304-315.
     
    63886388
    63896389static proc jInvariantOfACubic (poly f,list #)
    6390 "USAGE:      jInvariantOfACubic(f[,#]); f poly, # list
     6390"USAGE:      jInvariantOfACubic(f[,#]); f poly, # list 
    63916391ASSUME:      poly is a cubic polynomial defining an elliptic curve
    63926392RETURN:      poly, the j-invariant of the elliptic curve defined by poly
     
    64296429
    64306430static proc jInvariantOfA2x2Curve (poly f,list #)
    6431 "USAGE:      jInvariantOfA2x2Curve(f[,#]); f poly, # list
     6431"USAGE:      jInvariantOfA2x2Curve(f[,#]); f poly, # list 
    64326432ASSUME:      poly, is a polynomial defining an elliptic curve of type (2,2) on P^1xP^1,
    64336433             i.e. a polynomial of the form a+bx+cx2+dy+exy+fx2y+gy2+hxy2+ix2y2
     
    64756475
    64766476static proc jInvariantOfA4x2Curve (poly f,list #)
    6477 "USAGE:      jInvariantOfA4x2Curve(f[,#]); f poly, # list
     6477"USAGE:      jInvariantOfA4x2Curve(f[,#]); f poly, # list 
    64786478ASSUME:      poly, is a polynomial defining an elliptic curve of type (4,2),
    64796479             i.e. a polynomial of the form a+bx+cx2+dx3+ex4+fy+gxy+hx2y+iy2
     
    65156515
    65166516static proc jInvariantOfAPuiseuxCubic (poly f,list #)
    6517 "USAGE:      jInvariantOfAPuiseuxCubic(f[,#]); f poly, # list
     6517"USAGE:      jInvariantOfAPuiseuxCubic(f[,#]); f poly, # list 
    65186518ASSUME:      poly is a cubic polynomial over Q(t) defining an elliptic curve and # is empty
    6519 RETURN:      list, containing two polynomials whose ratio is the j-invariant of the
     6519RETURN:      list, containing two polynomials whose ratio is the j-invariant of the 
    65206520                   elliptic curve defined by poly
    65216521ASSUME:      poly is a cubic polynomial over Q(t) defining an elliptic curve and # is non-empty
     
    66246624// Example 3 - the ideal is not zero dimensional
    66256625// --------------------------------------------------------
    6626 ring r1=0,(t,x,y),dp;
     6626ring r1=0,(t,x,y),dp; 
    66276627poly 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);
    66286628f;
     
    68106810poly f=t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2;
    68116811list graph=tropicalCurve(f);
    6812 graph;
     6812graph; 
    68136813size(graph)-1;
    68146814drawTropicalCurve(graph);
Note: See TracChangeset for help on using the changeset viewer.