Changeset 3360fb in git


Ignore:
Timestamp:
Apr 14, 2009, 2:00:15 PM (15 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
334c21f9e573112667d39f4cd9dcad9c7b19a50c
Parents:
2c3a5db391a25c28449b80c5f27e1dd77ed2c30f
Message:
*hannes: format


git-svn-id: file:///usr/local/Singular/svn/trunk@11695 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular/LIB
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/algebra.lib

    r2c3a5d r3360fb  
    33//new proc  nonZeroEntry(id), used to fix a bug in proc finitenessTest
    44///////////////////////////////////////////////////////////////////////////////
    5 version="$Id: algebra.lib,v 1.21 2009-04-07 16:18:05 seelisch Exp $";
     5version="$Id: algebra.lib,v 1.22 2009-04-14 12:00:13 Singular Exp $";
    66category="Commutative Algebra";
    77info="
     
    254254NOTE:    the proc algebra_containment tests the same using a different
    255255         algorithm, which is often faster
    256          if l[1] == 0 then l[2] may contain more than one relation h(y(0),y(1),...,y(k)), 
     256         if l[1] == 0 then l[2] may contain more than one relation h(y(0),y(1),...,y(k)),
    257257         separated by comma
    258258EXAMPLE: example inSubring; shows an example
     
    300300     }
    301301     if (deg(ker[i]/y(0))>0)
    302      { if( l[2] != "" ){ l[2] = l[2] + ","; } 
     302     { if( l[2] != "" ){ l[2] = l[2] + ","; }
    303303       l[2] = l[2] + string(ker[i]);
    304304     }
  • Singular/LIB/bfun.lib

    r2c3a5d r3360fb  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: bfun.lib,v 1.7 2009-04-08 16:51:07 seelisch Exp $";
     2version="$Id: bfun.lib,v 1.8 2009-04-14 12:00:13 Singular Exp $";
    33category="Noncommutative";
    44info="
     
    1010@*      one is interested in the global b-function (also known as Bernstein-Sato
    1111@*      polynomial) b(s) in K[s], defined to be the non-zero monic polynomial of minimal
    12 @*      degree, satisfying a functional identity L * F^{s+1} = b(s) F^s,   
     12@*      degree, satisfying a functional identity L * F^{s+1} = b(s) F^s,
    1313@*      for some operator L in D[s] (* stands for the action of differential operator)
    1414@*      By D one denotes the n-th Weyl algebra
     
    2121@*   There is a constructive definition of a b-function of a holonomic ideal I in D
    2222@*   (that is, an ideal I in a Weyl algebra D, such that D/I is holonomic module)
    23 @*   with respect to the given weight vector w: For a poly p in D, its initial 
    24 @*   form w.r.t. (-w,w) is defined as the sum of all terms of p which have 
     23@*   with respect to the given weight vector w: For a poly p in D, its initial
     24@*   form w.r.t. (-w,w) is defined as the sum of all terms of p which have
    2525@*   maximal weighted total degree where the weight of x_i is -w_i and the weight
    26 @*   of d_i is w_i. Let J be the initial ideal of I w.r.t. (-w,w), i.e. the 
     26@*   of d_i is w_i. Let J be the initial ideal of I w.r.t. (-w,w), i.e. the
    2727@*   K-vector space generated by all initial forms w.r.t (-w,w) of elements of I.
    2828@*   Put s = w_1 x_1 d_1 + ... + w_n x_n d_n. Then the monic generator b_w(s) of
    29 @*   the intersection of J with the PID K[s] is called the b-function of I w.r.t.  w. 
     29@*   the intersection of J with the PID K[s] is called the b-function of I w.r.t.  w.
    3030@*   Unlike Bernstein-Sato polynomial, general b-function with respect to
    3131@*   arbitrary weights need not have rational roots at all. However, b-function
    3232@*  of a holonomic ideal is known to be non-zero as well.
    33 @* 
    34 @*      References: [SST] Saito, Sturmfels, Takayama: Groebner Deformations of 
     33@*
     34@*      References: [SST] Saito, Sturmfels, Takayama: Groebner Deformations of
    3535@*      Hypergeometric Differential Equations (2000),
    3636@*      Noro: An Efficient Modular Algorithm for Computing the Global b-function,
     
    4747pIntersect(f,I[,s]);      intersection of ideal with subalgebra K[f] for a poly f
    4848pIntersectSyz(f,I[,p,s,t]); intersection of ideal with subalgebra K[f] with syz-solver
    49 linReduce(f,I[,s]);         reduce a poly by linear reductions wrt ideal 
     49linReduce(f,I[,s]);         reduce a poly by linear reductions wrt ideal
    5050linReduceIdeal(I,[s,t]);  interreduce generators of ideal by linear reductions
    5151linSyzSolve(I[,s]);         compute a linear dependency of elements of ideal I
     
    5353AUXILIARY PROCEDURES:
    5454
    55 allPositive(v);  checks whether all entries of an intvec are positive 
     55allPositive(v);  checks whether all entries of an intvec are positive
    5656scalarProd(v,w); computes the standard scalar product of two intvecs
    5757vec2poly(v[,i]); constructs an univariate poly with given coefficients
     
    9797EXAMPLE: example gradedWeyl; shows examples
    9898NOTE:    u[i] is the weight of x(i), v[i] the weight of D(i).
    99 @*       u+v has to be a non-negative intvec. 
     99@*       u+v has to be a non-negative intvec.
    100100"
    101101{
     
    107107  {
    108108    ERROR("weight vectors have wrong dimension");
    109   } 
     109  }
    110110  intvec uv,gr;
    111111  uv = u+v;
     
    133133  for (i=1; i<=n; i++)
    134134  {
    135     if (gr[i] == 1) 
     135    if (gr[i] == 1)
    136136    {
    137137       l2[n+i] = "xi("+string(i)+")";
     
    358358      for (i=1; i<=ncols(I); i++) { M[i] = gen(i);  }
    359359    }
    360   } 
     360  }
    361361  dbprint(ppl-1,"// initially sorted ideal:", I);
    362362  if (remembercoeffs <> 0) { dbprint(ppl-1,"// used permutations:", M); }
     
    411411    lmJ = insertGenerator(lmJ,lm,j);
    412412    ordJ = insertGenerator(ordJ,poly(ordlm),j);
    413     if (remembercoeffs <> 0) 
     413    if (remembercoeffs <> 0)
    414414    {
    415415      v = M[i];
     
    434434        {
    435435          if (ordJ[i] == ord(J[j][k]))
    436           {   
     436          {
    437437            if (lm == normalize(J[j][k]))
    438438            {
     
    469469RETURN:  poly or list, linear reductum (over field) of f by elements from I
    470470PURPOSE: reduce a poly only by linear reductions (no monomial multiplications)
    471 NOTE:    If s<>0, a list consisting of the reduced poly and the coefficient 
     471NOTE:    If s<>0, a list consisting of the reduced poly and the coefficient
    472472@*       vector of the used reductions is returned, otherwise (and by default)
    473473@*       only reduced poly is returned.
    474474@*       If t<>0 (and by default) all monomials are reduced (if possible),
    475475@*       otherwise, only leading monomials are reduced.
    476 @*       If u<>0 (and by default), the ideal is linearly pre-reduced, i.e. 
     476@*       If u<>0 (and by default), the ideal is linearly pre-reduced, i.e.
    477477@*       instead of the given ideal, the output of @code{linReduceIdeal} is used.
    478478@*       If u is set to 0 and the given ideal does not equal the output of
     
    605605  f = x3+y2+x2+y+x;
    606606  I = x3-y3, y3-x2,x3-y2,x2-y,y2-x;
    607   list l = linReduce(f,I,1); 
     607  list l = linReduce(f,I,1);
    608608  l;
    609609  module M = I;
     
    739739proc pIntersect (poly s, ideal I, list #)
    740740"USAGE:  pIntersect(f, I [,s]);  f a poly, I an ideal, s an optional int
    741 RETURN:  vector, coefficient vector of the monic polynomial 
     741RETURN:  vector, coefficient vector of the monic polynomial
    742742PURPOSE: compute the intersection of ideal I with the subalgebra K[f]
    743743ASSUME:  I is given as Groebner basis, basering is not a qring.
     
    810810    print("// Try a bound of at least " + string(degbound));
    811811    return(vector(0));
    812   } 
     812  }
    813813  dbprint(ppl,"// lower bound for the degree of the insection is " +string(degbound));
    814814  if (degbound == 0) // lm(s) does not appear in lm(I)
     
    894894    v = v + m[j,1]*gen(j);
    895895  }
    896   setring save; 
     896  setring save;
    897897  v = imap(@R,v);
    898898  kill @R;
     
    918918NOTE:    If the intersection is zero, this procedure might not terminate.
    919919@*       If p>0 is given, this proc computes the generator of the intersection in
    920 @*       char p first and then only searches for a generator of the obtained 
    921 @*       degree in the basering. Otherwise, it searches for all degrees by 
     920@*       char p first and then only searches for a generator of the obtained
     921@*       degree in the basering. Otherwise, it searches for all degrees by
    922922@*       computing syzygies.
    923923@*       If s<>0, @code{std} is used for Groebner basis computations in char 0,
    924924@*       otherwise, and by default, @code{slimgb} is used.
    925 @*       If t<>0 and by default, @code{std} is used for Groebner basis 
     925@*       If t<>0 and by default, @code{std} is used for Groebner basis
    926926@*       computations in char >0, otherwise, @code{slimgb} is used.
    927927DISPLAY: If printlevel=1, progress debug messages will be printed,
     
    11311131  }
    11321132  dbprint(ppl,"// pIntersectSyz finished");
    1133   if (solveincharp) { short = shortSave; } 
     1133  if (solveincharp) { short = shortSave; }
    11341134  return(v);
    11351135}
     
    12721272  {
    12731273    return(list(ideal(0),intvec(0)));
    1274   } 
     1274  }
    12751275  if (inorann == 0) // bfct using initial ideal
    12761276  {
     
    13641364RETURN:  list of ideal and intvec
    13651365PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s)
    1366 @*       for the hypersurface defined by f. 
     1366@*       for the hypersurface defined by f.
    13671367ASSUME:  The basering is commutative and of characteristic 0.
    13681368BACKGROUND: In this proc, the initial Malgrange ideal is computed according to
    13691369@*       the algorithm by Masayuki Noro and then a system of linear equations is
    13701370@*       solved by linear reductions.
    1371 NOTE:    In the output list, the ideal contains all the roots 
     1371NOTE:    In the output list, the ideal contains all the roots
    13721372@*       and the intvec their multiplicities.
    13731373@*       If s<>0, @code{std} is used for GB computations,
    1374 @*       otherwise, and by default, @code{slimgb} is used. 
     1374@*       otherwise, and by default, @code{slimgb} is used.
    13751375@*       If t<>0, a matrix ordering is used for Groebner basis computations,
    13761376@*       otherwise, and by default, a block ordering is used.
     
    14351435@*       the algorithm by Masayuki Noro and then a system of linear equations is
    14361436@*       solved by computing syzygies.
    1437 NOTE:    In the output list, the ideal contains all the roots and the intvec 
     1437NOTE:    In the output list, the ideal contains all the roots and the intvec
    14381438@*       their multiplicities.
    14391439@*       If r<>0, @code{std} is used for GB computations in characteristic 0,
     
    15201520ASSUME:  The basering is the n-th Weyl algebra in characteristic 0 and for all
    15211521@*       1<=i<=n the identity var(i+n)*var(i)=var(i)*var(i+1)+1 holds, i.e. the
    1522 @*       sequence of variables is given by x(1),...,x(n),D(1),...,D(n), 
     1522@*       sequence of variables is given by x(1),...,x(n),D(1),...,D(n),
    15231523@*       where D(i) is the differential operator belonging to x(i).
    15241524@*       Further we assume that I is holonomic.
     
    15331533@*  L[3] is 1 (for nonzero constant) or 0 (for zero b-function).
    15341534@*       If s<>0, @code{std} is used for GB computations in characteristic 0,
    1535 @*       otherwise, and by default, @code{slimgb} is used. 
     1535@*       otherwise, and by default, @code{slimgb} is used.
    15361536@*       If t<>0, a matrix ordering is used for GB computations, otherwise,
    15371537@*       and by default, a block ordering is used.
     
    16221622@*       their multiplicities.
    16231623@*       If s<>0, @code{std} is used for the GB computation, otherwise,
    1624 @*       and by default, @code{slimgb} is used. 
     1624@*       and by default, @code{slimgb} is used.
    16251625@*       If t<>0, a matrix ordering is used for GB computations,
    16261626@*       otherwise, and by default, a block ordering is used.
     
    16341634  def save = basering;
    16351635  int n = nvars(save);
    1636   if (char(save) <> 0) 
     1636  if (char(save) <> 0)
    16371637  {
    16381638    ERROR("characteristic of basering has to be 0");
     
    16711671  // create names for vars
    16721672  list Lvar;
    1673   Lvar[1]   = safeVarName("t"); 
     1673  Lvar[1]   = safeVarName("t");
    16741674  Lvar[2]   = safeVarName("s");
    16751675  Lvar[n+3] = safeVarName("D"+Lvar[1]);
     
    16841684  intvec @a = 1:N; @a[2] = 2;
    16851685  intvec @a2 = @a; @a2[2] = 0; @a2[2*n+4] = 0;
    1686   list Lord; 
     1686  list Lord;
    16871687  Lord[1] = list("a",@a); Lord[2] = list("a",@a2);
    16881688  if (methodord == 0) // default: block ordering
     
    17821782@*       their multiplicities.
    17831783@*       If r<>0, @code{std} is used for GB computations,
    1784 @*       otherwise, and by default, @code{slimgb} is used. 
     1784@*       otherwise, and by default, @code{slimgb} is used.
    17851785DISPLAY: If printlevel=1, progress debug messages will be printed,
    17861786@*       if printlevel>=2, all the debug messages will be printed.
  • Singular/LIB/crypto.lib

    r2c3a5d r3360fb  
    11//GP, last modified 28.6.06
    22///////////////////////////////////////////////////////////////////////////////
    3 version="$Id: crypto.lib,v 1.7 2009-04-06 12:39:02 seelisch Exp $";
     3version="$Id: crypto.lib,v 1.8 2009-04-14 12:00:14 Singular Exp $";
    44category="Teaching";
    55info="
     
    15751575"USAGE:  generateG(a,b,m);
    15761576RETURN: m-th division polynomial
    1577 NOTE: generate the so-called division polynomials, i.e., the recursively defined 
     1577NOTE: generate the so-called division polynomials, i.e., the recursively defined
    15781578polynomials p_m=generateG(a,b,m) in Z[x, y] such that, for a point (x:y:1) on the
    15791579elliptic curve defined by y^2=x^3+a*x+b  over Z/N the point@*
  • Singular/LIB/decodegb.lib

    r2c3a5d r3360fb  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: decodegb.lib,v 1.13 2009-04-10 15:18:18 Singular Exp $";
     2version="$Id: decodegb.lib,v 1.14 2009-04-14 12:00:14 Singular Exp $";
    33category="Coding theory";
    44info="
     
    19951995"USAGE:    decodeRandomFL(redun,p,e,n,t,ncodes,ntrials,minpol);
    19961996@format
    1997           - n is length of codes generated, 
     1997          - n is length of codes generated,
    19981998          - redun = redundancy of codes generated,
    19991999          - p is the characteristic,
  • Singular/LIB/dmod.lib

    r2c3a5d r3360fb  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: dmod.lib,v 1.39 2009-04-09 12:04:41 seelisch Exp $";
     2version="$Id: dmod.lib,v 1.40 2009-04-14 12:00:14 Singular Exp $";
    33category="Noncommutative";
    44info="
     
    77@*             Jorge Martin Morales,    jorge@unizar.es
    88
    9 THEORY: Let K be a field of characteristic 0. Given a polynomial ring 
     9THEORY: Let K be a field of characteristic 0. Given a polynomial ring
    1010@*      R = K[x_1,...,x_n] and a polynomial F in R,
    11 @*      one is interested in the R[1/F]-module of rank one, generated by 
     11@*      one is interested in the R[1/F]-module of rank one, generated by
    1212@*      the symbol F^s for a symbolic discrete variable s.
    1313@* In fact, the module R[1/F]*F^s has a structure of a D(R)[s]-module, where D(R)
     
    1919@* One is interested in the following data:
    2020@* - Ann F^s = I = I(F^s) in D(R)[s], denoted by LD in the output
    21 @* - global Bernstein polynomial in K[s], denoted by bs, 
     21@* - global Bernstein polynomial in K[s], denoted by bs,
    2222@* - its minimal integer root s0, the list of all roots of bs, which are known
    2323@*   to be rational, with their multiplicities, which is denoted by BS
    24 @* - Ann F^s0 = I(F^s0) in D(R), denoted by LD0 in the output 
     24@* - Ann F^s0 = I(F^s0) in D(R), denoted by LD0 in the output
    2525@*   (LD0 is a holonomic ideal in D(R))
    2626@* - Ann^(1) F^s in D(R)[s], denoted by LD1 (logarithmic derivations)
     
    2828@*     PS*F^(s+1) = bs*F^s holds in K[x_1,...,x_n,1/F]*F^s.
    2929
    30 REFERENCES: 
     30REFERENCES:
    3131@* We provide the following implementations of algorithms:
    32 @* (OT) the classical Ann F^s algorithm from Oaku and Takayama (Journal of 
     32@* (OT) the classical Ann F^s algorithm from Oaku and Takayama (Journal of
    3333@* Pure and Applied Math., 1999),
    3434@* (LOT) Levandovskyy's modification of the Oaku-Takayama algorithm (ISSAC 2007)
     
    3636@*        l'ideal de Bernstein associe a des polynomes, preprint, 2002)
    3737@* (LM08) V. Levandovskyy and J. Martin-Morales, ISSAC 2008
    38 @* (C) Countinho, A Primer of Algebraic D-Modules, 
    39 @* (SST) Saito, Sturmfels, Takayama 'Groebner Deformations of Hypergeometric 
     38@* (C) Countinho, A Primer of Algebraic D-Modules,
     39@* (SST) Saito, Sturmfels, Takayama 'Groebner Deformations of Hypergeometric
    4040@*         Differential Equations', Springer, 2000
    4141
     
    143143"USAGE:  annfs(f [,S,eng]);  f a poly, S a string, eng an optional int
    144144RETURN:  ring
    145 PURPOSE: compute the D-module structure of basering[1/f]*f^s with the algorithm 
     145PURPOSE: compute the D-module structure of basering[1/f]*f^s with the algorithm
    146146@*  given in S and with the Groebner basis engine given in ''eng''
    147147NOTE:  activate the output ring with the @code{setring} command.
     
    267267"USAGE:  Sannfs(f [,S,eng]);  f a poly, S a string, eng an optional int
    268268RETURN:  ring
    269 PURPOSE: compute the D-module structure of basering[f^s] with the algorithm 
     269PURPOSE: compute the D-module structure of basering[f^s] with the algorithm
    270270@*  given in S and with the Groebner basis engine given in eng
    271271NOTE:    activate the output ring with the @code{setring} command.
     
    388388PURPOSE: compute the D-module structure of basering[1/f]*f^s
    389389NOTE:    activate the output ring with the @code{setring} command.
    390 @*   In the output ring D[s], the ideal LD1 is generated by the elements 
     390@*   In the output ring D[s], the ideal LD1 is generated by the elements
    391391@*   in Ann F^s in D[s], coming from logarithmic derivations.
    392392@*       If eng <>0, @code{std} is used for Groebner basis computations,
     
    536536"USAGE:  ALTannfsBM(f [,eng]);  f a poly, eng an optional int
    537537RETURN:  ring
    538 PURPOSE: compute the annihilator ideal of f^s in D[s], where D is the Weyl 
     538PURPOSE: compute the annihilator ideal of f^s in D[s], where D is the Weyl
    539539@*   algebra, according to the algorithm by Briancon and Maisonobe
    540540NOTE:  activate the output ring with the @code{setring} command. In this ring,
     
    728728"USAGE:  bernsteinBM(f [,eng]);  f a poly, eng an optional int
    729729RETURN:  list (of roots of the Bernstein polynomial b and their multiplicies)
    730 PURPOSE: compute the global Bernstein-Sato polynomial for a hypersurface, 
     730PURPOSE: compute the global Bernstein-Sato polynomial for a hypersurface,
    731731@* defined by f, according to the algorithm by Briancon and Maisonobe
    732732NOTE:    If eng <>0, @code{std} is used for Groebner basis computations,
     
    12511251"USAGE:  annfs2(I, F [,eng]);  I an ideal, F a poly, eng an optional int
    12521252RETURN:  ring
    1253 PURPOSE: compute the annihilator ideal of f^s in the Weyl Algebra, 
     1253PURPOSE: compute the annihilator ideal of f^s in the Weyl Algebra,
    12541254@*       based on the output of Sannfs-like procedure
    12551255@*       annfs2 uses shorter expressions in the variable s (the idea of Noro).
     
    14121412"USAGE:  annfsRB(I, F [,eng]);  I an ideal, F a poly, eng an optional int
    14131413RETURN:  ring
    1414 PURPOSE: compute the annihilator ideal of f^s in the Weyl Algebra, 
     1414PURPOSE: compute the annihilator ideal of f^s in the Weyl Algebra,
    14151415@* based on the output of Sannfs like procedure
    14161416NOTE:    activate the output ring with the @code{setring} command. In this ring,
     
    16011601"USAGE:  operatorBM(f [,eng]);  f a poly, eng an optional int
    16021602RETURN:  ring
    1603 PURPOSE: compute the B-operator and other relevant data for Ann F^s, 
     1603PURPOSE: compute the B-operator and other relevant data for Ann F^s,
    16041604@*  using e.g. algorithm by Briancon and Maisonobe for Ann F^s and BS.
    16051605NOTE:    activate the output ring with the @code{setring} command. In the output ring D[s]
     
    22382238"USAGE:  annfsBMI(F [,eng]);  F an ideal, eng an optional int
    22392239RETURN:  ring
    2240 PURPOSE: compute the D-module structure of basering[1/f]*f^s where 
     2240PURPOSE: compute the D-module structure of basering[1/f]*f^s where
    22412241@* f = F[1]*..*F[P], according to the algorithm by Briancon and Maisonobe.
    22422242NOTE:    activate the output ring with the @code{setring} command. In this ring,
     
    25672567"USAGE:  annfsOT(f [,eng]);  f a poly, eng an optional int
    25682568RETURN:  ring
    2569 PURPOSE: compute the D-module structure of basering[1/f]*f^s, 
     2569PURPOSE: compute the D-module structure of basering[1/f]*f^s,
    25702570@* according to the algorithm by Oaku and Takayama
    25712571NOTE:    activate the output ring with the @code{setring} command. In this ring,
     
    29492949"USAGE:  SannfsOT(f [,eng]);  f a poly, eng an optional int
    29502950RETURN:  ring
    2951 PURPOSE: compute the D-module structure of basering[1/f]*f^s, according to the 
     2951PURPOSE: compute the D-module structure of basering[1/f]*f^s, according to the
    29522952@* 1st step of the algorithm by Oaku and Takayama in the ring D[s]
    29532953NOTE:    activate the output ring with the @code{setring} command.
    2954 @*  In the output ring D[s], the ideal LD (which is NOT a Groebner basis) 
     2954@*  In the output ring D[s], the ideal LD (which is NOT a Groebner basis)
    29552955@*  is the needed D-module structure.
    29562956@*  If eng <>0, @code{std} is used for Groebner basis computations,
     
    32333233"USAGE:  SannfsBM(f [,eng]);  f a poly, eng an optional int
    32343234RETURN:  ring
    3235 PURPOSE: compute the D-module structure of basering[1/f]*f^s, according to the 
     3235PURPOSE: compute the D-module structure of basering[1/f]*f^s, according to the
    32363236@* 1st step of the algorithm by Briancon and Maisonobe in the ring D[s].
    32373237NOTE:  activate the output ring with the @code{setring} command.
    3238 @*   In the output ring D[s], the ideal LD (which is NOT a Groebner basis) is 
     3238@*   In the output ring D[s], the ideal LD (which is NOT a Groebner basis) is
    32393239@*   the needed D-module structure.
    32403240@*   If eng <>0, @code{std} is used for Groebner basis computations,
     
    34423442PURPOSE: compute Ann f^s and Groebner basis of Ann f^s+f in D[s]
    34433443NOTE:    activate the output ring with the @code{setring} command.
    3444 @*  This procedure, unlike SannfsBM, returns a ring with the degrevlex 
     3444@*  This procedure, unlike SannfsBM, returns a ring with the degrevlex
    34453445@*  ordering in all variables.
    34463446@*  In the ring D[s], the ideal LD is the ideal needed (which is returned as a Groebner basis).
     
    36483648PURPOSE: compute Ann f^s and Groebner basis of Ann f^s+f in D[s]
    36493649NOTE:    activate the output ring with the @code{setring} command.
    3650 @*    This procedure, unlike SannfsBM, returns a ring with the degrevlex 
     3650@*    This procedure, unlike SannfsBM, returns a ring with the degrevlex
    36513651@*    ordering in all variables.
    36523652@*    In the ring D[s], the ideal LD (which IS a Groebner basis) is the needed ideal.
     
    36573657"
    36583658{
    3659   // DEBUG INFO: ordering on the output ring = dp, 
     3659  // DEBUG INFO: ordering on the output ring = dp,
    36603660  // use std(K,F); for reusing the std property of K
    36613661
     
    38693869"USAGE:  SannfsLOT(f [,eng]);  f a poly, eng an optional int
    38703870RETURN:  ring
    3871 PURPOSE: compute the D-module structure of basering[1/f]*f^s, according to the 
     3871PURPOSE: compute the D-module structure of basering[1/f]*f^s, according to the
    38723872@* Levandovskyy's modification of the algorithm by Oaku and Takayama in D[s]
    38733873NOTE:    activate the output ring with the @code{setring} command.
    3874 @*    In the ring D[s], the ideal LD (which is NOT a Groebner basis) is 
     3874@*    In the ring D[s], the ideal LD (which is NOT a Groebner basis) is
    38753875@*    the needed D-module structure.
    38763876@*    If eng <>0, @code{std} is used for Groebner basis computations,
     
    43264326"USAGE:  annfsLOT(F [,eng]);  F a poly, eng an optional int
    43274327RETURN:  ring
    4328 PURPOSE: compute the D-module structure of basering[1/f]*f^s, according to 
     4328PURPOSE: compute the D-module structure of basering[1/f]*f^s, according to
    43294329@* the Levandovskyy's modification of the algorithm by Oaku and Takayama
    43304330NOTE:    activate the output ring with the @code{setring} command. In this ring,
     
    43714371"USAGE:  annfs0(I, F [,eng]);  I an ideal, F a poly, eng an optional int
    43724372RETURN:  ring
    4373 PURPOSE: compute the annihilator ideal of f^s in the Weyl Algebra, based 
     4373PURPOSE: compute the annihilator ideal of f^s in the Weyl Algebra, based
    43744374@* on the output of Sannfs-like procedure
    43754375NOTE:    activate the output ring with the @code{setring} command. In this ring,
     
    48604860"USAGE:  annfspecial(I,F,mir,n);  I an ideal, F a poly, int mir, number n
    48614861RETURN:  ideal
    4862 PURPOSE: compute the annihilator ideal of F^n in the Weyl Algebra 
     4862PURPOSE: compute the annihilator ideal of F^n in the Weyl Algebra
    48634863@*           for the given rational number n
    48644864ASSUME:  The basering is D[s] and contains 's' explicitly as a variable,
     
    48664866@*   the integer 'mir' is the minimal integer root of the BS polynomial of F,
    48674867@*   and the number n is rational.
    4868 NOTE: We compute the real annihilator for any rational value of n (both 
    4869 @*       generic and exceptional). The implementation goes along the lines of 
    4870 @*       the Algorithm 5.3.15 from Saito-Sturmfels-Takayama. 
     4868NOTE: We compute the real annihilator for any rational value of n (both
     4869@*       generic and exceptional). The implementation goes along the lines of
     4870@*       the Algorithm 5.3.15 from Saito-Sturmfels-Takayama.
    48714871DISPLAY: If printlevel=1, progress debug messages will be printed,
    48724872@*       if printlevel>=2, all the debug messages will be printed.
     
    51925192RETURN:  int
    51935193ASSUME: Basering is a commutative ring, alpha is a rational number.
    5194 PURPOSE: check whether a rational number alpha is a root of the global 
     5194PURPOSE: check whether a rational number alpha is a root of the global
    51955195@* Bernstein-Sato polynomial of f and compute its multiplicity,
    51965196@* with the algorithm given by S and with the Groebner basis engine given by eng.
    5197 NOTE:  The annihilator of f^s in D[s] is needed and hence it is computed with the 
     5197NOTE:  The annihilator of f^s in D[s] is needed and hence it is computed with the
    51985198@*       algorithm by Briancon and Maisonobe. The value of a string S can be
    51995199@*       'alg1' (default) - for the algorithm 1 of [LM08]
     
    54425442proc checkRoot2 (ideal I, poly F, number a, list #)
    54435443"USAGE:  checkRoot2(I,f,a [,eng]);  I an ideal, f a poly, alpha a number, eng an optional int
    5444 ASSUME:  I is the annihilator of f^s in D[s], basering is D[s], 
     5444ASSUME:  I is the annihilator of f^s in D[s], basering is D[s],
    54455445@* that is basering and I are the output os Sannfs-like procedure,
    54465446@* f is a polynomial in K[_x] and alpha is a rational number.
    5447 RETURN:  int, the multiplicity of -alpha as a root of the BS polynomial of f. 
     5447RETURN:  int, the multiplicity of -alpha as a root of the BS polynomial of f.
    54485448PURPOSE: check whether a rational number alpha is a root of the global Bernstein-
    54495449@* Sato polynomial of f and compute its multiplicity from the known Ann F^s in D[s]
     
    54575457{
    54585458
    5459  
     5459
    54605460  // to check: alpha is rational (has char 0 check inside)
    54615461  if (!isRational(a))
     
    55925592ASSUME:  checkFactor is called from the basering, created by Sannfs-like proc,
    55935593@* that is, from the Weyl algebra in x1,..,xN,d1,..,dN tensored with K[s].
    5594 @* The ideal I is the annihilator of f^s in D[s], that is the ideal, computed 
     5594@* The ideal I is the annihilator of f^s in D[s], that is the ideal, computed
    55955595@* by Sannfs-like procedure (usually called LD there).
    55965596@* Moreover, f is a polynomial in K[x1,..,xN] and qs is a polynomial in K[s].
    55975597RETURN:  int, 1 if qs is a factor of the global Bernstein polynomial of f and 0 otherwise
    5598 PURPOSE: check whether a univariate polynomial qs is a factor of the 
     5598PURPOSE: check whether a univariate polynomial qs is a factor of the
    55995599@*  Bernstein-Sato polynomial of f without explicit knowledge of the latter.
    56005600NOTE:    If eng <>0, @code{std} is used for Groebner basis computations,
     
    56935693"USAGE:  indAR(L,n);  list L, int n
    56945694RETURN:  list
    5695 PURPOSE: computes arrangement inductively, using L and 
     5695PURPOSE: computes arrangement inductively, using L and
    56965696@* var(n) as the next variable
    56975697ASSUME: L has a structure of an arrangement
     
    57415741
    57425742proc isRational(number n)
    5743 "USAGE:  isRational(n); n number 
     5743"USAGE:  isRational(n); n number
    57445744RETURN:  int
    57455745PURPOSE: determine whether n is a rational number,
  • Singular/LIB/elim.lib

    r2c3a5d r3360fb  
    1 // $Id: elim.lib,v 1.29 2009-04-07 16:18:05 seelisch Exp $
     1// $Id: elim.lib,v 1.30 2009-04-14 12:00:14 Singular Exp $
    22// (GMG, modified 22.06.96)
    33// GMG, last modified 30.10.08: new procedure elimRing;
     
    1010// and can now choose as method slimgb or std.
    1111///////////////////////////////////////////////////////////////////////////////
    12 version="$Id: elim.lib,v 1.29 2009-04-07 16:18:05 seelisch Exp $";
     12version="$Id: elim.lib,v 1.30 2009-04-14 12:00:14 Singular Exp $";
    1313category="Commutative Algebra";
    1414info="
     
    223223  //------------------ set resp. compute ring weights ----------------------
    224224  int ii;
    225   intvec @w;              //to store weights of all variables
    226   @w[nvarBR] = 0;
    227   @w = @w + 1;            //initialize @w as 1..1
     225  intvec @w=1:nvarBR;     //to store weights of all variables
    228226  string str = "a";       //default for specifying elimination ordering
    229227  if (size(#) == 0)       //default values
     
    250248       @w = #[1];              //take the given weights
    251249       str = #[2];             //string for specifying elimination ordering
    252 
    253250    }
    254251    if ( typeof(#[1]) == "string" and typeof(#[2]) == "intvec" )
     
    280277        {
    281278           int local = (var(ii) < 1);
    282          }
     279        }
    283280     }
    284281     else
     
    376373
    377374    //define now the first a-block of the form a(w1,0..0)
    378     intvec @v;
    379     @v[nvarBR] = 0;
     375    intvec @v=0:nvarBR;
    380376    @v = @v+w1;
    381377    B3[1] = list("a", @v);
  • Singular/LIB/freegb.lib

    r2c3a5d r3360fb  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: freegb.lib,v 1.21 2009-04-09 12:04:41 seelisch Exp $";
     2version="$Id: freegb.lib,v 1.22 2009-04-14 12:00:14 Singular Exp $";
    33category="Noncommutative";
    44info="
     
    6060PURPOSE: sets attributes for a letterplace ring:
    6161@*      'isLetterplaceRing' = true, 'uptodeg' = d, 'lV' = b, where
    62 @*      'uptodeg' stands for the degree bound, 
     62@*      'uptodeg' stands for the degree bound,
    6363@*      'lV' for the number of variables in the block 0.
    6464NOTE: Activate the resulting ring by using @code{setring}
     
    6969    ERROR("uptodeg and lV do not agree on the basering!");
    7070  }
    71  
     71
    7272    // Set letterplace-specific attributes for the output ring!
    7373  attrib(R, "uptodeg", uptodeg);
    74   attrib(R, "lV", lV); 
    75   attrib(R, "isLetterplaceRing", 1); 
    76   return (R); 
     74  attrib(R, "lV", lV);
     75  attrib(R, "isLetterplaceRing", 1);
     76  return (R);
    7777}
    7878example
     
    365365"USAGE:  isVar(p);  poly p
    366366RETURN:  int
    367 PURPOSE: check, whether leading monomial of p is a power of a single variable 
     367PURPOSE: check, whether leading monomial of p is a power of a single variable
    368368@* from the basering. Returns the exponent or 0 if p is multivariate.
    369369EXAMPLE: example isVar; shows examples
     
    21482148  def R = makeLetterplaceRing(d);
    21492149  setring R;
    2150   int uptodeg = d; 
    2151   int lV = 2; 
     2150  int uptodeg = d;
     2151  int lV = 2;
    21522152  def R = setLetterplaceAttributes(r,uptodeg,2); // supply R with letterplace structure
    21532153  setring R;
  • Singular/LIB/jacobson.lib

    r2c3a5d r3360fb  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: jacobson.lib,v 1.10 2009-03-05 20:36:11 levandov Exp $";
     2version="$Id: jacobson.lib,v 1.11 2009-04-14 12:00:14 Singular Exp $";
    33category="System and Control Theory";
    44info="
     
    1313@* with respect to the mult. closed set S = K[x] without 0.
    1414@* Thus, we treat basering as principal ideal ring with d a polynomial
    15 @* variable and x an invertible one. 
     15@* variable and x an invertible one.
    1616@* Note, that in computations no division by x will actually happen.
    1717@*
     
    2222REFERENCES:
    2323@* (1) N. Jacobson, 'The theory of rings', AMS, 1943.
    24 @* (2) Manuel Avelino Insua Hermo, 'Varias perspectives sobre las bases de Groebner : 
    25 @* Forma normal de Smith, Algorithme de Berlekamp y algebras de Leibniz'. 
     24@* (2) Manuel Avelino Insua Hermo, 'Varias perspectives sobre las bases de Groebner :
     25@* Forma normal de Smith, Algorithme de Berlekamp y algebras de Leibniz'.
    2626@* PhD thesis, Universidad de Santiago de Compostela, 2005.
    2727
     
    6565    L = LL;
    6666  }
    67  
     67
    6868
    6969  // divide units out
     
    7474  int i; int nsize = Min(intvec(nrM,ncM));
    7575  poly p; number n; intvec lexp;
    76  
     76
    7777  for(i=1; i<=nsize; i++)
    7878  {
     
    123123RETURN: matrix or list of matrices, depending on arguments
    124124ASSUME: Basering is a commutative polynomial ring in one variable
    125 PURPOSE: compute the Smith Normal Form of M with (optionally) transformation matrices 
     125PURPOSE: compute the Smith Normal Form of M with (optionally) transformation matrices
    126126THEORY: Groebner bases are used for the Smith form like in (2).
    127127NOTE: By default, just the Smith normal form of M is returned.
     
    129129@* where U*M*V = D and the diagonal field entries of D are not normalized.
    130130@* The normalization of the latter can be done with the 'divideUnits' procedure.
    131 @* U and V above are square unimodular (invertible) matrices. 
     131@* U and V above are square unimodular (invertible) matrices.
    132132@* Note, that the procedure works for a rectangular matrix M.
    133133@*
  • Singular/LIB/nctools.lib

    r2c3a5d r3360fb  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: nctools.lib,v 1.48 2009-04-14 08:25:19 Singular Exp $";
     2version="$Id: nctools.lib,v 1.49 2009-04-14 12:00:14 Singular Exp $";
    33category="Noncommutative";
    44info="
     
    901901  {
    902902    print("Warning: Since the current ordering is not global there might be problems computing twostd(Q)!");
    903     "Q:"; 
     903    "Q:";
    904904    @Q;
    905905  }
  • Singular/LIB/polymake.lib

    r2c3a5d r3360fb  
    1 version="$Id: polymake.lib,v 1.14 2009-04-07 16:18:06 seelisch Exp $";
     1version="$Id: polymake.lib,v 1.15 2009-04-14 12:00:14 Singular Exp $";
    22category="Tropical Geometry";
    33info="
    4 LIBRARY:   polymake.lib    Computations with polytopes and fans, 
     4LIBRARY:   polymake.lib    Computations with polytopes and fans,
    55                           interface to polymake and TOPCOM
    66AUTHOR:    Thomas Markwig,  email: keilen@mathematik.uni-kl.de
     
    88WARNING:
    99   Most procedures will not work unless polymake or topcom is installed and
    10    if so, they will only work with the operating system LINUX! 
     10   if so, they will only work with the operating system LINUX!
    1111   For more detailed information see the following note or consult the
    1212   help string of the procedures.
    1313
    1414NOTE:
    15    Even though this is a Singular library for computing polytopes and fans 
    16    such as the Newton polytope or the Groebner fan of a polynomial, most of 
    17    the hard computations are NOT done by Singular but by the program 
     15   Even though this is a Singular library for computing polytopes and fans
     16   such as the Newton polytope or the Groebner fan of a polynomial, most of
     17   the hard computations are NOT done by Singular but by the program
    1818@* - polymake by Ewgenij Gawrilow, TU Berlin and Michael Joswig, TU Darmstadt
    19 @*   (see http://www.math.tu-berlin.de/polymake/), 
     19@*   (see http://www.math.tu-berlin.de/polymake/),
    2020@* respectively (only in the procedure triangularions) by the program
    2121@* - topcom by Joerg Rambau, Universitaet Bayreuth (see http://www.uni-bayreuth.de/
    2222     departments/wirtschaftsmathematik/rambau/TOPCOM);
    2323@*   This library should rather be seen as an interface which allows to use a
    24      (very limited) number of options which polymake respectively topcom offers 
    25      to compute with polytopes and fans and to make the results available in 
     24     (very limited) number of options which polymake respectively topcom offers
     25     to compute with polytopes and fans and to make the results available in
    2626     Singular for further computations;
    2727     moreover, the user familiar with Singular does not have to learn the syntax
    28      of polymake or topcom, if the options offered here are sufficient for his 
     28     of polymake or topcom, if the options offered here are sufficient for his
    2929     purposes.
    30 @*   Note, though, that the procedures concerned with planar polygons are 
     30@*   Note, though, that the procedures concerned with planar polygons are
    3131     independent of both, polymake and topcom.
    3232
     
    3838  groebnerFan        computes the Groebner fan of a polynomial
    3939  intmatToPolymake   transforms an integer matrix into polymake format
    40   polymakeToIntmat   transforms polymake output into an integer matrix 
     40  polymakeToIntmat   transforms polymake output into an integer matrix
    4141
    4242PROCEDURES USING TOPCOM:
     
    5151  splitPolygon     splits a marked polygon into vertices, facets, interior points
    5252  eta              computes the eta-vector of a triangulation
    53   findOrientedBoundary    computes the boundary of a convex hull 
     53  findOrientedBoundary    computes the boundary of a convex hull
    5454  cyclePoints      computes lattice points connected to some lattice point
    5555  latticeArea      computes the lattice area of a polygon
     
    6262
    6363KEYWORDS:    polytope; fan; secondary fan; secondary polytope; polymake;
    64              Newton polytope; Groebner fan 
     64             Newton polytope; Groebner fan
    6565";
    6666
     
    9595proc polymakePolytope (intmat polytope,list #)
    9696"USAGE:  polymakePolytope(polytope[,#]);   polytope list, # string
    97 ASSUME:  each row of polytope gives the coordinates of a lattice point of a 
    98          polytope with their affine coordinates as given by the output of 
     97ASSUME:  each row of polytope gives the coordinates of a lattice point of a
     98         polytope with their affine coordinates as given by the output of
    9999         secondaryPolytope
    100 PURPOSE: the procedure calls polymake to compute the vertices of the polytope 
     100PURPOSE: the procedure calls polymake to compute the vertices of the polytope
    101101         as well as its dimension and information on its facets
    102102RETURN:  list L with four entries
    103103@*            L[1] : an integer matrix whose rows are the coordinates of vertices
    104                      of the polytope 
     104                     of the polytope
    105105@*            L[2] : the dimension of the polytope
    106106@*            L[3] : a list whose i-th entry explains to which vertices the
    107                      ith vertex of the Newton polytope is connected 
    108                      -- i.e. L[3][i] is an integer vector and an entry k in 
    109                         there means that the vertex L[1][i] is connected to the 
     107                     ith vertex of the Newton polytope is connected
     108                     -- i.e. L[3][i] is an integer vector and an entry k in
     109                        there means that the vertex L[1][i] is connected to the
    110110                        vertex L[1][k]
    111 @*            L[4] : an integer matrix whose rows mulitplied by 
    112                      (1,var(1),...,var(nvar)) give a linear system of equations 
     111@*            L[4] : an integer matrix whose rows mulitplied by
     112                     (1,var(1),...,var(nvar)) give a linear system of equations
    113113                     describing the affine hull of the polytope,
    114114                     i.e. the smallest affine space containing the polytope
    115 NOTE: -  for its computations the procedure calls the program polymake by 
    116          Ewgenij Gawrilow, TU Berlin and Michael Joswig, TU Darmstadt; 
    117          it therefore is necessary that this program is installed in order 
     115NOTE: -  for its computations the procedure calls the program polymake by
     116         Ewgenij Gawrilow, TU Berlin and Michael Joswig, TU Darmstadt;
     117         it therefore is necessary that this program is installed in order
    118118         to use this procedure;
    119119         see http://www.math.tu-berlin.de/polymake/
    120 @*    -  note that in the vertex edge graph we have changed the polymake 
    121          convention which starts indexing its vertices by zero while we start 
     120@*    -  note that in the vertex edge graph we have changed the polymake
     121         convention which starts indexing its vertices by zero while we start
    122122         with one !
    123 @*    -  the procedure creates the file  /tmp/polytope.polymake which contains 
    124          the polytope in polymake format; if you wish to use this for further 
    125          computations with polymake, you have to use the procedure 
     123@*    -  the procedure creates the file  /tmp/polytope.polymake which contains
     124         the polytope in polymake format; if you wish to use this for further
     125         computations with polymake, you have to use the procedure
    126126         polymakeKeepTmpFiles in before
    127127@*    -  moreover, the procedure creates the file /tmp/polytope.output which
    128128         it deletes again before ending
    129129@*    -  it is possible to provide an optional second argument a string
    130          which then will be used instead of 'polytope' in the name of the 
     130         which then will be used instead of 'polytope' in the name of the
    131131         polymake output file
    132132EXAMPLE: example polymakePolytope;   shows an example"
     
    200200      }
    201201    }
    202   } 
     202  }
    203203  newveg=newveg[1,size(newveg)-1];
    204204  execute("list nveg="+newveg+";");
     
    235235   "EXAMPLE:";
    236236   echo=2;
    237    // the lattice points of the unit square in the plane 
     237   // the lattice points of the unit square in the plane
    238238   list points=intvec(0,0),intvec(0,1),intvec(1,0),intvec(1,1);
    239239   // the secondary polytope of this lattice point configuration is computed
     
    261261                     of the Newton polytope of f
    262262@*            L[2] : the dimension of the Newton polytope of f
    263 @*            L[3] : a list whose ith entry explains to which vertices the 
    264                      ith vertex of the Newton polytope is connected 
    265                      -- i.e. L[3][i] is an integer vector and an entry k in 
     263@*            L[3] : a list whose ith entry explains to which vertices the
     264                     ith vertex of the Newton polytope is connected
     265                     -- i.e. L[3][i] is an integer vector and an entry k in
    266266                        there means that the vertex L[1][i] is
    267267                        connected to the vertex L[1][k]
    268 @*            L[4] : an integer matrix whose rows mulitplied by 
    269                      (1,var(1),...,var(nvar)) give a linear system of equations 
     268@*            L[4] : an integer matrix whose rows mulitplied by
     269                     (1,var(1),...,var(nvar)) give a linear system of equations
    270270                     describing the affine hull of the Newton polytope, i.e. the
    271271                     smallest affine space containing the Newton polytope
    272 NOTE: -  if we replace the first column of L[4] by zeros, i.e. if we move 
    273          the affine hull to the origin, then we get the equations for the 
    274          orthogonal comploment of the linearity space of the normal fan dual 
     272NOTE: -  if we replace the first column of L[4] by zeros, i.e. if we move
     273         the affine hull to the origin, then we get the equations for the
     274         orthogonal comploment of the linearity space of the normal fan dual
    275275         to the Newton polytope, i.e. we get the EQUATIONS that
    276276         we need as input for polymake when computing the normal fan
     
    278278         TU Berlin and Michael Joswig, so it only works if polymake is installed;
    279279         see http://www.math.tu-berlin.de/polymake/
    280 @*    -  the procedure creates the file  /tmp/newtonPolytope.polymake which 
    281          contains the polytope in polymake format and which can be used for 
     280@*    -  the procedure creates the file  /tmp/newtonPolytope.polymake which
     281         contains the polytope in polymake format and which can be used for
    282282         further computations with polymake
    283 @*    -  moreover, the procedure creates the file /tmp/newtonPolytope.output 
     283@*    -  moreover, the procedure creates the file /tmp/newtonPolytope.output
    284284         and deletes it again before ending
    285 @*    -  it is possible to give as an optional second argument a string 
    286          which then will be used instead of 'newtonPolytope' in the name of 
     285@*    -  it is possible to give as an optional second argument a string
     286         which then will be used instead of 'newtonPolytope' in the name of
    287287         the polymake output file
    288288EXAMPLE: example newtonPolytope;   shows an example"
    289289{
    290290  int i,j;
    291   // compute the list of exponent vectors of the polynomial, 
     291  // compute the list of exponent vectors of the polynomial,
    292292  // which are the lattice points
    293293  // whose convex hull is the Newton polytope of f
     
    320320   np[2];
    321321   // np[3] contains information how the vertices are connected to each other,
    322    // e.g. the first vertex (number 0) is connected to the second, third and 
     322   // e.g. the first vertex (number 0) is connected to the second, third and
    323323   //      fourth vertex
    324324   np[3][1];
     
    330330   np[1];
    331331   // its dimension is
    332    np[2];   
    333    // the Newton polytope is contained in the affine space given 
     332   np[2];
     333   // the Newton polytope is contained in the affine space given
    334334   //     by the equations
    335335   np[4]*M;
     
    340340proc newtonPolytopeLP (poly f)
    341341"USAGE:  newtonPolytopeLP(f);  f poly
    342 RETURN: list, the exponent vectors of the monomials occuring in f, 
     342RETURN: list, the exponent vectors of the monomials occuring in f,
    343343              i.e. the lattice points of the Newton polytope of f
    344344EXAMPLE: example normalFan;   shows an example"
     
    368368proc normalFan (intmat vertices,intmat affinehull,list graph,int er,list #)
    369369"USAGE:  normalFan (vert,aff,graph,rays,[,#]);   vert,aff intmat,  graph list, rays int, # string
    370 ASSUME:  - vert is an integer matrix whose rows are the coordinate of 
    371            the vertices of a convex lattice polytope; 
     370ASSUME:  - vert is an integer matrix whose rows are the coordinate of
     371           the vertices of a convex lattice polytope;
    372372@*       - aff describes the affine hull of this polytope, i.e.
    373            the smallest affine space containing it, in the following sense: 
    374            denote by n the number of columns of vert, then multiply aff by 
    375            (1,x(1),...,x(n)) and set the resulting terms to zero in order to 
     373           the smallest affine space containing it, in the following sense:
     374           denote by n the number of columns of vert, then multiply aff by
     375           (1,x(1),...,x(n)) and set the resulting terms to zero in order to
    376376           get the equations for the affine hull;
    377 @*       - the ith entry of graph is an integer vector describing to which 
    378            vertices the ith vertex is connected, i.e. a k as entry means that 
     377@*       - the ith entry of graph is an integer vector describing to which
     378           vertices the ith vertex is connected, i.e. a k as entry means that
    379379           the vertex vert[i] is connected to vert[k];
    380 @*       - the integer rays is either one (if the extreme rays should be 
     380@*       - the integer rays is either one (if the extreme rays should be
    381381           computed) or zero (otherwise)
    382 RETURN:  list, the ith entry of L[1] contains information about the cone in the 
    383                normal fan dual to the ith vertex of the polytope 
    384 @*             L[1][i][1] = integer matrix representing the inequalities which 
     382RETURN:  list, the ith entry of L[1] contains information about the cone in the
     383               normal fan dual to the ith vertex of the polytope
     384@*             L[1][i][1] = integer matrix representing the inequalities which
    385385                            describe the cone dual to the ith vertex
    386 @*             L[1][i][2] = a list which contains the inequalities represented 
    387                             by L[i][1] as a list of strings, where we use the 
     386@*             L[1][i][2] = a list which contains the inequalities represented
     387                            by L[i][1] as a list of strings, where we use the
    388388                            variables x(1),...,x(n)
    389389@*             L[1][i][3] = only present if 'er' is set to 1; in that case it is
    390                             an interger matrix whose rows are the extreme rays 
     390                            an interger matrix whose rows are the extreme rays
    391391                            of the cone
    392 @*             L[2] = is an integer matrix whose rows span the linearity space 
    393                       of the fan, i.e. the linear space which is contained in 
     392@*             L[2] = is an integer matrix whose rows span the linearity space
     393                      of the fan, i.e. the linear space which is contained in
    394394                      each cone
    395395NOTE:    - the procedure calls for its computation polymake by Ewgenij Gawrilow,
    396            TU Berlin and Michael Joswig, so it only works if polymake is 
     396           TU Berlin and Michael Joswig, so it only works if polymake is
    397397           installed;
    398398           see http://www.math.tu-berlin.de/polymake/
    399 @*       - in the optional argument # it is possible to hand over other names 
     399@*       - in the optional argument # it is possible to hand over other names
    400400           for the variables to be used -- be careful, the format must be correct
    401401           which is not tested, e.g. if you want the variable names to be
     
    405405  list ineq; // stores the inequalities of the cones
    406406  int i,j,k;
    407   // we work over the following ring 
     407  // we work over the following ring
    408408  execute("ring ineqring=0,x(1.."+string(ncols(vertices))+"),lp;");
    409409  string greatersign=">";
     
    430430  for (i=1;i<=nrows(vertices);i++)
    431431  {
    432     // first we produce for each vertex in the polytope 
     432    // first we produce for each vertex in the polytope
    433433    // the inequalities describing the dual cone in the normal fan
    434     list pp;  // contain strings representing the inequalities 
     434    list pp;  // contain strings representing the inequalities
    435435              // describing the normal cone
    436     intmat ie[size(graph[i])][ncols(vertices)]; // contains the inequalities 
     436    intmat ie[size(graph[i])][ncols(vertices)]; // contains the inequalities
    437437                                                // as rows
    438     // consider all the vertices to which the ith vertex in the 
     438    // consider all the vertices to which the ith vertex in the
    439439    // polytope is connected by an edge
    440440    for (j=1;j<=size(graph[i]);j++)
    441441    {
    442442      // produce the vector ie_j pointing from the jth vertex to the ith vertex;
    443       // this will be the jth inequality for the cone in the normal fan dual to 
     443      // this will be the jth inequality for the cone in the normal fan dual to
    444444      // the ith vertex
    445445      ie[j,1..ncols(vertices)]=vertices[i,1..ncols(vertices)]-vertices[graph[i][j],1..ncols(vertices)];
     
    448448      p=(VAR*EXP)[1,1];
    449449      pl,pr=0,0;
    450       // separate the terms with positive coefficients in p from 
     450      // separate the terms with positive coefficients in p from
    451451      // those with negative coefficients
    452452      for (k=1;k<=size(p);k++)
     
    461461        }
    462462      }
    463       // build the string which represents the jth inequality 
     463      // build the string which represents the jth inequality
    464464      // for the cone dual to the ith vertex
    465       // as polynomial inequality of type string, and store this 
     465      // as polynomial inequality of type string, and store this
    466466      // in the list pp as jth entry
    467467      pp[j]=string(pl)+" "+greatersign+" "+string(pr);
     
    496496    // create the file ineq.output
    497497    write(":w /tmp/ineq.output","");
    498     int dimension; // keeps the dimension of the intersection the 
     498    int dimension; // keeps the dimension of the intersection the
    499499                   // bad cones with the u11tobeseencone
    500500    for (i=1;i<=size(ineq);i++)
    501501    {
    502       i,". Cone of ",nrows(vertices); // indicate how many 
     502      i,". Cone of ",nrows(vertices); // indicate how many
    503503                                      // vertices have been dealt with
    504504      ungleichungen=intmatToPolymake(ineq[i][1],"rays");
     
    525525  }
    526526  // get the linearity space
    527   return(list(ineq,linearity)); 
     527  return(list(ineq,linearity));
    528528}
    529529example
     
    554554proc groebnerFan (poly f,list #)
    555555"USAGE:  groebnerFan(f[,#]);  f poly, # string
    556 RETURN:  list, the ith entry of L[1] contains information about the ith cone 
    557                in the Groebner fan dual to the ith vertex in the Newton 
     556RETURN:  list, the ith entry of L[1] contains information about the ith cone
     557               in the Groebner fan dual to the ith vertex in the Newton
    558558               polytope of the f
    559 @*             L[1][i][1] = integer matrix representing the inequalities 
    560                             which describe the cone         
    561 @*             L[1][i][2] = a list which contains the inequalities represented 
     559@*             L[1][i][1] = integer matrix representing the inequalities
     560                            which describe the cone
     561@*             L[1][i][2] = a list which contains the inequalities represented
    562562                            by L[1][i][1] as a list of strings
    563 @*             L[1][i][3] = an interger matrix whose rows are the extreme rays 
     563@*             L[1][i][3] = an interger matrix whose rows are the extreme rays
    564564                            of the cone
    565 @*             L[2] = is an integer matrix whose rows span the linearity space 
    566                       of the fan, i.e. the linear space which is contained 
    567                       in each cone               
    568 @*             L[3] = the Newton polytope of f in the format of the procedure 
     565@*             L[2] = is an integer matrix whose rows span the linearity space
     566                      of the fan, i.e. the linear space which is contained
     567                      in each cone
     568@*             L[3] = the Newton polytope of f in the format of the procedure
    569569                      newtonPolytope
    570 @*             L[4] = integer matrix where each row represents the exponet 
     570@*             L[4] = integer matrix where each row represents the exponet
    571571                      vector of one monomial occuring in the input polynomial
    572572NOTE: - if you have already computed the Newton polytope of f then you might want
    573         to use the procedure normalFan instead in order to avoid doing costly 
     573        to use the procedure normalFan instead in order to avoid doing costly
    574574        computation twice
    575575@*    - the procedure calls for its computation polymake by Ewgenij Gawrilow,
    576576        TU Berlin and Michael Joswig, so it only works if polymake is installed;
    577577        see http://www.math.tu-berlin.de/polymake/
    578 @*    - the procedure creates the file  /tmp/newtonPolytope.polymake which 
    579         contains the Newton polytope of f in polymake format and which can 
     578@*    - the procedure creates the file  /tmp/newtonPolytope.polymake which
     579        contains the Newton polytope of f in polymake format and which can
    580580        be used for further computations with polymake
    581 @*    - it is possible to give as an optional second argument as string which 
    582         then will be used instead of 'newtonPolytope' in the name of the 
     581@*    - it is possible to give as an optional second argument as string which
     582        then will be used instead of 'newtonPolytope' in the name of the
    583583        polymake output file
    584584EXAMPLE: example groebnerFan;   shows an example"
    585585{
    586586  int i,j;
    587   // compute the list of exponent vectors of the polynomial, which are 
     587  // compute the list of exponent vectors of the polynomial, which are
    588588  // the lattice points whose convex hull is the Newton polytope of f
    589589  intmat exponents[size(f)][nvars(basering)];
     
    649649proc intmatToPolymake (intmat M,string art)
    650650"USAGE:  intmatToPolymake(M,art);  M intmat, art string
    651 ASSUME:  - M is an integer matrix which should be transformed into polymake 
     651ASSUME:  - M is an integer matrix which should be transformed into polymake
    652652           format;
    653653@*       - art is one of the following strings:
    654654@*           + 'rays'   : indicating that a first column of 0's should be added
    655 @*           + 'points' : indicating that a first column of 1's should be added 
    656 RETURN:  string, the matrix is transformed in a string and a first column has 
     655@*           + 'points' : indicating that a first column of 1's should be added
     656RETURN:  string, the matrix is transformed in a string and a first column has
    657657                 been added
    658658EXAMPLE: example intmatToPolymake;   shows an example"
     
    662662    string anf="0 ";
    663663  }
    664   else 
     664  else
    665665  {
    666666    string anf="1 ";
     
    697697proc polymakeToIntmat (string pm,string art)
    698698"USAGE:  polymakeToIntmat(pm,art);  pm, art string
    699 ASSUME:  pm is the result of calling polymake with one 'argument' like 
    700          VERTICES, AFFINE_HULL, etc., so that the first row of the string is 
    701          the name of the corresponding 'argument' and the further rows contain 
     699ASSUME:  pm is the result of calling polymake with one 'argument' like
     700         VERTICES, AFFINE_HULL, etc., so that the first row of the string is
     701         the name of the corresponding 'argument' and the further rows contain
    702702         the result which consists of vectors either over the integers
    703703         or over the rationals
     
    705705                 from the second row, where each row has been multiplied with the
    706706                 lowest common multiple of the denominators of its entries as if
    707                  it is an integer matrix; moreover, if art=='affine', then 
    708                  the first column is omitted since we only want affine 
     707                 it is an integer matrix; moreover, if art=='affine', then
     708                 the first column is omitted since we only want affine
    709709                 coordinates
    710710EXAMPLE: example polymakeToIntmat;   shows an example"
     
    718718    pm=stringdelete(pm,1);
    719719  }
    720   pm=stringdelete(pm,1); 
    721   // find out how many entries each vector has, namely one more 
     720  pm=stringdelete(pm,1);
     721  // find out how many entries each vector has, namely one more
    722722  // than 'spaces' in a row
    723723  int i=1;
     
    734734  // if we want to have affine coordinates
    735735  if (art=="affine")
    736   {   
     736  {
    737737    s--; // then there is one column less
    738738    // and the entry of the first column (in the first row) has to be removed
     
    743743    pm=stringdelete(pm,1);
    744744  }
    745   // we add two line breaks at the end in order to have this as 
     745  // we add two line breaks at the end in order to have this as
    746746  // a stopping criterion
    747747  pm=pm+zeilenumbruch+zeilenumbruch;
     
    761761        z++;
    762762        pm[i]=",";
    763         // if we want to have affine coordinates, 
     763        // if we want to have affine coordinates,
    764764        // then we have to delete the first entry in each row
    765765        if (art=="affine")
     
    775775      if (pm[i]==" ")
    776776      {
    777         pm[i]=",";     
     777        pm[i]=",";
    778778      }
    779779    }
     
    784784    pm=stringdelete(pm,size(pm));
    785785  }
    786   // since the matrix could be over the rationals, 
     786  // since the matrix could be over the rationals,
    787787  // we need a ring with rational coefficients
    788   ring zwischering=0,x,lp;   
     788  ring zwischering=0,x,lp;
    789789  // create the matrix with the elements of pm as entries
    790790  execute("matrix mm["+string(z)+"]["+string(s)+"]="+pm+";");
     
    835835proc triangulations (list polygon)
    836836"USAGE:  triangulations(polygon); list polygon
    837 ASSUME:  polygon is a list of integer vectors of the same size representing 
    838          the affine coordinates of the lattice points 
     837ASSUME:  polygon is a list of integer vectors of the same size representing
     838         the affine coordinates of the lattice points
    839839PURPOSE: the procedure considers the marked polytope given as the convex hull of
    840840         the lattice points and with these lattice points as markings; it then
    841          computes all possible triangulations of this marked polytope 
     841         computes all possible triangulations of this marked polytope
    842842RETURN:  list, each entry corresponds to one triangulation and the ith entry is
    843843               itself a list of integer vectors of size three, where each integer
     
    846846NOTE:- the procedure calls for its computations the program points2triangs
    847847       from the program topcom by Joerg Rambau, Universitaet Bayreuth; it
    848        therefore is necessary that this program is installed in order to use 
     848       therefore is necessary that this program is installed in order to use
    849849       this  procedure; see
    850850@*     http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM
    851 @*   - the procedure creates the files /tmp/triangulationsinput and 
     851@*   - the procedure creates the files /tmp/triangulationsinput and
    852852       /tmp/triangulationsoutput;
    853        the former is used as input for points2triangs and the latter is its 
    854        output containing the triangulations of corresponding to points in the 
    855        format of points2triangs; if you wish to use this for further 
    856        computations with topcom, you have to use the procedure 
     853       the former is used as input for points2triangs and the latter is its
     854       output containing the triangulations of corresponding to points in the
     855       format of points2triangs; if you wish to use this for further
     856       computations with topcom, you have to use the procedure
    857857       polymakeKeepTmpFiles in before
    858 @*   - note that an integer i in an integer vector representing a triangle 
    859        refers to the ith lattice point, i.e. polygon[i]; this convention is 
    860        different from TOPCOM's convention, where i would refer to the i-1st 
     858@*   - note that an integer i in an integer vector representing a triangle
     859       refers to the ith lattice point, i.e. polygon[i]; this convention is
     860       different from TOPCOM's convention, where i would refer to the i-1st
    861861       lattice point
    862862EXAMPLE: example triangulations;   shows an example"
    863863{
    864864  int i,j;
    865   // prepare the input for points2triangs by writing the input polygon in the 
     865  // prepare the input for points2triangs by writing the input polygon in the
    866866  // necessary format
    867867  string spi="[";
     
    885885    system("sh","cd /tmp; rm -f triangulationsinput; rm -f triangulationsoutput");
    886886  }
    887   // preprocessing of p2t if points2triangs is version >= 0.15 
     887  // preprocessing of p2t if points2triangs is version >= 0.15
    888888  // brings p2t to the format of version 0.14
    889889  string np2t; // takes the triangulations in Singular format
     
    907907      }
    908908      else
    909       {       
     909      {
    910910        np2t=np2t+p2t[i];
    911911      }
     
    919919  {
    920920    if (np2t[size(np2t)]!=";")
    921     {     
     921    {
    922922      np2t=np2t+p2t[size(p2t)-1]+p2t[size(p2t)];
    923923    }
     
    941941          np2t=np2t+"))";
    942942          i++;
    943         }     
     943        }
    944944        else
    945945        {
     
    979979   "EXAMPLE:";
    980980   echo=2;
    981    // the lattice points of the unit square in the plane 
     981   // the lattice points of the unit square in the plane
    982982   list polygon=intvec(0,0),intvec(0,1),intvec(1,0),intvec(1,1);
    983983   // the triangulations of this lattice point configuration are computed
     
    10251025  int i,j,k,l;
    10261026  intmat N[2][2]; // is used to compute areas of triangles
    1027   intvec vertex;  // stores a point in the secondary polytope as 
     1027  intvec vertex;  // stores a point in the secondary polytope as
    10281028                  // intermediate result
    10291029  int eintrag;
    10301030  int halt;
    1031   intmat secpoly[size(triangs)][size(polygon)];   // stores all lattice points 
     1031  intmat secpoly[size(triangs)][size(polygon)];   // stores all lattice points
    10321032                                                  // of the secondary polytope
    1033   // consider each triangulation and compute the corresponding point 
     1033  // consider each triangulation and compute the corresponding point
    10341034  // in the secondary polytope
    10351035  for (i=1;i<=size(triangs);i++)
    10361036  {
    1037     // for each triangulation we have to compute the coordinates 
     1037    // for each triangulation we have to compute the coordinates
    10381038    // corresponding to each marked point
    10391039    for (j=1;j<=size(polygon);j++)
    10401040    {
    10411041      eintrag=0;
    1042       // for each marked point we have to consider all triangles in the 
     1042      // for each marked point we have to consider all triangles in the
    10431043      // triangulation which involve this particular point
    10441044      for (k=1;k<=size(triangs[i]);k++)
     
    10621062    secpoly[i,1..size(polygon)]=vertex;
    10631063  }
    1064   return(list(secpoly,triangs));         
     1064  return(list(secpoly,triangs));
    10651065}
    10661066example
     
    10841084proc secondaryFan (list polygon,list #)
    10851085"USAGE:  secondaryFan(polygon[,#]); list polygon, list #
    1086 ASSUME:  - polygon is a list of integer vectors of the same size representing 
     1086ASSUME:  - polygon is a list of integer vectors of the same size representing
    10871087           the affine coordinates of lattice points
    1088 @*       - if the triangulations of the corresponding polygon have already been 
    1089            computed with the procedure triangulations then these can be given 
    1090            as a second (optional) argument in order to avoid doing this 
     1088@*       - if the triangulations of the corresponding polygon have already been
     1089           computed with the procedure triangulations then these can be given
     1090           as a second (optional) argument in order to avoid doing this
    10911091           computation again
    10921092PURPOSE: the procedure considers the marked polytope given as the convex hull of
    10931093         the lattice points and with these lattice points as markings; it then
    1094          computes the lattice points of the secondary polytope given by this 
     1094         computes the lattice points of the secondary polytope given by this
    10951095         marked polytope which correspond to the triangulations computed by
    10961096         the procedure triangulations
    1097 RETURN:  list, the ith entry of L[1] contains information about the ith cone in 
    1098                the secondary fan of the polygon, i.e. the cone dual to the 
     1097RETURN:  list, the ith entry of L[1] contains information about the ith cone in
     1098               the secondary fan of the polygon, i.e. the cone dual to the
    10991099               ith vertex of the secondary polytope
    1100 @*             L[1][i][1] = integer matrix representing the inequalities which 
     1100@*             L[1][i][1] = integer matrix representing the inequalities which
    11011101                            describe the cone dual to the ith vertex
    1102 @*             L[1][i][2] = a list which contains the inequalities represented 
     1102@*             L[1][i][2] = a list which contains the inequalities represented
    11031103                            by L[1][i][1] as a list of strings, where we use the
    11041104                            variables x(1),...,x(n)
    11051105@*             L[1][i][3] = only present if 'er' is set to 1; in that case it is
    1106                             an interger matrix whose rows are the extreme rays 
     1106                            an interger matrix whose rows are the extreme rays
    11071107                            of the cone
    1108 @*             L[2] = is an integer matrix whose rows span the linearity space 
    1109                       of the fan, i.e. the linear space which is contained in 
     1108@*             L[2] = is an integer matrix whose rows span the linearity space
     1109                      of the fan, i.e. the linear space which is contained in
    11101110                      each cone
    1111 @*             L[3] = the secondary polytope in the format of the procedure 
     1111@*             L[3] = the secondary polytope in the format of the procedure
    11121112                      polymakePolytope
    1113 @*             L[4] = the list of triangulations corresponding to the vertices 
     1113@*             L[4] = the list of triangulations corresponding to the vertices
    11141114                      of the secondary polytope
    11151115NOTE:- the procedure calls for its computation polymake by Ewgenij Gawrilow,
    11161116       TU Berlin and Michael Joswig, so it only works if polymake is installed;
    11171117       see http://www.math.tu-berlin.de/polymake/
    1118 @*   - in the optional argument # it is possible to hand over other names for 
     1118@*   - in the optional argument # it is possible to hand over other names for
    11191119       the variables to be used -- be careful, the format must be correct
    11201120       which is not tested, e.g. if you want the variable names to be
    11211121       u00,u10,u01,u11 then you must hand over the string 'u11,u10,u01,u11'
    1122 @*   - if the triangluations are not handed over as optional argument the 
    1123        procedure calls for its computation of these triangulations the program 
    1124        points2triangs from the program topcom by Joerg Rambau, Universitaet 
    1125        Bayreuth; it therefore is necessary that this program is installed in 
     1122@*   - if the triangluations are not handed over as optional argument the
     1123       procedure calls for its computation of these triangulations the program
     1124       points2triangs from the program topcom by Joerg Rambau, Universitaet
     1125       Bayreuth; it therefore is necessary that this program is installed in
    11261126       order to use this procedure; see
    11271127@*     http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM
     
    11721172proc cycleLength (list boundary,intvec interior)
    11731173"USAGE:  cycleLength(boundary,interior); list boundary, intvec interior
    1174 ASSUME:  boundary is a list of integer vectors describing a cycle in some 
    1175          convex lattice polygon around the lattice point interior ordered 
     1174ASSUME:  boundary is a list of integer vectors describing a cycle in some
     1175         convex lattice polygon around the lattice point interior ordered
    11761176         clock wise
    11771177RETURN:  string, the cycle length of the corresponding cycle in the dual
     
    11801180{
    11811181  int j;
    1182   // create a ring whose variables are indexed by the points in 
     1182  // create a ring whose variables are indexed by the points in
    11831183  // boundary resp. by interior
    11841184  string rst="ring cyclering=0,(u"+string(interior[1])+string(interior[2]);
     
    12181218   // interior is a lattice point in the interior of this lattice polygon
    12191219   intvec interior=1,1;
    1220    // compute the general cycle length of a cycle of the corresponding cycle 
     1220   // compute the general cycle length of a cycle of the corresponding cycle
    12211221   // in the dual tropical curve, note that (0,1) and (2,1) do not contribute
    12221222   cycleLength(boundary,interior);
     
    12271227proc splitPolygon (list markings)
    12281228"USAGE:  splitPolygon (markings);  markings list
    1229 ASSUME:  markings is a list of integer vectors representing lattice points in 
    1230          the plane which we consider as the marked points of the convex lattice 
     1229ASSUME:  markings is a list of integer vectors representing lattice points in
     1230         the plane which we consider as the marked points of the convex lattice
    12311231         polytope spanned by them
    1232 PURPOSE: split the marked points in the vertices, the points on the facets 
     1232PURPOSE: split the marked points in the vertices, the points on the facets
    12331233         which are not vertices, and the interior points
    12341234RETURN:  list, L consisting of three lists
     
    12361236@*                       L[1][i][1] = intvec, the coordinates of the ith vertex
    12371237@*                       L[1][i][2] = int, the position of L[1][i][1] in markings
    1238 @*             L[2][i] : represents the lattice points on the facet of the 
    1239                          polygon with endpoints L[1][i] and L[1][i+1] 
     1238@*             L[2][i] : represents the lattice points on the facet of the
     1239                         polygon with endpoints L[1][i] and L[1][i+1]
    12401240                         (i considered modulo size(L[1]))
    1241 @*                       L[2][i][j][1] = intvec, the coordinates of the jth 
     1241@*                       L[2][i][j][1] = intvec, the coordinates of the jth
    12421242                                                 lattice point on that facet
    1243 @*                       L[2][i][j][2] = int, the position of L[2][i][j][1] 
     1243@*                       L[2][i][j][2] = int, the position of L[2][i][j][1]
    12441244                                              in markings
    1245 @*             L[3]    : represents the interior lattice points of the polygon 
     1245@*             L[3]    : represents the interior lattice points of the polygon
    12461246@*                       L[3][i][1] = intvec, coordinates of ith interior point
    12471247@*                       L[3][i][2] = int, the position of L[3][i][1] in markings
     
    12541254  vert[1]=pb[2];
    12551255  int i,j,k;      // indices
    1256   list boundary;  // stores the points on the facets of the 
     1256  list boundary;  // stores the points on the facets of the
    12571257                  // polygon which are not vertices
    1258   // append to the boundary points as well as to the vertices 
     1258  // append to the boundary points as well as to the vertices
    12591259  // the first vertex a second time
    12601260  pb[1]=pb[1]+list(pb[1][1]);
     
    12811281  // store the information on the boundary in vert[2]
    12821282  vert[2]=boundary;
    1283   // find the remaining points in the input which are not on 
     1283  // find the remaining points in the input which are not on
    12841284  // the boundary by checking
    12851285  // for each point in markings if it is contained in pb[1]
     
    12981298  // store the interior points in vert[3]
    12991299  vert[3]=interior;
    1300   // add to each point in vert the index which it gets from 
     1300  // add to each point in vert the index which it gets from
    13011301  // its position in the input markings;
    13021302  // do so for ver[1]
     
    13321332    }
    13331333    vert[3][i]=list(vert[3][i],j);
    1334   } 
     1334  }
    13351335  return(vert);
    13361336}
     
    13391339   "EXAMPLE:";
    13401340   echo=2;
    1341    // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 
     1341   // the lattice polygon spanned by the points (0,0), (3,0) and (0,3)
    13421342   // with all integer points as markings
    13431343   list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),
     
    13591359proc eta (list triang,list polygon)
    13601360"USAGE:  eta(triang,polygon);  triang, polygon list
    1361 ASSUME:  polygon has the format of the output of splitPolygon, i.e. it is a 
    1362          list with three entries describing a convex lattice polygon in the 
     1361ASSUME:  polygon has the format of the output of splitPolygon, i.e. it is a
     1362         list with three entries describing a convex lattice polygon in the
    13631363         following way:
    1364 @*       polygon[1] : is a list of lists; for each i the entry polygon[1][i][1] 
    1365                       is a lattice point which is a vertex of the lattice 
     1364@*       polygon[1] : is a list of lists; for each i the entry polygon[1][i][1]
     1365                      is a lattice point which is a vertex of the lattice
    13661366                      polygon, and polygon[1][i][2] is an integer assigned to
    13671367                      this lattice point as identifying index
    1368 @*       polygon[2] : is a list of lists; for each vertex of the polygon, 
    1369                       i.e. for each entry in polygon[1], it contains a list 
    1370                       polygon[2][i], which contains the lattice points on the 
    1371                       facet with endpoints polygon[1][i] and polygon[1][i+1] 
     1368@*       polygon[2] : is a list of lists; for each vertex of the polygon,
     1369                      i.e. for each entry in polygon[1], it contains a list
     1370                      polygon[2][i], which contains the lattice points on the
     1371                      facet with endpoints polygon[1][i] and polygon[1][i+1]
    13721372                      - i considered mod size(polygon[1]);
    1373                       each such lattice point contributes an entry 
     1373                      each such lattice point contributes an entry
    13741374                      polygon[2][i][j][1] which is an integer
    1375                       vector giving the coordinate of the lattice point and an 
     1375                      vector giving the coordinate of the lattice point and an
    13761376                      entry polygon[2][i][j][2] which is the identifying index
    1377 @*       polygon[3] : is a list of lists, where each entry corresponds to a 
    1378                       lattice point in the interior of the polygon, with 
     1377@*       polygon[3] : is a list of lists, where each entry corresponds to a
     1378                      lattice point in the interior of the polygon, with
    13791379                      polygon[3][j][1] being the coordinates of the point
    13801380                      and polygon[3][j][2] being the identifying index;
    1381 @*       triang is a list of integer vectors all of size three describing a 
    1382          triangulation of the polygon described by polygon; if an entry of 
     1381@*       triang is a list of integer vectors all of size three describing a
     1382         triangulation of the polygon described by polygon; if an entry of
    13831383         triang is the vector (i,j,k) then the triangle is built from the vertices
    13841384         with indices i, j and k
    1385 RETURN:  intvec, the integer vector eta describing that vertex of the Newton 
    1386                  polytope discriminant of the polygone whose dual cone in the 
    1387                  Groebner fan contains the cone of the secondary fan of the 
     1385RETURN:  intvec, the integer vector eta describing that vertex of the Newton
     1386                 polytope discriminant of the polygone whose dual cone in the
     1387                 Groebner fan contains the cone of the secondary fan of the
    13881388                 polygon corresponding to the given triangulation
    1389 NOTE:  for a better description of eta see Gelfand, Kapranov, 
     1389NOTE:  for a better description of eta see Gelfand, Kapranov,
    13901390       Zelevinski: Discriminants, Resultants and multidimensional Determinants.
    13911391       Chapter 10.
     
    13931393{
    13941394  int i,j,k,l,m,n; // index variables
    1395   list ordpolygon;   // stores the lattice points in the order 
     1395  list ordpolygon;   // stores the lattice points in the order
    13961396                     // used in the triangulation
    13971397  list triangarea; // stores the areas of the triangulations
     
    14191419  for (i=1;i<=size(triang);i++)
    14201420  {
    1421     // Note that the ith lattice point in orderedpolygon has the 
     1421    // Note that the ith lattice point in orderedpolygon has the
    14221422    // number i-1 in the triangulation!
    14231423    N=ordpolygon[triang[i][1]]-ordpolygon[triang[i][2]],ordpolygon[triang[i][1]]-ordpolygon[triang[i][3]];
     
    14251425  }
    14261426  intvec ETA;        // stores the eta_ij
    1427   int etaij;         // stores the part of eta_ij during computations 
     1427  int etaij;         // stores the part of eta_ij during computations
    14281428                     // which comes from triangle areas
    1429   int seitenlaenge;  // stores the part of eta_ij during computations 
     1429  int seitenlaenge;  // stores the part of eta_ij during computations
    14301430                     // which comes from boundary facets
    14311431  list seiten;       // stores the lattice points on facets of the polygon
    14321432  intvec v;          // used to compute a facet length
    1433   // 3) store first in seiten[i] all lattice points on the facet 
     1433  // 3) store first in seiten[i] all lattice points on the facet
    14341434  //    connecting the ith vertex,
    1435   //    i.e. polygon[1][i], with the i+1st vertex, i.e. polygon[1][i+1], 
     1435  //    i.e. polygon[1][i], with the i+1st vertex, i.e. polygon[1][i+1],
    14361436  //    where we replace i+1
    14371437  //    1 if i=size(polygon[1]);
    1438   //    then append the last entry of seiten once more at the very 
     1438  //    then append the last entry of seiten once more at the very
    14391439  //    beginning of seiten, so
    14401440  //    that the index is shifted by one
     
    14621462      if ((polygon[1][j][2]==triang[k][1]) or (polygon[1][j][2]==triang[k][2]) or (polygon[1][j][2]==triang[k][3]))
    14631463      {
    1464         // ... if so, add the area of the triangle to etaij 
     1464        // ... if so, add the area of the triangle to etaij
    14651465        etaij=etaij+triangarea[k];
    1466         // then check if that triangle has a facet which is contained 
    1467         // in one of the 
     1466        // then check if that triangle has a facet which is contained
     1467        // in one of the
    14681468        // two facets of the polygon which are adjecent to the given vertex ...
    14691469        // these two facets are seiten[j] and seiten[j+1]
     
    14791479              if ((seiten[n][l][2]==triang[k][m]) and (seiten[n][l][2]!=polygon[1][j][2]))
    14801480              {
    1481                 // if so, then compute the vector pointing from this 
     1481                // if so, then compute the vector pointing from this
    14821482                // lattice point to the vertex
    14831483                v=polygon[1][j][1]-seiten[n][l][1];
    1484                 // and the lattice length of this vector has to be 
     1484                // and the lattice length of this vector has to be
    14851485                // subtracted from etaij
    14861486                etaij=etaij-abs(gcd(v[1],v[2]));
     
    14941494    ETA[polygon[1][j][2]]=etaij;
    14951495  }
    1496   // 5) compute the eta_ij for all lattice points on the facets 
     1496  // 5) compute the eta_ij for all lattice points on the facets
    14971497  //    of the polygon which are not vertices, these are the
    14981498  //    lattice points in polygon[2][1] to polygon[2][size(polygon[1])]
     
    15001500  {
    15011501    for (j=1;j<=size(polygon[2][i]);j++)
    1502     {     
     1502    {
    15031503      // initialise etaij
    15041504      etaij=0;
     
    15111511        if ((polygon[2][i][j][2]==triang[k][1]) or (polygon[2][i][j][2]==triang[k][2]) or (polygon[2][i][j][2]==triang[k][3]))
    15121512        {
    1513           // ... if so, add the area of the triangle to etaij 
     1513          // ... if so, add the area of the triangle to etaij
    15141514          etaij=etaij+triangarea[k];
    1515           // then check if that triangle has a facet which is contained in the 
     1515          // then check if that triangle has a facet which is contained in the
    15161516          // facet of the polygon which contains the lattice point in question,
    15171517          // this is the facet seiten[i+1];
     
    15211521            // ... and for each lattice point in the triangle ...
    15221522            for (m=1;m<=size(triang[k]);m++)
    1523             {           
     1523            {
    15241524              // ... if they coincide and are not the vertex itself ...
    15251525              if ((seiten[i+1][l][2]==triang[k][m]) and (seiten[i+1][l][2]!=polygon[2][i][j][2]))
    15261526              {
    1527                 // if so, then compute the vector pointing from 
     1527                // if so, then compute the vector pointing from
    15281528                // this lattice point to the vertex
    15291529                v=polygon[2][i][j][1]-seiten[i+1][l][1];
    1530                 // and the lattice length of this vector contributes 
     1530                // and the lattice length of this vector contributes
    15311531                // to seitenlaenge
    15321532                seitenlaenge=seitenlaenge+abs(gcd(v[1],v[2]));
     
    15361536        }
    15371537      }
    1538       // if the lattice point was a vertex of any triangle 
     1538      // if the lattice point was a vertex of any triangle
    15391539      // in the triangulation ...
    15401540      if (etaij!=0)
     
    15611561      if ((polygon[3][j][2]==triang[k][1]) or (polygon[3][j][2]==triang[k][2]) or (polygon[3][j][2]==triang[k][3]))
    15621562      {
    1563         // ... if so, add the area of the triangle to etaij 
     1563        // ... if so, add the area of the triangle to etaij
    15641564        etaij=etaij+triangarea[k];
    15651565      }
     
    15741574   "EXAMPLE:";
    15751575   echo=2;
    1576    // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 
     1576   // the lattice polygon spanned by the points (0,0), (3,0) and (0,3)
    15771577   // with all integer points as markings
    15781578   list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),
     
    15811581   // split the polygon in its vertices, its facets and its interior points
    15821582   list sp=splitPolygon(polygon);
    1583    // define a triangulation by connecting the only interior point 
     1583   // define a triangulation by connecting the only interior point
    15841584   //        with the vertices
    15851585   list triang=intvec(1,2,5),intvec(1,5,10),intvec(1,5,10);
     
    15871587   eta(triang,sp);
    15881588}
    1589  
     1589
    15901590/////////////////////////////////////////////////////////////////////////////
    15911591
     
    16141614  }
    16151615  // check is the polygon is only a line segment given by more than two points;
    1616   // for this first compute sum of the absolute values of the determinants 
     1616  // for this first compute sum of the absolute values of the determinants
    16171617  // of the matrices whose
    1618   // rows are the vectors pointing from the first to the second point 
     1618  // rows are the vectors pointing from the first to the second point
    16191619  // and from the
    1620   // the first point to the ith point for i=3,...,size(polygon); 
     1620  // the first point to the ith point for i=3,...,size(polygon);
    16211621  // if this sum is zero
    16221622  // then the polygon is a line segment and we have to find its end points
     
    16311631    intmat laenge[size(polygon)][size(polygon)];
    16321632    intvec mp;
    1633     //   for this collect first all vectors pointing from one lattice 
     1633    //   for this collect first all vectors pointing from one lattice
    16341634    //   point to the next,
    16351635    //   compute their pairwise angles and their lengths
    16361636    for (i=1;i<=size(polygon)-1;i++)
    1637     {     
     1637    {
    16381638      for (j=i+1;j<=size(polygon);j++)
    16391639      {
     
    16591659    polygon=sortlistbyintvec(polygon,abstand);
    16601660    return(list(polygon,endpoints));
    1661   } 
     1661  }
    16621662  ///////////////////////////////////////////////////////////////
    16631663  list orderedvertices;  // stores the vertices in an ordered way
    1664   list minimisedorderedvertices;  // stores the vertices in an ordered way; 
     1664  list minimisedorderedvertices;  // stores the vertices in an ordered way;
    16651665                                  // redundant ones removed
    1666   list comparevertices; // stores vertices which should be compared to 
     1666  list comparevertices; // stores vertices which should be compared to
    16671667                        // the testvertex
    16681668  orderedvertices[1]=polygon[1]; // set the starting vertex
    16691669  minimisedorderedvertices[1]=polygon[1]; // set the starting vertex
    16701670  intvec testvertex=polygon[1];  //vertex to which the others have to be compared
    1671   intvec startvertex=polygon[1]; // keep the starting vertex to test, 
     1671  intvec startvertex=polygon[1]; // keep the starting vertex to test,
    16721672                                 // when the end is reached
    16731673  int endtest;                   // is set to one, when the end is reached
    1674   int startvertexfound;// is 1, once for some testvertex a candidate 
    1675                        // for the next vertex has been found 
     1674  int startvertexfound;// is 1, once for some testvertex a candidate
     1675                       // for the next vertex has been found
    16761676  polygon=delete(polygon,1);    // delete the testvertex
    16771677  intvec v,w;
    16781678  int l=1;  // counts the vertices
    1679   // the basic idea is that a vertex can be 
     1679  // the basic idea is that a vertex can be
    16801680  // the next one on the boundary if all other vertices
    1681   // lie to the right of the vector v pointing 
     1681  // lie to the right of the vector v pointing
    16821682  // from the testvertex to this one; this can be tested
    1683   // by checking if the determinant of the 2x2-matrix 
     1683  // by checking if the determinant of the 2x2-matrix
    16841684  // with first column v and second column the vector w,
    1685   // pointing from the testvertex to the new vertex, 
     1685  // pointing from the testvertex to the new vertex,
    16861686  // is non-positive; if this is the case for all
    1687   // new vertices, then the one in consideration is 
     1687  // new vertices, then the one in consideration is
    16881688  // a possible choice for the next vertex on the boundary
    1689   // and it is stored in naechste; we can then order 
     1689  // and it is stored in naechste; we can then order
    16901690  // the candidates according to their distance from
    16911691  // the testvertex; then they occur on the boundary in that order!
     
    16991699      v=polygon[i]-testvertex; // points from the testvertex to the ith vertex
    17001700      comparevertices=delete(polygon,i); // we needn't compare v to itself
    1701       // we should compare v to the startvertex-testvertex; 
     1701      // we should compare v to the startvertex-testvertex;
    17021702      // in the first calling of the loop
    1703       // this is irrelevant since the difference will be zero; 
     1703      // this is irrelevant since the difference will be zero;
    17041704      // however, later on it will
    1705       // be vital, since we delete the vertices 
     1705      // be vital, since we delete the vertices
    17061706      // which we have already tested from the list
    1707       // of all vertices, and when all vertices 
     1707      // of all vertices, and when all vertices
    17081708      // on the boundary have been found we would
    1709       // therefore find a vertex in the interior 
     1709      // therefore find a vertex in the interior
    17101710      // as candidate; but always testing against
    17111711      // the starting vertex, this can not happen
    1712       comparevertices[size(comparevertices)+1]=startvertex; 
     1712      comparevertices[size(comparevertices)+1]=startvertex;
    17131713      for (j=1;(j<=size(comparevertices)) and (d<=0);j++)
    17141714      {
     
    17181718        d=det(D);
    17191719      }
    1720       if (d<=0) // if all determinants are non-positive, 
     1720      if (d<=0) // if all determinants are non-positive,
    17211721      { // then the ith vertex is a candidate
    17221722        naechste[k]=list(polygon[i],i,scalarproduct(v,v));// we store the vertex,
     
    17261726    }
    17271727    if (size(naechste)>0) // then a candidate for the next vertex has been found
    1728     {     
     1728    {
    17291729      startvertexfound=1; // at least once a candidate has been found
    1730       naechste=sortlist(naechste,3);  // we order the candidates according 
     1730      naechste=sortlist(naechste,3);  // we order the candidates according
    17311731                                      // to their distance from testvertex;
    1732       for (j=1;j<=size(naechste);j++) // then we store them in this 
     1732      for (j=1;j<=size(naechste);j++) // then we store them in this
    17331733      { // order in orderedvertices
    17341734        l++;
    17351735        orderedvertices[l]=naechste[j][1];
    17361736      }
    1737       testvertex=naechste[size(naechste)][1];  // we store the last one as 
     1737      testvertex=naechste[size(naechste)][1];  // we store the last one as
    17381738                                               // next testvertex;
    17391739      // store the next corner of NSD
    1740       minimisedorderedvertices[size(minimisedorderedvertices)+1]=testvertex; 
    1741       naechste=sortlist(naechste,2); // then we reorder the vertices 
     1740      minimisedorderedvertices[size(minimisedorderedvertices)+1]=testvertex;
     1741      naechste=sortlist(naechste,2); // then we reorder the vertices
    17421742                                     // according to their position
    17431743      for (j=size(naechste);j>=1;j--) // and we delete them from the vertices
     
    17461746      }
    17471747    }
    1748     else // that means either that the vertex was inside the polygon, 
    1749     {    // or that we have reached the last vertex on the boundary 
     1748    else // that means either that the vertex was inside the polygon,
     1749    {    // or that we have reached the last vertex on the boundary
    17501750         // of the polytope
    1751       if (startvertexfound==0) // the vertex was in the interior; 
     1751      if (startvertexfound==0) // the vertex was in the interior;
    17521752      { // we delete it and start all over again
    1753         orderedvertices[1]=polygon[1]; 
    1754         minimisedorderedvertices[1]=polygon[1]; 
     1753        orderedvertices[1]=polygon[1];
     1754        minimisedorderedvertices[1]=polygon[1];
    17551755        testvertex=polygon[1];
    17561756        startvertex=polygon[1];
    17571757        polygon=delete(polygon,1);
    17581758      }
    1759       else // we have reached the last vertex on the boundary of 
     1759      else // we have reached the last vertex on the boundary of
    17601760      { // the polytope and can stop
    17611761        endtest=1;
     
    17641764    kill naechste;
    17651765  }
    1766   // test if the first vertex in minimisedorderedvertices 
     1766  // test if the first vertex in minimisedorderedvertices
    17671767  // is on the same line with the second and
    1768   // the last, i.e. if we started our search in the 
     1768  // the last, i.e. if we started our search in the
    17691769  // middle of a face; if so, delete it
    17701770  v=minimisedorderedvertices[2]-minimisedorderedvertices[1];
     
    17751775    minimisedorderedvertices=delete(minimisedorderedvertices,1);
    17761776  }
    1777   // test if the first vertex in minimisedorderedvertices 
     1777  // test if the first vertex in minimisedorderedvertices
    17781778  // is on the same line with the two
    1779   // last ones, i.e. if we started our search at the end of a face; 
     1779  // last ones, i.e. if we started our search at the end of a face;
    17801780  // if so, delete it
    17811781  v=minimisedorderedvertices[size(minimisedorderedvertices)-1]-minimisedorderedvertices[1];
     
    18091809proc cyclePoints (list triang,list points,int pt)
    18101810"USAGE:      cyclePoints(triang,points,pt)  triang,points list, pt int
    1811 ASSUME:      - points is a list of integer vectors describing the lattice 
     1811ASSUME:      - points is a list of integer vectors describing the lattice
    18121812               points of a marked polygon;
    1813 @*           - triang is a list of integer vectors describing a triangulation 
    1814                of the marked polygon in the sense that an integer vector of 
    1815                the form (i,j,k) describes the triangle formed by polygon[i], 
     1813@*           - triang is a list of integer vectors describing a triangulation
     1814               of the marked polygon in the sense that an integer vector of
     1815               the form (i,j,k) describes the triangle formed by polygon[i],
    18161816               polygon[j] and polygon[k];
    1817 @*           - pt is an integer between 1 and size(points), singling out a 
     1817@*           - pt is an integer between 1 and size(points), singling out a
    18181818               lattice point among the marked points
    1819 PURPOSE:     consider the convex lattice polygon, say P, spanned by all lattice 
    1820              points in points which in the triangulation triang are connected 
    1821              to the point points[pt]; the procedure computes all marked points 
     1819PURPOSE:     consider the convex lattice polygon, say P, spanned by all lattice
     1820             points in points which in the triangulation triang are connected
     1821             to the point points[pt]; the procedure computes all marked points
    18221822             in points which lie on the boundary of that polygon, ordered
    18231823             clockwise
    1824 RETURN:      list, of integer vectors which are the coordinates of the lattice 
    1825                    points on the boundary of the above mentioned polygon P, if 
    1826                    this polygon is not the empty set (that would be the case if 
    1827                    points[pt] is not a vertex of any triangle in the 
     1824RETURN:      list, of integer vectors which are the coordinates of the lattice
     1825                   points on the boundary of the above mentioned polygon P, if
     1826                   this polygon is not the empty set (that would be the case if
     1827                   points[pt] is not a vertex of any triangle in the
    18281828                   triangulation); otherwise return the empty list
    18291829EXAMPLE:     example cyclePoints;   shows an example"
    18301830{
    18311831  int i,j; // indices
    1832   list v;  // saves the indices of lattice points connected to the 
     1832  list v;  // saves the indices of lattice points connected to the
    18331833           // interior point in the triangulation
    18341834  // save all points in triangulations containing pt in v
     
    18661866    pts[i]=points[v[i]];
    18671867  }
    1868   // consider the convex polytope spanned by the points in pts, 
     1868  // consider the convex polytope spanned by the points in pts,
    18691869  // find the points on the
    18701870  // boundary and order them clockwise
     
    18751875   "EXAMPLE:";
    18761876   echo=2;
    1877    // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 
     1877   // the lattice polygon spanned by the points (0,0), (3,0) and (0,3)
    18781878   // with all integer points as markings
    18791879   list points=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),
    18801880               intvec(0,0),intvec(2,1),intvec(0,1),intvec(1,2),
    18811881               intvec(0,2),intvec(0,3);
    1882    // define a triangulation 
     1882   // define a triangulation
    18831883   list triang=intvec(1,2,5),intvec(1,5,7),intvec(1,7,9),intvec(8,9,10),
    18841884               intvec(1,8,9),intvec(1,2,8);
     
    18921892"USAGE:  latticeArea(polygon);   polygon list
    18931893ASSUME:  polygon is a list of integer vectors in the plane
    1894 RETURN:  int, the lattice area of the convex hull of the lattice points in 
     1894RETURN:  int, the lattice area of the convex hull of the lattice points in
    18951895              polygon, i.e. twice the Euclidean area
    18961896EXAMPLE: example polygonlatticeArea;   shows an example"
     
    19211921proc picksFormula (list polygon)
    19221922"USAGE:  picksFormula(polygon);   polygon list
    1923 ASSUME:  polygon is a list of integer vectors in the plane and consider their 
    1924          convex hull C 
    1925 RETURN:  list, L of three integersthe 
     1923ASSUME:  polygon is a list of integer vectors in the plane and consider their
     1924         convex hull C
     1925RETURN:  list, L of three integersthe
    19261926@*             L[1] : the lattice area of C, i.e. twice the Euclidean area
    19271927@*             L[2] : the number of lattice points on the boundary of C
     
    19481948    bdpts=bdpts+abs(gcd(edge[1],edge[2]));
    19491949  }
    1950   // Pick's formula says that the lattice area A, the number g of interior 
     1950  // Pick's formula says that the lattice area A, the number g of interior
    19511951  // points and
    19521952  // the number b of boundary points are connected by the formula: A=b+2g-2
     
    19761976"USAGE:  ellipticNF(polygon);   polygon list
    19771977ASSUME:  polygon is a list of integer vectors in the plane such that their
    1978          convex hull C has precisely one interior lattice point, i.e. C is the 
     1978         convex hull C has precisely one interior lattice point, i.e. C is the
    19791979         Newton polygon of an elliptic curve
    1980 PURPOSE: compute the normal form of the polygon with respect to the unimodular 
     1980PURPOSE: compute the normal form of the polygon with respect to the unimodular
    19811981         affine transformations T=A*x+v; there are sixteen different normal forms
    1982          (see e.g. Bjorn Poonen, Fernando Rodriguez-Villegas: Lattice Polygons 
    1983                    and the number 12.  Amer. Math. Monthly  107  (2000),  no. 3, 
     1982         (see e.g. Bjorn Poonen, Fernando Rodriguez-Villegas: Lattice Polygons
     1983                   and the number 12.  Amer. Math. Monthly  107  (2000),  no. 3,
    19841984                   238--250.)
    19851985RETURN:  list, L such that
    1986 @*             L[1] : list whose entries are the vertices of the normal form of 
     1986@*             L[1] : list whose entries are the vertices of the normal form of
    19871987                      the polygon
    19881988@*             L[2] : the matrix A of the unimodular transformation
    19891989@*             L[3] : the translation vector v of the unimodular transformation
    1990 @*             L[4] : list such that the ith entry is the image of polygon[i] 
     1990@*             L[4] : list such that the ith entry is the image of polygon[i]
    19911991                      under the unimodular transformation T
    19921992EXAMPLE: example ellipticNF;   shows an example"
     
    20202020  intvec trans;    // stores the vector by which we have to translate the polygon
    20212021  intmat A[2][2];  // stores the matrix by which we have to transform the polygon
    2022   matrix M[3][3];  // stores the projective coordinates of the points 
     2022  matrix M[3][3];  // stores the projective coordinates of the points
    20232023                   // which are to be transformed
    2024   matrix N[3][3];  // stores the projective coordinates of the points to 
     2024  matrix N[3][3];  // stores the projective coordinates of the points to
    20252025                   // which M is to be transformed
    2026   intmat T[3][3];  // stores the unimodular affine transformation in 
     2026  intmat T[3][3];  // stores the unimodular affine transformation in
    20272027                   // projective form
    20282028  // add the second point of pg once again at the end
    20292029  pg=insert(pg,pg[2],size(pg));
    2030   // if there is only one edge which has the maximal number of lattice points, 
     2030  // if there is only one edge which has the maximal number of lattice points,
    20312031  // then M should be:
    20322032  M=pg[max],1,pg[max+1],1,pg[max+2],1;
     
    21182118    M=pg[max],1,pg[max+1],1,pg[max+2],1;
    21192119    // the orientation of the polygon matters
    2120     A=pg[max-1]-pg[max],pg[max+1]-pg[max];   
     2120    A=pg[max-1]-pg[max],pg[max+1]-pg[max];
    21212121    if (det(A)==4)
    21222122    {
     
    21672167    {
    21682168      max++;
    2169     }   
     2169    }
    21702170    M=pg[max],1,pg[max+1],1,pg[max+2],1;
    21712171    N=0,1,1,1,2,1,2,1,1;
     
    22302230   // the vertices of the normal form are
    22312231   nf[1];
    2232    // it has been transformed by the unimodular affine transformation A*x+v 
     2232   // it has been transformed by the unimodular affine transformation A*x+v
    22332233   // with matrix A
    22342234   nf[2];
     
    22472247"USAGE:  ellipticNFDB(n[,#]);   n int, # list
    22482248ASSUME:  n is an integer between 1 and 16
    2249 PURPOSE: this is a database storing the 16 normal forms of planar polygons with 
     2249PURPOSE: this is a database storing the 16 normal forms of planar polygons with
    22502250         precisely one interior point up to unimodular affine transformations
    2251 @*       (see e.g. Bjorn Poonen, Fernando Rodriguez-Villegas: Lattice Polygons 
     2251@*       (see e.g. Bjorn Poonen, Fernando Rodriguez-Villegas: Lattice Polygons
    22522252                   and the number 12.  Amer. Math. Monthly  107  (2000),  no. 3,
    22532253                   238--250.)
    22542254RETURN:  list, L such that
    2255 @*             L[1] : list whose entries are the vertices of the nth normal form 
    2256 @*             L[2] : list whose entries are all the lattice points of the 
    2257                       nth normal form 
    2258 @*             L[3] : only present if the optional parameter # is present, and 
    2259                       then it is a polynomial in the variables (x,y) whose 
     2255@*             L[1] : list whose entries are the vertices of the nth normal form
     2256@*             L[2] : list whose entries are all the lattice points of the
     2257                      nth normal form
     2258@*             L[3] : only present if the optional parameter # is present, and
     2259                      then it is a polynomial in the variables (x,y) whose
    22602260                      Newton polygon is the nth normal form
    2261 NOTE:    the optional parameter is only allowed if the basering has the 
     2261NOTE:    the optional parameter is only allowed if the basering has the
    22622262         variables x and y
    22632263EXAMPLE: example ellipticNFDB;   shows an example"
     
    23102310proc polymakeKeepTmpFiles (int i)
    23112311"USAGE:  polymakeKeepTmpFiles(int i);   i int
    2312 PURPOSE: some procedures create files in the directory /tmp which are used for 
     2312PURPOSE: some procedures create files in the directory /tmp which are used for
    23132313         computations with polymake respectively topcom; these will be removed
    2314          when the corresponding procedure is left; however, it might be 
     2314         when the corresponding procedure is left; however, it might be
    23152315         desireable to keep them for further computations with either polymake or
    23162316         topcom; this can be achieved by this procedure; call the procedure as:
     
    23552355static proc scalarproduct (intvec w,intvec v)
    23562356"USAGE:      scalarproduct(w,v); w,v intvec
    2357 ASSUME:      w and v are integer vectors of the same length 
     2357ASSUME:      w and v are integer vectors of the same length
    23582358RETURN:      int, the scalarproduct of v and w
    23592359NOTE:        the procedure is called by findOrientedBoundary"
     
    24022402  {
    24032403    int m=nrows(M);
    2404    
     2404
    24052405  }
    24062406  else
     
    24602460  {
    24612461    return("");
    2462    
     2462
    24632463  }
    24642464  if (i==1)
     
    25702570        k++;
    25712571      }
    2572       else 
     2572      else
    25732573      {
    25742574        stop=1;
     
    26132613        k++;
    26142614      }
    2615       else 
     2615      else
    26162616      {
    26172617        stop=1;
     
    26622662static proc polygonToCoordinates (list points)
    26632663"USAGE:      polygonToCoordinates(points);   points list
    2664 ASSUME:      points is a list of integer vectors each of size two describing the 
    2665              marked points of a convex lattice polygon like the output of 
     2664ASSUME:      points is a list of integer vectors each of size two describing the
     2665             marked points of a convex lattice polygon like the output of
    26662666             polygonDB
    2667 RETURN:      list, the first entry is a string representing the coordinates 
     2667RETURN:      list, the first entry is a string representing the coordinates
    26682668                   corresponding to the latticpoints seperated by commata
    2669                    the second entry is a list where the ith entry is a string 
    2670                    representing the coordinate of corresponding to the ith 
    2671                    lattice point the third entry is the latex format of the 
     2669                   the second entry is a list where the ith entry is a string
     2670                   representing the coordinate of corresponding to the ith
     2671                   lattice point the third entry is the latex format of the
    26722672                   first entry
    26732673NOTE:        the procedure is called by fan"
  • Singular/LIB/presolve.lib

    r2c3a5d r3360fb  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: presolve.lib,v 1.29 2009-04-06 09:17:01 seelisch Exp $";
     2version="$Id: presolve.lib,v 1.30 2009-04-14 12:00:14 Singular Exp $";
    33category="Symbolic-numerical solving";
    44info="
     
    190190   if ( size(#)!=0 ) {  n=#[1]; }
    191191   ideal maxi,rest = maxideal(1),0;
    192    if ( n < nvars(BAS) ) 
    193    { 
    194       rest = maxi[n+1..nvars(BAS)]; 
     192   if ( n < nvars(BAS) )
     193   {
     194      rest = maxi[n+1..nvars(BAS)];
    195195   }
    196196   attrib(rest,"isSB",1);
     
    200200// which do not contain elements not to be eliminated
    201201
    202    //ideal id = interred(i); 
    203    //## gmg, geŠndert 9/2008: interred sehr lange z.B. bei Leonard1 in normal, 
     202   //ideal id = interred(i);
     203   //## gmg, geŠndert 9/2008: interred sehr lange z.B. bei Leonard1 in normal,
    204204   //daher interred ersetzt durch: std nur auf linearpart angewendet
    205205   //Ordnung muss global sein, sonst egal (da Lin affin linear)
     
    207207//--------------- replace ordering by dp if it is not global -----------------
    208208   if ( ord_test(BAS) <= 0 )
    209    { 
    210       intvec V; 
     209   {
     210      intvec V;
    211211      V[n]=0; V=V+1;                          //weights for dp ordering
    212212      gnirlist[3] = list("dp",V), g32;
     
    215215      ideal i = imap(BAS,i);
    216216   }
    217      
     217
    218218   list  Lin = linearpart(i);
    219219   ideal lin = std(Lin[1]);          //SB of ideal generated by polys of i
     
    231231//------------- check for special case of unit ideal and return ---------------
    232232   int check;
    233    if( lin[1] == 1 ) 
    234    { 
    235      check = 1; 
    236    }
    237    else             
     233   if( lin[1] == 1 )
     234   {
     235     check = 1;
     236   }
     237   else
    238238   {
    239239     for (ii=1; ii<=size(id); ii++ )
    240240     {
    241241       if ( id[ii] == 1 )
    242        { 
     242       {
    243243         check = 1; break;
    244244        }
     
    356356/*
    357357Alte Version mit interred:
    358 // Then go to ring newBAS with ordering c,dp(n) and create a matrix with 
    359 // size(k1) colums and 2 rows, such that if [f1,f2] is a column of M then f1+f2 
    360 // is one of the polys of lin containing a pure degree 1 part and f1 is this 
    361 // part interreduce this matrix (i.e. Gauss elimination on linear part, with 
     358// Then go to ring newBAS with ordering c,dp(n) and create a matrix with
     359// size(k1) colums and 2 rows, such that if [f1,f2] is a column of M then f1+f2
     360// is one of the polys of lin containing a pure degree 1 part and f1 is this
     361// part interreduce this matrix (i.e. Gauss elimination on linear part, with
    362362// rest transformed accordingly).
    363363//Ist jetzt durch direkte Substitution gemacht (schneller!)
     
    365365         //ideal k12 = k1,k2;
    366366         //matrix M = matrix(k12,2,kk);     //degree 1 part is now in row 1
    367          //M = interred(M);             
    368          //### interred zu teuer, muss nicht sein. Wenn interred angewendet 
     367         //M = interred(M);
     368         //### interred zu teuer, muss nicht sein. Wenn interred angewendet
    369369         //werden soll, vorher in Ring mit Ordnung (c,dp) wechseln!
    370370         //Abfrage:  if( ordstr(BAS) != "c,dp("+string(n)+")" )
     
    378378-z ergibt ich auch i[2]-z*i[3] mit option(redThrough)
    379379statt interred kann man hier auch NF(i,i[3])+i[3] verwenden
    380 hier lifert elimpart(i) 2 Substitutionen (x,y) elimpart(interred(i)) 
     380hier lifert elimpart(i) 2 Substitutionen (x,y) elimpart(interred(i))
    381381aber 3 (x,y,z)
    382382Da interred oder NF aber die Laenge der polys vergroessern kann, nicht gemacht
     
    397397   //since lin1 != 0 there are candidates for substituting variables
    398398
    399    lin2 = lin - lin1;      //difference as matrix       
     399   lin2 = lin - lin1;      //difference as matrix
    400400   // rest of lin, part of pure degree 1 substracted from each generator of lin
    401401
     
    410410      }
    411411   }
    412    //Now each !=0 generator of lin2 contains only constant terms or terms of 
     412   //Now each !=0 generator of lin2 contains only constant terms or terms of
    413413   //degree >= 2, hence lin 2 can never be used for further substitutions
    414414   //We have: lin = ideal(matrix(k1)+matrix(k2)), lin2
    415415
    416    ideal kin = matrix(k1)+matrix(k2); 
     416   ideal kin = matrix(k1)+matrix(k2);
    417417   //kin = polys of lin which contained a pure degree 1 part.
    418418   kin = simplify(kin,2);
     
    421421   int count=1;
    422422   while ( count != 0 )
    423    {   
     423   {
    424424         count = 0;
    425425         for ( ii=1; ii<=n; ii++  )    //start direct substitution of var(ii)
     
    432432               {
    433433                  //we look for the shortest candidate to substitute var(ii)
    434                   if ( cand == 0 ) 
    435                   { 
     434                  if ( cand == 0 )
     435                  {
    436436                     cand = kin[kk];  //candidate for substituting var(ii)
    437                   } 
     437                  }
    438438                  else
    439439                  {
    440                      if ( size(kin[kk]) < size(cand) ) 
    441                      { 
    442                         cand = kin[kk]; 
     440                     if ( size(kin[kk]) < size(cand) )
     441                     {
     442                        cand = kin[kk];
    443443                     }
    444444                  }
    445445                }
    446             }                     
     446            }
    447447            if ( cand != 0 )
    448448            {
     
    452452                  neva[ii] = 0;
    453453                  sub = sub+kip;     //poly defining substituion
    454                   //## gmg: geŠndert 08/2008, map durch subst ersetzt 
     454                  //## gmg: geŠndert 08/2008, map durch subst ersetzt
    455455                  //(viel schneller)
    456456                  vip = var(ii) - kip;  //poly to be substituted
     
    465465         }
    466466   }
    467          
     467
    468468   lin = kin+lin;
    469  
     469
    470470   for( ii=1; ii<=size(lin); ii++ )
    471471   {
     
    473473   }
    474474
    475    for( ii=1; ii<=n; ii++ )     
     475   for( ii=1; ii<=n; ii++ )
    476476   {
    477477      for( kk=1; kk<=size(eva); kk++ )
  • Singular/LIB/random.lib

    r2c3a5d r3360fb  
    11//(GMG/BM, last modified 22.06.96)
    22///////////////////////////////////////////////////////////////////////////////
    3 version="$Id: random.lib,v 1.18 2009-03-30 18:36:35 motsak Exp $";
     3version="$Id: random.lib,v 1.19 2009-04-14 12:00:14 Singular Exp $";
    44category="General purpose";
    55info="
     
    154154proc sparseHomogIdeal (int k, int u, list #)
    155155"USAGE:   sparseid(k,u[,o,p,b]);  k,u,o,p,b integers
    156 RETURN:  ideal having k homogeneous generators, each of random degree in the 
    157          interval [u,o], p percent of terms in degree d are 0, the remaining 
    158          have random coefficients in the interval [1,b], (default: o=u, p=75, 
     156RETURN:  ideal having k homogeneous generators, each of random degree in the
     157         interval [u,o], p percent of terms in degree d are 0, the remaining
     158         have random coefficients in the interval [1,b], (default: o=u, p=75,
    159159         b=30000)
    160160EXAMPLE: example sparseid; shows an example
     
    172172   {
    173173       id = maxideal(random(u, o)); // monomial basis of some degree
    174        m = sparsemat(size(id),1,p,b); // random coefficients       
     174       m = sparsemat(size(id),1,p,b); // random coefficients
    175175       i[ii] = (matrix(id)*m)[1,1];
    176176   }
  • Singular/LIB/ratgb.lib

    r2c3a5d r3360fb  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: ratgb.lib,v 1.14 2009-02-21 15:26:42 levandov Exp $";
     2version="$Id: ratgb.lib,v 1.15 2009-04-14 12:00:15 Singular Exp $";
    33category="Noncommutative";
    44info="
     
    174174      va = L3[w][2];
    175175      for(z=1;z<=nvars(save)-is;z++)
    176       { 
    177         vb[z] = va[is+z]; 
     176      {
     177        vb[z] = va[is+z];
    178178      }
    179179      tmp3[1] = "a";
     
    372372  setring A;
    373373  IAppel1;
    374   def F1 = ratstd(IAppel1,2); 
    375   lead(pGBid); 
     374  def F1 = ratstd(IAppel1,2);
     375  lead(pGBid);
    376376  setring F1; rGBid;
    377377}
     
    385385  setring A;
    386386  IAppel2;
    387   def F1 = ratstd(IAppel2,2); 
    388   lead(pGBid); 
     387  def F1 = ratstd(IAppel2,2);
     388  lead(pGBid);
    389389  setring F1; rGBid;
    390390}
     
    398398  setring A;
    399399  IAppel4;
    400   def F1 = ratstd(IAppel4,2); 
    401   lead(pGBid); 
     400  def F1 = ratstd(IAppel4,2);
     401  lead(pGBid);
    402402  setring F1; rGBid;
    403403}
  • Singular/LIB/sing4ti2.lib

    r2c3a5d r3360fb  
    11///////////////////////////////////////////////////////////////////
    2 version="$Id: sing4ti2.lib,v 1.2 2009-04-07 16:18:06 seelisch Exp $";
     2version="$Id: sing4ti2.lib,v 1.3 2009-04-14 12:00:15 Singular Exp $";
    33category="Commutative Algebra";
    44info="
     
    1212@*    the returned result
    1313
    14 REQUIRES: External programs 4ti2, sed and awk to be installed 
     14REQUIRES: External programs 4ti2, sed and awk to be installed
    1515
    1616PROCEDURES:
     
    8888
    8989//----------------------------------------------------------------------
    90 // calling 4ti2 and converting output 
     90// calling 4ti2 and converting output
    9191// Singular's string is too clumsy for this, hence we first prepare
    9292// using standard unix commands
    9393//----------------------------------------------------------------------
    9494   j=system("sh","markov sing4ti2");
    95    j=system("sh","awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.mar | sed s/[\\\ \\\t\\\v\\\f]/,/g | sed s/,+/,/g|sed s/,,/,/g|sed s/,,/,/g > sing4ti2.converted"); 
     95   j=system("sh","awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.mar | sed s/[\\\ \\\t\\\v\\\f]/,/g | sed s/,+/,/g|sed s/,,/,/g|sed s/,,/,/g > sing4ti2.converted");
    9696   if(!defined(keepfiles))
    9797   {
    9898      j=system("sh",("rm -f sing4ti2.mar sing4ti2."+fileending));
    99    } 
     99   }
    100100//----------------------------------------------------------------------
    101101// reading output of 4ti2
     
    115115     {
    116116        if(erglist[2+(i-1)*erglist[2]+j]>=0)
    117         { 
     117        {
    118118//--- positive exponents
    119119           temppol1=temppol1*(var(j)^erglist[2+(i-1)*erglist[2]+j]);
     
    125125        }
    126126     }
    127      toric=toric,temppol1-temppol2; 
     127     toric=toric,temppol1-temppol2;
    128128   }
    129129//--- get rid of leading entry 0;
     
    210210
    211211//----------------------------------------------------------------------
    212 // calling 4ti2 and converting output 
     212// calling 4ti2 and converting output
    213213// Singular's string is too clumsy for this, hence we first prepare
    214214// using standard unix commands
    215215//----------------------------------------------------------------------
    216216   j=system("sh","graver sing4ti2");
    217    j=system("sh","awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.gra | sed s/[\\\ \\\t\\\v\\\f]/,/g | sed s/,+/,/g |sed s/,,/,/g|sed s/,,/,/g > sing4ti2.converted"); 
     217   j=system("sh","awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.gra | sed s/[\\\ \\\t\\\v\\\f]/,/g | sed s/,+/,/g |sed s/,,/,/g|sed s/,,/,/g > sing4ti2.converted");
    218218   if(!defined(keepfiles))
    219219   {
    220220      j=system("sh",("rm -f sing4ti2.gra sing4ti2."+fileending));
    221    } 
     221   }
    222222//----------------------------------------------------------------------
    223223// reading output of 4ti2
     
    237237     {
    238238        if(erglist[2+(i-1)*erglist[2]+j]>=0)
    239         { 
     239        {
    240240//--- positive exponents
    241241           temppol1=temppol1*(var(j)^erglist[2+(i-1)*erglist[2]+j]);
     
    247247        }
    248248     }
    249      toric=toric,temppol1-temppol2; 
     249     toric=toric,temppol1-temppol2;
    250250   }
    251251//--- get rid of leading entry 0;
     
    272272@*       - number of variables of basering equals number of columns of A
    273273@*         (for ker(A)) resp. of rows of A (for Im(A))
    274 CREATE:  temporary files sing4ti2.mat, sing4ti2.lat, sing4ti2.mar 
     274CREATE:  temporary files sing4ti2.mat, sing4ti2.lat, sing4ti2.mar
    275275@*       in the current directory (I/O files for communication with 4ti2)
    276276NOTE:    input rules for 4ti2 also apply to input to this procedure
     
    330330
    331331//----------------------------------------------------------------------
    332 // calling 4ti2 and converting output 
     332// calling 4ti2 and converting output
    333333// Singular's string is too clumsy for this, hence we first prepare
    334334// using standard unix commands
    335335//----------------------------------------------------------------------
    336336   j=system("sh","hilbert sing4ti2");
    337    j=system("sh","awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.hil | sed s/[\\\ \\\t\\\v\\\f]/,/g | sed s/,+/,/g |sed s/,,/,/g|sed s/,,/,/g > sing4ti2.converted"); 
     337   j=system("sh","awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.hil | sed s/[\\\ \\\t\\\v\\\f]/,/g | sed s/,+/,/g |sed s/,,/,/g|sed s/,,/,/g > sing4ti2.converted");
    338338   if(!defined(keepfiles))
    339339   {
    340340      j=system("sh",("rm -f sing4ti2.hil sing4ti2."+fileending));
    341    } 
     341   }
    342342//----------------------------------------------------------------------
    343343// reading output of 4ti2
     
    357357     {
    358358        if(erglist[2+(i-1)*erglist[2]+j]>=0)
    359         { 
     359        {
    360360//--- positive exponents
    361361           temppol1=temppol1*(var(j)^erglist[2+(i-1)*erglist[2]+j]);
     
    367367        }
    368368     }
    369      toric=toric,temppol1-temppol2; 
     369     toric=toric,temppol1-temppol2;
    370370   }
    371371//--- get rid of leading entry 0;
  • Singular/LIB/teachstd.lib

    r2c3a5d r3360fb  
    22//GMG, last modified 28.9.01
    33///////////////////////////////////////////////////////////////////////////////
    4 version="$Id: teachstd.lib,v 1.11 2009-04-06 12:39:02 seelisch Exp $";
     4version="$Id: teachstd.lib,v 1.12 2009-04-14 12:00:15 Singular Exp $";
    55category="Teaching";
    66info="
     
    422422  if( size(#) > 0 )
    423423  {// "size(#): ", size(#);   "typeof(#[1]): ", typeof(#[1]);
    424    
     424
    425425    if( typeof(#[1]) == "int" )
    426426    {// "#[1] = int ", #[1];
    427427      if( #[1] > 0 )
    428       {       
     428      {
    429429        return(0);
    430430      }
  • Singular/LIB/triang.lib

    r2c3a5d r3360fb  
    11//last change: 13.02.2001 (Eric Westenberger)
    22//////////////////////////////////////////////////////////////////////////////
    3 version="$Id: triang.lib,v 1.13 2009-04-06 09:17:01 seelisch Exp $";
     3version="$Id: triang.lib,v 1.14 2009-04-14 12:00:15 Singular Exp $";
    44category="Symbolic-numerical solving";
    55info="
     
    629629         If i = 2, then each polynomial of the triangular systems
    630630         is factorized.
    631 NOTE:    Algorithm of Moeller (see: Moeller, H.M.: On decomposing systems of 
    632          polynomial equations with finitely many solutions, Appl. Algebra Eng. 
     631NOTE:    Algorithm of Moeller (see: Moeller, H.M.: On decomposing systems of
     632         polynomial equations with finitely many solutions, Appl. Algebra Eng.
    633633         Commun. Comput. 4, 217 - 230, 1993).
    634634EXAMPLE: example triangM; shows an example
  • Singular/LIB/tropical.lib

    r2c3a5d r3360fb  
    1 version="$Id: tropical.lib,v 1.14 2009-04-08 12:42:19 seelisch Exp $";
     1version="$Id: tropical.lib,v 1.15 2009-04-14 12:00:15 Singular Exp $";
    22category="Tropical Geometry";
    33info="
     
    88@*               Thomas Markwig,  email: keilen@mathematik.uni-kl.de
    99
    10 WARNING: 
     10WARNING:
    1111- tropicalLifting will only work with LINUX and if in addition gfan is installed.
    12 @*- drawTropicalCurve and drawTropicalNewtonSubdivision will only display the 
    13 @*  tropical curve with LINUX and if in addition latex and kghostview 
     12@*- drawTropicalCurve and drawTropicalNewtonSubdivision will only display the
     13@*  tropical curve with LINUX and if in addition latex and kghostview
    1414@*  are installed.
    15 @*- For tropicalLifting in the definition of the basering the parameter t 
     15@*- For tropicalLifting in the definition of the basering the parameter t
    1616@*  from the Puiseux series field C{{t}} must be defined as a variable,
    1717@*  while for all other procedures it must be defined as a parameter.
    1818
    1919THEORY:
    20   Fix some base field K and a bunch of lattice points v0,...,vm in the integer 
    21   lattice Z^n, then this defines a toric variety as the closure of (K*)^n in 
    22   the projective space P^m, where the torus is embedded via the map sending a 
     20  Fix some base field K and a bunch of lattice points v0,...,vm in the integer
     21  lattice Z^n, then this defines a toric variety as the closure of (K*)^n in
     22  the projective space P^m, where the torus is embedded via the map sending a
    2323  point x in (K*)^n to the point (x^v0,...,x^vm).
    24   The generic hyperplane sections are just the images of the hypersurfaces 
     24  The generic hyperplane sections are just the images of the hypersurfaces
    2525  in (K*)^n defined by the polynomials f=a0*x^v0+...+am*x^vm=0. Some properties
    26   of these hypersurfaces can be studied via tropicalisation. 
    27 
    28   For this we suppose that K=C{{t}} is the field of Puiseux series over the 
     26  of these hypersurfaces can be studied via tropicalisation.
     27
     28  For this we suppose that K=C{{t}} is the field of Puiseux series over the
    2929  field of complex numbers (or any other field with a valuation into the real
    30   numbers). One associates to the hypersurface given by f=a0*x^v0+...+am*x^vm 
     30  numbers). One associates to the hypersurface given by f=a0*x^v0+...+am*x^vm
    3131  the tropical hypersurface defined by the tropicalisation
    32   trop(f)=min{val(a0)+<v0,x>,...,val(am)+<vm,x>}. 
     32  trop(f)=min{val(a0)+<v0,x>,...,val(am)+<vm,x>}.
    3333  Here, <v,x> denotes the standard scalar product of the integer vector v in Z^n
    3434  with the vector x=(x1,...,xn) of variables, so that trop(f) is a piecewise
    35   linear function on R^n. The corner locus of this function (i.e. the points 
    36   at which the minimum is attained a least twice) is the tropical hypersurface 
    37   defined by trop(f). 
    38   The theorem of Newton-Kapranov states that this tropical hypersurface is 
    39   the same as if one computes pointwise the valuation of the hypersurface 
    40   given by f. The analogue holds true if one replaces one equation f by an 
    41   ideal I. A constructive proof of the theorem is given by an adapted 
    42   version of the Newton-Puiseux algorithm. The hard part is to find a point 
    43   in the variety over C{{t}} which corresponds to a given point in the 
     35  linear function on R^n. The corner locus of this function (i.e. the points
     36  at which the minimum is attained a least twice) is the tropical hypersurface
     37  defined by trop(f).
     38  The theorem of Newton-Kapranov states that this tropical hypersurface is
     39  the same as if one computes pointwise the valuation of the hypersurface
     40  given by f. The analogue holds true if one replaces one equation f by an
     41  ideal I. A constructive proof of the theorem is given by an adapted
     42  version of the Newton-Puiseux algorithm. The hard part is to find a point
     43  in the variety over C{{t}} which corresponds to a given point in the
    4444  tropical variety.
    4545
    46   It is the purpose of this library to provide basic means to deal with 
    47   tropical varieties. Of course we cannot represent the field of Puiseux 
    48   series over C in its full strength, however, in order to compute interesting 
    49   examples it will be sufficient to replace the complex numbers C by the 
    50   rational numbers Q and to replace Puiseux series in t by rational functions 
    51   in t, i.e. we replace C{{t}} by Q(t), or sometimes even by Q[t]. 
     46  It is the purpose of this library to provide basic means to deal with
     47  tropical varieties. Of course we cannot represent the field of Puiseux
     48  series over C in its full strength, however, in order to compute interesting
     49  examples it will be sufficient to replace the complex numbers C by the
     50  rational numbers Q and to replace Puiseux series in t by rational functions
     51  in t, i.e. we replace C{{t}} by Q(t), or sometimes even by Q[t].
    5252  Note, that this in particular forbids rational exponents for the t's.
    5353
    54   Moreover, in Singular no negative exponents of monomials are allowed, so 
    55   that the integer vectors vi will have to have non-negative entries. 
    56   Shifting all exponents by a fixed integer vector does not change the 
    57   tropicalisation nor does it change the toric variety. Thus this does not 
     54  Moreover, in Singular no negative exponents of monomials are allowed, so
     55  that the integer vectors vi will have to have non-negative entries.
     56  Shifting all exponents by a fixed integer vector does not change the
     57  tropicalisation nor does it change the toric variety. Thus this does not
    5858  cause any restriction.
    59   If, however, for some reason you prefer to work with general vi, then you 
    60   have to pass right away to the tropicalisation of the equations, whereever 
     59  If, however, for some reason you prefer to work with general vi, then you
     60  have to pass right away to the tropicalisation of the equations, whereever
    6161  this is allowed -- these are linear polynomials where the constant coefficient
    62   corresponds to the valuation of the original coefficient and where 
    63   the non-constant coefficient correspond to the exponents of the monomials, 
    64   thus they may be rational numbers respectively negative numbers: 
     62  corresponds to the valuation of the original coefficient and where
     63  the non-constant coefficient correspond to the exponents of the monomials,
     64  thus they may be rational numbers respectively negative numbers:
    6565  e.g. if f=t^{1/2}*x^{-2}*y^3+2t*x*y+4  then  trop(f)=min{1/2-2x+3y,1+x+y,0}.
    6666
    6767  The main tools provided in this library are as follows:
    68 @*  - tropicalLifting    implements the constructive proof of the Theorem of 
    69                          Newton-Kapranov and constructs a point in the variety 
    70                          over C{{t}} corresponding to a given point in the 
    71                          corresponding tropical variety associated to an 
    72                          ideal I; the generators of I have to be in the 
    73                          polynomial ring Q[t,x1,...,xn] considered as a 
    74                          subring of C{{t}}[x1,...,xn]; a solution will be 
    75                          constructed up to given order; note that several 
     68@*  - tropicalLifting    implements the constructive proof of the Theorem of
     69                         Newton-Kapranov and constructs a point in the variety
     70                         over C{{t}} corresponding to a given point in the
     71                         corresponding tropical variety associated to an
     72                         ideal I; the generators of I have to be in the
     73                         polynomial ring Q[t,x1,...,xn] considered as a
     74                         subring of C{{t}}[x1,...,xn]; a solution will be
     75                         constructed up to given order; note that several
    7676                         field extensions of Q might be necessary throughout
    7777                         the intermediate computations; the procedures use
    7878                         the external program gfan
    79 @*  - drawTropicalCurve  visualises a tropical plane curve either given by a 
    80                          polynomial in Q(t)[x,y] or by a list of linear 
    81                          polynomials of the form ax+by+c with a,b in Z and c 
     79@*  - drawTropicalCurve  visualises a tropical plane curve either given by a
     80                         polynomial in Q(t)[x,y] or by a list of linear
     81                         polynomials of the form ax+by+c with a,b in Z and c
    8282                         in Q; latex must be installed on your computer
    83 @*  - tropicalJInvariant computes the tropical j-invaiant of a tropical 
     83@*  - tropicalJInvariant computes the tropical j-invaiant of a tropical
    8484                         elliptic curve
    8585@*  - jInvariant         computes the j-invariant of an elliptic curve
    86 @*  - weierstrassForm     computes the Weierstrass form of an elliptic curve 
     86@*  - weierstrassForm     computes the Weierstrass form of an elliptic curve
    8787
    8888PROCEDURES FOR TROPICAL LIFTING:
    89   tropicalLifting          computes a point in the tropical variety 
     89  tropicalLifting          computes a point in the tropical variety
    9090  displayTropicalLifting   displays the output of tropicalLifting
    9191
     
    104104  tropicalise        computes the tropicalisation of a polynomial
    105105  tropicaliseSet     computes the tropicalisation several polynomials
    106   tInitialForm       computes the tInitial form of a poly in Q[t,x_1,...,x_n] 
     106  tInitialForm       computes the tInitial form of a poly in Q[t,x_1,...,x_n]
    107107  tInitialIdeal      computes the tInitial ideal of an ideal in Q[t,x_1,...,x_n]
    108   initialForm        computes the initial form of poly in Q[x_1,...,x_n] 
    109   initialIdeal       computes the initial ideal of an ideal in Q[x_1,...,x_n] 
     108  initialForm        computes the initial form of poly in Q[x_1,...,x_n]
     109  initialIdeal       computes the initial ideal of an ideal in Q[x_1,...,x_n]
    110110
    111111PROCEDURES FOR LATEX CONVERSION:
    112112  texNumber          outputs the texcommand for the leading coefficient of poly
    113   texPolynomial      outputs the texcommand for the polynomial poly 
     113  texPolynomial      outputs the texcommand for the polynomial poly
    114114  texMatrix          outputs the texcommand for the matrix
    115115  texDrawBasic       embeds output of texDrawTropical in a texdraw environment
    116116  texDrawTropical    computes the texdraw commands for a tropical curve
    117   texDrawNewtonSubdivision   computes texdraw commands for a Newton subdivision 
     117  texDrawNewtonSubdivision   computes texdraw commands for a Newton subdivision
    118118  texDrawTriangulation       computes texdraw commands for a triangulation
    119119
     
    121121  radicalMemberShip     checks radical membership
    122122  tInitialFormPar       computes the t-initial form of poly in Q(t)[x_1,...,x_n]
    123   tInitialFormParMax    same as tInitialFormPar, but uses maximum 
     123  tInitialFormParMax    same as tInitialFormPar, but uses maximum
    124124  solveTInitialFormPar  displays approximated solution of a 0-dim ideal
    125125  detropicalise         computes the detropicalisation of a linear form
    126   dualConic             computes the dual of an affine plane conic 
     126  dualConic             computes the dual of an affine plane conic
    127127  parameterSubstitute   substitutes in the poly the parameter t by t^N
    128128  tropicalSubst         makes certain substitutions in a tropical polynomial
     
    155155/// - eliminatecomponents
    156156/// - findzerosAndBasictransform
    157 /// - ordermaximalideals 
     157/// - ordermaximalideals
    158158/// - verticesTropicalCurve
    159159/// - bunchOfLines
     
    204204
    205205///////////////////////////////////////////////////////////////////////////////
    206 /// Procedures concerned with tropical parametrisation 
     206/// Procedures concerned with tropical parametrisation
    207207///////////////////////////////////////////////////////////////////////////////
    208208
    209209proc tropicalLifting (ideal i,intvec w,int ordnung,list #)
    210210"USAGE:  tropicalLifting(i,w,ord[,opt]); i ideal, w intvec, ord int, opt string
    211 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n], w=(w_0,w_1,...,w_n) 
    212            and (w_1/w_0,...,w_n/w_0) is in the tropical variety of i, 
    213            and ord is the order up to which a point in V(i) over Q{{t}} 
    214            lying over (w_1/w_0,...,w_n/w_0) shall be computed; 
     211ASSUME:  - i is an ideal in Q[t,x_1,...,x_n], w=(w_0,w_1,...,w_n)
     212           and (w_1/w_0,...,w_n/w_0) is in the tropical variety of i,
     213           and ord is the order up to which a point in V(i) over Q{{t}}
     214           lying over (w_1/w_0,...,w_n/w_0) shall be computed;
    215215           w_0 may NOT be ZERO
    216 @*       - the basering should not have any parameters on its own 
    217            and it should have a global monomial ordering, 
     216@*       - the basering should not have any parameters on its own
     217           and it should have a global monomial ordering,
    218218           e.g. ring r=0,(t,x(1..n)),dp;
    219 @*       - the first variable of the basering will be treated as the 
     219@*       - the first variable of the basering will be treated as the
    220220           parameter t in the Puiseux series field
    221 @*       - the optional parameter opt should be one or more strings among 
     221@*       - the optional parameter opt should be one or more strings among
    222222           the following:
    223223@*         'isZeroDimensional'  : the dimension i is zero (not to be checked);
    224 @*         'isPrime'            : the ideal is prime over Q(t)[x_1,...,x_n] 
     224@*         'isPrime'            : the ideal is prime over Q(t)[x_1,...,x_n]
    225225                                  (not to be checked);
    226 @*         'isInTrop'           : (w_1/w_0,...,w_n/w_0) is in the tropical 
     226@*         'isInTrop'           : (w_1/w_0,...,w_n/w_0) is in the tropical
    227227                                  variety (not to be checked);
    228 @*         'oldGfan'            : uses gfan version 0.2.1 or less 
    229 @*         'findAll'            : find all solutions of a zero-dimensional 
     228@*         'oldGfan'            : uses gfan version 0.2.1 or less
     229@*         'findAll'            : find all solutions of a zero-dimensional
    230230                                  ideal over (w_1/w_0,...,w_n/w_0)
    231231@*         'noAbs'              : do NOT use absolute primary decomposition
     
    233233RETURN:  IF THE OPTION 'findAll' WAS NOT SET THEN:
    234234@*       list, containing one lifting of the given point (w_1/w_0,...,w_n/w_0)
    235                in the tropical variety of i to a point in V(i) over Puiseux 
     235               in the tropical variety of i to a point in V(i) over Puiseux
    236236               series field up to the first ord terms; more precisely:
    237237@*             IF THE OPTION 'noAbs' WAS NOT SET, THEN:
     
    248248@*       IF THE OPITON 'findAll' WAS SET, THEN:
    249249@*       list, containing ALL liftings of the given point ((w_1/w_0,...,w_n/w_0)
    250                in the tropical variety of i to a point in V(i) over Puiseux 
    251                series field up to the first ord terms, if the ideal is 
     250               in the tropical variety of i to a point in V(i) over Puiseux
     251               series field up to the first ord terms, if the ideal is
    252252               zero-dimensional over Q{{t}};
    253                more precisely, each entry of the list is a list l as computed 
     253               more precisely, each entry of the list is a list l as computed
    254254               if  'findAll' was NOT set
    255255@*       WE NOW DESCRIBE THE LIST ENTRIES IF 'findAll' WAS NOT SET:
    256 @*       - the ring l[1] contains an ideal LIFT, which contains 
     256@*       - the ring l[1] contains an ideal LIFT, which contains
    257257           a point in V(i) lying over w up to the first ord terms;
    258 @*       - and if the integer l[2] is N then t has to be replaced by t^1/N 
     258@*       - and if the integer l[2] is N then t has to be replaced by t^1/N
    259259           in the lift, or alternatively replace t by t^N in the defining ideal
    260 @*       - if the k+1st entry of l[3] is  non-zero, then the kth component of 
    261            LIFT has to be multiplied t^(-l[3][k]/l[3][1]) AFTER substituting t 
     260@*       - if the k+1st entry of l[3] is  non-zero, then the kth component of
     261           LIFT has to be multiplied t^(-l[3][k]/l[3][1]) AFTER substituting t
    262262           by t^1/N
    263 @*       - unless the option 'noResubst' was set, the kth entry of list l[4] 
     263@*       - unless the option 'noResubst' was set, the kth entry of list l[4]
    264264           is a string which represents the kth generator of
    265            the ideal i where the coordinates have been replaced by the result 
     265           the ideal i where the coordinates have been replaced by the result
    266266           of the lift;
    267            the t-order of the kth entry should in principle be larger than the 
     267           the t-order of the kth entry should in principle be larger than the
    268268           t-degree of LIFT
    269 @*       - if the option 'noAbs' was set, then the string in l[5] defines 
    270            a maximal ideal in the field Q[X(1),...,X(k)], where X(1),...,X(k) 
     269@*       - if the option 'noAbs' was set, then the string in l[5] defines
     270           a maximal ideal in the field Q[X(1),...,X(k)], where X(1),...,X(k)
    271271           are the parameters of the ring in l[1];
    272            the basefield of the ring in l[1] should be considered modulo this 
     272           the basefield of the ring in l[1] should be considered modulo this
    273273           ideal
    274 REMARK:  - it is best to use the procedure displayTropicalLifting to 
     274REMARK:  - it is best to use the procedure displayTropicalLifting to
    275275           display the result
    276276@*       - the option 'findAll' cannot be used if 'noAbs' is set
    277277@*       - if the parameter 'findAll' is set AND the ideal i is zero-dimensional
    278            in Q{{t}}[x_1,...,x_n] then ALL points in V(i) lying over w are 
     278           in Q{{t}}[x_1,...,x_n] then ALL points in V(i) lying over w are
    279279           computed up to order ord; if the ideal is not-zero dimenisonal, then
    280280           only the points in the ideal after cutting down to dimension zero
    281281           will be computed
    282282@*       - the procedure requires that the program GFAN is installed on your
    283            computer; if you have GFAN version less than 0.3.0 then you must 
     283           computer; if you have GFAN version less than 0.3.0 then you must
    284284           use the optional parameter 'oldGfan'
    285 @*       - the procedure requires the Singular procedure absPrimdecGTZ to be 
     285@*       - the procedure requires the Singular procedure absPrimdecGTZ to be
    286286           present in the package primdec.lib, unless the option 'noAbs' is set;
    287            but even if absPrimdecGTZ is present it might be necessary to set 
    288            the option 'noAbs' in order to avoid the costly absolute primary 
    289            decomposition; the side effect is that the field extension which is 
     287           but even if absPrimdecGTZ is present it might be necessary to set
     288           the option 'noAbs' in order to avoid the costly absolute primary
     289           decomposition; the side effect is that the field extension which is
    290290           computed throughout the recursion might need more than one
    291291           parameter to be described
    292292@*       - since Q is infinite, the procedure finishes with probability one
    293 @*       - you can call the procedure with Z/pZ as base field instead of Q, 
     293@*       - you can call the procedure with Z/pZ as base field instead of Q,
    294294           but there are some problems you should be aware of:
    295 @*         + the Puiseux series field over the algebraic closure of Z/pZ is 
    296              NOT algebraicall closed, and thus there may not exist a point in 
    297              V(i) over the Puiseux series field with the desired valuation; 
     295@*         + the Puiseux series field over the algebraic closure of Z/pZ is
     296             NOT algebraicall closed, and thus there may not exist a point in
     297             V(i) over the Puiseux series field with the desired valuation;
    298298             so there is no chance that the procedure produced a sensible output
    299              - e.g. if i=tx^p-tx-1 
    300 @*         + if the dimension of i over Z/pZ(t) is not zero the process of 
    301              reduction to zero might not work if the characteristic is small 
     299             - e.g. if i=tx^p-tx-1
     300@*         + if the dimension of i over Z/pZ(t) is not zero the process of
     301             reduction to zero might not work if the characteristic is small
    302302             and you are unlucky
    303 @*         + the option 'noAbs' has to be used since absolute primary 
     303@*         + the option 'noAbs' has to be used since absolute primary
    304304             decomposition in Singular only works in characteristic zero
    305 @*       - the basefield should either be Q or Z/pZ for some prime p; 
    306            field extensions will be computed if necessary; if you need 
    307            parameters or field extensions from the beginning they should 
    308            rather be simulated as variables possibly adding their relations to 
     305@*       - the basefield should either be Q or Z/pZ for some prime p;
     306           field extensions will be computed if necessary; if you need
     307           parameters or field extensions from the beginning they should
     308           rather be simulated as variables possibly adding their relations to
    309309           the ideal; the weights for the additional variables should be zero
    310310EXAMPLE: example tropicalLifting;   shows an example"
     
    357357      noabs=1;
    358358    }
    359     // this option is not documented -- it prevents the execution of gfan and 
    360     // just asks for wneu to be inserted -- it can be used to check problems 
    361     // with the precedure without calling gfan, if wneu is know from previous 
     359    // this option is not documented -- it prevents the execution of gfan and
     360    // just asks for wneu to be inserted -- it can be used to check problems
     361    // with the precedure without calling gfan, if wneu is know from previous
    362362    // computations
    363363    if (#[j]=="noGfan")
     
    370370    }
    371371  }
    372   // if the basering has characteristic not equal to zero, 
     372  // if the basering has characteristic not equal to zero,
    373373  // then absolute factorisation
    374374  // is not available, and thus we need the option noAbs
     
    384384  {
    385385    Error("The first coordinate of your input w must be NON-ZERO, since it is a DENOMINATOR!");
    386   } 
     386  }
    387387  // if w_0<0, then replace w by -w, so that the "denominator" w_0 is positive
    388388  if (w[1]<0)
     
    391391  }
    392392  intvec prew=w; // stores w for later reference
    393   // for our computations, w[1] represents the weight of t and this 
     393  // for our computations, w[1] represents the weight of t and this
    394394  // should be -w_0 !!!
    395395  w[1]=-w[1];
     
    401401    w[1]=-1;
    402402  }
    403   // if some entry of w is positive, we have to make a transformation, 
     403  // if some entry of w is positive, we have to make a transformation,
    404404  // which moves it to something non-positive
    405405  for (j=2;j<=nvars(basering);j++)
     
    427427  {
    428428    variablen=variablen+var(j);
    429   }   
     429  }
    430430  map GRUNDPHI=BASERING,t,variablen;
    431431  ideal i=GRUNDPHI(i);
    432   // compute the initial ideal of i and test if w is in the tropical 
    433   // variety of i 
     432  // compute the initial ideal of i and test if w is in the tropical
     433  // variety of i
    434434  // - the last entry 1 only means that t is the last variable in the ring
    435435  ideal ini=tInitialIdeal(i,w,1);
    436436  if (isintrop==0) // test if w is in trop(i) only if isInTrop has not been set
    437   {   
     437  {
    438438    poly product=1;
    439439    for (j=1;j<=nvars(basering)-1;j++)
     
    453453    int dd=dim(i);
    454454    setring GRUNDRING;
    455     // if the dimension is not zero, we cut the ideal down to dimension zero 
     455    // if the dimension is not zero, we cut the ideal down to dimension zero
    456456    // and compute the
    457457    // t-initial ideal of the new ideal at the same time
    458458    if(dd!=0)
    459459    {
    460       // the procedurce cutdown computes a new ring, in which there lives a 
     460      // the procedurce cutdown computes a new ring, in which there lives a
    461461      // zero-dimensional
    462       // ideal which has been computed by cutting down the input with 
     462      // ideal which has been computed by cutting down the input with
    463463      // generic linear forms
    464       // of the type x_i1-p_1,...,x_id-p_d for some polynomials 
    465       // p_1,...,p_d not depending 
    466       // on the variables x_i1,...,x_id; that way we have reduced 
     464      // of the type x_i1-p_1,...,x_id-p_d for some polynomials
     465      // p_1,...,p_d not depending
     466      // on the variables x_i1,...,x_id; that way we have reduced
    467467      // the number of variables by dd !!!
    468       // the new zero-dimensional ideal is called i, its t-initial 
     468      // the new zero-dimensional ideal is called i, its t-initial
    469469      // ideal (with respect to
    470       // the new w=CUTDOWN[2]) is ini, and finally there is a list 
    471       // repl in the ring 
     470      // the new w=CUTDOWN[2]) is ini, and finally there is a list
     471      // repl in the ring
    472472      // which contains at the polynomial p_j at position i_j and
    473473      //a zero otherwise;
     
    492492  list liftrings; // will contain the final result
    493493  // if the procedure is called without 'findAll' then it may happen, that no
    494   // proper solution is found when dd>0; in that case we have 
     494  // proper solution is found when dd>0; in that case we have
    495495  // to start all over again;
    496496  // this is controlled by the while-loop
     
    508508    // compute the liftrings by resubstitution
    509509    kk=1;  // counts the liftrings
    510     int isgood;  // test in the non-zerodimensional case 
     510    int isgood;  // test in the non-zerodimensional case
    511511                 // if the result has the correct valuation
    512512    for (jj=1;jj<=size(TP);jj++)
    513513    {
    514       // the list TP contains as a first entry the ring over which the 
    515       // tropical parametrisation 
     514      // the list TP contains as a first entry the ring over which the
     515      // tropical parametrisation
    516516      // of the (possibly cutdown ideal) i lives
    517517      def LIFTRING=TP[jj][1];
    518       // if the dimension of i originally was not zero, 
     518      // if the dimension of i originally was not zero,
    519519      // then we have to fill in the missing
    520520      // parts of the parametrisation
    521521      if (dd!=0)
    522522      {
    523         // we need a ring where the parameters X_1,...,X_k 
     523        // we need a ring where the parameters X_1,...,X_k
    524524        // from LIFTRING are present,
    525525        // and where also the variables of CUTDOWNRING live
    526526        execute("ring REPLACEMENTRING=("+charstr(LIFTRING)+"),("+varstr(CUTDOWNRING)+"),dp;");
    527         list repl=imap(CUTDOWNRING,repl); // get the replacement rules 
     527        list repl=imap(CUTDOWNRING,repl); // get the replacement rules
    528528                                          // from CUTDOWNRING
    529         ideal PARA=imap(LIFTRING,PARA);   // get the zero-dim. parametrisatio 
     529        ideal PARA=imap(LIFTRING,PARA);   // get the zero-dim. parametrisatio
    530530                                          // from LIFTRING
    531531        // compute the lift of the solution of the original ideal i
     
    533533        k=1;
    534534        // the lift has as many components as GRUNDRING has variables!=t
    535         for (j=1;j<=nvars(GRUNDRING)-1;j++) 
     535        for (j=1;j<=nvars(GRUNDRING)-1;j++)
    536536        {
    537537          // if repl[j]=0, then the corresponding variable was not eliminated
    538           if (repl[j]==0) 
     538          if (repl[j]==0)
    539539          {
    540             LIFT[j]=PARA[k]; // thus the lift has been 
     540            LIFT[j]=PARA[k]; // thus the lift has been
    541541                             // computed by tropicalparametrise
    542542            k++; // k checks how many entries of PARA have already been used
     
    544544          else  // if repl[j]!=0, repl[j] contains replacement rule for the lift
    545545          {
    546             LIFT[j]=repl[j]; // we still have to replace the vars 
     546            LIFT[j]=repl[j]; // we still have to replace the vars
    547547                             // in repl[j] by the corresp. entries of PARA
    548548            // replace all variables!=t (from CUTDOWNRING)
    549             for (l=1;l<=nvars(CUTDOWNRING)-1;l++) 
     549            for (l=1;l<=nvars(CUTDOWNRING)-1;l++)
    550550            {
    551551              // substitute the kth variable by PARA[k]
    552               LIFT[j]=subst(LIFT[j],var(l),PARA[l]); 
     552              LIFT[j]=subst(LIFT[j],var(l),PARA[l]);
    553553            }
    554554          }
    555555        }
    556556        setring LIFTRING;
    557         ideal LIFT=imap(REPLACEMENTRING,LIFT);   
    558         // test now if the LIFT has the correct valuation !!!     
    559         // note: it may happen, that when resubstituting PARA into 
     557        ideal LIFT=imap(REPLACEMENTRING,LIFT);
     558        // test now if the LIFT has the correct valuation !!!
     559        // note: it may happen, that when resubstituting PARA into
    560560        //       the replacement rules
    561         //       there occured some unexpected cancellation; 
     561        //       there occured some unexpected cancellation;
    562562        //       we only know that for SOME
    563         //       solution of the zero-dimensional reduction NO 
    564         //       canellation will occur, 
    565         //       but for others this may very well happen; 
     563        //       solution of the zero-dimensional reduction NO
     564        //       canellation will occur,
     565        //       but for others this may very well happen;
    566566        //       this in particular means that
    567         //       we possibly MUST compute all zero-dimensional 
     567        //       we possibly MUST compute all zero-dimensional
    568568        //       solutions when cutting down!
    569569        intvec testw=precutdownw[1];
     
    589589      kill PARA;
    590590      // only if LIFT has the right valuation we have to do something
    591       if (isgood==1) 
    592       {
    593         // it remains to reverse the original substitutions, 
     591      if (isgood==1)
     592      {
     593        // it remains to reverse the original substitutions,
    594594        // where appropriate !!!
    595         // if some entry of the original w was positive, 
     595        // if some entry of the original w was positive,
    596596        // we replace the corresponding
    597597        // variable x_i by t^-w[i]*x_i, so we must now replace
     
    610610        */
    611611        // if LIFTRING contains a parameter @a, change it to a
    612         if ((noabs==0) and (defined(@a)==-1)) 
     612        if ((noabs==0) and (defined(@a)==-1))
    613613        {
    614           // pass first to a ring where a and @a 
     614          // pass first to a ring where a and @a
    615615          // are variables in order to use maps
    616616          poly mp=minpoly;
     
    621621          // replace @a by a in minpoly and in LIFT
    622622          map phi=INTERRING,t,a,a;
    623           mp=phi(mp);     
     623          mp=phi(mp);
    624624          LIFT=phi(LIFT);
    625625          // pass now to a ring whithout @a and with a as parameter
     
    628628          ideal LIFT=imap(INTERRING,LIFT);
    629629          kill INTERRING;
    630         }   
     630        }
    631631        // then export LIFT
    632         export(LIFT); 
     632        export(LIFT);
    633633        // test the  result by resubstitution
    634         setring GRUNDRING; 
     634        setring GRUNDRING;
    635635        list resubst;
    636636        if (noresubst==0)
     
    641641          }
    642642          else
    643           {     
     643          {
    644644            resubst=tropicalliftingresubstitute(substitute(i,t,t^(TP[jj][2])),list(LIFTRING),N*TP[jj][2]);
    645645          }
    646646        }
    647647        setring BASERING;
    648         // Finally, if t has been replaced by t^N, then we have to change the 
     648        // Finally, if t has been replaced by t^N, then we have to change the
    649649        // third entry of TP by multiplying by N.
    650650        if (noabs==1)
     
    662662      kill LIFTRING;
    663663    }
    664     // if dd!=0 and the procedure was called without the 
     664    // if dd!=0 and the procedure was called without the
    665665    // option findAll, then it might very well
    666     // be the case that no solution is found, since 
     666    // be the case that no solution is found, since
    667667    // only one solution for the zero-dimensional
    668     // reduction was computed and this one might have 
     668    // reduction was computed and this one might have
    669669    // had cancellations when resubstituting;
    670670    // if so we have to restart the process with the option findAll
     
    674674      "The procedure will be restarted with the option 'findAll'.";
    675675      "Go on by hitting RETURN!";
    676       findall=1;   
     676      findall=1;
    677677      noabs=0;
    678678      setring CUTDOWNRING;
     
    680680      "i";i;
    681681      "ini";tInitialIdeal(i,w,1);
    682      
     682
    683683/*
    684684      setring GRUNDRING;
     
    698698    }
    699699  }
    700   // if internally the option findall was set, then return 
     700  // if internally the option findall was set, then return
    701701  // only the first solution
    702702  if (defined(hadproblems)!=0)
     
    707707  if (voice+printlevel>=2)
    708708  {
    709      
     709
    710710      "The procedure has created a list of lists. The jth entry of this list
    711711contains a ring, an integer and an intvec.
    712712In this ring lives an ideal representing the wanted lifting,
    713713if the integer is N then in the parametrisation t has to be replaced by t^1/N,
    714 and if the ith component of the intvec is w[i] then the ith component in LIFT 
     714and if the ith component of the intvec is w[i] then the ith component in LIFT
    715715should be multiplied by t^-w[i]/N in order to get the parametrisation.
    716    
     716
    717717Suppose your list has the name L, then you can access the 1st ring via:
    718718";
    719719    if (findall==1)
    720720    {
    721       "def LIFTRing=L[1][1]; setring LIFTRing; LIFT; 
     721      "def LIFTRing=L[1][1]; setring LIFTRing; LIFT;
    722722";
    723723    }
    724724    else
    725725    {
    726       "def LIFTRing=L[1]; setring LIFTRing; LIFT; 
     726      "def LIFTRing=L[1]; setring LIFTRing; LIFT;
    727727";
    728     } 
     728    }
    729729  }
    730730  if (findall==1) // if all solutions have been computed, return a list of lists
     
    751751   def LIFTRing=LIST[1];
    752752   setring LIFTRing;
    753    // LIFT contains the first 4 terms of a point in the variety of i 
     753   // LIFT contains the first 4 terms of a point in the variety of i
    754754   // over the Puiseux series field C{{t}} whose order is -w[1]/w[0]=1
    755755   LIFT;
     
    779779   // NOTE: since the last component of v is positive, the lifting
    780780   //       must start with a negative power of t, which in Singular
    781    //       is not allowed for a variable. 
     781   //       is not allowed for a variable.
    782782   def LIFTRing3=LIST[1];
    783783   setring LIFTRing3;
     
    834834      string Kstring="Z/"+string(char(LIFTRing))+"Z";
    835835    }
    836     // this means that tropicalLifting was called with 
     836    // this means that tropicalLifting was called with
    837837    // absolute primary decomposition
    838     if (size(troplift)==4) 
    839     {     
     838    if (size(troplift)==4)
     839    {
    840840      setring LIFTRing;
    841841      "The lifting of the point in the tropical variety lives in the ring";
    842842      if ((size(LIFTpar)==0) and (N==1))
    843843      {
    844         Kstring+"[[t]]"; 
     844        Kstring+"[[t]]";
    845845      }
    846846      if ((size(LIFTpar)==0) and (N!=1))
    847847      {
    848         Kstring+"[[t^(1/"+string(N)+")]]"; 
     848        Kstring+"[[t^(1/"+string(N)+")]]";
    849849      }
    850850      if ((size(LIFTpar)!=0) and (N!=1))
    851       {   
    852         Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]"; 
     851      {
     852        Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]";
    853853      }
    854854      if ((size(LIFTpar)!=0) and (N==1))
    855       {   
    856         Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]"; 
     855      {
     856        Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]";
    857857      }
    858858    }
     
    871871      }
    872872      if ((size(LIFTpar)!=0) and (N!=1))
    873       {   
    874         Kstring+"["+LIFTpar+"]/M[[t^(1/"+string(N)+")]]"; 
     873      {
     874        Kstring+"["+LIFTpar+"]/M[[t^(1/"+string(N)+")]]";
    875875        "where M is the maximal ideal";
    876876        "M=<"+m+">";
    877877      }
    878878      if ((size(LIFTpar)!=0) and (N==1))
    879       {   
    880         Kstring+"["+LIFTpar+"]/M[[t]]"; 
     879      {
     880        Kstring+"["+LIFTpar+"]/M[[t]]";
    881881        "where M is the maximal ideal";
    882882        "M=<"+m+">";
    883       }     
     883      }
    884884    }
    885885    "";
     
    908908      }
    909909    }
    910   }     
     910  }
    911911}
    912912example
     
    922922
    923923///////////////////////////////////////////////////////////////////////////////
    924 /// Procedures concerned with drawing a tropical curve or a Newton subdivision 
     924/// Procedures concerned with drawing a tropical curve or a Newton subdivision
    925925///////////////////////////////////////////////////////////////////////////////
    926926
    927927proc tropicalCurve (def tp,list #)
    928928"USAGE:      tropicalCurve(tp[,#]); tp list, # optional list
    929 ASSUME:      tp is list of linear polynomials of the form ax+by+c 
    930              with integers a, b and a rational number c representing 
     929ASSUME:      tp is list of linear polynomials of the form ax+by+c
     930             with integers a, b and a rational number c representing
    931931             a tropical Laurent polynomial defining a tropical plane curve;
    932              alternatively tp can be a polynomial in Q(t)[x,y] defining a 
    933              tropical plane curve via the valuation map; 
    934              the basering must have a global monomial ordering, 
     932             alternatively tp can be a polynomial in Q(t)[x,y] defining a
     933             tropical plane curve via the valuation map;
     934             the basering must have a global monomial ordering,
    935935             two variables and up to one parameter!
    936 RETURN:      list, each entry i=1,...,size(l)-1 corresponds to a vertex 
     936RETURN:      list, each entry i=1,...,size(l)-1 corresponds to a vertex
    937937                   in the tropical plane curve defined by tp
    938938                   l[i][1] = x-coordinate of the ith vertex
    939939                   l[i][2] = y-coordinate of the ith vertex
    940                    l[i][3] = intmat, if j is an entry in the first row 
     940                   l[i][3] = intmat, if j is an entry in the first row
    941941                             of intmat then the ith vertex of
    942                              the tropical curve is connected to the 
     942                             the tropical curve is connected to the
    943943                             jth vertex with multiplicity given
    944944                             by the corresponding entry in the second row
    945                    l[i][4] = list of lists, the first entry of a list is 
    946                              a primitive integer vector defining the direction 
    947                              of an unbounded edge emerging from the ith vertex 
    948                              of the graph, the corresponding second entry in 
     945                   l[i][4] = list of lists, the first entry of a list is
     946                             a primitive integer vector defining the direction
     947                             of an unbounded edge emerging from the ith vertex
     948                             of the graph, the corresponding second entry in
    949949                             the list is the multiplicity of the unbounded edge
    950                    l[i][5] = a polynomial whose monomials mark the vertices 
     950                   l[i][5] = a polynomial whose monomials mark the vertices
    951951                             in the Newton polygon corresponding to the entries
    952                              in tp which take the common minimum at the ith 
    953                              vertex -- if some coefficient a or b of the 
    954                              linear polynomials in the input was negative, 
     952                             in tp which take the common minimum at the ith
     953                             vertex -- if some coefficient a or b of the
     954                             linear polynomials in the input was negative,
    955955                             then each monomial has to be shifted by
    956956                             the values in l[size(l)][3]
    957                    l[size(l)][1] = list, the entries describe the boundary 
     957                   l[size(l)][1] = list, the entries describe the boundary
    958958                                         points of the Newton subdivision
    959                    l[size(l)][2] = list, the entries are pairs of integer 
     959                   l[size(l)][2] = list, the entries are pairs of integer
    960960                                         vectors defining an interior
    961961                                         edge of the Newton subdivision
    962                    l[size(l)][3] = intvec, the monmials occuring in l[i][5] 
    963                                            have to be shifted by this vector 
    964                                            in order to represent marked 
     962                   l[size(l)][3] = intvec, the monmials occuring in l[i][5]
     963                                           have to be shifted by this vector
     964                                           in order to represent marked
    965965                                           vertices in the Newton polygon
    966 NOTE:        here the tropical polynomial is supposed to be the MINIMUM 
    967              of the linear forms in tp, unless the optional input #[1] 
     966NOTE:        here the tropical polynomial is supposed to be the MINIMUM
     967             of the linear forms in tp, unless the optional input #[1]
    968968             is the string 'max'
    969969EXAMPLE:     example tropicalCurve;   shows an example"
     
    978978    ERROR("The basering should have a global monomial ordering, e.g. ring r=(0,t),(x,y),dp;");
    979979  }
    980   // if you insert a single polynomial instead of an ideal 
     980  // if you insert a single polynomial instead of an ideal
    981981  // representing a tropicalised polynomial,
    982   // then we compute first the tropicalisation of this polynomial 
     982  // then we compute first the tropicalisation of this polynomial
    983983  // -- this feature is not documented in the above help string
    984984  if (typeof(tp)=="poly")
    985985  {
    986     // exclude the case that the basering has not precisely 
     986    // exclude the case that the basering has not precisely
    987987    // one parameter and two indeterminates
    988988    if ((npars(basering)!=1) or (nvars(basering)!=2))
    989989    {
    990       ERROR("The basering should have precisely one parameter and two indeterminates!");     
     990      ERROR("The basering should have precisely one parameter and two indeterminates!");
    991991    }
    992992    poly f=tp;
     
    997997  if (nvars(basering) != 2)
    998998  {
    999     ERROR("The basering should have precisely two indeterminates!");     
    1000   }
    1001   // -1) Exclude the pathological case that the defining 
     999    ERROR("The basering should have precisely two indeterminates!");
     1000  }
     1001  // -1) Exclude the pathological case that the defining
    10021002  //     tropical polynomial has only one term,
    10031003  //     so that the tropical variety is not defined.
     
    10071007    intmat M[2][1]=0,0;
    10081008    return(list(list(0,0,M,list(),detropicalise(tp[1])),list(list(leadexp(detropicalise(tp[1]))),list())));
    1009   }   
    1010   // 0) If the input was a list of linear polynomials, 
     1009  }
     1010  // 0) If the input was a list of linear polynomials,
    10111011  //    then some coefficient of x or y can be negative,
    1012   //    i.e. the input corresponds to the tropical curve 
     1012  //    i.e. the input corresponds to the tropical curve
    10131013  //    of a Laurent polynomial. In that case we should
    1014   //    add some ax+by, so that all coefficients are positive. 
     1014  //    add some ax+by, so that all coefficients are positive.
    10151015  //    This does not change the tropical curve.
    1016   //    however, we have to save (a,b), since the Newton 
     1016  //    however, we have to save (a,b), since the Newton
    10171017  //    polygone has to be shifted by (-a,-b).
    10181018  poly aa,bb; // koeffizienten
     
    10261026    {
    10271027      bb=koeffizienten(tp[i],2);
    1028     }   
     1028    }
    10291029  }
    10301030  if ((aa!=0) or (bb!=0))
     
    10351035    }
    10361036  }
    1037   // 1) compute the vertices of the tropical curve 
     1037  // 1) compute the vertices of the tropical curve
    10381038  //    defined by tp and the Newton subdivision
    10391039  list vtp=verticesTropicalCurve(tp,#);
    1040   //    if vtp is empty, then the Newton polygone is just 
     1040  //    if vtp is empty, then the Newton polygone is just
    10411041  //    a line segment and constitutes a bunch of lines
    10421042  //    which can be computed by bunchOfLines
     
    10451045    return(bunchOfLines(tp));
    10461046  }
    1047   // 2) store all vertices belonging to the ith part of the 
     1047  // 2) store all vertices belonging to the ith part of the
    10481048  //    Newton subdivision in the list vtp[i] as 4th entry,
    10491049  //    and store those, which are not corners of the ith subdivision polygon
    10501050  //    in vtp[i][6]
    1051   poly nwt; 
     1051  poly nwt;
    10521052  list boundaryNSD;  // stores the boundary of a Newton subdivision
    1053   intmat zwsp[2][1]; // used for intermediate storage   
     1053  intmat zwsp[2][1]; // used for intermediate storage
    10541054  for (i=1;i<=size(vtp);i++)
    10551055  {
    10561056    k=1;
    1057     nwt=vtp[i][3]; // the polynomial representing the 
     1057    nwt=vtp[i][3]; // the polynomial representing the
    10581058    // ith part of the Newton subdivision
    1059     // store the vertices of the ith part of the 
     1059    // store the vertices of the ith part of the
    10601060    // Newton subdivision in the list newton
    1061     list newton; 
     1061    list newton;
    10621062    while (nwt!=0)
    10631063    {
     
    10661066      k++;
    10671067    }
    1068     boundaryNSD=findOrientedBoundary(newton);// a list of the vertices 
    1069                                              // of the Newton subdivision 
    1070                                              // as integer vectors (only those 
    1071                                              // on the boundary, and oriented 
     1068    boundaryNSD=findOrientedBoundary(newton);// a list of the vertices
     1069                                             // of the Newton subdivision
     1070                                             // as integer vectors (only those
     1071                                             // on the boundary, and oriented
    10721072                                             // clockwise)
    10731073    vtp[i][4]=boundaryNSD[1];
    10741074    vtp[i][5]=boundaryNSD[2];
    1075     vtp[i][6]=zwsp; // the entries of the first row will denote to which 
    1076                     // vertex the ith one is connected 
    1077                     // and the entries of the second row will denote 
     1075    vtp[i][6]=zwsp; // the entries of the first row will denote to which
     1076                    // vertex the ith one is connected
     1077                    // and the entries of the second row will denote
    10781078                    //with which multiplicity
    10791079    kill newton; // we kill the superflous list
    10801080  }
    1081   // 3) Next we build for each part of the Newton 
     1081  // 3) Next we build for each part of the Newton
    10821082  //    subdivision the list of all pairs of vertices on the
    10831083  //    boundary, which are involved, including those which are not corners
     
    10961096    kill ipairs;
    10971097  }
    1098   // 4) Check for all pairs of verticies in the Newton diagram if they 
     1098  // 4) Check for all pairs of verticies in the Newton diagram if they
    10991099  //    occur in two different parts of the Newton subdivision
    1100   int deleted; // if a pair occurs in two NSD, it can be removed 
     1100  int deleted; // if a pair occurs in two NSD, it can be removed
    11011101               // from both - deleted is then set to 1
    1102   list inneredges; // contains the list of all pairs contained in two NSD 
     1102  list inneredges; // contains the list of all pairs contained in two NSD
    11031103                   // - these are inner the edges of NSD
    11041104  int ggt;
    11051105  d=1;  // counts the inner edges
    11061106  for (i=1;i<=size(pairs)-1;i++)
    1107   { 
     1107  {
    11081108    for (j=i+1;j<=size(pairs);j++)
    11091109    {
     
    11121112        deleted=0;
    11131113        for (l=size(pairs[j]);l>=1 and deleted==0;l--)
    1114         { 
     1114        {
    11151115          if (((pairs[i][k][1]==pairs[j][l][1]) and (pairs[i][k][2]==pairs[j][l][2])) or ((pairs[i][k][1]==pairs[j][l][2]) and (pairs[i][k][2]==pairs[j][l][1])))
    11161116          {
     
    11181118            d++;
    11191119            ggt=abs(gcd(pairs[i][k][1][1]-pairs[i][k][2][1],pairs[i][k][1][2]-pairs[i][k][2][2]));
    1120             zwsp=j,ggt;   // and it is recorded that the ith and jth 
     1120            zwsp=j,ggt;   // and it is recorded that the ith and jth
    11211121                          // vertex should be connected with mult ggt
    11221122            vtp[i][6]=intmatconcat(vtp[i][6],zwsp);
    11231123            zwsp=i,ggt;
    11241124            vtp[j][6]=intmatconcat(vtp[j][6],zwsp);
    1125             pairs[i]=delete(pairs[i],k);  // finally the pair is deleted 
     1125            pairs[i]=delete(pairs[i],k);  // finally the pair is deleted
    11261126                                          // from both sets of pairs
    11271127            pairs[j]=delete(pairs[j],l);
     
    11631163    }
    11641164  }
    1165   // 6.3) Order the vertices such that passing from one to the next we 
     1165  // 6.3) Order the vertices such that passing from one to the next we
    11661166  //      travel along the boundary of the Newton polytope clock wise.
    11671167  boundaryNSD=findOrientedBoundary(vertices);
    11681168  list orderedvertices=boundaryNSD[1];
    11691169  // 7) Find the unbounded edges emerging from a vertex in the tropical curve.
    1170   //    For this we check the remaining pairs for the ith NSD. 
     1170  //    For this we check the remaining pairs for the ith NSD.
    11711171  //    Each pair is ordered according
    1172   //    to the order in which the vertices occur in orderedvertices. 
     1172  //    to the order in which the vertices occur in orderedvertices.
    11731173  //    The direction of the
    1174   //    unbounded edge is then the outward pointing primitive normal 
     1174  //    unbounded edge is then the outward pointing primitive normal
    11751175  //    vector to the vector
    11761176  //    pointing from the first vertex in a pair to the second one.
     
    11821182  for (i=1;i<=size(pairs);i++)
    11831183  {
    1184     list ubedges; // stores the unbounded edges 
     1184    list ubedges; // stores the unbounded edges
    11851185    k=1; // counts the unbounded edges
    11861186    for (j=1;j<=size(pairs[i]);j++)
    11871187    {
    11881188      // computes the position of the vertices in the
    1189       pos1=positionInList(orderedvertices,pairs[i][j][1]); 
     1189      pos1=positionInList(orderedvertices,pairs[i][j][1]);
    11901190      // pair in the list orderedvertices
    1191       pos2=positionInList(orderedvertices,pairs[i][j][2]); 
     1191      pos2=positionInList(orderedvertices,pairs[i][j][2]);
    11921192      if (((pos1>pos2) and !((pos1==size(orderedvertices)) and (pos2==1))) or ((pos2==size(orderedvertices)) and (pos1==1)))  // reorders them if necessary
    11931193      {
     
    11971197      }
    11981198      // the vector pointing from vertex 1 in the pair to vertex2
    1199       normalvector=pairs[i][j][2]-pairs[i][j][1]; 
     1199      normalvector=pairs[i][j][2]-pairs[i][j][1];
    12001200      ggt=gcd(normalvector[1],normalvector[2]);   // the gcd of the entries
    12011201      zw=normalvector[2];    // create the outward pointing normal vector
     
    12291229    kill ubedges;
    12301230  }
    1231   // 8) Store the computed information for the ith part 
     1231  // 8) Store the computed information for the ith part
    12321232  //    of the NSD in the list graph[i].
    12331233  list graph,gr;
     
    12351235  {
    12361236    // the first coordinate of the ith vertex of the tropical curve
    1237     gr[1]=vtp[i][1]; 
     1237    gr[1]=vtp[i][1];
    12381238    // the second coordinate of the ith vertex of the tropical curve
    1239     gr[2]=vtp[i][2]; 
     1239    gr[2]=vtp[i][2];
    12401240    // to which vertices is the ith vertex of the tropical curve connected
    1241     gr[3]=vtp[i][6]; 
    1242     // the directions unbounded edges emerging from the ith 
     1241    gr[3]=vtp[i][6];
     1242    // the directions unbounded edges emerging from the ith
    12431243    // vertex of the trop. curve
    1244     gr[4]=vtp[i][7]; 
    1245     // the vertices of the boundary of the ith part of the NSD 
    1246     gr[5]=vtp[i][3]; 
     1244    gr[4]=vtp[i][7];
     1245    // the vertices of the boundary of the ith part of the NSD
     1246    gr[5]=vtp[i][3];
    12471247    graph[i]=gr;
    12481248  }
     
    12631263    }
    12641264  }
    1265   // 10) Finally store the boundary vertices and 
     1265  // 10) Finally store the boundary vertices and
    12661266  //     the inner edges as last entry in the list graph.
    12671267  //     This represents the NSD.
     
    12801280// the coordinates of the first vertex are graph[1][1],graph[1][2];
    12811281   graph[1][1],graph[1][2];
    1282 // the first vertex is connected to the vertices 
     1282// the first vertex is connected to the vertices
    12831283//     graph[1][3][1,1..ncols(graph[1][3])]
    12841284   intmat M=graph[1][3];
    12851285   M[1,1..ncols(graph[1][3])];
    1286 // the weights of the edges to these vertices are 
     1286// the weights of the edges to these vertices are
    12871287//     graph[1][3][2,1..ncols(graph[1][3])]
    12881288   M[2,1..ncols(graph[1][3])];
    12891289// from the first vertex emerge size(graph[1][4]) unbounded edges
    12901290   size(graph[1][4]);
    1291 // the primitive integral direction vector of the first unbounded edge 
     1291// the primitive integral direction vector of the first unbounded edge
    12921292//     of the first vertex
    12931293   graph[1][4][1][1];
    12941294// the weight of the first unbounded edge of the first vertex
    12951295   graph[1][4][1][2];
    1296 // the monomials which are part of the Newton subdivision of the first vertex 
     1296// the monomials which are part of the Newton subdivision of the first vertex
    12971297   graph[1][5];
    1298 // connecting the points in graph[size(graph)][1] we get 
     1298// connecting the points in graph[size(graph)][1] we get
    12991299//     the boundary of the Newton polytope
    13001300   graph[size(graph)][1];
    1301 // an entry in graph[size(graph)][2] is a pair of points 
     1301// an entry in graph[size(graph)][2] is a pair of points
    13021302//     in the Newton polytope bounding an inner edge
    13031303   graph[size(graph)][2][1];
     
    13081308proc drawTropicalCurve (def f,list #)
    13091309"USAGE:      drawTropicalCurve(f[,#]); f poly or list, # optional list
    1310 ASSUME:      f is list of linear polynomials of the form ax+by+c with 
    1311              integers a, b and a rational number c representing a tropical 
     1310ASSUME:      f is list of linear polynomials of the form ax+by+c with
     1311             integers a, b and a rational number c representing a tropical
    13121312             Laurent polynomial defining a tropical plane curve;
    1313              alternatively f can be a polynomial in Q(t)[x,y] defining 
    1314              a tropical plane curve via the valuation map; 
    1315              the basering must have a global monomial ordering, two 
     1313             alternatively f can be a polynomial in Q(t)[x,y] defining
     1314             a tropical plane curve via the valuation map;
     1315             the basering must have a global monomial ordering, two
    13161316             variables and up to one parameter!
    13171317RETURN:      NONE
    1318 NOTE:        - the procedure creates the files /tmp/tropicalcurveNUMBER.tex and 
    1319                /tmp/tropicalcurveNUMBER.ps, where NUMBER is a random four 
    1320                digit integer; 
     1318NOTE:        - the procedure creates the files /tmp/tropicalcurveNUMBER.tex and
     1319               /tmp/tropicalcurveNUMBER.ps, where NUMBER is a random four
     1320               digit integer;
    13211321               moreover it displays the tropical curve via kghostview;
    1322                if you wish to remove all these files from /tmp, 
     1322               if you wish to remove all these files from /tmp,
    13231323               call the procedure cleanTmp
    13241324@*           - edges with multiplicity greater than one carry this multiplicity
    13251325@*           - if # is empty, then the tropical curve is computed w.r.t. minimum,
    1326                if #[1] is the string 'max', then it is computed w.r.t. maximum 
    1327 @*           - if the last optional argument is 'onlytexfile' then only the 
    1328                latex file is produced; this option should be used if kghostview 
     1326               if #[1] is the string 'max', then it is computed w.r.t. maximum
     1327@*           - if the last optional argument is 'onlytexfile' then only the
     1328               latex file is produced; this option should be used if kghostview
    13291329               is not installed on your system
    1330 @*           - note that lattice points in the Newton subdivision which are 
    1331                black correspond to markings of the marked subdivision, 
     1330@*           - note that lattice points in the Newton subdivision which are
     1331               black correspond to markings of the marked subdivision,
    13321332               while lattice points in grey are not marked
    13331333EXAMPLE:     example drawTropicalCurve  shows an example"
     
    13471347  if (typeof(f)=="poly")
    13481348  {
    1349     // exclude the case that the basering has not precisely 
     1349    // exclude the case that the basering has not precisely
    13501350    // one parameter and two indeterminates
    13511351    if ((npars(basering)!=1) or (nvars(basering)!=2))
    13521352    {
    1353       ERROR("The basering should have precisely one parameter and two indeterminates!");     
     1353      ERROR("The basering should have precisely one parameter and two indeterminates!");
    13541354    }
    13551355    texf=texPolynomial(f); // write the polynomial over Q(t)
     
    13621362      texf="\\mbox{\\tt The defining equation was not handed over!}";
    13631363      list graph=f;
    1364     }   
     1364    }
    13651365    else
    13661366    { // write the tropical polynomial defined by f
    13671367      if (size(#)==0)
    1368       {     
     1368      {
    13691369        texf="\\min\\{";
    13701370      }
     
    13751375      for (j=1;j<=size(f);j++)
    13761376      {
    1377         texf=texf+texPolynomial(f[j]);   
     1377        texf=texf+texPolynomial(f[j]);
    13781378        if (j<size(f))
    13791379        {
     
    13841384          texf=texf+"\\}";
    13851385        }
    1386       }   
     1386      }
    13871387      list graph=tropicalCurve(f,#); // the graph of the tropical polynomial f
    13881388    }
     
    14021402\\addtolength{\\topmargin}{-\\headheight}
    14031403\\addtolength{\\topmargin}{-\\topskip}
    1404 \\setlength{\\textheight}{267mm} 
     1404\\setlength{\\textheight}{267mm}
    14051405\\addtolength{\\textheight}{\\topskip}
    14061406\\addtolength{\\textheight}{-\\footskip}
    14071407\\addtolength{\\textheight}{-30pt}
    1408 \\setlength{\\oddsidemargin}{-1in} 
     1408\\setlength{\\oddsidemargin}{-1in}
    14091409\\addtolength{\\oddsidemargin}{20mm}
    14101410\\setlength{\\evensidemargin}{\\oddsidemargin}
    1411 \\setlength{\\textwidth}{170mm} 
     1411\\setlength{\\textwidth}{170mm}
    14121412
    14131413\\begin{document}
    14141414   \\parindent0cm
    14151415   \\begin{center}
    1416       \\large\\bf The Tropicalisation of 
     1416      \\large\\bf The Tropicalisation of
    14171417
    14181418      \\bigskip
     
    14381438
    14391439   \\begin{center}
    1440        "+texDrawNewtonSubdivision(graph,#)+" 
     1440       "+texDrawNewtonSubdivision(graph,#)+"
    14411441   \\end{center}
    14421442\\end{document}";
     
    14451445    int rdnum=random(1000,9999);
    14461446    write(":w /tmp/tropicalcurve"+string(rdnum)+".tex",TEXBILD);
    1447     system("sh","cd /tmp; latex /tmp/tropicalcurve"+string(rdnum)+".tex; dvips /tmp/tropicalcurve"+string(rdnum)+".dvi -o; /bin/rm tropicalcurve"+string(rdnum)+".log;  /bin/rm tropicalcurve"+string(rdnum)+".aux;  /bin/rm tropicalcurve"+string(rdnum)+".ps?;  /bin/rm tropicalcurve"+string(rdnum)+".dvi; kghostview tropicalcurve"+string(rdnum)+".ps &"); 
     1447    system("sh","cd /tmp; latex /tmp/tropicalcurve"+string(rdnum)+".tex; dvips /tmp/tropicalcurve"+string(rdnum)+".dvi -o; /bin/rm tropicalcurve"+string(rdnum)+".log;  /bin/rm tropicalcurve"+string(rdnum)+".aux;  /bin/rm tropicalcurve"+string(rdnum)+".ps?;  /bin/rm tropicalcurve"+string(rdnum)+".dvi; kghostview tropicalcurve"+string(rdnum)+".ps &");
    14481448  }
    14491449  else
     
    14721472proc drawNewtonSubdivision (def f,list #)
    14731473"USAGE:   drawTropicalCurve(f[,#]); f poly, # optional list
    1474 ASSUME:   f is list of linear polynomials of the form ax+by+c with integers 
    1475           a, b and a rational number c representing a tropical Laurent 
     1474ASSUME:   f is list of linear polynomials of the form ax+by+c with integers
     1475          a, b and a rational number c representing a tropical Laurent
    14761476          polynomial defining a tropical plane curve;
    1477           alternatively f can be a polynomial in Q(t)[x,y] defining a tropical 
    1478           plane curve via the valuation map; 
    1479           the basering must have a global monomial ordering, two variables 
     1477          alternatively f can be a polynomial in Q(t)[x,y] defining a tropical
     1478          plane curve via the valuation map;
     1479          the basering must have a global monomial ordering, two variables
    14801480          and up to one parameter!
    14811481RETURN:   NONE
    1482 NOTE:     - the procedure creates the files /tmp/newtonsubdivisionNUMBER.tex, 
    1483             and /tmp/newtonsubdivisionNUMBER.ps, where NUMBER is a random 
    1484             four digit integer; 
     1482NOTE:     - the procedure creates the files /tmp/newtonsubdivisionNUMBER.tex,
     1483            and /tmp/newtonsubdivisionNUMBER.ps, where NUMBER is a random
     1484            four digit integer;
    14851485            moreover it desplays the tropical curve defined by f via kghostview;
    1486             if you wish to remove all these files from /tmp, call the procedure 
     1486            if you wish to remove all these files from /tmp, call the procedure
    14871487            cleanTmp;
    1488 @*          if # is empty, then the tropical curve is computed w.r.t. minimum, 
    1489             if #[1] is the string 'max', then it is computed w.r.t. maximum 
    1490 @*        - note that lattice points in the Newton subdivision which are black 
    1491             correspond to markings of the marked subdivision, while lattice 
     1488@*          if # is empty, then the tropical curve is computed w.r.t. minimum,
     1489            if #[1] is the string 'max', then it is computed w.r.t. maximum
     1490@*        - note that lattice points in the Newton subdivision which are black
     1491            correspond to markings of the marked subdivision, while lattice
    14921492            points in grey are not marked
    14931493EXAMPLE:     example drawNewtonSubdivision;   shows an example"
     
    15031503  { // write the tropical polynomial defined by f
    15041504    if (size(#)==0)
    1505     {     
     1505    {
    15061506      texf="\\min\\{";
    15071507    }
     
    15121512    for (j=1;j<=size(f);j++)
    15131513    {
    1514       texf=texf+texPolynomial(f[j]);   
     1514      texf=texf+texPolynomial(f[j]);
    15151515      if (j<size(f))
    15161516      {
     
    15211521        texf=texf+"\\}";
    15221522      }
    1523     }   
     1523    }
    15241524    list graph=tropicalCurve(f,#); // the graph of the tropical polynomial f
    15251525  }
     
    15291529   \\parindent0cm
    15301530   \\begin{center}
    1531       \\large\\bf The Newtonsubdivison of 
     1531      \\large\\bf The Newtonsubdivison of
    15321532      \\begin{displaymath}
    15331533          f="+texf+"
     
    15371537
    15381538   \\begin{center}
    1539 "+texDrawNewtonSubdivision(graph)+ 
     1539"+texDrawNewtonSubdivision(graph)+
    15401540"   \\end{center}
    15411541
     
    15431543  int rdnum=random(1000,9999);
    15441544  write(":w /tmp/newtonsubdivision"+string(rdnum)+".tex",TEXBILD);
    1545   system("sh","cd /tmp; latex /tmp/newtonsubdivision"+string(rdnum)+".tex; dvips /tmp/newtonsubdivision"+string(rdnum)+".dvi -o; /bin/rm newtonsubdivision"+string(rdnum)+".log;  /bin/rm newtonsubdivision"+string(rdnum)+".aux;  /bin/rm newtonsubdivision"+string(rdnum)+".ps?;  /bin/rm newtonsubdivision"+string(rdnum)+".dvi; kghostview newtonsubdivision"+string(rdnum)+".ps &"); 
     1545  system("sh","cd /tmp; latex /tmp/newtonsubdivision"+string(rdnum)+".tex; dvips /tmp/newtonsubdivision"+string(rdnum)+".dvi -o; /bin/rm newtonsubdivision"+string(rdnum)+".log;  /bin/rm newtonsubdivision"+string(rdnum)+".aux;  /bin/rm newtonsubdivision"+string(rdnum)+".ps?;  /bin/rm newtonsubdivision"+string(rdnum)+".dvi; kghostview newtonsubdivision"+string(rdnum)+".ps &");
    15461546//  return(TEXBILD);
    15471547}
     
    15681568proc tropicalJInvariant (def f,list #)
    15691569"USAGE:      tropicalJInvariant(f[,#]); f poly or list, # optional list
    1570 ASSUME:      f is list of linear polynomials of the form ax+by+c with integers 
    1571              a, b and a rational number c representing a tropical Laurent 
     1570ASSUME:      f is list of linear polynomials of the form ax+by+c with integers
     1571             a, b and a rational number c representing a tropical Laurent
    15721572             polynomial defining a tropical plane curve;
    1573              alternatively f can be a polynomial in Q(t)[x,y] defining a 
    1574              tropical plane curve via the valuation map; 
    1575 @*           the basering must have a global monomial ordering, two variables 
     1573             alternatively f can be a polynomial in Q(t)[x,y] defining a
     1574             tropical plane curve via the valuation map;
     1575@*           the basering must have a global monomial ordering, two variables
    15761576             and up to one parameter!
    1577 RETURN:      number, if the graph underlying the tropical curve has precisely 
    1578                      one loop then its weighted lattice length is returned, 
     1577RETURN:      number, if the graph underlying the tropical curve has precisely
     1578                     one loop then its weighted lattice length is returned,
    15791579                     otherwise the result will be -1
    1580 NOTE:        - if the tropical curve is elliptic and its embedded graph has 
    1581                precisely one loop, then the weigthed lattice length of 
     1580NOTE:        - if the tropical curve is elliptic and its embedded graph has
     1581               precisely one loop, then the weigthed lattice length of
    15821582               the loop is its tropical j-invariant
    1583 @*           - the procedure checks if the embedded graph of the tropical 
    1584                curve has genus one, but it does NOT check if the loop can 
    1585                be resolved, so that the curve is not a proper tropical 
    1586                elliptic curve 
    1587 @*           - if the embedded graph of a tropical elliptic curve has more 
    1588                than one loop, then all but one can be resolved, but this is 
    1589                not observed by this procedure, so it will not compute 
     1583@*           - the procedure checks if the embedded graph of the tropical
     1584               curve has genus one, but it does NOT check if the loop can
     1585               be resolved, so that the curve is not a proper tropical
     1586               elliptic curve
     1587@*           - if the embedded graph of a tropical elliptic curve has more
     1588               than one loop, then all but one can be resolved, but this is
     1589               not observed by this procedure, so it will not compute
    15901590               the j-invariant
    15911591@*           - if # is empty, then the tropical curve is computed w.r.t. minimum,
    1592                if #[1] is the string 'max', then it is computed w.r.t. maximum 
    1593 @*           - the tropicalJInvariant of a plane tropical cubic is the 
    1594                'cycle length' of the cubic as introduced in the paper: 
    1595                Eric Katz, Hannah Markwig, Thomas Markwig: The j-invariant 
     1592               if #[1] is the string 'max', then it is computed w.r.t. maximum
     1593@*           - the tropicalJInvariant of a plane tropical cubic is the
     1594               'cycle length' of the cubic as introduced in the paper:
     1595               Eric Katz, Hannah Markwig, Thomas Markwig: The j-invariant
    15961596               of a cubic tropical plane curve.
    15971597EXAMPLE:     example tropicalJInvariant;   shows an example"
     
    16071607    {
    16081608      if (typeof(f[1])=="list")
    1609       {       
     1609      {
    16101610        list graph=f;
    16111611      }
     
    16191619        {
    16201620          ERROR("This is no valid input.");
    1621         }       
     1621        }
    16221622      }
    16231623    }
     
    16361636  genus=-genus/2; // we have counted each bounded edge twice
    16371637  genus=genus+size(graph); // the genus is 1-#bounded_edges+#vertices
    1638   // 3) if the embedded graph has not genus one, 
     1638  // 3) if the embedded graph has not genus one,
    16391639  //    we cannot compute the j-invariant
    16401640  if(genus!=1)
     
    16481648  else
    16491649  {
    1650     intmat nullmat[2][1];  // used to set 
    1651     // 4) find a vertex which has only one bounded edge, 
    1652     //    if none exists zero is returned, 
     1650    intmat nullmat[2][1];  // used to set
     1651    // 4) find a vertex which has only one bounded edge,
     1652    //    if none exists zero is returned,
    16531653    //    otherwise the number of the vertex in the list graph
    1654     int nonloopvertex=findNonLoopVertex(graph);   
     1654    int nonloopvertex=findNonLoopVertex(graph);
    16551655    int dv; //checks if vert. has been found to which nonloopvertex is connected
    1656     intmat delvert; // takes for a moment graph[i][3] of the vertex 
     1656    intmat delvert; // takes for a moment graph[i][3] of the vertex
    16571657                    // to which nonloopvertex is connected
    1658     // 5) delete successively vertices in the graph which 
     1658    // 5) delete successively vertices in the graph which
    16591659    //    have only one bounded edge
    16601660    while (nonloopvertex>0)
    16611661    {
    1662       // find the only vertex to which the nonloopvertex 
     1662      // find the only vertex to which the nonloopvertex
    16631663      // is connected, when it is found
    16641664      // delete the connection in graph[i][3] and set dv=1
     
    16731673            {
    16741674              delvert=graph[i][3];
    1675               delvert=intmatcoldelete(delvert,j); // delete the connection (note 
     1675              delvert=intmatcoldelete(delvert,j); // delete the connection (note
    16761676                                                  // there must have been two!)
    16771677              dv=1;
     
    16811681        }
    16821682      }
    1683       graph[nonloopvertex][3]=nullmat; // the only connection of nonloopvertex 
     1683      graph[nonloopvertex][3]=nullmat; // the only connection of nonloopvertex
    16841684                                       // is killed
    1685       nonloopvertex=findNonLoopVertex(graph); // find the next vertex 
     1685      nonloopvertex=findNonLoopVertex(graph); // find the next vertex
    16861686                                              // which has only one edge
    16871687    }
     
    16891689    intvec loop,weights; // encodes the loop and the edges
    16901690    i=1;
    1691     //    start by finding some vertex which belongs to the loop 
    1692     while (loop==0) 
     1691    //    start by finding some vertex which belongs to the loop
     1692    while (loop==0)
    16931693    {
    16941694      // if graph[i][3] of a vertex in the loop has 2 columns, all others have 1
    1695       if (ncols(graph[i][3])==1) 
     1695      if (ncols(graph[i][3])==1)
    16961696      {
    16971697        i++;
     
    16991699      else
    17001700      {
    1701         loop[1]=i; // a starting vertex is found 
    1702         loop[2]=graph[i][3][1,1]; // it is connected to vertex with this number 
     1701        loop[1]=i; // a starting vertex is found
     1702        loop[2]=graph[i][3][1,1]; // it is connected to vertex with this number
    17031703        weights[2]=graph[i][3][2,1]; // and the edge has this weight
    17041704      }
     
    17081708    while (j!=i)  // the loop ends with the same vertex with which it starts
    17091709    {
    1710       // the first row of graph[j][3] has two entries 
     1710      // the first row of graph[j][3] has two entries
    17111711      // corresponding to the two vertices
    1712       // to which the active vertex j is connected; 
     1712      // to which the active vertex j is connected;
    17131713      // one is loop[k-1], i.e. the one which
    17141714      // precedes j in the loop; we have to choose the other one
    1715       if (graph[j][3][1,1]==loop[k-1]) 
     1715      if (graph[j][3][1,1]==loop[k-1])
    17161716      {
    17171717        loop[k+1]=graph[j][3][1,2];
     
    17241724      }
    17251725      j=loop[k+1]; // set loop[k+1] the new active vertex
    1726       k++; 
    1727     }   
     1726      k++;
     1727    }
    17281728    // 7) compute for each edge in the loop the lattice length
    1729     poly xcomp,ycomp; // the x- and y-components of the vectors 
     1729    poly xcomp,ycomp; // the x- and y-components of the vectors
    17301730                      // connecting two vertices of the loop
    1731     number nenner;    // the product of the denominators of 
     1731    number nenner;    // the product of the denominators of
    17321732                      // the x- and y-components
    17331733    number jinvariant;  // the j-invariant
    1734     int eins,zwei,ggt; 
     1734    int eins,zwei,ggt;
    17351735    for (i=1;i<=size(loop)-1;i++) // compute the lattice length for each edge
    17361736    {
    1737       xcomp=graph[loop[i]][1]-graph[loop[i+1]][1]; 
    1738       ycomp=graph[loop[i]][2]-graph[loop[i+1]][2]; 
     1737      xcomp=graph[loop[i]][1]-graph[loop[i+1]][1];
     1738      ycomp=graph[loop[i]][2]-graph[loop[i+1]][2];
    17391739      nenner=denominator(leadcoef(xcomp))*denominator(leadcoef(ycomp));
    1740       execute("eins="+string(numerator(leadcoef(nenner*xcomp)))+";"); 
    1741       execute("zwei="+string(numerator(leadcoef(nenner*ycomp)))+";"); 
     1740      execute("eins="+string(numerator(leadcoef(nenner*xcomp)))+";");
     1741      execute("zwei="+string(numerator(leadcoef(nenner*ycomp)))+";");
    17421742      ggt=gcd(eins,zwei); // the lattice length is the "gcd"
    17431743                          // of the x-component and the y-component
    1744       jinvariant=jinvariant+ggt/(nenner*weights[i+1]); // divided by the 
     1744      jinvariant=jinvariant+ggt/(nenner*weights[i+1]); // divided by the
    17451745                                                       // weight of the edge
    17461746    }
    1747     return(jinvariant);   
     1747    return(jinvariant);
    17481748  }
    17491749}
     
    17591759// the curve can have arbitrary degree
    17601760   tropicalJInvariant(t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2);
    1761 // the procedure does not realise, if the embedded graph of the tropical 
     1761// the procedure does not realise, if the embedded graph of the tropical
    17621762//     curve has a loop that can be resolved
    17631763   tropicalJInvariant(1+x+y+xy+tx2y+txy2);
    17641764// but it does realise, if the curve has no loop at all ...
    17651765   tropicalJInvariant(x+y+1);
    1766 // or if the embedded graph has more than one loop - even if only one 
     1766// or if the embedded graph has more than one loop - even if only one
    17671767//     cannot be resolved
    17681768   tropicalJInvariant(1+x+y+xy+tx2y+txy2+t3x5+t3y5+tx2y2+t2xy4+t2yx4);
     
    17731773proc weierstrassForm (poly f,list #)
    17741774"USAGE:      weierstrassForm(wf[,#]); wf poly, # list
    1775 ASSUME:      wf is a a polynomial whose Newton polygon has precisely one 
    1776              interior lattice point, so that it defines an elliptic curve 
     1775ASSUME:      wf is a a polynomial whose Newton polygon has precisely one
     1776             interior lattice point, so that it defines an elliptic curve
    17771777             on the toric surface corresponding to the Newton polygon
    17781778RETURN:      poly, the Weierstrass normal form of the polynomial
     
    17801780               to Fernando Rodriguez Villegas, villegas@math.utexas.edu
    17811781@*           - the characteristic of the base field should not be 2 or 3
    1782 @*           - if an additional argument # is given, a simplified Weierstrass 
     1782@*           - if an additional argument # is given, a simplified Weierstrass
    17831783               form is computed
    17841784EXAMPLE:     example weierstrassForm;   shows an example"
     
    18411841
    18421842proc jInvariant (poly f,list #)
    1843 "USAGE:      jInvariant(f[,#]); f poly, # list 
    1844 ASSUME:      - f is a a polynomial whose Newton polygon has precisely one 
    1845                interior lattice point, so that it defines an elliptic curve 
     1843"USAGE:      jInvariant(f[,#]); f poly, # list
     1844ASSUME:      - f is a a polynomial whose Newton polygon has precisely one
     1845               interior lattice point, so that it defines an elliptic curve
    18461846               on the toric surface corresponding to the Newton polygon
    1847 @*           - it the optional argument # is present the base field should be 
    1848                Q(t) and the optional argument should be one of the following 
     1847@*           - it the optional argument # is present the base field should be
     1848               Q(t) and the optional argument should be one of the following
    18491849               strings:
    1850 @*             'ord'   : then the return value is of type integer, 
     1850@*             'ord'   : then the return value is of type integer,
    18511851                         namely the order of the j-invariant
    1852 @*             'split' : then the return value is a list of two polynomials, 
     1852@*             'split' : then the return value is a list of two polynomials,
    18531853                         such that the quotient of these two is the j-invariant
    18541854RETURN:      poly, the j-invariant of the elliptic curve defined by poly
    1855 NOTE:        the characteristic of the base field should not be 2 or 3, 
     1855NOTE:        the characteristic of the base field should not be 2 or 3,
    18561856             unless the input is a plane cubic
    18571857EXAMPLE:     example jInvariant;   shows an example"
     
    18791879   echo=2;
    18801880   ring r=(0,t),(x,y),dp;
    1881 // jInvariant computes the j-invariant of a cubic 
     1881// jInvariant computes the j-invariant of a cubic
    18821882   jInvariant(x+y+x2y+y3+1/t*xy);
    1883 // if the ground field has one parameter t, then we can instead 
     1883// if the ground field has one parameter t, then we can instead
    18841884//    compute the order of the j-invariant
    18851885   jInvariant(x+y+x2y+y3+1/t*xy,"ord");
     
    18891889   poly h=x22y11+x19y10+x17y9+x16y9+x12y7+x9y6+x7y5+x2y3+x14y8;
    18901890// its j-invariant is
    1891    jInvariant(h); 
     1891   jInvariant(h);
    18921892}
    18931893
     
    19081908@*                 l[6] = a list containing the vertices of the tropical conic f
    19091909@*                 l[7] = a list containing lists with vertices of the tangents
    1910 @*                 l[8] = a string which contains the latex-code to draw the 
     1910@*                 l[8] = a string which contains the latex-code to draw the
    19111911                          tropical conic and its tropicalised tangents
    19121912@*                 l[9] = if # is non-empty, this is the same data for the dual
     
    19321932  ring LINRING=(0,t),(x,y,a(1..6)),lp;
    19331933  list points=imap(BASERING,points);
    1934   ideal I; // the ideal will contain the linear equations given by the conic 
     1934  ideal I; // the ideal will contain the linear equations given by the conic
    19351935           // and the points
    19361936  for (i=1;i<=5;i++)
     
    19531953  ring tRING=0,t,ls;
    19541954  list pointdenom=imap(BASERING,pointdenom);
    1955   list pointnum=imap(BASERING,pointnum); 
     1955  list pointnum=imap(BASERING,pointnum);
    19561956  intvec pointcoordinates;
    19571957  for (i=1;i<=size(pointdenom);i++)
     
    20292029   We consider the concic through the following five points:
    20302030   \\begin{displaymath}
    2031 "; 
     2031";
    20322032  string texf=texDrawTropical(graphf,list("",scalefactor));
    20332033  for (i=1;i<=size(points);i++)
     
    20672067\\end{document}";
    20682068  setring BASERING;
    2069   // If # non-empty, compute the dual conic and the tangents 
    2070   // through the dual points 
     2069  // If # non-empty, compute the dual conic and the tangents
     2070  // through the dual points
    20712071  // corresponding to the tangents of the given conic.
    20722072  if (size(#)>0)
    20732073  {
    20742074    list dualpoints;
    2075     for (i=1;i<=size(points);i++) 
     2075    for (i=1;i<=size(points);i++)
    20762076    {
    20772077      dualpoints[i]=list(leadcoef(tangents[i])/substitute(tangents[i],x,0,y,0),leadcoef(tangents[i]-lead(tangents[i]))/substitute(tangents[i],x,0,y,0));
     
    20972097// conic[2] is the equation of the conic f passing through the five points
    20982098   conic[2];
    2099 // conic[3] is a list containing the equations of the tangents 
     2099// conic[3] is a list containing the equations of the tangents
    21002100//          through the five points
    21012101   conic[3];
    21022102// conic[4] is an ideal representing the tropicalisation of the conic f
    21032103   conic[4];
    2104 // conic[5] is a list containing the tropicalisation 
     2104// conic[5] is a list containing the tropicalisation
    21052105//          of the five tangents in conic[3]
    21062106   conic[5];
    2107 // conic[6] is a list containing the vertices of the tropical conic 
     2107// conic[6] is a list containing the vertices of the tropical conic
    21082108   conic[6];
    21092109// conic[7] is a list containing the vertices of the five tangents
    21102110   conic[7];
    2111 // conic[8] contains the latex code to draw the tropical conic and 
    2112 //          its tropicalised tangents; it can written in a file, processed and 
    2113 //          displayed via kghostview 
    2114    write(":w /tmp/conic.tex",conic[8]);   
    2115    system("sh","cd /tmp; latex /tmp/conic.tex; dvips /tmp/conic.dvi -o; 
     2111// conic[8] contains the latex code to draw the tropical conic and
     2112//          its tropicalised tangents; it can written in a file, processed and
     2113//          displayed via kghostview
     2114   write(":w /tmp/conic.tex",conic[8]);
     2115   system("sh","cd /tmp; latex /tmp/conic.tex; dvips /tmp/conic.dvi -o;
    21162116            kghostview conic.ps &");
    2117 // with an optional argument the same information for the dual conic is computed 
     2117// with an optional argument the same information for the dual conic is computed
    21182118//         and saved in conic[9]
    21192119   conic=conicWithTangents(points,1);
    21202120   conic[9][2]; // the equation of the dual conic
    21212121}
    2122  
     2122
    21232123///////////////////////////////////////////////////////////////////////////////
    21242124/// Procedures concerned with tropicalisation
     
    21292129ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n]
    21302130RETURN:      list, the linear forms of the tropicalisation of f
    2131 NOTE:        if # is empty, then the valuation of t will be 1, 
    2132 @*           if # is the string 'max' it will be -1; 
    2133 @*           the latter supposes that we consider the maximum of the 
     2131NOTE:        if # is empty, then the valuation of t will be 1,
     2132@*           if # is the string 'max' it will be -1;
     2133@*           the latter supposes that we consider the maximum of the
    21342134             computed linear forms, the former that we consider their minimum
    21352135EXAMPLE:     example tropicalise;   shows an example"
     
    21542154    {
    21552155      tropicalf[i]=tropicalf[i]+exp[j]*var(j);
    2156     }   
     2156    }
    21572157    f=f-lead(f);
    21582158  }
     
    21942194/////////////////////////////////////////////////////////////////////////
    21952195
    2196 proc tInitialForm (poly f, intvec w) 
     2196proc tInitialForm (poly f, intvec w)
    21972197"USAGE:      tInitialForm(f,w); f a polynomial, w an integer vector
    21982198ASSUME:      f is a polynomial in Q[t,x_1,...,x_n] and w=(w_0,w_1,...,w_n)
    21992199RETURN:      poly, the t-initialform of f(t,x) w.r.t. w evaluated at t=1
    2200 NOTE:        the t-initialform is the sum of the terms with MAXIMAL 
     2200NOTE:        the t-initialform is the sum of the terms with MAXIMAL
    22012201             weighted order w.r.t. w
    22022202EXAMPLE:     example tInitialForm;   shows an example"
     
    22082208  // do the same for the remaining part of f and compare the results
    22092209  // keep only the smallest ones
    2210   int vglgewicht; 
    2211   f=f-lead(f); 
     2210  int vglgewicht;
     2211  f=f-lead(f);
    22122212  while (f!=0)
    22132213  {
     
    22242224        initialf=initialf+lead(f);
    22252225      }
    2226     }   
     2226    }
    22272227    f=f-lead(f);
    22282228  }
     
    22442244proc tInitialIdeal (ideal i,intvec w,list #)
    22452245"USAGE:      tInitialIdeal(i,w); i ideal, w intvec
    2246 ASSUME:      i is an ideal in Q[t,x_1,...,x_n] and w=(w_0,...,w_n) 
     2246ASSUME:      i is an ideal in Q[t,x_1,...,x_n] and w=(w_0,...,w_n)
    22472247RETURN:      ideal ini, the t-initial ideal of i with respect to w"
    22482248{
    22492249  // THE PROCEDURE WILL BE CALLED FROM OTHER PROCEDURES INSIDE THIS LIBRARY;
    2250   // IN THIS CASE THE VARIABLE t WILL INDEED BE THE LAST VARIABLE INSTEAD OF 
     2250  // IN THIS CASE THE VARIABLE t WILL INDEED BE THE LAST VARIABLE INSTEAD OF
    22512251  // THE FIRST,
    22522252  // AND WE THEREFORE HAVE TO MOVE IT BACK TO THE FRONT!
     
    22722272  // ... and compute a standard basis with
    22732273  // respect to the homogenised ordering defined by w. Since the generators
    2274   // of i will be homogeneous it we can instead take the ordering wp 
    2275   // with the weightvector (0,w) replaced by (M,...,M)+(0,w) for some 
    2276   // large M, so that all entries are positive 
    2277   int M=-minInIntvec(w)[1]+1; // find M such that w[j]+M is 
     2274  // of i will be homogeneous it we can instead take the ordering wp
     2275  // with the weightvector (0,w) replaced by (M,...,M)+(0,w) for some
     2276  // large M, so that all entries are positive
     2277  int M=-minInIntvec(w)[1]+1; // find M such that w[j]+M is
    22782278                              // strictly positive for all j
    22792279  intvec whomog=M+1;
     
    22832283  }
    22842284  execute("ring WEIGHTRING=("+charstr(basering)+"),("+varstr(basering)+"),(wp("+string(whomog)+"));");
    2285   // map i to the new ring and compute a GB of i, then dehomogenise i, 
    2286   // so that we can be sure, that the 
     2285  // map i to the new ring and compute a GB of i, then dehomogenise i,
     2286  // so that we can be sure, that the
    22872287  // initial forms of the generators generate the initial ideal
    22882288  ideal i=subst(groebner(imap(HOMOGRING,i)),@s,1);
     
    25382538proc texDrawBasic (list texdraw)
    25392539"USAGE:      texDrawBasic(texdraw); list texdraw
    2540 ASSUME:      texdraw is a list of strings representing texdraw commands 
    2541              (as produced by texDrawTropical) which should be embedded into 
     2540ASSUME:      texdraw is a list of strings representing texdraw commands
     2541             (as produced by texDrawTropical) which should be embedded into
    25422542             a texdraw environment
    25432543RETURN:      string, a texdraw environment enclosing the input
     
    25592559    \\end{texdraw}";
    25602560  return(texdrawtp);
    2561 } 
     2561}
    25622562example
    25632563{
     
    25762576ASSUME:  graph is the output of tropicalCurve
    25772577RETURN:  string, the texdraw code of the tropical plane curve encoded by graph
    2578 NOTE:    - if the list # is non-empty, the first entry should be a string; 
    2579            if this string is 'max', then the tropical curve is considered 
    2580            with respect to the maximum; otherwise the curve is considered 
    2581            with respect to the minimum and the string can be used to insert 
     2578NOTE:    - if the list # is non-empty, the first entry should be a string;
     2579           if this string is 'max', then the tropical curve is considered
     2580           with respect to the maximum; otherwise the curve is considered
     2581           with respect to the minimum and the string can be used to insert
    25822582           further texdraw commands (e.g. to have a lighter image as when called
    2583            from inside conicWithTangents); 
    2584 @*       - the procedure computes a scalefactor for the texdraw command which 
    2585            should help to display the curve in the right way; this may, 
    2586            however, be a bad idea if several texDrawTropical outputs are 
    2587            put together to form one image; the scalefactor can be prescribed 
     2583           from inside conicWithTangents);
     2584@*       - the procedure computes a scalefactor for the texdraw command which
     2585           should help to display the curve in the right way; this may,
     2586           however, be a bad idea if several texDrawTropical outputs are
     2587           put together to form one image; the scalefactor can be prescribed
    25882588           by a second optional entry of type poly
    25892589@*       - the list # is optional and may as well be empty
     
    25912591{
    25922592  int i,j;
    2593   // deal first with the pathological case that 
     2593  // deal first with the pathological case that
    25942594  // the input polynomial was a monomial
    2595   // and does therefore not define a tropical curve, 
    2596   // and check if the Newton polytope is 
     2595  // and does therefore not define a tropical curve,
     2596  // and check if the Newton polytope is
    25972597  // a line segment so that the curve defines a bunch of lines
    25982598  int bunchoflines;
    25992599  // if the boundary of the Newton polytope consists of a single point
    2600   if (size(graph[size(graph)][1])==1) 
     2600  if (size(graph[size(graph)][1])==1)
    26012601  {
    26022602    return(string());
     
    26112611    }
    26122612    // then the Newton polytope is a line segment
    2613     if ((size(graph[size(graph)][1])-size(syz(M)))==1) 
     2613    if ((size(graph[size(graph)][1])-size(syz(M)))==1)
    26142614    {
    26152615      bunchoflines=1;
     
    26182618  // go on with the case that a tropical curve is defined
    26192619  if (size(#)==0)
    2620   {   
     2620  {
    26212621     string texdrawtp="
    26222622
     
    26262626  {
    26272627    if ((#[1]!="max") and (#[1]!=""))
    2628     {     
     2628    {
    26292629      string texdrawtp=#[1];
    26302630    }
     
    26752675  {
    26762676    // if the curve is a bunch of lines no vertex has to be drawn
    2677     if (bunchoflines==0) 
     2677    if (bunchoflines==0)
    26782678    {
    26792679      texdrawtp=texdrawtp+"
     
    26812681    }
    26822682    // draw the bounded edges emerging from the ith vertex
    2683     for (j=1;j<=ncols(graph[i][3]);j++) 
    2684     {
    2685       // don't draw it twice - and if there is only one vertex 
     2683    for (j=1;j<=ncols(graph[i][3]);j++)
     2684    {
     2685      // don't draw it twice - and if there is only one vertex
    26862686      //                       and graph[i][3][1,1] is thus 0, nothing is done
    2687       if (i<graph[i][3][1,j]) 
    2688       {                       
     2687      if (i<graph[i][3][1,j])
     2688      {
    26892689        texdrawtp=texdrawtp+"
    26902690       \\move ("+decimal(graph[i][1]-centerx)+" "+decimal(graph[i][2]-centery)+") \\lvec ("+decimal(graph[graph[i][3][1,j]][1]-centerx)+" "+decimal(graph[graph[i][3][1,j]][2]-centery)+")";
    26912691        // if the multiplicity is more than one, denote it in the picture
    2692         if (graph[i][3][2,j]>1) 
     2692        if (graph[i][3][2,j]>1)
    26932693        {
    26942694          texdrawtp=texdrawtp+"
     
    26992699    // draw the unbounded edges emerging from the ith vertex
    27002700    // they should not be too long
    2701     for (j=1;j<=size(graph[i][4]);j++) 
    2702     {     
     2701    for (j=1;j<=size(graph[i][4]);j++)
     2702    {
    27032703      relxy=shorten(list(decimal(3*graph[i][4][j][1][1]/scalefactor),decimal(3*graph[i][4][j][1][2]/scalefactor),"2.5"));
    27042704      texdrawtp=texdrawtp+"
    27052705       \\move ("+decimal(graph[i][1]-centerx)+" "+decimal(graph[i][2]-centery)+") \\rlvec ("+relxy[1]+" "+relxy[2]+")";
    27062706      // if the multiplicity is more than one, denote it in the picture
    2707       if (graph[i][4][j][2]>1) 
     2707      if (graph[i][4][j][2]>1)
    27082708      {
    27092709        texdrawtp=texdrawtp+"
     
    27832783  poly scalefactor=minOfPolys(list(12/leadcoef(maxx),12/leadcoef(maxy)));
    27842784  if (scalefactor<1)
    2785   {   
     2785  {
    27862786    subdivision=subdivision+"
    27872787       \\relunitscale"+ decimal(scalefactor);
     
    27912791  {
    27922792    subdivision=subdivision+"
    2793         \\move ("+string(boundary[i][1])+" "+string(boundary[i][2])+")       
     2793        \\move ("+string(boundary[i][1])+" "+string(boundary[i][2])+")
    27942794        \\lvec ("+string(boundary[i+1][1])+" "+string(boundary[i+1][2])+")";
    2795   } 
     2795  }
    27962796  subdivision=subdivision+"
    2797         \\move ("+string(boundary[size(boundary)][1])+" "+string(boundary[size(boundary)][2])+")       
     2797        \\move ("+string(boundary[size(boundary)][1])+" "+string(boundary[size(boundary)][2])+")
    27982798        \\lvec ("+string(boundary[1][1])+" "+string(boundary[1][2])+")
    27992799
     
    28022802  {
    28032803    subdivision=subdivision+"
    2804         \\move ("+string(inneredges[i][1][1])+" "+string(inneredges[i][1][2])+")       
     2804        \\move ("+string(inneredges[i][1][1])+" "+string(inneredges[i][1][2])+")
    28052805        \\lvec ("+string(inneredges[i][2][1])+" "+string(inneredges[i][2][2])+")";
    28062806  }
     
    28222822    }
    28232823  }
    2824   // deal with the pathological cases 
     2824  // deal with the pathological cases
    28252825  if (size(boundary)==1) // then the Newton polytope is a point
    28262826  {
     
    28772877  {
    28782878    subdivision=subdivision+"
    2879        \\move ("+string(markings[i][1])+" "+string(markings[i][2])+") 
     2879       \\move ("+string(markings[i][1])+" "+string(markings[i][2])+")
    28802880       \\fcir f:0 r:"+decimal(2/(8*scalefactor),size(string(int(scalefactor)))+1);
    28812881  }
    28822882  // enclose subdivision in the texdraw environment
    2883   string texsubdivision="     
     2883  string texsubdivision="
    28842884    \\begin{texdraw}
    2885        \\drawdim cm  \\relunitscale 1 
     2885       \\drawdim cm  \\relunitscale 1
    28862886       \\linewd 0.05"
    28872887    +subdivision+"
     
    28972897   poly f=x+y+x2y+xy2+1/t*xy;
    28982898   list graph=tropicalCurve(f);
    2899 // compute the texdraw code of the Newton subdivision of the tropical curve 
     2899// compute the texdraw code of the Newton subdivision of the tropical curve
    29002900   texDrawNewtonSubdivision(graph);
    29012901}
     
    29052905proc texDrawTriangulation (list triang,list polygon)
    29062906"USAGE:      texDrawTriangulation(triang,polygon);  triang,polygon list
    2907 ASSUME:      polygon is a list of integer vectors describing the 
     2907ASSUME:      polygon is a list of integer vectors describing the
    29082908             lattice points of a marked polygon;
    2909              triang is a list of integer vectors describing a 
     2909             triang is a list of integer vectors describing a
    29102910             triangulation of the marked polygon
    2911              in the sense that an integer vector of the form (i,j,k) describes 
     2911             in the sense that an integer vector of the form (i,j,k) describes
    29122912             the triangle formed by polygon[i], polygon[j] and polygon[k]
    2913 RETURN:      string, a texdraw code for the triangulation described 
     2913RETURN:      string, a texdraw code for the triangulation described
    29142914                     by triang without the texdraw environment
    29152915EXAMPLE:     example texDrawTriangulation;   shows an example"
     
    29202920   ";
    29212921  int i,j; // indices
    2922   list pairs,markings; // stores edges of the triangulation, respecively 
    2923   // the marked points for each triangle store the edges and marked 
     2922  list pairs,markings; // stores edges of the triangulation, respecively
     2923  // the marked points for each triangle store the edges and marked
    29242924  // points of the triangle
    29252925  for (i=1;i<=size(triang);i++)
     
    29302930    markings[3*i-2]=triang[i][1];
    29312931    markings[3*i-1]=triang[i][2];
    2932     markings[3*i]=triang[i][3];   
     2932    markings[3*i]=triang[i][3];
    29332933  }
    29342934  // delete redundant pairs which occur more than once
     
    29632963  {
    29642964    latex=latex+"
    2965         \\move ("+string(polygon[markings[i]][1])+" "+string(polygon[markings[i]][2])+")       
     2965        \\move ("+string(polygon[markings[i]][1])+" "+string(polygon[markings[i]][2])+")
    29662966        \\fcir f:0 r:0.08";
    29672967  }
     
    29702970  {
    29712971    latex=latex+"
    2972         \\move ("+string(polygon[pairs[i][1]][1])+" "+string(polygon[pairs[i][1]][2])+")       
     2972        \\move ("+string(polygon[pairs[i][1]][1])+" "+string(polygon[pairs[i][1]][2])+")
    29732973        \\lvec ("+string(polygon[pairs[i][2]][1])+" "+string(polygon[pairs[i][2]][2])+")";
    29742974  }
     
    29772977  {
    29782978    latex=latex+"
    2979         \\move ("+string(polygon[i][1])+" "+string(polygon[i][2])+")       
     2979        \\move ("+string(polygon[i][1])+" "+string(polygon[i][2])+")
    29802980        \\fcir f:0.7 r:0.04";
    29812981  }
     
    29862986   "EXAMPLE:";
    29872987   echo=2;
    2988    // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 
     2988   // the lattice polygon spanned by the points (0,0), (3,0) and (0,3)
    29892989   // with all integer points as markings
    29902990   list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),intvec(0,0),
    29912991                intvec(2,1),intvec(0,1),intvec(1,2),intvec(0,2),intvec(0,3);
    2992    // define a triangulation by connecting the only interior point 
     2992   // define a triangulation by connecting the only interior point
    29932993   //        with the vertices
    29942994   list triang=intvec(1,2,5),intvec(1,5,10),intvec(1,2,10);
     
    29982998
    29992999///////////////////////////////////////////////////////////////////////////////
    3000 /// Auxilary Procedures 
     3000/// Auxilary Procedures
    30013001///////////////////////////////////////////////////////////////////////////////
    30023002
     
    30043004"USAGE:  radicalMemberShip (f,i); f poly, i ideal
    30053005RETURN:  int, 1 if f is in the radical of i, 0 else
    3006 EXAMPLE:     example radicalMemberShip;   shows an example" 
     3006EXAMPLE:     example radicalMemberShip;   shows an example"
    30073007{
    30083008  def BASERING=basering;
     
    30443044{
    30453045  // compute first the t-order of the leading coefficient of f (leitkoef[1]) and
    3046   // the rational constant corresponding to this order in leadkoef(f) 
     3046  // the rational constant corresponding to this order in leadkoef(f)
    30473047  // (leitkoef[2])
    30483048  list leitkoef=simplifyToOrder(f);
     
    30543054  // do the same for the remaining part of f and compare the results
    30553055  // keep only the smallest ones
    3056   int vglgewicht; 
    3057   f=f-lead(f); 
     3056  int vglgewicht;
     3057  f=f-lead(f);
    30583058  while (f!=0)
    30593059  {
    3060     leitkoef=simplifyToOrder(f);   
     3060    leitkoef=simplifyToOrder(f);
    30613061    vglgewicht=leitkoef[1]+scalarproduct(w,leadexp(f));
    30623062    if (vglgewicht<gewicht)
     
    30733073        initialf=initialf+koef*leadmonom(f);
    30743074      }
    3075     }   
     3075    }
    30763076    f=f-lead(f);
    30773077  }
     
    30983098{
    30993099  // compute first the t-order of the leading coefficient of f (leitkoef[1]) and
    3100   // the rational constant corresponding to this order in leadkoef(f) 
     3100  // the rational constant corresponding to this order in leadkoef(f)
    31013101  // (leitkoef[2])
    3102   list leitkoef=simplifyToOrder(f); 
     3102  list leitkoef=simplifyToOrder(f);
    31033103  execute("poly koef="+leitkoef[2]+";");
    31043104  // take in lead(f) only the term of lowest t-order and set t=1
     
    31093109  // keep only the largest ones
    31103110  int vglgewicht;
    3111   f=f-lead(f); 
     3111  f=f-lead(f);
    31123112  while (f!=0)
    31133113  {
     
    31273127        initialf=initialf+koef*leadmonom(f);
    31283128      }
    3129     }   
     3129    }
    31303130    f=f-lead(f);
    31313131  }
     
    31463146proc solveTInitialFormPar (ideal i)
    31473147"USAGE:      solveTInitialFormPar(i); i ideal
    3148 ASSUME:      i is a zero-dimensional ideal in Q(t)[x_1,...,x_n] generated 
    3149              by the (1,w)-homogeneous elements for some integer vector w 
     3148ASSUME:      i is a zero-dimensional ideal in Q(t)[x_1,...,x_n] generated
     3149             by the (1,w)-homogeneous elements for some integer vector w
    31503150             - i.e. by the (1,w)-initialforms of polynomials
    31513151RETURN:      none
    3152 NOTE:        the procedure just displays complex approximations 
     3152NOTE:        the procedure just displays complex approximations
    31533153             of the solution set of i
    31543154EXAMPLE:     example solveTInitialFormPar;   shows an example"
     
    31753175/////////////////////////////////////////////////////////////////////////
    31763176
    3177 proc detropicalise (poly p) 
     3177proc detropicalise (poly p)
    31783178"USAGE:   detropicalise(f); f poly
    31793179ASSUME:   f is a linear polynomial with an arbitrary constant term and
    31803180          positive integer coefficients as further coefficients;
    31813181RETURN:   poly, the detropicalisation of (the non-constant part of) f
    3182 NOTE:     the output will be a monomial and the constant coefficient 
     3182NOTE:     the output will be a monomial and the constant coefficient
    31833183          has been ignored
    31843184EXAMPLE:  example detropicalise;   shows an example"
     
    31883188  {
    31893189    if (leadmonom(p)!=1)
    3190     { 
     3190    {
    31913191      dtp=dtp*leadmonom(p)^int(leadcoef(p));
    31923192    }
     
    32413241proc parameterSubstitute (poly f,int N)
    32423242"USAGE:   parameterSubstitute(f,N); f poly, N int
    3243 ASSUME:   f is a polynomial in Q(t)[x_1,...,x_n] describing 
     3243ASSUME:   f is a polynomial in Q(t)[x_1,...,x_n] describing
    32443244          a plane curve over Q(t)
    32453245RETURN:   poly f with t replaced by t^N
     
    32953295   poly f=t2x+1/t*y-1;
    32963296   tropicalSubst(f,2,x,x+t,y,tx+y+t2);
    3297    // The procedure can be used to study the effect of a transformation of 
     3297   // The procedure can be used to study the effect of a transformation of
    32983298   // the form x -> x+t^b, with b a rational number, on the tropicalisation and
    32993299   // the j-invariant of a cubic over the Puiseux series.
    33003300   f=t7*y3+t3*y2+t*(x3+xy2+y+1)+xy;
    3301    // - the j-invariant, and hence its valuation, 
     3301   // - the j-invariant, and hence its valuation,
    33023302   //   does not change under the transformation
    33033303   jInvariant(f,"ord");
    3304    // - b=3/2, then the cycle length of the tropical cubic equals -val(j-inv)   
    3305    list g32=tropicalSubst(f,2,x,x+t3,y,y); 
     3304   // - b=3/2, then the cycle length of the tropical cubic equals -val(j-inv)
     3305   list g32=tropicalSubst(f,2,x,x+t3,y,y);
    33063306   tropicalJInvariant(g32);
    33073307   // - b=1, then it is still true, but only just ...
     
    33163316
    33173317proc randomPoly (int d,int ug, int og, list #)
    3318 "USAGE:      randomPoly(d,ug,og[,#]);   d, ug, og int, # list 
     3318"USAGE:      randomPoly(d,ug,og[,#]);   d, ug, og int, # list
    33193319ASSUME:      the basering has a parameter t
    3320 RETURN:      poly, a polynomial of degree d where the coefficients are 
     3320RETURN:      poly, a polynomial of degree d where the coefficients are
    33213321                   of the form t^j with j a random integer between ug and og
    3322 NOTE:        if an optional argument # is given, then the coefficients are 
    3323              instead either of the form t^j as above or they are zero, 
     3322NOTE:        if an optional argument # is given, then the coefficients are
     3323             instead either of the form t^j as above or they are zero,
    33243324             and this is chosen randomly
    33253325EXAMPLE:     example randomPoly;   shows an example"
     
    33373337  {
    33383338    if (size(#)!=0)
    3339     {     
     3339    {
    33403340      k=random(0,1);
    33413341    }
    33423342    if (k==0)
    3343     {     
     3343    {
    33443344      j=random(ug,og);
    33453345      randomPolynomial=randomPolynomial+t^j*m[i];
     
    33713371RETURN:  none"
    33723372{
    3373   system("sh","cd /tmp; /bin/rm -f tropicalcurve*; /bin/rm -f tropicalnewtonsubdivision*"); 
     3373  system("sh","cd /tmp; /bin/rm -f tropicalcurve*; /bin/rm -f tropicalnewtonsubdivision*");
    33743374}
    33753375
     
    34283428static proc cutdown (ideal jideal,intvec wvec,int dimension,list #)
    34293429"USAGE:      cutdown(i,w,d); i ideal, w intvec, d int, # list
    3430 ASSUME:      i an ideal in Q[t,x_1,...,x_n], (w_1,...,w_n) is in the tropical 
    3431              variety of jideal and d=dim(i)>0, in Q(t)[x]; the optional 
    3432              parameter # can contain the string 'isPrime' to indicate that 
    3433              the input ideal is prime and no minimal associated primes have 
     3430ASSUME:      i an ideal in Q[t,x_1,...,x_n], (w_1,...,w_n) is in the tropical
     3431             variety of jideal and d=dim(i)>0, in Q(t)[x]; the optional
     3432             parameter # can contain the string 'isPrime' to indicate that
     3433             the input ideal is prime and no minimal associated primes have
    34343434             to be computed
    3435 RETURN:      list, the first entry is a ring, namely the basering where some 
    3436                    variables have been eliminated, and the ring contains 
     3435RETURN:      list, the first entry is a ring, namely the basering where some
     3436                   variables have been eliminated, and the ring contains
    34373437                   the ideal i (with the same variables eliminated),
    3438                    the t-initial ideal ini of i (w.r.t. the weight vector 
    3439                    where the entries corresponding to the deleted variables 
    3440                    have been eliminated) and a list repl where for each 
     3438                   the t-initial ideal ini of i (w.r.t. the weight vector
     3439                   where the entries corresponding to the deleted variables
     3440                   have been eliminated) and a list repl where for each
    34413441                   eliminated variable there is one entry, namely a polynomial
    3442                    in the remaining variables and t that explains how 
    3443                    resubstitution of a solution for the new i gives a solution 
     3442                   in the remaining variables and t that explains how
     3443                   resubstitution of a solution for the new i gives a solution
    34443444                   for the old i; the second entry is the weight vector
    3445                    wvec with the components corresponding to the eliminated 
     3445                   wvec with the components corresponding to the eliminated
    34463446                   variables removed
    3447 NOTE:        needs the libraries random.lib and primdec.lib; 
     3447NOTE:        needs the libraries random.lib and primdec.lib;
    34483448             is called from tropicalLifting"
    3449 { 
    3450   // IDEA: i is an ideal of dimension d; we want to cut it with d random linear 
     3449{
     3450  // IDEA: i is an ideal of dimension d; we want to cut it with d random linear
    34513451  //       forms in such a way that the resulting
    34523452  //       ideal is 0-dim and still contains w in the tropical variety
    3453   // NOTE: t is the last variable in the basering 
     3453  // NOTE: t is the last variable in the basering
    34543454  ideal pideal;  //this is the ideal we want to return
    34553455  ideal cutideal;
     
    34693469  for (j1=1;j1<=nvars(basering)-1;j1++)
    34703470  {
    3471     variablen=variablen+var(j1); // read the set of variables 
     3471    variablen=variablen+var(j1); // read the set of variables
    34723472                                 // (needed to make the quotring later)
    3473     product=product*var(j1); // make product of all variables 
     3473    product=product*var(j1); // make product of all variables
    34743474                             // (needed for the initial-monomial-check later
    3475   }   
     3475  }
    34763476  execute("ring QUOTRING=("+charstr(basering)+",t),("+string(variablen)+"),dp;");
    34773477  setring BASERING;
     
    34803480  {
    34813481    setring QUOTRING;
    3482     ideal jideal=imap(BASERING,jideal); 
    3483     list primp=minAssGTZ(jideal); //compute the primary decomposition 
     3482    ideal jideal=imap(BASERING,jideal);
     3483    list primp=minAssGTZ(jideal); //compute the primary decomposition
    34843484    for (j1=1;j1<=size(primp);j1++)
    3485     {     
     3485    {
    34863486      for(j2=1;j2<=size(primp[j1]);j2++)
    34873487      {
    34883488        // clear all denominators
    34893489        primp[j1][j2]=primp[j1][j2]/content(primp[j1][j2]);
    3490       }       
     3490      }
    34913491    }
    34923492    setring BASERING;
    34933493    list primp=imap(QUOTRING,primp);
    34943494    // if i is not primary itself
    3495     // go through the list of min. ass. primes and find the first 
     3495    // go through the list of min. ass. primes and find the first
    34963496    // one which has w in its tropical variety
    3497     if (size(primp)>1) 
     3497    if (size(primp)>1)
    34983498    {
    34993499      j1=1;
     
    35023502        //compute the t-initial of the associated prime
    35033503        // - the last entry 1 only means that t is the last variable in the ring
    3504         primini=tInitialIdeal(primp[j1],wvec,1); 
    3505         // check if it contains a monomial (resp if the product of var 
     3504        primini=tInitialIdeal(primp[j1],wvec,1);
     3505        // check if it contains a monomial (resp if the product of var
    35063506        // is in the radical)
    3507         if (radicalMemberShip(product,primini)==0) 
    3508         { 
     3507        if (radicalMemberShip(product,primini)==0)
     3508        {
    35093509          // if w is in the tropical variety of the prime, we take that
    35103510          jideal=primp[j1];
     
    35133513          setring BASERING;
    35143514          winprim=1; // and stop the checking
    3515         } 
     3515        }
    35163516        j1=j1+1;  //else we look at the next associated prime
    35173517      }
     
    35203520    {
    35213521      jideal=primp[1]; //if i is primary itself we take its prime instead
    3522     } 
     3522    }
    35233523  }
    35243524  // now we start as a first try to intersect with a hyperplane parallel to
    35253525  // coordinate axes, because this would make our further computations
    3526   // a lot easier. 
    3527   // We choose a subset of our n variables of size d=dim(ideal). 
     3526  // a lot easier.
     3527  // We choose a subset of our n variables of size d=dim(ideal).
    35283528  // For each of these
    3529   // variables, we want to fix a value: x_i= a_i*t^-w_i. 
     3529  // variables, we want to fix a value: x_i= a_i*t^-w_i.
    35303530  // This will only work if the
    3531   // projection of the d-dim variety to the other n-d variables 
     3531  // projection of the d-dim variety to the other n-d variables
    35323532  // is the whole n-d plane.
    3533   // Then a general choice for a_i will intersect the variety 
     3533  // Then a general choice for a_i will intersect the variety
    35343534  // in finitely many points.
    3535   // If the projection is not the whole n-d plane, 
     3535  // If the projection is not the whole n-d plane,
    35363536  // then a general choice will not work.
    3537   // We could determine if we picked a good 
     3537  // We could determine if we picked a good
    35383538  // d-subset of variables using elimination
    3539   // (NOTE, there EXIST d variables such that 
     3539  // (NOTE, there EXIST d variables such that
    35403540  // a random choice of a_i's would work!).
    3541   // But since this involves many computations, 
     3541  // But since this involves many computations,
    35423542  // we prefer to choose randomly and just
    3543   // try in the end if our intersected ideal 
    3544   // satisfies our requirements. If this does not 
     3543  // try in the end if our intersected ideal
     3544  // satisfies our requirements. If this does not
    35453545  // work, we give up this try and use our second intersection idea, which
    35463546  // will work for a Zariksi-open subset (i.e. almost always).
    35473547  //
    3548   // As random subset of d variables we choose 
     3548  // As random subset of d variables we choose
    35493549  // those for which the absolute value of the
    3550   // wvec-coordinate is smallest, because this will 
     3550  // wvec-coordinate is smallest, because this will
    35513551  // give us the smallest powers of t and hence
    3552   // less effort in following computations. 
     3552  // less effort in following computations.
    35533553  // Note that the smallest absolute value have those
    3554   // which are biggest, because wvec is negative. 
     3554  // which are biggest, because wvec is negative.
    35553555  //print("first try");
    35563556  intvec wminust=intvecdelete(wvec,1);
     
    35593559  A[1,1..size(wminust)]=-wminust;
    35603560  A[2,1..size(wminust)]=1..size(wminust);
    3561   // sort this matrix in order to get 
     3561  // sort this matrix in order to get
    35623562  // the d biggest entries and their position in wvec
    3563   A=sortintmat(A); 
    3564   // we construct a vector which has 1 at entry j if j belongs to the list 
     3563  A=sortintmat(A);
     3564  // we construct a vector which has 1 at entry j if j belongs to the list
    35653565  // of the d biggest entries of wvec and a 0 else
    35663566  for (j1=1;j1<=nvars(basering)-1;j1++) //go through the variables
     
    35713571      {
    35723572        setvec[j1]=1;//put a 1
    3573       }       
    3574     } 
    3575   }
    3576   // using this 0/1-vector we produce 
    3577   // a random constant (i.e. coeff in Q times something in t) 
    3578   // for each of the biggest variables, 
     3573      }
     3574    }
     3575  }
     3576  // using this 0/1-vector we produce
     3577  // a random constant (i.e. coeff in Q times something in t)
     3578  // for each of the biggest variables,
    35793579  // we add the forms x_i-random constant to the ideal
    3580   // and we save the constant at the i-th place of 
     3580  // and we save the constant at the i-th place of
    35813581  // a list we want to return for later computations
    35823582  j3=0;
     
    35893589    {
    35903590      if(setvec[j1]==1)//if x_i belongs to the biggest variables
    3591       {     
     3591      {
    35923592        if ((j3==1) and ((char(basering)==0) or (char(basering)>3)))
    3593         {       
     3593        {
    35943594          randomp1=random(1,3);
    3595           randomp=t^(A[1,j2])*randomp1;// make a random constant 
     3595          randomp=t^(A[1,j2])*randomp1;// make a random constant
    35963596                                       // --- first we try small numbers
    3597         }   
     3597        }
    35983598        if ((j3==2) and ((char(basering)==0) or (char(basering)>100)))
    35993599        {
    36003600          randomp1=random(1,100);
    3601           randomp=t^(A[1,j2])*randomp1;// make a random constant 
     3601          randomp=t^(A[1,j2])*randomp1;// make a random constant
    36023602                                       // --- next we try bigger numbers
    3603         }   
     3603        }
    36043604        else
    36053605        {
     
    36133613      else
    36143614      {
    3615         ergl[j1]=0; //if the variable is not among the d biggest ones, 
     3615        ergl[j1]=0; //if the variable is not among the d biggest ones,
    36163616                    //save 0 in the list
    36173617        erglini[j1]=0;
    3618       }       
     3618      }
    36193619    }
    36203620      // print(ergl);print(pideal);
    3621       // now we check if we made a good choice of pideal, i.e. if dim=0 and 
     3621      // now we check if we made a good choice of pideal, i.e. if dim=0 and
    36223622      // wvec is still in the tropical variety
    36233623      // change to quotring where we compute dimension
     
    36263626    {
    36273627      if(setvec[j1]==1)
    3628       {     
    3629         cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
    3630       }     
     3628      {
     3629        cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
     3630      }
    36313631    }
    36323632    setring QUOTRING;
     
    36403640    {
    36413641      // compute the t-initial of the associated prime
    3642       // - the last 1 just means that the variable t is 
     3642      // - the last 1 just means that the variable t is
    36433643      //   the last variable in the ring
    36443644      pini=tInitialIdeal(cutideal,wvec ,1);
    36453645      //print("initial");
    36463646      //print(pini);
    3647       // and if the initial w.r.t. t contains no monomial 
     3647      // and if the initial w.r.t. t contains no monomial
    36483648      // as we want (checked with
    36493649      // radical-membership of the product of all variables)
    3650       if (radicalMemberShip(product,pini)==0) 
    3651       {
    3652         // we made the right choice and now 
    3653         // we substitute the variables in the ideal   
     3650      if (radicalMemberShip(product,pini)==0)
     3651      {
     3652        // we made the right choice and now
     3653        // we substitute the variables in the ideal
    36543654        // to get an ideal in less variables
    3655         // also we make a projected vector 
     3655        // also we make a projected vector
    36563656        // from wvec only the components of the remaining variables
    36573657        wvecp=wvec;
    3658         variablen=0;   
     3658        variablen=0;
    36593659        j2=0;
    36603660        for(j1=1;j1<=nvars(basering)-1;j1++)
     
    36693669          else
    36703670          {
    3671             variablen=variablen+var(j1); // read the set of remaining variables 
     3671            variablen=variablen+var(j1); // read the set of remaining variables
    36723672                                         // (needed to make quotring later)
    3673           }   
    3674         }     
     3673          }
     3674        }
    36753675        // return pideal, the initial and the list ergl which tells us
    36763676        // which variables we replaced by which form
     
    36823682        export(ini);
    36833683        export(repl);
    3684         return(list(BASERINGLESS1,wvecp)); 
     3684        return(list(BASERINGLESS1,wvecp));
    36853685      }
    36863686    }
    36873687  }
    36883688  // this is our second try to cut down, which we only use if the first try
    3689   // didn't work out. We intersect with d general hyperplanes 
     3689  // didn't work out. We intersect with d general hyperplanes
    36903690  // (i.e. we don't choose
    36913691  // them to be parallel to coordinate hyperplanes anymore. This works out with
    36923692  // probability 1.
    36933693  //
    3694   // We choose general hyperplanes, i.e. linear forms which involve all x_i. 
    3695   // Each x_i has to be multiplied bz t^(w_i) in order 
    3696   // to get the same weight (namely 0) 
     3694  // We choose general hyperplanes, i.e. linear forms which involve all x_i.
     3695  // Each x_i has to be multiplied bz t^(w_i) in order
     3696  // to get the same weight (namely 0)
    36973697  // for each term. As we cannot have negative exponents, we multiply
    3698   // the whole form by t^minimumw. Notice that then in the first form, 
     3698  // the whole form by t^minimumw. Notice that then in the first form,
    36993699  // there is one term without t- the term of the variable
    37003700  // x_i such that w_i is minimal. That is, we can solve for this variable.
    3701   // In the second form, we can replace that variable, 
    3702   // and divide by t as much as possible. 
    3703   // Then there is again one term wihtout t - 
    3704   // the term of the variable with second least w. 
     3701  // In the second form, we can replace that variable,
     3702  // and divide by t as much as possible.
     3703  // Then there is again one term wihtout t -
     3704  // the term of the variable with second least w.
    37053705  // So we can solve for this one again and also replace it in the first form.
    3706   // Since all our coefficients are chosen randomly, 
    3707   // we can also from the beginning on 
    3708   // choose the set of variables which belong to the d smallest entries of wvec 
    3709   // (t not counting) and pick random forms g_i(t,x') 
    3710   // (where x' is the set of remaining variables) 
    3711   // and set x_i=g_i(t,x'). 
     3706  // Since all our coefficients are chosen randomly,
     3707  // we can also from the beginning on
     3708  // choose the set of variables which belong to the d smallest entries of wvec
     3709  // (t not counting) and pick random forms g_i(t,x')
     3710  // (where x' is the set of remaining variables)
     3711  // and set x_i=g_i(t,x').
    37123712  //
    37133713  // make a matrix with first row wvec (without t) and second row 1..n
    37143714  //print("second try");
    37153715  setring BASERING;
    3716   A[1,1..size(wminust)]=wminust; 
     3716  A[1,1..size(wminust)]=wminust;
    37173717  A[2,1..size(wminust)]=1..size(wminust);
    3718   // sort this matrix in otder to get the d smallest entries 
     3718  // sort this matrix in otder to get the d smallest entries
    37193719  // (without counting the t-entry)
    37203720  A=sortintmat(A);
     
    37223722  setvec=0;
    37233723  setvec[nvars(basering)-1]=0;
    3724   // we construct a vector which has 1 at entry j if j belongs to the list of 
     3724  // we construct a vector which has 1 at entry j if j belongs to the list of
    37253725  // the d smallest entries of wvec and a 0 else
    37263726  for (j1=1;j1<=nvars(basering)-1;j1++) //go through the variables
     
    37423742    {
    37433743      j2=j2+1;
    3744       wvecp=intvecdelete(wvecp,j1+2-j2);// delete the components 
     3744      wvecp=intvecdelete(wvecp,j1+2-j2);// delete the components
    37453745                                        // we substitute from wvec
    37463746    }
    37473747    else
    37483748    {
    3749       variablen=variablen+var(j1); // read the set of remaining variables 
     3749      variablen=variablen+var(j1); // read the set of remaining variables
    37503750                                   // (needed to make the quotring later)
    37513751    }
    3752   } 
     3752  }
    37533753  setring BASERING;
    37543754  execute("ring BASERINGLESS2=("+charstr(BASERING)+"),("+string(variablen)+",t),(dp("+string(ncols(variablen))+"),lp(1));");
    3755   // using the 0/1-vector which tells us which variables belong 
     3755  // using the 0/1-vector which tells us which variables belong
    37563756  // to the set of smallest entries of wvec
    3757   // we construct a set of d random linear 
    3758   // polynomials of the form x_i=g_i(t,x'), 
     3757  // we construct a set of d random linear
     3758  // polynomials of the form x_i=g_i(t,x'),
    37593759  // where the set of all x_i is the set of
    3760   // all variables which are in the list of smallest 
     3760  // all variables which are in the list of smallest
    37613761  // entries in wvec, and x' are the other variables.
    3762   // We add these d random linear polynomials to 
    3763   // the ideal pideal, i.e. we intersect 
     3762  // We add these d random linear polynomials to
     3763  // the ideal pideal, i.e. we intersect
    37643764  // with these and hope to get something
    3765   // 0-dim which still contains wvec in its 
    3766   // tropical variety. Also, we produce a list ergl 
     3765  // 0-dim which still contains wvec in its
     3766  // tropical variety. Also, we produce a list ergl
    37673767  // with g_i at the i-th position.
    37683768  // This is a list we want to return.
     
    37703770  setring BASERING;
    37713771  pideal=jideal;
    3772   for(j1=1;j1<=dimension;j1++)//go through the list of variables 
     3772  for(j1=1;j1<=dimension;j1++)//go through the list of variables
    37733773  { // corres to the d smallest in wvec
    37743774    if ((char(basering)==0) or (char(basering)>3))
    3775     { 
     3775    {
    37763776      randomp1=random(1,3);
    37773777      randomp=randomp1*t^(-A[1,j1]);
     
    37863786      if(setvec[j2]==0)//if x_j belongs to the set x'
    37873787      {
    3788         // add a random term with the suitable power 
     3788        // add a random term with the suitable power
    37893789        // of t to the random linear form
    37903790        if ((char(basering)==0) or (char(basering)>3))
     
    38113811    }
    38123812  //print(ergl);
    3813   // Again, we have to test if we made a good choice 
    3814   // to intersect,i.e. we have to check whether 
     3813  // Again, we have to test if we made a good choice
     3814  // to intersect,i.e. we have to check whether
    38153815  // pideal is 0-dim and contains wvec in the tropical variety.
    38163816  cutideal=pideal;
     
    38193819    if(setvec[j1]==1)
    38203820    {
    3821       cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
    3822     }   
     3821      cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
     3822    }
    38233823  }
    38243824  setring QUOTRING;
     
    38323832  {
    38333833    // compute the t-initial of the associated prime
    3834     // - the last 1 just means that the variable t 
     3834    // - the last 1 just means that the variable t
    38353835    // is the last variable in the ring
    38363836    pini=tInitialIdeal(cutideal,wvec ,1);
     
    38393839    // and if the initial w.r.t. t contains no monomial as we want (checked with
    38403840    // radical-membership of the product of all variables)
    3841     if (radicalMemberShip(product,pini)==0) 
     3841    if (radicalMemberShip(product,pini)==0)
    38423842    {
    38433843      // we want to replace the variables x_i by the forms -g_i in
    3844       // our ideal in order to return an ideal with less variables 
     3844      // our ideal in order to return an ideal with less variables
    38453845      // first we substitute the chosen variables
    38463846      for(j1=1;j1<=nvars(basering)-1;j1++)
     
    38593859      export(ini);
    38603860      export(repl);
    3861       return(list(BASERINGLESS2,wvecp)); 
     3861      return(list(BASERINGLESS2,wvecp));
    38623862    }
    38633863  }
    38643864  // now we try bigger numbers
    3865   while (1) //a never-ending loop which will stop with prob. 1 
     3865  while (1) //a never-ending loop which will stop with prob. 1
    38663866  { // as we find a suitable ideal with that prob
    38673867    setring BASERING;
    38683868    pideal=jideal;
    3869     for(j1=1;j1<=dimension;j1++)//go through the list of variables 
     3869    for(j1=1;j1<=dimension;j1++)//go through the list of variables
    38703870    { // corres to the d smallest in wvec
    38713871      randomp1=random(1,100);
    38723872      randomp=randomp1*t^(-A[1,j1]);
    38733873      for(j2=1;j2<=nvars(basering)-1;j2++)//go through all variables
    3874       { 
     3874      {
    38753875        if(setvec[j2]==0)//if x_j belongs to the set x'
    38763876        {
    3877           // add a random term with the suitable power 
     3877          // add a random term with the suitable power
    38783878          // of t to the random linear form
    38793879          if ((char(basering)==0) or (char(basering)>100))
    3880           { 
     3880          {
    38813881            randomp2=random(1,100);
    38823882            randomp1=randomp1+randomp2*var(j2);
     
    38993899      }
    39003900    //print(ergl);
    3901     // Again, we have to test if we made a good choice to 
    3902     // intersect,i.e. we have to check whether 
     3901    // Again, we have to test if we made a good choice to
     3902    // intersect,i.e. we have to check whether
    39033903    // pideal is 0-dim and contains wvec in the tropical variety.
    39043904    cutideal=pideal;
     
    39073907      if(setvec[j1]==1)
    39083908      {
    3909         cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
    3910       }     
     3909        cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
     3910      }
    39113911    }
    39123912    setring QUOTRING;
     
    39163916    //print(dimp);
    39173917    kill cutideal;
    3918     setring BASERING; 
     3918    setring BASERING;
    39193919    if (dimp==0) // if it is 0 as we want
    39203920    {
    39213921      // compute the t-initial of the associated prime
    3922       // - the last 1 just means that the variable t 
     3922      // - the last 1 just means that the variable t
    39233923      // is the last variable in the ring
    39243924      pini=tInitialIdeal(cutideal,wvec ,1);
    39253925      //print("initial");
    39263926      //print(pini);
    3927       // and if the initial w.r.t. t contains no monomial 
     3927      // and if the initial w.r.t. t contains no monomial
    39283928      // as we want (checked with
    39293929      // radical-membership of the product of all variables)
    3930       if (radicalMemberShip(product,pini)==0) 
     3930      if (radicalMemberShip(product,pini)==0)
    39313931      {
    39323932        // we want to replace the variables x_i by the forms -g_i in
     
    39393939            pideal=subst(pideal,var(j1),ergl[j1]);//substitute it
    39403940            pini=subst(pini,var(j1),erglini[j1]);
    3941           }   
    3942         }   
     3941          }
     3942        }
    39433943        // return pideal and the list ergl which tells us
    39443944        // which variables we replaced by which form
     
    39503950        export(ini);
    39513951        export(repl);
    3952         return(list(BASERINGLESS2,wvecp)); 
     3952        return(list(BASERINGLESS2,wvecp));
    39533953      }
    39543954    }
     
    39613961static proc tropicalparametriseNoabs (ideal i,intvec ww,int ordnung,int gfanold,int nogfan,list #)
    39623962"USAGE:  tropicalparametriseNoabs(i,tw,ord,gf,ng[,#]); i ideal, tw intvec, ord int, gf,ng int, # opt. list
    3963 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], 
    3964            tw=(w_0,w_1,...,w_n,0,...,0) and (w_0,...,w_n,0,...,0) is in 
    3965            the tropical variety of i, and ord is the order up to which a point 
    3966            in V(i) over C((t)) lying over w shall be computed; 
     3963ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k],
     3964           tw=(w_0,w_1,...,w_n,0,...,0) and (w_0,...,w_n,0,...,0) is in
     3965           the tropical variety of i, and ord is the order up to which a point
     3966           in V(i) over C((t)) lying over w shall be computed;
    39673967         - moreover, k should be zero if the procedure is not called recursively;
    3968          - the point in the tropical variety is supposed to lie in the NEGATIVE 
     3968         - the point in the tropical variety is supposed to lie in the NEGATIVE
    39693969           orthant;
    3970          - the ideal is zero-dimensional when considered 
     3970         - the ideal is zero-dimensional when considered
    39713971           in (Q(t)[X_1,...,X_k]/m)[x_1,...,x_n],
    3972            where m=#[2] is a maximal ideal in Q(t)[X_1,...,X_k]; 
     3972           where m=#[2] is a maximal ideal in Q(t)[X_1,...,X_k];
    39733973         - gf is 0 if version 2.2 or larger is used and it is 1 else
    3974          - ng is 1 if gfan should not be executed 
     3974         - ng is 1 if gfan should not be executed
    39753975RETURN:  list, l[1] = ring Q(0,X_1,...,X_r)[[t]]
    39763976               l[2] = int
    39773977               l[3] = string
    39783978NOTE:    - the procedure is also called recursively by itself, and
    3979            if it is called in the first recursion, the list # is empty, 
    3980            otherwise #[1] is an integer, one more than the number 
     3979           if it is called in the first recursion, the list # is empty,
     3980           otherwise #[1] is an integer, one more than the number
    39813981           of true variables x_1,...,x_n,
    39823982           and #[2] will contain the maximal ideal m in the variables X_1,...X_k
     
    39843984           work correctly in K[t,x_1,...,x_n] where K=Q[X_1,...,X_k]/m is a field
    39853985           extension of Q;
    3986          - the ring l[1] contains an ideal PARA, which contains the 
    3987            parametrisation of a point in V(i) lying over w up to the 
     3986         - the ring l[1] contains an ideal PARA, which contains the
     3987           parametrisation of a point in V(i) lying over w up to the
    39883988           first ord terms;
    3989          - the string m=l[3] contains the code of the maximal ideal m, 
    3990            by which we have to divide Q[X_1,...,X_r] in order to have 
     3989         - the string m=l[3] contains the code of the maximal ideal m,
     3990           by which we have to divide Q[X_1,...,X_r] in order to have
    39913991           the appropriate field extension over which the parametrisation lives;
    3992          - and if the integer l[2] is N then t has to be replaced by t^1/N in 
    3993            the parametrisation, or alternatively replace t by t^N in the 
     3992         - and if the integer l[2] is N then t has to be replaced by t^1/N in
     3993           the parametrisation, or alternatively replace t by t^N in the
    39943994           defining ideal
    3995          - the procedure REQUIRES that the program GFAN is installed on 
     3995         - the procedure REQUIRES that the program GFAN is installed on
    39963996           your computer"
    39973997{
     
    40014001  if (size(#)==2) // this means the precedure has been called recursively
    40024002  {
    4003     // how many variables are true variables, and how many come 
     4003    // how many variables are true variables, and how many come
    40044004    // from the field extension
    40054005    // only true variables have to be transformed
     
    40074007    ideal gesamt_m=std(#[2]); // stores all maxideals used for field extensions
    40084008    // find the zeros of the w-initial ideal and transform the ideal i;
    4009     // findzeros and basictransformideal need to know how 
     4009    // findzeros and basictransformideal need to know how
    40104010    // many of the variables are true variables
    40114011    list m_ring=findzeros(i,ww,anzahlvariablen);
     
    40144014  else // the procedure has been called by tropicalLifting
    40154015  {
    4016     // how many variables are true variables, and how many come from 
     4016    // how many variables are true variables, and how many come from
    40174017    // the field extension only true variables have to be transformed
    40184018    int anzahlvariablen=nvars(basering);
     
    40214021    ideal ini=#[1];
    40224022    // find the zeros of the w-initial ideal and transform the ideal i;
    4023     // we should hand the t-initial ideal ine to findzeros, 
     4023    // we should hand the t-initial ideal ine to findzeros,
    40244024    // since we know it already
    40254025    list m_ring=findzeros(i,ww,ini);
     
    40434043    list a=btr[2];
    40444044    ideal m=btr[3];
    4045     gesamt_m=gesamt_m+m; // add the newly found maximal 
     4045    gesamt_m=gesamt_m+m; // add the newly found maximal
    40464046                         // ideal to the previous ones
    40474047  }
    40484048  // check if there is a solution which has the n-th component zero,
    4049   // if so, then eliminate the n-th variable from sat(i+x_n,t), 
     4049  // if so, then eliminate the n-th variable from sat(i+x_n,t),
    40504050  // otherwise leave i as it is;
    4051   // then check if the (remaining) ideal has as solution 
     4051  // then check if the (remaining) ideal has as solution
    40524052  // where the n-1st component is zero,
    40534053  // and procede as before; do the same for the remaining variables;
    4054   // this way we make sure that the remaining ideal has 
     4054  // this way we make sure that the remaining ideal has
    40554055  // a solution which has no component zero;
    40564056  intvec deletedvariables;    // the jth entry is set 1, if we eliminate x_j
    40574057  int numberdeletedvariables; // the number of eliminated variables
    40584058  ideal variablen;  // will contain the variables which are not eliminated
    4059   intvec tw=ww;     // in case some variables are deleted, 
     4059  intvec tw=ww;     // in case some variables are deleted,
    40604060                    // we have to store the old weight vector
    40614061  deletedvariables[anzahlvariablen]=0;
    4062   ideal I,LI; 
     4062  ideal I,LI;
    40634063  i=i+m; // if a field extension was necessary, then i has to be extended by m
    40644064  for (jj=anzahlvariablen-1;jj>=1;jj--)  // the variable t is the last one !!!
     
    40674067    LI=subst(I,var(nvars(basering)),0);
    40684068    //size(deletedvariables)=anzahlvariablen(before elim.)
    4069     for (kk=1;kk<=size(deletedvariables)-1;kk++) 
     4069    for (kk=1;kk<=size(deletedvariables)-1;kk++)
    40704070    {
    40714071      LI=subst(LI,var(kk),0);
    40724072    }
    4073     if (size(LI)==0) // if no power of t is in lead(I) 
     4073    if (size(LI)==0) // if no power of t is in lead(I)
    40744074    { // (where the X(i) are considered as field elements)
    4075       // get rid of var(jj)   
     4075      // get rid of var(jj)
    40764076      i=eliminate(I,var(jj));
    40774077      deletedvariables[jj]=1;
    4078       anzahlvariablen--; // if a variable is eliminated, 
     4078      anzahlvariablen--; // if a variable is eliminated,
    40794079                         // then the number of true variables drops
    40804080      numberdeletedvariables++;
     
    40864086  }
    40874087  variablen=invertorder(variablen);
    4088   // store also the additional variables and t, 
     4088  // store also the additional variables and t,
    40894089  // since they for sure have not been eliminated
    40904090  for (jj=anzahlvariablen+numberdeletedvariables-1;jj<=nvars(basering);jj++)
     
    40924092    variablen=variablen+var(jj);
    40934093  }
    4094   // if some variables have been eliminated, 
     4094  // if some variables have been eliminated,
    40954095  // then pass to a new ring which has less variables,
    40964096  // but if no variables are left, then we are done
    40974097  def BASERING=basering;
    4098   if ((numberdeletedvariables>0) and (anzahlvariablen>1)) // if only t remains, 
     4098  if ((numberdeletedvariables>0) and (anzahlvariablen>1)) // if only t remains,
    40994099  { // all true variables are gone
    41004100    execute("ring NEURING=("+charstr(basering)+"),("+string(variablen)+"),(dp("+string(size(variablen)-1)+"),lp(1));");
    41014101    ideal i=imap(BASERING,i);
    4102     ideal gesamt_m=imap(BASERING,gesamt_m);   
    4103   }
    4104   // now we have to compute a point ww on the tropical variety 
     4102    ideal gesamt_m=imap(BASERING,gesamt_m);
     4103  }
     4104  // now we have to compute a point ww on the tropical variety
    41054105  // of the transformed ideal i;
    4106   // of course, we only have to do so, if we have not yet 
     4106  // of course, we only have to do so, if we have not yet
    41074107  // reached the order up to which we
    41084108  // were supposed to do our computations
    4109   if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains, 
     4109  if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains,
    41104110  { // all true variables are gone
    41114111    def PREGFANRING=basering;
    41124112    if (nogfan!=1)
    4113     {     
     4113    {
    41144114      // pass to a ring which has variables which are suitable for gfan
    41154115      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;");
    4116       ideal phiideal=b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z; 
     4116      ideal phiideal=b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
    41174117      phiideal[nvars(PREGFANRING)]=a; // map t to a
    4118       map phi=PREGFANRING,phiideal; 
     4118      map phi=PREGFANRING,phiideal;
    41194119      ideal i=phi(i);
    4120       // homogenise the ideal i with the first not yet 
    4121       // used variable in our ring, since gfan 
    4122       // only handles homogenous ideals; in principle 
     4120      // homogenise the ideal i with the first not yet
     4121      // used variable in our ring, since gfan
     4122      // only handles homogenous ideals; in principle
    41234123      // for this one has first to compute a
    4124       // standard basis of i and homogenise that, 
    4125       // but for the tropical variety (says Anders) 
     4124      // standard basis of i and homogenise that,
     4125      // but for the tropical variety (says Anders)
    41264126      // it suffices to homogenise an arbitrary system of generators
    4127       // i=groebner(i); 
     4127      // i=groebner(i);
    41284128      i=homog(i,maxideal(1)[nvars(PREGFANRING)+1]);
    41294129      // if gfan version >= 0.3.0 is used and the characteristic
     
    41374137        write(":a /tmp/gfaninput","{"+string(i)+"}");
    41384138      }
    4139       else 
     4139      else
    41404140      {
    41414141        // write the ideal to a file which gfan takes as input and call gfan
     
    41584158        string trop=read("/tmp/gfanoutput");
    41594159        setring PREGFANRING;
    4160         intvec wneu=-1;    // this integer vector will store 
     4160        intvec wneu=-1;    // this integer vector will store
    41614161                           // the point on the tropical variety
    41624162        wneu[nvars(basering)]=0;
     
    41714171        "IF YOU WANT wneu TO BE TESTED, THEN SET goon=0;";
    41724172        ~
    4173           // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE 
     4173          // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE
    41744174          // TROPICAL PREVARIETY
    4175           // test, if wneu really is in the tropical variety   
     4175          // test, if wneu really is in the tropical variety
    41764176        while (goon==0)
    41774177        {
     
    41904190      {
    41914191        system("sh","gfan_tropicallifting -n "+string(anzahlvariablen)+" --noMult -c < /tmp/gfaninput > /tmp/gfanoutput");
    4192         // read the result from gfan and store it to a string, 
     4192        // read the result from gfan and store it to a string,
    41934193        // which in a later version
    41944194        // should be interpreded by Singular
     
    42034203    }
    42044204  }
    4205   // if we have not yet computed our parametrisation 
     4205  // if we have not yet computed our parametrisation
    42064206  // up to the required order and
    4207   // zero is not yet a solution, then we have 
     4207  // zero is not yet a solution, then we have
    42084208  // to go on by calling the procedure recursively;
    42094209  // if all variables were deleted, then i=0 and thus anzahlvariablen==0
    42104210  if ((ordnung>1) and (anzahlvariablen>1))
    4211   {   
    4212     // we call the procedure with the transformed ideal i, 
     4211  {
     4212    // we call the procedure with the transformed ideal i,
    42134213    // the new weight vector, with the
    4214     // required order lowered by one, and with 
     4214    // required order lowered by one, and with
    42154215    // additional parameters, namely the number of
    4216     // true variables and the maximal ideal that 
     4216    // true variables and the maximal ideal that
    42174217    // was computed so far to describe the field extension
    42184218    list PARALIST=tropicalparametriseNoabs(i,wneu,ordnung-1,gfanold,nogfan,anzahlvariablen,gesamt_m);
    4219     // the output will be a ring, in which the 
     4219    // the output will be a ring, in which the
    42204220    // parametrisation lives, and a string, which contains
    42214221    // the maximal ideal that describes the necessary field extension
     
    42244224    string PARAm=PARALIST[3];
    42254225    setring PARARing;
    4226     // if some variables have been eliminated in before, 
    4227     // then we have to insert zeros 
     4226    // if some variables have been eliminated in before,
     4227    // then we have to insert zeros
    42284228    // into the parametrisation for those variables
    42294229    if (numberdeletedvariables>0)
     
    42314231      ideal PARAneu=PARA;
    42324232      int k;
    4233       for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++) // t admits 
     4233      for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++) // t admits
    42344234      { // no parametrisation
    42354235        if (deletedvariables[jj]!=1)
     
    42454245    }
    42464246  }
    4247   // otherwise we are done and we can start to compute 
     4247  // otherwise we are done and we can start to compute
    42484248  // the last step of the parametrisation
    42494249  else
     
    42514251    // we store the information on m in a string
    42524252    string PARAm=string(gesamt_m);
    4253     // we define the weight of t, i.e. in the parametrisation t 
     4253    // we define the weight of t, i.e. in the parametrisation t
    42544254    // has to be replaced by t^1/tweight
    42554255    int tweight=-tw[1];
    4256     // if additional variables were necessary, 
     4256    // if additional variables were necessary,
    42574257    // we introduce them now as parameters;
    4258     // in any case the parametrisation ring will 
    4259     // have only one variable, namely t, 
    4260     // and its order will be local, so that it 
     4258    // in any case the parametrisation ring will
     4259    // have only one variable, namely t,
     4260    // and its order will be local, so that it
    42614261    // displays the lowest term in t first
    42624262    if (anzahlvariablen+numberdeletedvariables<nvars(basering))
     
    42694269    }
    42704270    ideal PARA; // will contain the parametrisation
    4271     // we start by initialising the entries to be zero; 
     4271    // we start by initialising the entries to be zero;
    42724272    // one entry for each true variable
    4273     // here we also have to consider the variables 
     4273    // here we also have to consider the variables
    42744274    // that we have eliminated in before
    42754275    for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++)
     
    42784278    }
    42794279  }
    4280   // we now have to change the parametrisation by 
     4280  // we now have to change the parametrisation by
    42814281  // reverting the transformations that we have done
    42824282  list a=imap(BASERING,a);
    4283   if (defined(wneu)==0) // when tropicalparametriseNoabs is called for the 
    4284   { // last time, it does not enter the part, where wneu is defined and the 
     4283  if (defined(wneu)==0) // when tropicalparametriseNoabs is called for the
     4284  { // last time, it does not enter the part, where wneu is defined and the
    42854285    intvec wneu=-1;     // variable t should have weight -1
    42864286  }
     
    42894289    PARA[jj]=(PARA[jj]+a[jj+1])*t^(tw[jj+1]*tweight/ww[1]);
    42904290  }
    4291   // if we have reached the stop-level, i.e. either 
     4291  // if we have reached the stop-level, i.e. either
    42924292  // we had only to compute up to order 1
    4293   // or zero was a solution of the ideal, then we have 
     4293  // or zero was a solution of the ideal, then we have
    42944294  // to export the computed parametrisation
    42954295  // otherwise it has already been exported before
    42964296  // note, if all variables were deleted, then i==0 and thus testaufnull==0
    42974297  if ((ordnung==1) or (anzahlvariablen==1))
    4298   {   
     4298  {
    42994299    export(PARA);
    43004300  }
    43014301  // kill the gfan files in /tmp
    4302   system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput"); 
    4303   // we return a list which contains the 
     4302  system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput");
     4303  // we return a list which contains the
    43044304  // parametrisation ring (with the parametrisation ideal)
    4305   // and the string representing the maximal ideal 
     4305  // and the string representing the maximal ideal
    43064306  // describing the necessary field extension
    43074307  return(list(PARARing,tweight,PARAm));
     
    43124312static proc findzeros (ideal i,intvec w,list #)
    43134313"USAGE:      findzeros(i,w[,#]); i ideal, w intvec, # an optional list
    4314 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_n+1,...,X_m] and 
     4314ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_n+1,...,X_m] and
    43154315             w=(w_0,...,w_n,0,...,0) is in the tropical variety of i
    4316 RETURN:      list, l[1] = is polynomial ring containing an associated maximal 
    4317                           ideal m of the w-initial ideal of i which does not 
     4316RETURN:      list, l[1] = is polynomial ring containing an associated maximal
     4317                          ideal m of the w-initial ideal of i which does not
    43184318                          contain any monomial and where the variables
    4319                           which do not lead to a field extension have already 
    4320                           been eliminated, and containing a list a such that 
    4321                           the non-zero entries of a correspond to the values 
     4319                          which do not lead to a field extension have already
     4320                          been eliminated, and containing a list a such that
     4321                          the non-zero entries of a correspond to the values
    43224322                          of the zero of the associated maximal ideal for the
    43234323                          eliminated variables
    43244324                   l[2] = number of variables which have not been eliminated
    4325                    l[3] = intvec, if the entry is one then the corresponding 
     4325                   l[3] = intvec, if the entry is one then the corresponding
    43264326                                  variable has not been eliminated
    4327 NOTE:        the procedure is called from inside the recursive procedure 
     4327NOTE:        the procedure is called from inside the recursive procedure
    43284328             tropicalparametriseNoabs;
    4329              if it is called in the first recursion, the list #[1] contains 
    4330              the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer, 
     4329             if it is called in the first recursion, the list #[1] contains
     4330             the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer,
    43314331             one more than the number of true variables x_1,...,x_n"
    43324332{
    4333   def BASERING=basering; 
     4333  def BASERING=basering;
    43344334  // set anzahlvariablen to the number of true variables
    43354335  if (typeof(#[1])=="int")
     
    43374337    int anzahlvariablen=#[1];
    43384338    // compute the initial ideal of i
    4339     // - the last 1 just means that the variable t is the last 
     4339    // - the last 1 just means that the variable t is the last
    43404340    //   variable in the ring
    43414341    ideal ini=tInitialIdeal(i,w,1);
     
    43444344  {
    43454345    int anzahlvariablen=nvars(basering);
    4346     ideal ini=#[1]; // the t-initial ideal has been computed 
     4346    ideal ini=#[1]; // the t-initial ideal has been computed
    43474347                    // in before and was handed over
    43484348  }
    4349   // move to a polynomial ring with global monomial ordering 
     4349  // move to a polynomial ring with global monomial ordering
    43504350  // - the variable t is superflous
    43514351  ideal variablen;
    43524352  for (int j=1;j<=nvars(basering)-1;j++)
    4353   {   
     4353  {
    43544354    variablen=variablen+var(j);
    43554355  }
     
    43574357  ideal ini=imap(BASERING,ini);
    43584358  // compute the associated primes of the initialideal
    4359   // ordering the maximal ideals shall help to avoid 
     4359  // ordering the maximal ideals shall help to avoid
    43604360  // unneccessary field extensions
    43614361  list maximalideals=ordermaximalidealsNoabs(minAssGTZ(std(ini)),anzahlvariablen);
    43624362  ideal m=maximalideals[1][1];              // the first associated maximal ideal
    43634363  int neuvar=maximalideals[1][2];           // the number of new variables needed
    4364   intvec neuevariablen=maximalideals[1][3]; // the information which variable 
     4364  intvec neuevariablen=maximalideals[1][3]; // the information which variable
    43654365                                            // leads to a new one
    4366   list a=maximalideals[1][4];               // a_k is the kth component of a 
     4366  list a=maximalideals[1][4];               // a_k is the kth component of a
    43674367                                            // zero of m, if it is not zero
    4368   // eliminate from m the superflous variables, that is those ones, 
     4368  // eliminate from m the superflous variables, that is those ones,
    43694369  // which do not lead to a new variable
    43704370  poly elimvars=1;
     
    43764376    }
    43774377  }
    4378   m=eliminate(m,elimvars); 
    4379   export(a); 
     4378  m=eliminate(m,elimvars);
     4379  export(a);
    43804380  export(m);
    43814381  list m_ring=INITIALRING,neuvar,neuevariablen;
     
    43894389static proc basictransformideal (ideal i,intvec w,list m_ring,list #)
    43904390"USAGE:  basictransformideal(i,w,m_ring[,#]); i ideal, w intvec, m_ring list, # an optional list
    4391 ASSUME:  i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], 
    4392          w=(w_0,...,w_n,0,...,0) is in the tropical variety of i, and 
     4391ASSUME:  i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k],
     4392         w=(w_0,...,w_n,0,...,0) is in the tropical variety of i, and
    43934393         m_ring contains a ring containing a maximal ideal m needed
    4394          to describe the field extension over which a corresponding 
    4395          associated maximal ideal of the initialideal of i, considered 
    4396          in (Q[X_1,...,X_k]/m_alt)(t)[x_1,...,x_n], has a zero, and 
     4394         to describe the field extension over which a corresponding
     4395         associated maximal ideal of the initialideal of i, considered
     4396         in (Q[X_1,...,X_k]/m_alt)(t)[x_1,...,x_n], has a zero, and
    43974397         containing a list a describing the zero of m, and m_ring contains
    43984398         the information how many new variables are needed for m
     
    44014401                      l[3] = ideal, the maximal ideal m
    44024402               or l[1] = ring which contains the ideals i and m, and the list a
    4403 NOTE:    the procedure is called from inside the recursive procedure 
     4403NOTE:    the procedure is called from inside the recursive procedure
    44044404         tropicalparametriseNoabs;
    4405          if it is called in the first recursion, the list # is empty, 
     4405         if it is called in the first recursion, the list # is empty,
    44064406         otherwise #[1] is an integer, the number of true variables x_1,...,x_n;
    4407          during the procedure we check if a field extension is necessary 
    4408          to express a zero (a_1,...,a_n) of m; if so, we have to introduce 
    4409          new variables and a list containing a ring is returned, otherwise 
    4410          the list containing i, a and m is returned; 
    4411          the ideal m will be changed during the procedure since all variables 
     4407         during the procedure we check if a field extension is necessary
     4408         to express a zero (a_1,...,a_n) of m; if so, we have to introduce
     4409         new variables and a list containing a ring is returned, otherwise
     4410         the list containing i, a and m is returned;
     4411         the ideal m will be changed during the procedure since all variables
    44124412         which reduce to a polynomial in X_1,...,X_k modulo m will be eliminated,
    44134413         while the others are replaced by new variables X_k+1,...,X_k'"
     
    44214421    wdegs[j]=deg(i[j],intvec(w[2..size(w)],w[1]));
    44224422  }
    4423   // how many variables are true variables, 
     4423  // how many variables are true variables,
    44244424  // and how many come from the field extension
    44254425  // only real variables have to be transformed
     
    44364436  // get the information if any new variables are needed from m_ring
    44374437  int neuvar=m_ring[2];  // number of variables which have to be added
    4438   intvec neuevariablen=m_ring[3];  // [i]=1, if for the ith comp. 
     4438  intvec neuevariablen=m_ring[3];  // [i]=1, if for the ith comp.
    44394439                                   // of a zero of m a new variable is needed
    44404440  def MRING=m_ring[1];   // MRING contains a and m
    4441   list a=imap(MRING,a);  // (a_1,...,a_n)=(a[2],...,a[n+1]) will be 
     4441  list a=imap(MRING,a);  // (a_1,...,a_n)=(a[2],...,a[n+1]) will be
    44424442                         // a common zero of the ideal m
    4443   ideal m=std(imap(MRING,m)); // m is zero, if neuvar==0, 
     4443  ideal m=std(imap(MRING,m)); // m is zero, if neuvar==0,
    44444444                              // otherwise we change the ring anyway
    4445   // if a field extension is needed, then extend the polynomial 
     4445  // if a field extension is needed, then extend the polynomial
    44464446  // ring by new variables X_k+1,...,X_k';
    44474447  if (neuvar>0)
    44484448  {
    4449     // change to a ring where for each variable needed 
     4449    // change to a ring where for each variable needed
    44504450    // in m a new variable has been introduced
    44514451    ideal variablen;
     
    44584458    // map i into the new ring
    44594459    ideal i=imap(BASERING,i);
    4460     // define a map phi which maps the true variables, which are not 
     4460    // define a map phi which maps the true variables, which are not
    44614461    // reduced to polynomials in the additional variables modulo m, to
    4462     // the corresponding newly introduced variables, and which maps 
     4462    // the corresponding newly introduced variables, and which maps
    44634463    // the old additional variables to themselves
    44644464    ideal phiideal;
    44654465    k=1;
    4466     for (j=2;j<=size(neuevariablen);j++)  // starting with 2, since the 
     4466    for (j=2;j<=size(neuevariablen);j++)  // starting with 2, since the
    44674467    { // first entry corresponds to t
    44684468      if(neuevariablen[j]==1)
     
    44734473      else
    44744474      {
    4475         phiideal[j-1]=0; 
     4475        phiideal[j-1]=0;
    44764476      }
    44774477    }
     
    44804480      phiideal=phiideal,X(1..nvars(BASERING)-anzahlvariablen);
    44814481    }
    4482     map phi=MRING,phiideal; 
    4483     // map m and a to the new ring via phi, so that the true variables 
     4482    map phi=MRING,phiideal;
     4483    // map m and a to the new ring via phi, so that the true variables
    44844484    // in m and a are replaced by
    44854485    // the corresponding newly introduced variables
     
    44874487    list a=phi(a);
    44884488  }
    4489   // replace now the zeros among the a_j by the corresponding 
     4489  // replace now the zeros among the a_j by the corresponding
    44904490  // newly introduced variables;
    4491   // note that no component of a can be zero 
     4491  // note that no component of a can be zero
    44924492  // since the maximal ideal m contains no variable!
    4493   // moreover, substitute right away in the ideal i 
     4493  // moreover, substitute right away in the ideal i
    44944494  // the true variable x_j by (a_j+x_j)*t^w_j
    44954495  zaehler=nvars(BASERING)-anzahlvariablen+1;
    4496   for (j=1;j<=anzahlvariablen;j++) 
     4496  for (j=1;j<=anzahlvariablen;j++)
    44974497  {
    44984498    if ((a[j]==0) and (j!=1))  // a[1]=0, since t->t^w_0
    4499     {       
     4499    {
    45004500      a[j]=X(zaehler);
    45014501      zaehler++;
     
    45044504    {
    45054505      if (j!=1) // corresponds to  x_(j-1) --  note t is the last variable
    4506       {       
     4506      {
    45074507        i[k]=substitute(i[k],var(j-1),(a[j]+var(j-1))*t^(-w[j]));
    45084508      }
     
    45164516  for (j=1;j<=ncols(i);j++)
    45174517  {
    4518     if (wdegs[j]<0) // if wdegs[j]==0 there is no need to divide, and 
     4518    if (wdegs[j]<0) // if wdegs[j]==0 there is no need to divide, and
    45194519    { // we made sure that it is no positive
    45204520      i[j]=i[j]/t^(-wdegs[j]);
    45214521    }
    45224522  }
    4523   // since we want to consider i now in the ring 
     4523  // since we want to consider i now in the ring
    45244524  // (Q[X_1,...,X_k']/m)[t,x_1,...,x_n]
    4525   // we can  reduce i modulo m, so that "constant terms" 
     4525  // we can  reduce i modulo m, so that "constant terms"
    45264526  // which are "zero" since they
    45274527  // are in m will disappear; simplify(...,2) then really removes them
    45284528  i=simplify(reduce(i,m),2);
    4529   // if new variables have been introduced, we have 
     4529  // if new variables have been introduced, we have
    45304530  // to return the ring containing i, a and m
    45314531  // otherwise we can simply return a list containing i, a and m
     
    45484548static proc testw (ideal i,intvec w,int anzahlvariablen,list #)
    45494549"USAGE:      testw(i,w,n); i ideal, w intvec, n number
    4550 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k] and 
    4551              w=(w_0,...,w_n,0,...,0)           
    4552 RETURN:      int b, 0 if the t-initial ideal of i considered in 
     4550ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k] and
     4551             w=(w_0,...,w_n,0,...,0)
     4552RETURN:      int b, 0 if the t-initial ideal of i considered in
    45534553                    Q(X_1,...,X_k)[t,x_1,...,x_n] is monomial free, 1 else
    45544554NOTE:        the procedure is called by tinitialform"
     
    45644564    ideal tin=tInitialIdeal(i,w,1);
    45654565  }
    4566  
     4566
    45674567  int j;
    45684568  ideal variablen;
     
    45964596  def BASERING=basering;
    45974597  if (anzahlvariablen<nvars(basering))
    4598   {   
     4598  {
    45994599    execute("ring TINRING=("+charstr(basering)+","+string(Parameter)+"),("+string(variablen)+"),dp;");
    46004600  }
     
    46064606  poly monom=imap(BASERING,monom);
    46074607  return(radicalMemberShip(monom,tin));
    4608 } 
     4608}
    46094609
    46104610/////////////////////////////////////////////////////////////////////////
     
    46124612static proc simplifyToOrder (poly f)
    46134613"USAGE:      simplifyToOrder(f); f a polynomial
    4614 ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n] 
     4614ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n]
    46154615RETURN:      list, l[1] = t-order of leading term of f
    46164616                   l[2] = the rational coefficient of the term of lowest t-order
     
    46354635static proc scalarproduct (intvec w,intvec v)
    46364636"USAGE:      scalarproduct(w,v); w,v intvec
    4637 ASSUME:      w and v are integer vectors of the same length 
     4637ASSUME:      w and v are integer vectors of the same length
    46384638RETURN:      int, the scalarproduct of v and w
    46394639NOTE:        the procedure is called by tropicalparametriseNoabs"
     
    46934693"USAGE:      ordermaximalidealsNoabs(minassi); minassi list
    46944694ASSUME:      minassi is a list of maximal ideals
    4695 RETURN:      list, the procedure orders the maximal ideals in minassi according 
    4696                    to how many new variables are needed to describe the zeros 
     4695RETURN:      list, the procedure orders the maximal ideals in minassi according
     4696                   to how many new variables are needed to describe the zeros
    46974697                   of the ideal
    46984698                   l[j][1] = jth maximal ideal
    46994699                   l[j][2] = the number of variables needed
    4700                    l[j][3] = intvec, if for the kth variable a new variable is 
    4701                                      needed to define the corresponding zero of 
     4700                   l[j][3] = intvec, if for the kth variable a new variable is
     4701                                     needed to define the corresponding zero of
    47024702                                     l[j][1], then the k+1st entry is one
    4703                    l[j][4] = list, if for the kth variable no new variable is 
    4704                                    needed to define the corresponding zero of 
     4703                   l[j][4] = list, if for the kth variable no new variable is
     4704                                   needed to define the corresponding zero of
    47054705                                   l[j][1], then its value is the k+1st entry
    47064706NOTE:        if a maximal ideal contains a variable, it is removed from the list;
     
    47114711  int pruefer;       // is set one if a maximal ideal contains a variable
    47124712  list minassisort;  // will contain the output
    4713   for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort 
     4713  for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort
    47144714                                                    // to fix its initial length
    47154715  list zwischen;     // needed for reordering
    47164716  list a;// (a_1,...,a_n)=(a[2],...,a[n+1]) will be a common zero of the ideal m
    47174717  poly nf;           // normalform of a variable w.r.t. m
    4718   intvec neuevariablen; // ith entry is 1, if for the ith component of a zero 
     4718  intvec neuevariablen; // ith entry is 1, if for the ith component of a zero
    47194719                        // of m a new variable is needed
    47204720  intvec testvariablen; // integer vector of length n=number of variables
    4721   // compute for each maximal ideal the number of new variables, 
     4721  // compute for each maximal ideal the number of new variables,
    47224722  // which are needed to describe
    4723   // its zeros -- note, a new variable is needed if modulo 
    4724   // the maximal ideal it does not reduce 
     4723  // its zeros -- note, a new variable is needed if modulo
     4724  // the maximal ideal it does not reduce
    47254725  // to something which only depends on the following variables;
    4726   // if no new variable is needed, then store the value 
    4727   // a variable reduces to in the list a; 
     4726  // if no new variable is needed, then store the value
     4727  // a variable reduces to in the list a;
    47284728  for (j=size(minassi);j>=1;j--)
    47294729  {
    4730     a[1]=poly(0);         // the first entry in a and in neuevariablen 
     4730    a[1]=poly(0);         // the first entry in a and in neuevariablen
    47314731                          // corresponds to the variable t,
    47324732    neuevariablen[1]=0;   // which is not present in the INITIALRING
     
    47364736    {
    47374737      nf=reduce(var(k),minassi[j]);
    4738       // if a variable reduces to zero, then the maximal ideal 
     4738      // if a variable reduces to zero, then the maximal ideal
    47394739      // contains a variable and we can delete it
    47404740      if (nf==0)
     
    47424742        pruefer=1;
    47434743      }
    4744       // set the entries of testvariablen corresponding to the first 
     4744      // set the entries of testvariablen corresponding to the first
    47454745      // k variables to 1, and the others to 0
    47464746      for (l=1;l<=nvars(basering);l++)
    47474747      {
    47484748        if (l<=k)
    4749         {         
     4749        {
    47504750          testvariablen[l]=1;
    47514751        }
     
    47554755        }
    47564756      }
    4757       // if the variable x_j reduces to a polynomial 
     4757      // if the variable x_j reduces to a polynomial
    47584758      // in x_j+1,...,x_n,X_1,...,X_k modulo m
    4759       // then we can eliminate x_j from the maximal ideal 
     4759      // then we can eliminate x_j from the maximal ideal
    47604760      // (since we do not need any
    4761       // further field extension to express a_j) and a_j 
     4761      // further field extension to express a_j) and a_j
    47624762      // will just be this normalform,
    47634763      // otherwise we have to introduce a new variable in order to express a_j;
     
    47664766        a[k+1]=nf; // a_k is the normal form of the kth variable modulo m
    47674767        neuevariablen[k+1]=0;  // no new variable is needed
    4768       }   
     4768      }
    47694769      else
    47704770      {
    4771         a[k+1]=poly(0); // a_k is set to zero until we have 
     4771        a[k+1]=poly(0); // a_k is set to zero until we have
    47724772                        // introduced the new variable
    47734773        neuevariablen[k+1]=1;
     
    47774777    // if the maximal ideal contains a variable, we simply delete it
    47784778    if (pruefer==0)
    4779     {     
     4779    {
    47804780      minassisort[j]=list(minassi[j],neuvar,neuevariablen,a);
    47814781    }
    4782     // otherwise we store the information on a, 
     4782    // otherwise we store the information on a,
    47834783    // neuevariablen and neuvar together with the ideal
    47844784    else
     
    47894789    }
    47904790  }
    4791   // sort the maximal ideals ascendingly according to 
     4791  // sort the maximal ideals ascendingly according to
    47924792  // the number of new variables needed to
    47934793  // express the zero of the maximal ideal
     
    47964796    l=j;
    47974797    for (k=j-1;k>=1;k--)
    4798     {     
     4798    {
    47994799      if (minassisort[l][2]<minassisort[k][2])
    48004800      {
     
    48144814"USAGE:  displaypoly(p,N,wj,w1); p poly, N, wj, w1 int
    48154815ASSUME:  p is a polynomial in r=(0,X(1..k)),t,ls
    4816 RETURN:  string, the string of t^-wj/w1*p(t^1/N) 
     4816RETURN:  string, the string of t^-wj/w1*p(t^1/N)
    48174817NOTE:    the procedure is called from displayTropicalLifting"
    48184818{
     
    48324832  {
    48334833    if (koeffizienten[j-ord(p)+1]!=0)
    4834     {     
     4834    {
    48354835      if ((j-(N*wj)/w1)==0)
    48364836      {
     
    48824882static proc displaycoef (poly p)
    48834883"USAGE:      displaycoef(p); p poly
    4884 RETURN:      string, the string of p where brackets around 
     4884RETURN:      string, the string of p where brackets around
    48854885                     have been added if they were missing
    48864886NOTE:        the procedure is called from displaypoly"
     
    49544954static proc tropicalliftingresubstitute (ideal i,list liftring,int N,list #)
    49554955"USAGE:   tropicalliftingresubstitute(i,L,N[,#]); i ideal, L list, N int, # string
    4956 ASSUME:   i is an ideal and L[1] is a ring which contains the lifting of a 
    4957           point in the tropical variety of i computed with tropicalLifting; 
    4958           t has to be replaced by t^1/N in the lifting; #[1]=m is the string 
    4959           of the maximal ideal defining the necessary field extension as 
     4956ASSUME:   i is an ideal and L[1] is a ring which contains the lifting of a
     4957          point in the tropical variety of i computed with tropicalLifting;
     4958          t has to be replaced by t^1/N in the lifting; #[1]=m is the string
     4959          of the maximal ideal defining the necessary field extension as
    49604960          computed by tropicalLifting, if #[1] is present
    49614961RETURN:   string, the lifting has been substituted into i
     
    49804980      ideal i=imap(BASERING,i);
    49814981    }
    4982   } 
     4982  }
    49834983  else
    49844984  {
     
    49934993  }
    49944994  // map the resulting i back to LIFTRing;
    4995   // if noAbs, then reduce i modulo the maximal ideal 
     4995  // if noAbs, then reduce i modulo the maximal ideal
    49964996  // before going back to LIFTRing
    49974997  if ((size(parstr(LIFTRing))!=0) and size(#)>0)
     
    50105010  for (j=1;j<=ncols(i);j++)
    50115011  {
    5012     SUBSTTEST[j]=displaypoly(i[j],N,0,1); 
     5012    SUBSTTEST[j]=displaypoly(i[j],N,0,1);
    50135013  }
    50145014  return(SUBSTTEST);
     
    50205020/// - eliminatecomponents
    50215021/// - findzerosAndBasictransform
    5022 /// - ordermaximalideals 
     5022/// - ordermaximalideals
    50235023///////////////////////////////////////////////////////////////////////////////
    50245024
    50255025static proc tropicalparametrise (ideal i,intvec ww,int ordnung,int gfanold,int findall,int nogfan,list #)
    50265026"USAGE:  tropicalparametrise(i,tw,ord,gf,fa,ng[,#]); i ideal, tw intvec, ord int, gf,fa,ng int, # opt. list
    5027 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,@a], tw=(w_0,w_1,...,w_n,0) 
    5028            and (w_0,...,w_n,0) is in the tropical variety of i, 
    5029            and ord is the order up to which a point in V(i) 
    5030            over K{{t}} lying over w shall be computed; 
    5031          - moreover, @a should be not be there if the procedure is not 
     5027ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,@a], tw=(w_0,w_1,...,w_n,0)
     5028           and (w_0,...,w_n,0) is in the tropical variety of i,
     5029           and ord is the order up to which a point in V(i)
     5030           over K{{t}} lying over w shall be computed;
     5031         - moreover, @a should be not be there if the procedure is not
    50325032           called recursively;
    50335033         - the point in the tropical variety is supposed to lie in the
    50345034           NEGATIVE orthant;
    5035          - the ideal is zero-dimensional when considered in 
    5036            (K(t)[@a]/m)[x_1,...,x_n], where m=#[2] is a maximal ideal in K[@a]; 
     5035         - the ideal is zero-dimensional when considered in
     5036           (K(t)[@a]/m)[x_1,...,x_n], where m=#[2] is a maximal ideal in K[@a];
    50375037         - gf is 0 if version 2.2 or larger is used and it is 1 else
    50385038         - fa is 1 if all solutions should be found
     
    50415041               l[2] = int
    50425042NOTE:    - the procedure is also called recursively by itself, and
    5043            if it is called in the first recursion, the list # is empty, 
    5044            otherwise #[1] is an integer, one more than the number of 
    5045            true variables x_1,...,x_n, and #[2] will contain the maximal 
    5046            ideal m in the variable @a by which the ring K[t,x_1,...,x_n,@a] 
    5047            should be divided to work correctly in L[t,x_1,...,x_n] where 
     5043           if it is called in the first recursion, the list # is empty,
     5044           otherwise #[1] is an integer, one more than the number of
     5045           true variables x_1,...,x_n, and #[2] will contain the maximal
     5046           ideal m in the variable @a by which the ring K[t,x_1,...,x_n,@a]
     5047           should be divided to work correctly in L[t,x_1,...,x_n] where
    50485048           L=Q[@a]/m is a field extension of K
    5049          - the ring l[1] contains an ideal PARA, which contains the 
    5050            parametrisation of a point in V(i) lying over w up to the first 
     5049         - the ring l[1] contains an ideal PARA, which contains the
     5050           parametrisation of a point in V(i) lying over w up to the first
    50515051           ord terms;
    5052          - the string m contains the code of the maximal ideal m, by which we 
     5052         - the string m contains the code of the maximal ideal m, by which we
    50535053           have to divide K[@a] in order to have the appropriate field extension
    50545054           over which the parametrisation lives;
    50555055         - and if the integer l[3] is N then t has to be replaced by t^1/N in the
    5056            parametrisation, or alternatively replace t by t^N in the defining 
     5056           parametrisation, or alternatively replace t by t^N in the defining
    50575057           ideal
    5058          - the procedure REQUIRES that the program GFAN is installed 
     5058         - the procedure REQUIRES that the program GFAN is installed
    50595059           on your computer"
    50605060{
     
    50625062  int recursively; // is set 1 if the procedure is called recursively by itself
    50635063  int ii,jj,kk,ll,jjj,kkk,lll;
    5064   if (typeof(#[1])=="int") // this means the precedure has been 
     5064  if (typeof(#[1])=="int") // this means the precedure has been
    50655065  { // called recursively
    5066     // how many variables are true variables, and how many come 
     5066    // how many variables are true variables, and how many come
    50675067    // from the field extension
    50685068    // only true variables have to be transformed
    50695069    int anzahlvariablen=#[1];
    50705070    // find the zeros of the w-initial ideal and transform the ideal i;
    5071     // findzeros and basictransformideal need to know 
     5071    // findzeros and basictransformideal need to know
    50725072    // how many of the variables are true variables
    50735073    // and do the basic transformation as well
     
    50775077  else // the procedure has been called by tropicalLifting
    50785078  {
    5079     // how many variables are true variables, and 
     5079    // how many variables are true variables, and
    50805080    // how many come from the field extension
    50815081    // only true variables have to be transformed
    50825082    int anzahlvariablen=nvars(basering);
    5083     list zerolist; // will carry the zeros which are 
    5084     //computed in the recursion steps   
     5083    list zerolist; // will carry the zeros which are
     5084    //computed in the recursion steps
    50855085    // the initial ideal of i has been handed over as #[1]
    50865086    ideal ini=#[1];
    50875087    // find the zeros of the w-initial ideal and transform the ideal i;
    5088     // we should hand the t-initial ideal ine to findzeros, 
     5088    // we should hand the t-initial ideal ine to findzeros,
    50895089    // since we know it already;
    50905090    // and do the basic transformation as well
     
    50925092  }
    50935093  list wneulist; // carries all newly computed weight vector
    5094   intvec wneu;   // carries the newly computed weight vector 
     5094  intvec wneu;   // carries the newly computed weight vector
    50955095  int tweight;   // carries the weight of t
    5096   list PARALIST; // carries the result when tropicalparametrise 
     5096  list PARALIST; // carries the result when tropicalparametrise
    50975097                 // is recursively called
    50985098  list eliminaterings;     // carries the result of eliminatecomponents
     
    51035103  list liftings,partliftings;  // the computed liftings (all resp. partly)
    51045104  // consider each ring which has been returned when computing the zeros of the
    5105   // the t-initial ideal, equivalently, consider 
     5105  // the t-initial ideal, equivalently, consider
    51065106  // each zero which has been returned
    51075107  for (jj=1;jj<=size(trring);jj++)
     
    51095109    def TRRING=trring[jj];
    51105110    setring TRRING;
    5111     // check if a certain number of components lead to suitable 
     5111    // check if a certain number of components lead to suitable
    51125112    // solutions with zero components;
    51135113    // compute them all if findall==1
    51145114    eliminaterings=eliminatecomponents(i,m,oldanzahlvariablen,findall,oldanzahlvariablen-1,deletedvariables);
    5115     // consider each of the rings returned by eliminaterings ... 
     5115    // consider each of the rings returned by eliminaterings ...
    51165116    // there is at least one !!!
    51175117    for (ii=1;ii<=size(eliminaterings);ii++)
    51185118    {
    51195119      // #variables which have been eliminated
    5120       numberdeletedvariables=oldanzahlvariablen-eliminaterings[ii][2]; 
     5120      numberdeletedvariables=oldanzahlvariablen-eliminaterings[ii][2];
    51215121      // #true variables which remain (including t)
    5122       anzahlvariablen=eliminaterings[ii][2]; 
     5122      anzahlvariablen=eliminaterings[ii][2];
    51235123      // a 1 in this vector says that variable was eliminated
    5124       deletedvariables=eliminaterings[ii][3]; 
     5124      deletedvariables=eliminaterings[ii][3];
    51255125      setring TRRING; // set TRRING - this is important for the loop
    51265126      // pass the ring computed by eliminatecomponents
    5127       def PREGFANRING=eliminaterings[ii][1]; 
     5127      def PREGFANRING=eliminaterings[ii][1];
    51285128      setring PREGFANRING;
    51295129      poly m=imap(TRRING,m);        // map the maximal ideal to this ring
    51305130      list zero=imap(TRRING,zero);  // map the vector of zeros to this ring
    5131       // now we have to compute a point ww on the tropical 
     5131      // now we have to compute a point ww on the tropical
    51325132      // variety of the transformed ideal i;
    5133       // of course, we only have to do so, if we have 
     5133      // of course, we only have to do so, if we have
    51345134      // not yet reached the order up to which we
    51355135      // were supposed to do our computations
    5136       if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains, 
     5136      if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains,
    51375137      { // all true variables are gone
    51385138        if (nogfan!=1)
    5139         {         
     5139        {
    51405140          // pass to a ring which has variables which are suitable for gfan
    51415141          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;");
    5142           ideal phiideal=b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z; 
     5142          ideal phiideal=b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
    51435143          phiideal[nvars(PREGFANRING)]=a; // map t to a
    5144           map phi=PREGFANRING,phiideal; 
     5144          map phi=PREGFANRING,phiideal;
    51455145          ideal II=phi(i);
    5146           // homogenise the ideal II with the first not yet 
    5147           // used variable in our ring, since gfan 
    5148           // only handles homogenous ideals; in principle for this 
     5146          // homogenise the ideal II with the first not yet
     5147          // used variable in our ring, since gfan
     5148          // only handles homogenous ideals; in principle for this
    51495149          // one has first to compute a
    5150           // standard basis of II and homogenise that, 
    5151           // but for the tropical variety (says Anders) 
     5150          // standard basis of II and homogenise that,
     5151          // but for the tropical variety (says Anders)
    51525152          // it suffices to homogenise an arbitrary system of generators
    5153           // II=groebner(II); 
     5153          // II=groebner(II);
    51545154          II=homog(II,maxideal(1)[nvars(PREGFANRING)+1]);
    51555155          // if gfan version >= 0.3.0 is used and the characteristic
     
    51895189            int goon=1;
    51905190            trop;
    5191             "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY"; 
     5191            "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY";
    51925192            "NON-POSITIVE ENTRIES AND STARTS WITH A NEGATIVE ONE,";
    51935193            "E.G. (-3,-4,-1,-5,0,0,0) - the last entry will always be 0 -";
     
    51965196            "IF YOU WANT wneu TO BE TESTED, THEN SET goon=0;";
    51975197            ~
    5198             // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY 
     5198            // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY
    51995199            // THE TROPICAL PREVARIETY
    5200             // test, if wneu really is in the tropical variety   
     5200            // test, if wneu really is in the tropical variety
    52015201            while (goon==0)
    52025202            {
     
    52165216          {
    52175217            system("sh","gfan_tropicallifting -n "+string(anzahlvariablen)+" --noMult -c < /tmp/gfaninput > /tmp/gfanoutput");
    5218             // read the result from gfan and store it to a string, 
     5218            // read the result from gfan and store it to a string,
    52195219            // which in a later version
    52205220            // should be interpreded by Singular
     
    52395239        }
    52405240      }
    5241       // if we have not yet computed our parametrisation up to 
     5241      // if we have not yet computed our parametrisation up to
    52425242      // the required order and
    5243       // zero is not yet a solution, then we have to go on 
     5243      // zero is not yet a solution, then we have to go on
    52445244      // by calling the procedure recursively;
    52455245      // if all variables were deleted, then i=0 and thus anzahlvariablen==0
    52465246      lll=0;
    52475247      if ((ordnung>1) and (anzahlvariablen>1))
    5248       { 
     5248      {
    52495249        partliftings=list(); // initialise partliftings
    5250         // we call the procedure with the transformed 
     5250        // we call the procedure with the transformed
    52515251        // ideal i, the new weight vector, with the
    5252         // required order lowered by one, and with 
     5252        // required order lowered by one, and with
    52535253        // additional parameters, namely the number of
    5254         // true variables and the maximal ideal that 
     5254        // true variables and the maximal ideal that
    52555255        // was computed so far to describe the field extension
    52565256        for (kk=1;kk<=size(wneulist);kk++)
     
    52585258          wneu=wneulist[kk];
    52595259          PARALIST=tropicalparametrise(i,wneu,ordnung-1,gfanold,findall,nogfan,anzahlvariablen,zero);
    5260           // the output will be a ring, in which the 
     5260          // the output will be a ring, in which the
    52615261          // parametrisation lives, and a string, which contains
    52625262          // the maximal ideal that describes the necessary field extension
    52635263          for (ll=1;ll<=size(PARALIST);ll++)
    5264           { 
     5264          {
    52655265            def PARARing=PARALIST[ll][1];
    52665266            tweight=-ww[1]*PARALIST[ll][2];
    52675267            setring PARARing;
    5268             // if some variables have been eliminated 
    5269             // in before, then we have to insert zeros 
     5268            // if some variables have been eliminated
     5269            // in before, then we have to insert zeros
    52705270            // into the parametrisation for those variables
    52715271            if (numberdeletedvariables>0)
     
    52735273              ideal PARAneu=PARA;
    52745274              kkk=0;
    5275               for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++) 
     5275              for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++)
    52765276              { // t admits no parametrisation
    52775277                if (deletedvariables[jjj]!=1)
     
    52935293        }
    52945294      }
    5295       // otherwise we are done and we can start 
     5295      // otherwise we are done and we can start
    52965296      // to compute the last step of the parametrisation
    52975297      else
    52985298      {
    5299         // we define the weight of t, i.e. in the 
     5299        // we define the weight of t, i.e. in the
    53005300        // parametrisation t has to be replaced by t^1/tweight
    53015301        tweight=-ww[1];
    5302         // if additional variables were necessary, 
     5302        // if additional variables were necessary,
    53035303        // we introduce them now as parameters;
    5304         // in any case the parametrisation ring will 
    5305         // have only one variable, namely t, 
    5306         // and its order will be local, so that it 
     5304        // in any case the parametrisation ring will
     5305        // have only one variable, namely t,
     5306        // and its order will be local, so that it
    53075307        // displays the lowest term in t first
    53085308        if (anzahlvariablen<nvars(basering))
     
    53165316        }
    53175317        ideal PARA; // will contain the parametrisation
    5318         // we start by initialising the entries to be zero; 
     5318        // we start by initialising the entries to be zero;
    53195319        // one entry for each true variable
    5320         // here we also have to consider the variables 
     5320        // here we also have to consider the variables
    53215321        // that we have eliminated in before
    53225322        for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++)
     
    53305330        kill PARARing;
    53315331      }
    5332       // we now have to change the parametrisation by 
     5332      // we now have to change the parametrisation by
    53335333      // reverting the transformations that we have done
    53345334      for (lll=1;lll<=size(partliftings);lll++)
    53355335      {
    5336         if (size(partliftings[lll])==2) // when tropicalparametrise is called 
    5337         { // for the last time, it does not enter the part, where wneu is 
     5336        if (size(partliftings[lll])==2) // when tropicalparametrise is called
     5337        { // for the last time, it does not enter the part, where wneu is
    53385338          wneu=-1;     // defined and the variable t should have weight -1
    53395339        }
     
    53505350          PARA[jjj]=(PARA[jjj]+zeros[size(zeros)][jjj+1])*t^(ww[jjj+1]*tweight/ww[1]);
    53515351        }
    5352         // delete the last entry in zero, since that one has 
     5352        // delete the last entry in zero, since that one has
    53535353        // been used for the transformation
    53545354        zeros=delete(zeros,size(zeros));
    5355         // in order to avoid redefining commands an empty 
     5355        // in order to avoid redefining commands an empty
    53565356        // zeros list should be removed
    53575357        if (size(zeros)==0)
     
    53695369  }
    53705370  // kill the gfan files in /tmp
    5371   system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput"); 
    5372   // we return a list which contains lists of the parametrisation 
     5371  system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput");
     5372  // we return a list which contains lists of the parametrisation
    53735373  // rings (with the parametrisation ideal)
    53745374  // and an integer N such that t should be replaced by t^1/N
     
    53805380static proc eliminatecomponents (ideal i,ideal m,int anzahlvariablen,int findall,int lastvar,intvec deletedvariables)
    53815381"USAGE:  eliminatecomponents(i,m,n,a,v,d); i,m ideal, n,a,v int, d intvec
    5382 ASSUME:  i is an ideal in Q[x_1,...,x_n,@a,t] and w=(-w_1/w_0,...,-w_n/w_0) 
    5383          is in the tropical variety of i considered in 
    5384          Q[@a]/m{{t}}[x_1,...,x_n]; 
    5385          considered in this ring i is zero-dimensional; @a need not be present 
     5382ASSUME:  i is an ideal in Q[x_1,...,x_n,@a,t] and w=(-w_1/w_0,...,-w_n/w_0)
     5383         is in the tropical variety of i considered in
     5384         Q[@a]/m{{t}}[x_1,...,x_n];
     5385         considered in this ring i is zero-dimensional; @a need not be present
    53865386         in which case m is zero; 1<=v<=n
    53875387RETURN:  list, L of lists
     
    53895389               L[j][2] = an integer anzahlvariablen
    53905390               L[j][3] = an intvec deletedvariables
    5391 NOTE:    - the procedure is called from inside the recursive 
     5391NOTE:    - the procedure is called from inside the recursive
    53925392           procedure tropicalparametrise
    5393          - the procedure checks for solutions which have certain 
    5394            components zero; these are separated from the rest by 
    5395            elimination and saturation; the integer deletedvariables 
    5396            records which variables have been eliminated; 
    5397            the integer anzahlvariablen records how many true variables remain 
     5393         - the procedure checks for solutions which have certain
     5394           components zero; these are separated from the rest by
     5395           elimination and saturation; the integer deletedvariables
     5396           records which variables have been eliminated;
     5397           the integer anzahlvariablen records how many true variables remain
    53985398           after the elimination
    5399          - if the integer a is one then all zeros of the ideal i are 
    5400            considered and found, otherwise only one is considered, so that L 
     5399         - if the integer a is one then all zeros of the ideal i are
     5400           considered and found, otherwise only one is considered, so that L
    54015401           has length one"
    54025402{
     
    54065406  // if all solutions have to be found
    54075407  if (findall==1)
    5408   {   
     5408  {
    54095409    list saturatelist,eliminatelist; // carry the solution of the two tests
    5410     // we test first if there is a solution which has the component 
    5411     // lastvar zero and 
     5410    // we test first if there is a solution which has the component
     5411    // lastvar zero and
    54125412    // where the order of each component is strictly positive;
    5413     // if so, we add this variable to the ideal and 
     5413    // if so, we add this variable to the ideal and
    54145414    // eliminate it - which amounts to
    5415     // to projecting the solutions with this component 
     5415    // to projecting the solutions with this component
    54165416    // zero to the hyperplane without this component;
    5417     // for the test we compute the saturation with 
     5417    // for the test we compute the saturation with
    54185418    // respect to t and replace each variable
    5419     // x_i and also t by zero -- if the result is zero, 
    5420     // then 1 is not in I:t^infty 
     5419    // x_i and also t by zero -- if the result is zero,
     5420    // then 1 is not in I:t^infty
    54215421    // (i.e. there is a solution which has the component lastvar zero) and
    5422     // the result lives in the maximal 
    5423     // ideal <t,x_1,...,[no x_lastvar],...,x_n> so that 
     5422    // the result lives in the maximal
     5423    // ideal <t,x_1,...,[no x_lastvar],...,x_n> so that
    54245424    // there is a solution which has strictly positive valuation
    54255425/*
    54265426    // DER NACHFOLGENDE TEIL IST MUELL UND WIRD NICHT MEHR GAMACHT
    5427     // for the test we simply compute the leading ideal 
     5427    // for the test we simply compute the leading ideal
    54285428    // and set all true variables zero;
    5429     // since the ordering was an elimination ordering 
     5429    // since the ordering was an elimination ordering
    54305430    // with respect to (@a if present and) t
    5431     // there remains something not equal to zero 
     5431    // there remains something not equal to zero
    54325432    // if and only if there is polynomial which only
    5433     // depends on t (and @a if present), but that is 
     5433    // depends on t (and @a if present), but that is
    54345434    // a unit in K{{t}}, which would show that there
    54355435    // is no solution with the component lastvar zero;
    5436     // however, we also have to ensure that if there 
     5436    // however, we also have to ensure that if there
    54375437    // exists a solution with the component lastvar
    5438     // equal to zero then this component has a 
     5438    // equal to zero then this component has a
    54395439    // valuation with all strictly positive values!!!!;
    5440     // for this we can either saturate the ideal 
     5440    // for this we can either saturate the ideal
    54415441    // after elimination with respect to <t,x_1,...,x_n>
    5442     // and see if the saturated ideal is contained in <t,x_1,...x_n>+m, 
    5443     // or ALTERNATIVELY we can pass to the 
     5442    // and see if the saturated ideal is contained in <t,x_1,...x_n>+m,
     5443    // or ALTERNATIVELY we can pass to the
    54445444    // ring 0,(t,x_1,...,x_n,@a),(ds(n+1),dp(1)),
    5445     // compute a standard basis of the elimination 
     5445    // compute a standard basis of the elimination
    54465446    // ideal (plus m) there and check if the dimension 1
    5447     // (since we have not omitted the variable lastvar, 
     5447    // (since we have not omitted the variable lastvar,
    54485448    // this means that we have the ideal
    5449     // generated by t,x_1,...,[no x_lastvar],...,x_n 
     5449    // generated by t,x_1,...,[no x_lastvar],...,x_n
    54505450    // and this defines NO curve after omitting x_lastvar)
    54515451    I=std(ideal(var(lastvar)+i));
     
    54535453    LI=lead(reduce(I,std(m)));
    54545454    //size(deletedvariables)=anzahlvariablen(before elimination)
    5455     for (j=1;j<=anzahlvariablen-1;j++) 
     5455    for (j=1;j<=anzahlvariablen-1;j++)
    54565456    {
    54575457      LI=subst(LI,var(j),0);
     
    54595459    if (size(LI)==0) // if no power of t is in lead(I) (where @a is considered as a field element)
    54605460*/
    5461     I=reduce(sat(ideal(var(lastvar)+i),t)[1],std(m)); // get rid of the minimal 
     5461    I=reduce(sat(ideal(var(lastvar)+i),t)[1],std(m)); // get rid of the minimal
    54625462                                                      // polynomial for the test
    54635463    LI=subst(I,var(nvars(basering)),0);
    54645464    //size(deletedvariables)=anzahlvariablen(before elimination)
    5465     for (j=1;j<=anzahlvariablen-1;j++) 
     5465    for (j=1;j<=anzahlvariablen-1;j++)
    54665466    {
    54675467      LI=subst(LI,var(j),0);
    54685468    }
    5469     if (size(LI)==0) // the saturation lives in the maximal 
     5469    if (size(LI)==0) // the saturation lives in the maximal
    54705470    { // ideal generated by t and the x_i
    54715471      // get rid of var(lastvar)
     
    54825482      {
    54835483        string elring="ring ELIMINATERING=("+charstr(basering)+"),("+string(simplify(reduce(maxideal(1),std(var(lastvar))),2))+"),(";
    5484       }   
    5485       if (anzahlvariablen<nvars(basering)) // if @a was present, the 
     5484      }
     5485      if (anzahlvariablen<nvars(basering)) // if @a was present, the
    54865486      { // ordersting needs an additional entry
    54875487        elring=elring+"dp(1),";
    54885488      }
    54895489      elring=elring+"lp(1));";
    5490       execute(elring);     
     5490      execute(elring);
    54915491      ideal i=imap(BASERING,I); // move the ideal I to the new ring
    5492       // if not yet all variables have been checked, 
     5492      // if not yet all variables have been checked,
    54935493      // then go on with the next smaller variable,
    5494       // else prepare the elimination ring and the neccessary 
     5494      // else prepare the elimination ring and the neccessary
    54955495      // information for return
    54965496      if (lastvar>1)
     
    55055505      setring BASERING;
    55065506    }
    5507     // next we have to test if there is also a solution 
     5507    // next we have to test if there is also a solution
    55085508    // which has the variable lastvar non-zero;
    5509     // to do so, we saturate with respect to this variable; 
    5510     // since when considered over K{{t}} 
    5511     // the ideal is zero dimensional, this really removes 
     5509    // to do so, we saturate with respect to this variable;
     5510    // since when considered over K{{t}}
     5511    // the ideal is zero dimensional, this really removes
    55125512    // all solutions with that component zero;
    55135513    // the checking is then done as above
    55145514    i=std(sat(i,var(lastvar))[1]);
    55155515    I=reduce(i,std(m)); // "remove" m from i
    5516     // test first, if i still is in the ideal <t,x_1,...,x_n> -- if not, then 
    5517     // we know that i has no longer a point in the tropical 
     5516    // test first, if i still is in the ideal <t,x_1,...,x_n> -- if not, then
     5517    // we know that i has no longer a point in the tropical
    55185518    // variety with all components negative
    55195519    LI=subst(I,var(nvars(basering)),0);
    5520     for (j=1;j<=anzahlvariablen-1;j++) // set all variables 
     5520    for (j=1;j<=anzahlvariablen-1;j++) // set all variables
    55215521    { // t,x_1,...,x_n equal to zero
    55225522      LI=subst(LI,var(j),0);
    55235523    }
    55245524    if (size(LI)==0) // the entries of i have not constant part
    5525     {     
    5526       // check now, if the leading ideal of i contains an element 
     5525    {
     5526      // check now, if the leading ideal of i contains an element
    55275527      // which only depends on t
    55285528      LI=lead(I);
    55295529      //size(deletedvariables)=anzahlvariablen(before elimination)
    5530       for (j=1;j<=anzahlvariablen-1;j++) 
     5530      for (j=1;j<=anzahlvariablen-1;j++)
    55315531      {
    55325532        LI=subst(LI,var(j),0);
    55335533      }
    5534       if (size(LI)==0) // if no power of t is in lead(i) 
     5534      if (size(LI)==0) // if no power of t is in lead(i)
    55355535      { // (where @a is considered as a field element)
    5536         // if not yet all variables have been tested, go on with the 
     5536        // if not yet all variables have been tested, go on with the
    55375537        // next smaller variable
    55385538        // else prepare the neccessary information for return
     
    55425542        }
    55435543        else
    5544         {   
     5544        {
    55455545          execute("ring SATURATERING=("+charstr(basering)+"),("+varstr(basering)+"),("+ordstr(basering)+");");
    55465546          ideal i=imap(BASERING,i);
     
    55535553    return(eliminatelist+saturatelist);
    55545554  }
    5555   else // only one solution is searched for, we can do a simplified 
     5555  else // only one solution is searched for, we can do a simplified
    55565556  { // version of the above
    5557     // check if there is a solution which has the n-th component 
     5557    // check if there is a solution which has the n-th component
    55585558    // zero and with positive valuation,
    5559     // if so, then eliminate the n-th variable from 
     5559    // if so, then eliminate the n-th variable from
    55605560    // sat(i+x_n,t), otherwise leave i as it is;
    5561     // then check if the (remaining) ideal has as 
     5561    // then check if the (remaining) ideal has as
    55625562    // solution where the n-1st component is zero ...,
    55635563    // and procede as before; do the same for the remaining variables;
    5564     // this way we make sure that the remaining ideal has 
     5564    // this way we make sure that the remaining ideal has
    55655565    // a solution which has no component zero;
    55665566    ideal variablen; // will contain the variables which are not eliminated
     
    55705570      LI=subst(I,var(nvars(basering)),0);
    55715571      //size(deletedvariables)=anzahlvariablen-1(before elimination)
    5572       for (k=1;k<=size(deletedvariables);k++) 
     5572      for (k=1;k<=size(deletedvariables);k++)
    55735573      {
    55745574        LI=subst(LI,var(k),0);
    55755575      }
    5576       if (size(LI)==0) // if no power of t is in lead(I) 
     5576      if (size(LI)==0) // if no power of t is in lead(I)
    55775577      { // (where the X(i) are considered as field elements)
    5578         // get rid of var(j)   
     5578        // get rid of var(j)
    55795579        i=eliminate(I,var(j));
    55805580        deletedvariables[j]=1;
    5581         anzahlvariablen--; // if a variable is eliminated, 
     5581        anzahlvariablen--; // if a variable is eliminated,
    55825582                           // then the number of true variables drops
    55835583      }
     
    55885588    }
    55895589    variablen=invertorder(variablen);
    5590     // store also the additional variable and t, 
     5590    // store also the additional variable and t,
    55915591    // since they for sure have not been eliminated
    55925592    for (j=size(deletedvariables)+1;j<=nvars(basering);j++)
     
    55945594      variablen=variablen+var(j);
    55955595    }
    5596     // if there are variables left, then pass to a ring which 
    5597     // only realises these variables else we are done 
     5596    // if there are variables left, then pass to a ring which
     5597    // only realises these variables else we are done
    55985598    if (anzahlvariablen>1)
    55995599    {
     
    56035603    {
    56045604      string elring="ring ELIMINATERING=("+charstr(basering)+"),("+string(variablen)+"),(";
    5605     }   
    5606     if (size(deletedvariables)+1<nvars(basering)) // if @a was present, 
     5605    }
     5606    if (size(deletedvariables)+1<nvars(basering)) // if @a was present,
    56075607    { // the ordersting needs an additional entry
    56085608      elring=elring+"dp(1),";
    56095609    }
    56105610    elring=elring+"lp(1));";
    5611     execute(elring);     
     5611    execute(elring);
    56125612    ideal i=imap(BASERING,i);
    56135613    ideal m=imap(BASERING,m);
     
    56225622static proc findzerosAndBasictransform (ideal i,intvec w,list zerolist,int findall,list #)
    56235623"USAGE:  findzerosAndBasictransform(i,w,z,f[,#]); i ideal, w intvec, z list, f int,# an optional list
    5624 ASSUME:  i is an ideal in Q[t,x_1,...,x_n,@a] and w=(w_0,...,w_n,0) 
     5624ASSUME:  i is an ideal in Q[t,x_1,...,x_n,@a] and w=(w_0,...,w_n,0)
    56255625         is in the tropical variety of i; @a need not be present;
    56265626         the list 'zero' contains the zeros computed in previous recursion steps;
    5627          if 'f' is one then all zeros should be found and returned, 
     5627         if 'f' is one then all zeros should be found and returned,
    56285628         otherwise only one
    5629 RETURN:  list, each entry is a ring corresponding to one conjugacy class of 
    5630                zeros of the t-initial ideal inside the torus; each of the rings 
     5629RETURN:  list, each entry is a ring corresponding to one conjugacy class of
     5630               zeros of the t-initial ideal inside the torus; each of the rings
    56315631               contains the following objects
    56325632               ideal i    = the ideal i, where the variable @a (if present) has
    5633                             possibly been transformed according to the new 
    5634                             minimal polynomial, and where itself has been 
    5635                             submitted to the basic transform of the algorithm 
     5633                            possibly been transformed according to the new
     5634                            minimal polynomial, and where itself has been
     5635                            submitted to the basic transform of the algorithm
    56365636                            given by the jth zero found for the t-initial ideal;
    5637                             note that the new minimal polynomial has already 
     5637                            note that the new minimal polynomial has already
    56385638                            been added
    5639                poly m     = the new minimal polynomial for @a 
     5639               poly m     = the new minimal polynomial for @a
    56405640                            (it is zero if no @a is present)
    5641                list zero  = zero[k+1] is the kth component of a zero 
     5641               list zero  = zero[k+1] is the kth component of a zero
    56425642                            the t-initial ideal of i
    5643 NOTE:     -  the procedure is called from inside the recursive procedure 
     5643NOTE:     -  the procedure is called from inside the recursive procedure
    56445644             tropicalparametrise;
    5645              if it is called in the first recursion, the list #[1] contains 
    5646              the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer, 
     5645             if it is called in the first recursion, the list #[1] contains
     5646             the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer,
    56475647             one more than the number of true variables x_1,...,x_n
    5648           -  if #[2] is present, then it is an integer which tells whether 
     5648          -  if #[2] is present, then it is an integer which tells whether
    56495649             ALL zeros should be found or not"
    56505650{
     
    56645664    int anzahlvariablen=#[1];
    56655665    // compute the initial ideal of i
    5666     // - the last 1 just means that the variable t is the last 
     5666    // - the last 1 just means that the variable t is the last
    56675667    //   variable in the ring
    56685668    ideal ini=tInitialIdeal(i,w,1);
     
    56725672    int recursive=0;
    56735673    int anzahlvariablen=nvars(basering);
    5674     ideal ini=#[1]; // the t-initial ideal has been computed 
     5674    ideal ini=#[1]; // the t-initial ideal has been computed
    56755675                    // in before and was handed over
    5676   } 
     5676  }
    56775677  // collect the true variables x_1,...,x_n plus @a, if it is defined in BASERING
    56785678  ideal variablen;
    56795679  for (j=1;j<=nvars(basering)-1;j++)
    5680   {   
     5680  {
    56815681    variablen=variablen+var(j);
    56825682  }
    5683   // move to a polynomial ring with global monomial ordering 
     5683  // move to a polynomial ring with global monomial ordering
    56845684  // - the variable t is superflous,
    56855685  // the variable @a is not if it was already present
    56865686  execute("ring INITIALRING=("+charstr(basering)+"),("+string(variablen)+"),dp;");
    56875687  ideal ini=imap(BASERING,ini);
    5688   // compute the minimal associated primes of the 
     5688  // compute the minimal associated primes of the
    56895689  // initialideal over the algebraic closure;
    5690   // ordering the maximal ideals shall help to 
     5690  // ordering the maximal ideals shall help to
    56915691  // avoid unneccessary field extensions
    56925692  list absminass=absPrimdecGTZ(ini);
    5693   def ABSRING=absminass[1]; // the ring in which the minimal 
     5693  def ABSRING=absminass[1]; // the ring in which the minimal
    56945694                            // associated primes live
    56955695  setring ABSRING;
     
    57045704    // check fort the jth maximal ideal a field extension is necessary;
    57055705    // the latter condition says that @a is not in BASERING;
    5706     // if some of the maximal ideals needs a field extension, 
     5706    // if some of the maximal ideals needs a field extension,
    57075707    // then everything will live in this ring
    57085708    if ((maximalideals[j][1]!=0) and (nvars(BASERING)==anzahlvariablen))
    57095709    {
    5710       // define the extension ring which contains 
     5710      // define the extension ring which contains
    57115711      // the new variable @a, if it is not yet present
    57125712      execute("ring EXTENSIONRING=("+charstr(BASERING)+"),("+string(imap(BASERING,variablen))+",@a,"+tvar+"),(dp("+string(anzahlvariablen-1)+"),dp(1),lp(1));");
    5713       // phi maps x_i to x_i, @a to @a (if present in the ring), 
     5713      // phi maps x_i to x_i, @a to @a (if present in the ring),
    57145714      // and the additional variable
    5715       // for the field extension is mapped to @a as well 
     5715      // for the field extension is mapped to @a as well
    57165716      // -- note that we only apply phi
    5717       // to the list a, and in this list no @a is present; 
     5717      // to the list a, and in this list no @a is present;
    57185718      // therefore, it does not matter where this is mapped to
    57195719      map phi=ABSRING,imap(BASERING,variablen),@a;
    57205720    }
    5721     else // @a was already present in the BASERING or no 
     5721    else // @a was already present in the BASERING or no
    57225722    { // field extension is necessary
    57235723      execute("ring EXTENSIONRING=("+charstr(BASERING)+"),("+varstr(BASERING)+"),("+ordstr(BASERING)+");");
    5724       // phi maps x_i to x_i, @a to @a (if present in the ring), 
     5724      // phi maps x_i to x_i, @a to @a (if present in the ring),
    57255725      // and the additional variable
    5726       // for the field extension is mapped to @a as well respectively to 0, 
     5726      // for the field extension is mapped to @a as well respectively to 0,
    57275727      // if no @a is present;
    5728       // note that we only apply phi to the list a and to 
     5728      // note that we only apply phi to the list a and to
    57295729      // the replacement rule for
    5730       // the old variable @a, and in this list resp. 
    5731       // replacement rule no @a is present; 
     5730      // the old variable @a, and in this list resp.
     5731      // replacement rule no @a is present;
    57325732      // therefore, it does not matter where this is mapped to;
    57335733      if (anzahlvariablen<nvars(EXTENSIONRING)) // @a is in EXTENSIONRING
    5734       {     
     5734      {
    57355735        // additional variable is mapped to @a
    5736         map phi=ABSRING,imap(BASERING,variablen),@a; 
     5736        map phi=ABSRING,imap(BASERING,variablen),@a;
    57375737      }
    57385738      else
    57395739      {
    57405740        // additional variable is mapped to 0
    5741         map phi=ABSRING,imap(BASERING,variablen),0; 
     5741        map phi=ABSRING,imap(BASERING,variablen),0;
    57425742      }
    57435743    }
     
    57465746    poly m=maximalideals[j][1];    // extract m
    57475747    list zeroneu=maximalideals[j][2]; // extract the new zero
    5748     poly repl=maximalideals[j][3]; // extract the replacement rule   
    5749     // the list zero may very well exist as an EMPTY global list 
     5748    poly repl=maximalideals[j][3]; // extract the replacement rule
     5749    // the list zero may very well exist as an EMPTY global list
    57505750    // - in this case we have to remove it
    57515751    // in order to avoid a redefining warning
    5752     if (defined(zero)!=0) 
     5752    if (defined(zero)!=0)
    57535753    {
    57545754      if (size(zero)==0)
     
    57615761    {
    57625762      ideal i=imap(BASERING,i);
    5763       if (defined(zerolist)==0) // if zerolist is empty, it does not 
     5763      if (defined(zerolist)==0) // if zerolist is empty, it does not
    57645764      { // depend on BASERING !
    57655765        list zero=imap(BASERING,zerolist);
    57665766      }
    5767       else 
     5767      else
    57685768      {
    57695769        list zero=zerolist;
    57705770      }
    57715771    }
    5772     else // in BASERING was @a present 
     5772    else // in BASERING was @a present
    57735773    {
    57745774      ideal variablen=imap(BASERING,variablen);
    5775       // map i and zerolist to EXTENSIONRING replacing @a 
     5775      // map i and zerolist to EXTENSIONRING replacing @a
    57765776      // by the replacement rule repl
    57775777      map psi=BASERING,variablen[1..size(variablen)-1],repl,var(nvars(basering));
     
    57835783    zero[size(zero)+1]=zeroneu;
    57845784    // do now the basic transformation sending x_l -> t^-w_l*(zero_l+x_l)
    5785     for (l=1;l<=anzahlvariablen;l++) 
     5785    for (l=1;l<=anzahlvariablen;l++)
    57865786    {
    57875787      for (k=1;k<=size(i);k++)
    57885788      {
    57895789        if (l!=1) // corresponds to  x_(l-1) --  note t is the last variable
    5790         {       
     5790        {
    57915791          i[k]=substitute(i[k],var(l-1),(zeroneu[l]+var(l-1))*t^(-w[l]));
    57925792        }
     
    58005800    for (l=1;l<=ncols(i);l++)
    58015801    {
    5802       if (wdegs[l]<0) // if wdegs[l]==0 there is no need to divide, 
     5802      if (wdegs[l]<0) // if wdegs[l]==0 there is no need to divide,
    58035803      { // and we made sure that it is no positive
    58045804        i[l]=i[l]/t^(-wdegs[l]);
     
    58065806    }
    58075807    // since we want to consider i now in the ring (Q[@a]/m)[t,x_1,...,x_n]
    5808     // we can  reduce i modulo m, so that "constant terms" 
     5808    // we can  reduce i modulo m, so that "constant terms"
    58095809    // which are "zero" since they
    58105810    // are in m will disappear; simplify(...,2) then really removes them;
     
    58135813    export(i);
    58145814    export(m);
    5815     export(zero);   
     5815    export(zero);
    58165816    extensionringlist[j]=EXTENSIONRING;
    58175817    kill EXTENSIONRING;
     
    58255825static proc ordermaximalideals (list minassi,int anzahlvariablen)
    58265826"USAGE:      ordermaximalideals(minassi); minassi list
    5827 ASSUME:      minassi is a list of maximal ideals (together with the information 
    5828              how many conjugates it has), where the first polynomial is the 
    5829              minimal polynomial of the last variable in the ring which is 
     5827ASSUME:      minassi is a list of maximal ideals (together with the information
     5828             how many conjugates it has), where the first polynomial is the
     5829             minimal polynomial of the last variable in the ring which is
    58305830             considered as a parameter
    5831 RETURN:      list, the procedure orders the maximal ideals in minassi according 
    5832                    to how many new variables are needed (namely none or one) to 
    5833                    describe the zeros of the ideal, and accordingly to the 
     5831RETURN:      list, the procedure orders the maximal ideals in minassi according
     5832                   to how many new variables are needed (namely none or one) to
     5833                   describe the zeros of the ideal, and accordingly to the
    58345834                   degree of the corresponding minimal polynomial
    58355835                   l[j][1] = the minimal polynomial for the jth maximal ideal
    5836                    l[j][2] = list, the k+1st entry is the kth coordinate of the 
    5837                                    zero described by the maximal ideal in terms 
     5836                   l[j][2] = list, the k+1st entry is the kth coordinate of the
     5837                                   zero described by the maximal ideal in terms
    58385838                                   of the last variable
    5839                    l[j][3] = poly, the replacement for the old variable @a 
     5839                   l[j][3] = poly, the replacement for the old variable @a
    58405840NOTE:        if a maximal ideal contains a variable, it is removed from the list;
    58415841             the procedure is called by findzerosAndBasictransform"
     
    58445844  int pruefer;       // is set one if a maximal ideal contains a variable
    58455845  list minassisort;  // will contain the output
    5846   for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort 
     5846  for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort
    58475847                                                    // to fix its initial length
    58485848  list zwischen;     // needed for reordering
    5849   list zero;         // (a_1,...,a_n)=(zero[2],...,zero[n+1]) will be 
     5849  list zero;         // (a_1,...,a_n)=(zero[2],...,zero[n+1]) will be
    58505850                     // a common zero of the ideal m
    58515851  poly nf;           // normalform of a variable w.r.t. m
    5852   poly minimalpolynomial;  // minimal polynomial for the field extension 
     5852  poly minimalpolynomial;  // minimal polynomial for the field extension
    58535853  poly parrep;  // the old variable @a possibly has to be replaced by a new one
    5854   // compute for each maximal ideal the number of new variables, which are 
    5855   // needed to describe its zeros -- note, a new variable is needed 
     5854  // compute for each maximal ideal the number of new variables, which are
     5855  // needed to describe its zeros -- note, a new variable is needed
    58565856  // if the first entry of minassi[j][1] is not the last variable
    5857   // store the value a variable reduces to in the list a; 
     5857  // store the value a variable reduces to in the list a;
    58585858  for (j=size(minassi);j>=1;j--)
    58595859  {
     
    58635863      minimalpolynomial=0;
    58645864    }
    5865     zero[1]=poly(0);         // the first entry in zero and in 
     5865    zero[1]=poly(0);         // the first entry in zero and in
    58665866                             // neuevariablen corresponds to the variable t,
    58675867    minassi[j][1]=std(minassi[j][1]);
     
    58695869    {
    58705870      // zero_k+1 is the normal form of the kth variable modulo m
    5871       zero[k+1]=reduce(var(k),minassi[j][1]); 
    5872       // if a variable reduces to zero, then the maximal 
     5871      zero[k+1]=reduce(var(k),minassi[j][1]);
     5872      // if a variable reduces to zero, then the maximal
    58735873      // ideal contains a variable and we can delete it
    58745874      if (zero[k+1]==0)
     
    58775877      }
    58785878    }
    5879     // if anzahlvariablen<nvars(basering), then the old ring 
     5879    // if anzahlvariablen<nvars(basering), then the old ring
    58805880    // had already an additional variable;
    58815881    // the old parameter @a then has to be replaced by parrep
     
    58865886    // if the maximal ideal contains a variable, we simply delete it
    58875887    if (pruefer==0)
    5888     {     
     5888    {
    58895889      minassisort[j]=list(minimalpolynomial,zero,parrep);
    58905890    }
    5891     // otherwise we store the information on a, neuevariablen 
     5891    // otherwise we store the information on a, neuevariablen
    58925892    // and neuvar together with the ideal
    58935893    else
     
    58985898    }
    58995899  }
    5900   // sort the maximal ideals ascendingly according to the 
     5900  // sort the maximal ideals ascendingly according to the
    59015901  // number of new variables needed to
    59025902  // express the zero of the maximal ideal
     
    59055905    l=j;
    59065906    for (k=j-1;k>=1;k--)
    5907     {     
     5907    {
    59085908      if (deg(minassisort[l][1])<deg(minassisort[k][1]))
    59095909      {
     
    59405940static proc verticesTropicalCurve (def tp,list #)
    59415941"USAGE:      verticesTropicalCurve(tp[,#]); tp list, # optional list
    5942 ASSUME:      tp is represents an ideal in Z[x,y] representing a tropical 
     5942ASSUME:      tp is represents an ideal in Z[x,y] representing a tropical
    59435943             polynomial (in the form of the output of the procedure tropicalise)
    59445944             defining a tropical plane curve
    5945 RETURN:      list, each entry corresponds to a vertex in the tropical plane 
     5945RETURN:      list, each entry corresponds to a vertex in the tropical plane
    59465946                   curve defined by tp
    59475947                   l[i][1] = x-coordinate of the ith vertex
    59485948                   l[i][2] = y-coordinate of the ith vertex
    5949                    l[i][3] = a polynomial whose monimials mark the vertices in 
    5950                              the Newton polygon corresponding to the entries in 
     5949                   l[i][3] = a polynomial whose monimials mark the vertices in
     5950                             the Newton polygon corresponding to the entries in
    59515951                             tp which take the common minimum at the ith vertex
    59525952NOTE:      - the information in l[i][3] represents the subdivision of the Newton
    5953              polygon of tp (respectively a polynomial which defines tp); 
    5954            - if # is non-empty and #[1] is the string 'max', then in the 
    5955              computations minimum and maximum are exchanged; 
    5956            - if # is non-empty and the #[1] is not a string, only the vertices 
     5953             polygon of tp (respectively a polynomial which defines tp);
     5954           - if # is non-empty and #[1] is the string 'max', then in the
     5955             computations minimum and maximum are exchanged;
     5956           - if # is non-empty and the #[1] is not a string, only the vertices
    59575957             will be computed and the information on the Newton subdivision will
    59585958             be omitted;
    5959            - here the tropical polynomial is supposed to be the MINIMUM of the 
    5960              linear forms in tp, unless the optional input #[1] is the 
     5959           - here the tropical polynomial is supposed to be the MINIMUM of the
     5960             linear forms in tp, unless the optional input #[1] is the
    59615961             string 'max'
    5962            - the procedure is called from tropicalCurve and from 
     5962           - the procedure is called from tropicalCurve and from
    59635963             conicWithTangents"
    59645964{
    5965   // if you insert a single polynomial instead of an ideal representing 
     5965  // if you insert a single polynomial instead of an ideal representing
    59665966  // a tropicalised polynomial,
    5967   // then we compute first the tropicalisation of this polynomial 
     5967  // then we compute first the tropicalisation of this polynomial
    59685968  // -- this feature is not documented in the above help string
    59695969  if (typeof(tp)=="poly")
     
    59745974  }
    59755975  int i,j,k,l,z; // indices
    5976   // make sure that no constant entry of tp has type int since that 
     5976  // make sure that no constant entry of tp has type int since that
    59775977  // would lead to trouble
    59785978  // when using the procedure substitute
     
    59925992  int e=1;
    59935993  option(redSB);
    5994   // for each triple (i,j,k) of entries in tp check if they have a 
    5995   // point in common and if they attain at this point the minimal 
     5994  // for each triple (i,j,k) of entries in tp check if they have a
     5995  // point in common and if they attain at this point the minimal
    59965996  // possible value for all linear forms in tp
    59975997  for (i=1;i<=size(tp)-2;i++)
     
    60466046            e++;
    60476047          }
    6048         }         
     6048        }
    60496049      }
    60506050    }
     
    60696069static proc bunchOfLines (def tp,list #)
    60706070"USAGE:      bunchOfLines(tp[,#]); tp list, # optional list
    6071 ASSUME:      tp is represents an ideal in Q[x,y] representing a tropical 
     6071ASSUME:      tp is represents an ideal in Q[x,y] representing a tropical
    60726072             polynomial (in the form of the output of the procedure tropicalise)
    60736073             defining a bunch of ordinary lines in the plane,
    60746074             i.e. the Newton polygone is a line segment
    6075 RETURN:      list, see the procedure tropicalCurve for an explanation of 
     6075RETURN:      list, see the procedure tropicalCurve for an explanation of
    60766076                   the syntax of this list
    6077 NOTE:      - the tropical curve defined by tp will consist of a bunch of 
    6078              parallel lines and throughout the procedure a list with the 
    6079              name bunchoflines is computed, which represents these lines and 
     6077NOTE:      - the tropical curve defined by tp will consist of a bunch of
     6078             parallel lines and throughout the procedure a list with the
     6079             name bunchoflines is computed, which represents these lines and
    60806080             has the following interpretation:
    6081              list, each entry corresponds to a vertex in the tropical plane 
     6081             list, each entry corresponds to a vertex in the tropical plane
    60826082                   curve defined by tp
    60836083                   l[i][1] = the equation of the ith line in the tropical curve
    6084                    l[i][2] = a polynomial whose monimials mark the vertices in 
    6085                              the Newton polygon corresponding to the entries in 
     6084                   l[i][2] = a polynomial whose monimials mark the vertices in
     6085                             the Newton polygon corresponding to the entries in
    60866086                             tp which take the common minimum at the ith vertex
    60876087           - the information in l[i][2] represents the subdivision of the Newton
    6088              polygon of tp (respectively a polynomial which defines tp); 
    6089            - if # is non-empty and #[1] is the string 'max', then in the 
    6090              computations minimum and maximum are exchanged; 
    6091            - if # is non-empty and the #[1] is not a string, only the vertices 
    6092              will be computed and the information on the Newton subdivision 
     6088             polygon of tp (respectively a polynomial which defines tp);
     6089           - if # is non-empty and #[1] is the string 'max', then in the
     6090             computations minimum and maximum are exchanged;
     6091           - if # is non-empty and the #[1] is not a string, only the vertices
     6092             will be computed and the information on the Newton subdivision
    60936093             will be omitted;
    6094            - here the tropical polynomial is supposed to be the MINIMUM of the 
    6095              linear forms in tp, unless the optional input #[1] is the 
     6094           - here the tropical polynomial is supposed to be the MINIMUM of the
     6095             linear forms in tp, unless the optional input #[1] is the
    60966096             string 'max'
    60976097           - the procedure is called from tropicalCurve"
     
    61106110  intvec direction=leadexp(detropicalise(tp[1]))-leadexp(detropicalise(tp[2]));
    61116111  direction=direction/gcd(direction[1],direction[2]);
    6112   // change the coordinates in such a way, that the Newton polygon 
     6112  // change the coordinates in such a way, that the Newton polygon
    61136113  // lies on the x-axis
    6114   if (direction[1]==0) // there is no x-term - exchange x and y 
     6114  if (direction[1]==0) // there is no x-term - exchange x and y
    61156115  { // and get rid of the new y part
    61166116    for (i=1;i<=size(tp);i++)
     
    61266126    }
    61276127  }
    6128   // For all tuples (i,j) of entries in tp check if they attain 
     6128  // For all tuples (i,j) of entries in tp check if they attain
    61296129  // at their point of intersection
    61306130  // the minimal possible value for all linear forms in tp
     
    61426142      {
    61436143        vergleich=substitute(tp[l],var(1),px);
    6144         if (vergleich==wert) 
     6144        if (vergleich==wert)
    61456145        {
    61466146          newton=newton+detropicalise(oldtp[l]);
     
    61536153        e++;
    61546154      }
    6155     }         
     6155    }
    61566156  }
    61576157  // if a vertex appears several times, only its first occurence will be kept
     
    61606160    for (j=i-1;j>=1;j--)
    61616161    {
    6162       if (bunchoflines[i][1]==bunchoflines[j][1]) 
     6162      if (bunchoflines[i][1]==bunchoflines[j][1])
    61636163      {
    61646164        bunchoflines=delete(bunchoflines,i);
     
    61676167    }
    61686168  }
    6169   // sort the lines in an descending way according to the leading 
     6169  // sort the lines in an descending way according to the leading
    61706170  // exponent of the polynomial
    61716171  // defining the Newton polygone
     
    62026202    xc=substitute(bunchoflines[i][1]-cc,var(2),0,var(1),1);
    62036203    yc=substitute(bunchoflines[i][1]-cc,var(2),1,var(1),0);
    6204         if (xc!=0) // then there is a point on the line with y-coordinate zero
     6204        if (xc!=0) // then there is a point on the line with y-coordinate zero
    62056205    {
    62066206      gr[1]=-cc/leadcoef(xc);
    62076207      gr[2]=0;
    62086208    }
    6209     else // if there is no point with y-coordinate zero, then 
     6209    else // if there is no point with y-coordinate zero, then
    62106210    { // there is point with x-coordinate zero
    62116211      gr[1]=0;
     
    62246224
    62256225static proc clearintmat (intmat vv)
    6226 "USAGE:      clearintmat(vv); vv intmat 
    6227 ASSUME:      all entries of the first column of vv are non-negative, 
     6226"USAGE:      clearintmat(vv); vv intmat
     6227ASSUME:      all entries of the first column of vv are non-negative,
    62286228             not all entries are zero unless vv has only one column
    6229 RETURN:      intmat, vv has been ordered in an ascending way by the entries 
    6230                      of the first row; 
    6231                      if an entry in the first row occurs several times, the 
    6232                      entries in the second row have been added and only one 
     6229RETURN:      intmat, vv has been ordered in an ascending way by the entries
     6230                     of the first row;
     6231                     if an entry in the first row occurs several times, the
     6232                     entries in the second row have been added and only one
    62336233                     row has been kept;
    6234                      colums with a zero in the first row have been removed 
     6234                     colums with a zero in the first row have been removed
    62356235                     unless vv has only one column
    62366236NOTE:        called by tropicalCurve"
     
    62396239  for (int i=ncols(vv)-1;i>=1;i--)
    62406240  {
    6241     if (vv[1,i]==vv[1,i+1]) 
     6241    if (vv[1,i]==vv[1,i+1])
    62426242    {
    62436243      vv[2,i]=vv[2,i]+vv[2,i+1];
     
    62716271        k++;
    62726272      }
    6273       else 
     6273      else
    62746274      {
    62756275        stop=1;
     
    62996299static proc sortintmat (intmat vv)
    63006300"USAGE:      sortintmat(vv); vv intmat
    6301 RETURN:      intmat, the columns of vv have been ordered in an ascending 
     6301RETURN:      intmat, the columns of vv have been ordered in an ascending
    63026302                     way by the first entry
    63036303NOTE:        called by clearintmat"
     
    63536353  {
    63546354    int m=nrows(M);
    6355    
     6355
    63566356  }
    63576357  else
     
    63696369static proc minInIntvec (intvec v)
    63706370"USAGE:      minInIntvec(v); v intvec
    6371 RETURN:      list, first entry is the minimal value in v, second entry 
     6371RETURN:      list, first entry is the minimal value in v, second entry
    63726372                   is its position in v
    63736373NOTE:        called by sortintmat"
     
    64066406static proc sortlist (list v,int pos)
    64076407"USAGE:      sortlist(v,pos); v list, pos int
    6408 RETURN:      list, the list L ordered in an ascending way according 
     6408RETURN:      list, the list L ordered in an ascending way according
    64096409                   to the pos-th entries
    64106410NOTE:        called by tropicalCurve"
     
    64456445static proc vergleiche (poly wert,poly vglwert,list #)
    64466446"USAGE:      vergleiche(wert,vglwert,liste), wert, vglwert poly, liste list
    6447 RETURN:      int, if list contains a string as first entry then 1 
    6448                   is returned if wert is at most vglwert and 0 if wert is 
     6447RETURN:      int, if list contains a string as first entry then 1
     6448                  is returned if wert is at most vglwert and 0 if wert is
    64496449                  larger than vglwert, if liste is anything else 1 is returned if
    64506450                  wert is at least vglwert and 0 if wert s less than vglwert"
     
    64786478static proc koeffizienten (poly f,int k)
    64796479"USAGE:      koeffizienten(f,k)  f poly, k int
    6480 ASSUME:      f=a*x+b*y+c is a linear polynomial in two variables, 
     6480ASSUME:      f=a*x+b*y+c is a linear polynomial in two variables,
    64816481             k is either 0, 1 or 2
    64826482RETURN:      poly, one of the coefficients of f, depending on the value of k:
     
    64916491    return(c);
    64926492  }
    6493   f=f-c; 
     6493  f=f-c;
    64946494  if (k==1)
    64956495  {
    64966496    return(substitute(f,var(1),1,var(2),0));
    6497   }   
     6497  }
    64986498  else
    64996499  {
    65006500    return(substitute(f,var(1),0,var(2),1));
    6501   }   
     6501  }
    65026502}
    65036503
     
    65376537ASSUME:      AA has three entries representing decimal numbers a, b and c
    65386538RETURN:      list, containing strings representing the numbers a and b scaled
    6539                    down so that the absolute maximum of the two is no 
     6539                   down so that the absolute maximum of the two is no
    65406540                   larger than c
    65416541NOTE:        the procedure is called by texDrawTropical"
     
    65906590static proc decimal (poly n,list #)
    65916591"USAGE:      decimal(f[,#]); f poly, # list
    6592 ASSUME:      f is a polynomial in Q[x_1,...,x_n], and # is either empty 
     6592ASSUME:      f is a polynomial in Q[x_1,...,x_n], and # is either empty
    65936593             or #[1] is a positive integer
    6594 RETURN:      string, a decimal expansion of the leading coefficient of f up 
     6594RETURN:      string, a decimal expansion of the leading coefficient of f up
    65956595                     to order two respectively #[1]
    6596 NOTE:        the procedure is called by texDrawTropical and conicWithTangents 
     6596NOTE:        the procedure is called by texDrawTropical and conicWithTangents
    65976597             and f will actually be a number"
    65986598{
     
    66216621      }
    66226622      for (j=i;j<=i+nachkomma;j++)
    6623       {       
     6623      {
    66246624        news=news+s[j];
    66256625      }
     
    66536653  }
    66546654  return(0);
    6655 }     
     6655}
    66566656
    66576657/////////////////////////////////////////////////////////////////////////
     
    66696669  {
    66706670    return("");
    6671    
     6671
    66726672  }
    66736673  if (i==1)
     
    67286728      k=j+2;
    67296729      while (k<=size(F) and ((F[k]=="0") or (F[k]=="1") or (F[k]=="2") or (F[k]=="3") or
    6730                                 (F[k]=="4") or (F[k]=="5") or (F[k]=="6") or (F[k]=="7") or (F[k]=="8") 
     6730                                (F[k]=="4") or (F[k]=="5") or (F[k]=="6") or (F[k]=="7") or (F[k]=="8")
    67316731                             or (F[k]=="9")))
    67326732      {
     
    67426742      k=j+2;
    67436743      while (k<=size(F) and ((F[k]=="0") or (F[k]=="1") or (F[k]=="2") or (F[k]=="3") or
    6744                                 (F[k]=="4") or (F[k]=="5") or (F[k]=="6") or (F[k]=="7") or (F[k]=="8") 
     6744                                (F[k]=="4") or (F[k]=="5") or (F[k]=="6") or (F[k]=="7") or (F[k]=="8")
    67456745                             or (F[k]=="9")))
    67466746      {
     
    67556755      F=stringdelete(F,j);
    67566756      j--;
    6757     }     
     6757    }
    67586758  }
    67596759  short=altshort;
    67606760  return(F);
    67616761}
    6762  
     6762
    67636763/////////////////////////////////////////////////////////////////////////
    67646764
    67656765static proc texcoefficient (poly f,list #)
    67666766"USAGE:      texcoefficient(f[,#]); f poly, # optional list
    6767 RETURN:      string, the tex command representing the leading coefficient 
     6767RETURN:      string, the tex command representing the leading coefficient
    67686768                     of f using \frac as coefficient
    6769 NOTE:        if # is non-empty, then the cdot at the end is omitted; 
     6769NOTE:        if # is non-empty, then the cdot at the end is omitted;
    67706770             this is needed for the constant term"
    67716771{
     
    67996799  }
    68006800  if (size(koeffizient)>5)
    6801   {   
     6801  {
    68026802    string tfractest=koeffizient[2..6];
    68036803    if (tfractest=="tfrac")
     
    68866886static proc coordinatechange (poly f,intmat A,intvec v)
    68876887"USAGE:   coordinatechange(f,A,v);  f poly, A intmat, v intvec
    6888 ASSUME:   f is a polynomial in two variables, A is a 2x2 
     6888ASSUME:   f is a polynomial in two variables, A is a 2x2
    68896889          integer matrix, and v is an integer vector with 2 entries
    68906890RETURN:   poly, the polynomial transformed by (x,y)->A*(x,y)+v
     
    69086908"USAGE:      weierstrassFormOfACubic(wf[,#]); wf poly, # list
    69096909ASSUME:      poly is a cubic polynomial
    6910 RETURN:      poly, the Weierstrass normal form of the cubic, 0 if poly is 
     6910RETURN:      poly, the Weierstrass normal form of the cubic, 0 if poly is
    69116911                   not a cubic
    69126912NOTE:        - the algorithm for the coefficients of the Weierstrass form is due
    69136913               to Fernando Rodriguez Villegas, villegas@math.utexas.edu
    6914              - if an additional argument # is given, the simplified Weierstrass 
     6914             - if an additional argument # is given, the simplified Weierstrass
    69156915               form is computed
    69166916             - the procedure is called by weierstrassForm
    6917              - the characteristic of the base field should not be 2 or 3 
     6917             - the characteristic of the base field should not be 2 or 3
    69186918               if # is non-empty"
    69196919{
     
    69296929    return (f);
    69306930  }
    6931   // compute the coefficients a1,a2,a3,a4, and a6 of the Weierstrass 
     6931  // compute the coefficients a1,a2,a3,a4, and a6 of the Weierstrass
    69326932  // form y^2+a1xy+a3y=x^3+a2x^2+a4x+a6
    69336933  poly a1=r1;
     
    69366936  poly a4=((-3*t0*r0+s0^2)*q1+(-3*s1*s0*q0+s1*r0^2))*q3
    69376937    +(t0*r0*q2^2+(s1*s0*q1+((-3*t0*r2+s1^2)*q0+s0*r0*r2))*q2
    6938       +(t0*r2*q1^2+s1*r0*r2*q1+s0*r2^2*q0)); 
     6938      +(t0*r2*q1^2+s1*r0*r2*q1+s0*r2^2*q0));
    69396939  poly a6=(-27*t0^2*q0^2+(9*t0*s0*r0-s0^3)*q0-t0*r0^3)*q3^2+
    6940         (((9*t0^2*q0-t0*s0*r0)*q1+((-3*t0*s0*r1+(3*t0*s1*r0+
    6941         2*s1*s0^2))*q0+(t0*r0^2*r1-s1*s0*r0^2)))*q2+(-t0^2*q1^3
    6942         +(t0*s0*r1+(2*t0*s1*r0-s1*s0^2))*q1^2+((3*t0*s0*r2+
    6943         (-3*t0*s1*r1+2*s1^2*s0))*q0+((2*t0*r0^2-s0^2*r0)*r2+
    6944         (-t0*r0*r1^2+s1*s0*r0*r1-s1^2*r0^2)))*q1+((9*t0*s1*r2-
    6945         s1^3)*q0^2+(((-3*t0*r0+s0^2)*r1-s1*s0*r0)*r2+(t0*r1^3
    6946         -s1*s0*r1^2+s1^2*r0*r1))*q0)))*q3+(-t0^2*q0*q2^3+
    6947         (-t0*s1*r0*q1+((2*t0*s0*r2+(t0*s1*r1-s1^2*s0))*q0-
    6948         t0*r0^2*r2))*q2^2+(-t0*s0*r2*q1^2+(-t0*s1*r2*q0+
    6949         (t0*r0*r1-s1*s0*r0)*r2)*q1+((2*t0*r0-s0^2)*r2^2+
    6950         (-t0*r1^2+s1*s0*r1-s1^2*r0)*r2)*q0)*q2+
    6951         (-t0*r0*r2^2*q1^2+(t0*r1-s1*s0)*r2^2*q0*q1-
     6940        (((9*t0^2*q0-t0*s0*r0)*q1+((-3*t0*s0*r1+(3*t0*s1*r0+
     6941        2*s1*s0^2))*q0+(t0*r0^2*r1-s1*s0*r0^2)))*q2+(-t0^2*q1^3
     6942        +(t0*s0*r1+(2*t0*s1*r0-s1*s0^2))*q1^2+((3*t0*s0*r2+
     6943        (-3*t0*s1*r1+2*s1^2*s0))*q0+((2*t0*r0^2-s0^2*r0)*r2+
     6944        (-t0*r0*r1^2+s1*s0*r0*r1-s1^2*r0^2)))*q1+((9*t0*s1*r2-
     6945        s1^3)*q0^2+(((-3*t0*r0+s0^2)*r1-s1*s0*r0)*r2+(t0*r1^3
     6946        -s1*s0*r1^2+s1^2*r0*r1))*q0)))*q3+(-t0^2*q0*q2^3+
     6947        (-t0*s1*r0*q1+((2*t0*s0*r2+(t0*s1*r1-s1^2*s0))*q0-
     6948        t0*r0^2*r2))*q2^2+(-t0*s0*r2*q1^2+(-t0*s1*r2*q0+
     6949        (t0*r0*r1-s1*s0*r0)*r2)*q1+((2*t0*r0-s0^2)*r2^2+
     6950        (-t0*r1^2+s1*s0*r1-s1^2*r0)*r2)*q0)*q2+
     6951        (-t0*r0*r2^2*q1^2+(t0*r1-s1*s0)*r2^2*q0*q1-
    69526952     t0*r2^3*q0^2));
    69536953  poly b2=a1^2+4*a2;
     
    70017001        i.e. a polynomial of the form a+bx+cx2+dy+exy+fx2y+gy2+hxy2+ix2y2
    70027002RETURN: poly, a Weierstrass form of the elliptic curve defined by poly
    7003 NOTE:   - the algorithm is based on the paper Sang Yook An, Seog Young Kim, 
    7004           David C. Marshall, Susan H. Marshall, William G. McCallum and 
    7005           Alexander R. Perlis: Jacobians of Genus One Curves. Journal of Number 
     7003NOTE:   - the algorithm is based on the paper Sang Yook An, Seog Young Kim,
     7004          David C. Marshall, Susan H. Marshall, William G. McCallum and
     7005          Alexander R. Perlis: Jacobians of Genus One Curves. Journal of Number
    70067006          Theory 90,2 (2001), 304-315.
    70077007        - the procedure is called by weierstrassForm
     
    70127012  // define P1xP1 as quadric in P3
    70137013  matrix A[4][4]=0,0,0,1/2,0,0,1/2,0,0,1/2,0,0,1/2,0,0,0;
    7014   // define the image of the (2,2)-curve under the Segre embedding 
     7014  // define the image of the (2,2)-curve under the Segre embedding
    70157015  // as quadric which should be
    70167016  // intersected with the image of P1xP1
    70177017  matrix B[4][4]=A00,A10/2,A01/2,0,A10/2,A20,A11/2,A21/2,A01/2,A11/2,A02,A12/2,0,A21/2,A12/2,A22;
    7018   // compute the coefficients of the Weierstrass form of 
     7018  // compute the coefficients of the Weierstrass form of
    70197019  // the input polynomial and its j-invariant
    70207020  poly a=det(x*A+B);
     
    70297029
    70307030static proc jInvariantOfACubic (poly f,list #)
    7031 "USAGE:      jInvariantOfACubic(f[,#]); f poly, # list 
     7031"USAGE:      jInvariantOfACubic(f[,#]); f poly, # list
    70327032ASSUME:      poly is a cubic polynomial defining an elliptic curve
    70337033RETURN:      poly, the j-invariant of the elliptic curve defined by poly
    70347034NOTE:        - if the base field is Q(t) an optional argument # may be given;
    7035                then the algorithm only computes the negative of the order 
     7035               then the algorithm only computes the negative of the order
    70367036               of the j-invariant"
    70377037{
     
    70407040    ERROR("The input polynomial is not a cubic!");
    70417041  }
    7042   // compute first the Weierstrass form of the cubic 
     7042  // compute first the Weierstrass form of the cubic
    70437043  // - this does not change the j-invariant
    70447044  f=weierstrassFormOfACubic(f);
     
    70587058    ERROR("The input is a rational curve and has no j-invariant!");
    70597059  }
    7060   if (size(#)>0) // if the optional argument is given, then only the 
     7060  if (size(#)>0) // if the optional argument is given, then only the
    70617061  { // negative of the order is computed
    70627062    int zaehler=3*simplifyToOrder(c4)[1];
     
    70747074
    70757075static proc jInvariantOfA2x2Curve (poly f,list #)
    7076 "USAGE: jInvariantOfA2x2Curve(f[,#]); f poly, # list 
     7076"USAGE: jInvariantOfA2x2Curve(f[,#]); f poly, # list
    70777077ASSUME: poly, is a polynomial defining an elliptic curve of type (2,2) on P^1xP^1
    70787078             i.e. a polynomial of the form a+bx+cx2+dy+exy+fx2y+gy2+hxy2+ix2y2
    70797079RETURN: poly, the j-invariant of the elliptic curve defined by poly
    70807080NOTE:   - if the base field is Q(t) an optional argument # may be given;
    7081           then the algorithm only computes the negative of the order of the 
     7081          then the algorithm only computes the negative of the order of the
    70827082          j-invariant
    70837083        - the characteristic should not be 2 or 3
     
    70927092  // intersected with the image of P1xP1
    70937093  matrix B[4][4]=A00,A10/2,A01/2,0,A10/2,A20,A11/2,A21/2,A01/2,A11/2,A02,A12/2,0,A21/2,A12/2,A22;
    7094   // compute the coefficients of the Weierstrass form of 
     7094  // compute the coefficients of the Weierstrass form of
    70957095  // the input polynomial and its j-invariant
    70967096  poly a=det(var(1)*A+B);
     
    71087108    ERROR("The input is a rational curve and has no j-invariant!");
    71097109  }
    7110   if (size(#)>0) // if the optional argument is given, 
     7110  if (size(#)>0) // if the optional argument is given,
    71117111  { // then only the negative of the order is computed
    71127112    int zaehler=simplifyToOrder(jinvnum)[1];
     
    71247124
    71257125static proc jInvariantOfA4x2Curve (poly f,list #)
    7126 "USAGE:      jInvariantOfA4x2Curve(f[,#]); f poly, # list 
     7126"USAGE:      jInvariantOfA4x2Curve(f[,#]); f poly, # list
    71277127ASSUME:      poly, is a polynomial defining an elliptic curve of type (4,2),
    71287128             i.e. a polynomial of the form a+bx+cx2+dx3+ex4+fy+gxy+hx2y+iy2
    71297129RETURN:      poly, the j-invariant of the elliptic curve defined by poly
    71307130NOTE:        - if the base field is Q(t) an optional argument # may be given;
    7131                then the algorithm only computes the negative of the order 
     7131               then the algorithm only computes the negative of the order
    71327132               of the j-invariant
    71337133             - the characteristic should not be 2 or 3
    7134              - the procedure is not called at all, it is just stored 
     7134             - the procedure is not called at all, it is just stored
    71357135               for the purpose of comparison"
    71367136{
     
    71527152  poly c4cube=c4^3;
    71537153  poly jdenom=c4cube-c6^2;
    7154   if (size(#)>0) // if the optional argument is given, 
     7154  if (size(#)>0) // if the optional argument is given,
    71557155  { // then only the negative of the order is computed
    71567156    int zaehler=3*simplifyToOrder(c4)[1];
     
    71677167
    71687168static proc jInvariantOfAPuiseuxCubic (poly f,list #)
    7169 "USAGE:  jInvariantOfAPuiseuxCubic(f[,#]); f poly, # list 
    7170 ASSUME:  poly is a cubic polynomial over Q(t) defining an elliptic curve 
     7169"USAGE:  jInvariantOfAPuiseuxCubic(f[,#]); f poly, # list
     7170ASSUME:  poly is a cubic polynomial over Q(t) defining an elliptic curve
    71717171         and # is empty
    7172 RETURN:  list, containing two polynomials whose ratio is the j-invariant 
     7172RETURN:  list, containing two polynomials whose ratio is the j-invariant
    71737173               of the  elliptic curve defined by poly
    7174 ASSUME:  poly is a cubic polynomial over Q(t) defining an elliptic curve 
     7174ASSUME:  poly is a cubic polynomial over Q(t) defining an elliptic curve
    71757175         and # is non-empty
    71767176RETURN:  int, the order of the j-invariant of the elliptic curve defined by poly
     
    71817181    ERROR("The input polynomial is not a cubic!");
    71827182  }
    7183   // compute first the Weierstrass form of the cubic 
     7183  // compute first the Weierstrass form of the cubic
    71847184  // - this does not change the j-invariant
    71857185  f=weierstrassFormOfACubic(f);
     
    72067206    ERROR("The input is a rational curve and has no j-invariant!");
    72077207  }
    7208   if (size(#)>0) // if the optional argument is given, 
     7208  if (size(#)>0) // if the optional argument is given,
    72097209  { // then only the negative of the order is computed
    72107210    int zaehler=3*simplifyToOrder(c4)[1];
     
    72497249/*
    72507250
    7251 /// Note, only the following procedures need further examples 
     7251/// Note, only the following procedures need further examples
    72527252/// (the others are too simple):
    72537253/// A) tropicalLifting (best tested via displayTropicalLifting)
     
    72807280// Example 3 - the ideal is not zero dimensional
    72817281// --------------------------------------------------------
    7282 ring r1=0,(t,x,y),dp; 
     7282ring r1=0,(t,x,y),dp;
    72837283poly 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);
    72847284f;
     
    74667466poly f=t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2;
    74677467list graph=tropicalCurve(f);
    7468 graph; 
     7468graph;
    74697469size(graph)-1;
    74707470drawTropicalCurve(graph);
  • Singular/LIB/zeroset.lib

    r2c3a5d r3360fb  
    11// Last change 12.02.2001 (Eric Westenberger)
    22///////////////////////////////////////////////////////////////////////////////
    3 version="$Id: zeroset.lib,v 1.23 2009-04-14 08:20:45 Singular Exp $";
     3version="$Id: zeroset.lib,v 1.24 2009-04-14 12:00:15 Singular Exp $";
    44category="Symbolic-numerical solving";
    55info="
     
    479479  @end format
    480480ASSUME:  basering = Q[x] or Q(a)[x]
    481 NOTE: This procedure is outdated, and should no longer be used. Use div and mod 
     481NOTE: This procedure is outdated, and should no longer be used. Use div and mod
    482482instead.
    483483EXAMPLE: example Quotient; shows an example
Note: See TracChangeset for help on using the changeset viewer.