# Singular

#### D.13.4.8 tropicalJInvariant

Procedure from library `tropical.lib` (see tropical_lib).

Usage:
tropicalJInvariant(f[,#]); f poly or list, # optional list

Assume:
f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c representing a tropical Laurent polynomial defining a tropical plane curve;
alternatively f can be a polynomial in Q(t)[x,y] defining a tropical plane curve via the valuation map;
the basering must have a global monomial ordering, two variables and up to one parameter!

Return:
number, if the graph underlying the tropical curve has precisely one loop then its weighted lattice length is returned, otherwise the result will be -1

Note:
- if the tropical curve is elliptic and its embedded graph has precisely one loop, then the weigthed lattice length of the loop is its tropical j-invariant
- the procedure checks if the embedded graph of the tropical curve has genus one, but it does NOT check if the loop can be resolved, so that the curve is not a proper tropical elliptic curve
- if the embedded graph of a tropical elliptic curve has more than one loop, then all but one can be resolved, but this is not observed by this procedure, so it will not compute
the j-invariant
- if # is empty, then the tropical curve is computed w.r.t. minimum, if #[1] is the string 'max', then it is computed w.r.t. maximum
- the tropicalJInvariant of a plane tropical cubic is the 'cycle length' of the cubic as introduced in the paper: Eric Katz, Hannah Markwig, Thomas Markwig: The j-invariant of a cubic tropical plane curve.

Example:
 ```LIB "tropical.lib"; ==> Welcome to polymake version ==> Copyright (c) 1997-2015 ==> Ewgenij Gawrilow, Michael Joswig (TU Darmstadt) ==> http://www.polymake.org ring r=(0,t),(x,y),dp; // tropcialJInvariant computes the tropical j-invariant of an elliptic curve tropicalJInvariant(t*(x3+y3+1)+1/t*(x2+y2+x+y+x2y+xy2)+1/t2*xy); ==> // ** int division with `/`: use `div` instead in line >> genus=-genus/2\ ; // we have counted each bounded edge twice<< ==> 6 // the Newton polygone need not be the standard simplex tropicalJInvariant(x+y+x2y+xy2+1/t*xy); ==> // ** int division with `/`: use `div` instead in line >> genus=-genus/2\ ; // we have counted each bounded edge twice<< ==> 8 // the curve can have arbitrary degree tropicalJInvariant(t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2); ==> // ** int division with `/`: use `div` instead in line >> genus=-genus/2\ ; // we have counted each bounded edge twice<< ==> 14/3 // the procedure does not realise, if the embedded graph of the tropical // curve has a loop that can be resolved tropicalJInvariant(1+x+y+xy+tx2y+txy2); ==> // ** int division with `/`: use `div` instead in line >> genus=-genus/2\ ; // we have counted each bounded edge twice<< ==> 4 // but it does realise, if the curve has no loop at all ... tropicalJInvariant(x+y+1); ==> // ** int division with `/`: use `div` instead in line >> genus=-genus/2\ ; // we have counted each bounded edge twice<< ==> The embedded graph of the curve has not genus one. ==> -1 // or if the embedded graph has more than one loop - even if only one // cannot be resolved tropicalJInvariant(1+x+y+xy+tx2y+txy2+t3x5+t3y5+tx2y2+t2xy4+t2yx4); ==> // ** int division with `/`: use `div` instead in line >> genus=-genus/2\ ; // we have counted each bounded edge twice<< ==> The embedded graph of the curve has not genus one. ==> -1 ```