user_guide:tutorials:apps_tropical

This tutorial is probably also available as a Jupyter notebook in the demo folder in the polymake source and on github.

Different versions of this tutorial: latest release, release 4.1, release 4.0, release 3.6, nightly master

This is an old revision of the document!

# Tutorial: Tropical arithmetics and tropical geometry

This tutorial showcases the main features of application tropical, such as

• Tropical arithmetics
• Tropical convex hull computations
• Tropical cycles and hypersurfaces.

#### Disclaimer: Min or Max - you have to choose!

Most objects and data types related to tropical computations have a template parameter which tells it whether Min or Max is used as tropical addition. There is no default for this, so you have to choose!

You can create an element of the tropical semiring (over the rationals) simply by writing something like this:

tropical > $a = new TropicalNumber<Max>(4); tropical >$b = new TropicalNumber<Min>(4);
tropical > $c = new TropicalNumber<Min>("inf"); You can now do basic arithmetic - that is tropical addition and multiplication with these. Note that tropical numbers with different tropical additions don't mix! tropical > print$a * $a; 8 tropical > print$b + $c*$b;
4
tropical > #print $a +$b; This won't work!

Tropical vector/matrix arithmetics also work - you can even ask for the tropical determinant!

tropical > $m = new Matrix<TropicalNumber<Max> >([[0,1,2],[0,"-inf",3],[0,0,"-inf"]]); tropical >$v = new Vector<TropicalNumber<Max> >(1,1,2);
tropical > print $m +$m;
0 1 2
0 -inf 3
0 0 -inf
tropical > print $m *$v;
4 5 1
tropical > print tdet($m); 4 Finally, you can also create tropical polynomials. This can either be done in the usual manner or with a special parser: tropical >$r = new Ring<TropicalNumber<Min> >(3); #Tropical polynomial ring in 3 variables
tropical > ($x,$y, $z) =$r->variables;
tropical > $p =$x*$x +$y * $z; tropical > print$p;
x0^2 + x1*x2
tropical > $q = toTropicalPolynomial("min(2a,b+c)"); tropical > print$q;
x0^2 + x1*x2

The basic object for tropical convex hull computations is Cone (Careful: If you're not in application tropical, be sure to use the namespace identifier tropical::Cone to distinguish it from the polytope::Cone).

A tropical cone should always be created via POINTS:

tropical > \$c = new Cone<Min>(POINTS=>[[0,0,0],[0,2,1]]);
• user_guide/tutorials/apps_tropical.1444045812.txt.gz