# Singular

#### D.13.3.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"; 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); // the Newton polygone need not be the standard simplex tropicalJInvariant(x+y+x2y+xy2+1/t*xy); // the curve can have arbitrary degree tropicalJInvariant(t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2); // 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); // but it does realise, if the curve has no loop at all ... tropicalJInvariant(x+y+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); ```