user_guide:tutorials:apps_tropical

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:apps_tropical [2015/10/05 11:51] hampeuser_guide:tutorials:apps_tropical [2019/02/04 22:55] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Tutorial: Tropical arithmetics and tropical geometry ====== +{{page>.:latest:@FILEID@}}
- +
-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!  +
- +
-==== Tropical arithmetics ==== +
- +
-You can create an element of the tropical semiring (over the rationals) simply by writing something like this: +
-<code> +
-tropical > $a = new TropicalNumber<Max>(4); +
-tropical > $b = new TropicalNumber<Min>(4); +
-tropical > $c = new TropicalNumber<Min>("inf"); +
-</code> +
-You can now do basic arithmetic - that is **tropical** addition and multiplication with theseNote that tropical numbers with different tropical additions don't mix! +
-<code> +
-tropical > print $a * $a; +
-+
-tropical > print $b + $c*$b; +
-+
-tropical > #print $a + $b; This won't work! +
-</code> +
-Tropical vector/matrix arithmetics also work - you can even ask for the tropical determinant! +
-<code> +
-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); +
-+
-</code> +
- +
-Finally, you can also create tropical polynomials. This can either be done in the [[polynomials_tutorial|usual manner]] or with a special parser: +
- +
-<code> +
-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 +
-</code> +
- +
-==== Tropical convex hull computations ==== +
- +
-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 ''<nowiki>[[POINTS]]</nowiki>'': +
-<code> +
-tropical > $c = new Cone<Min>(POINTS=>[[0,0,0],[0,2,1]]); +
-</code> +
- +
  
  • user_guide/tutorials/apps_tropical.1444045909.txt.gz
  • Last modified: 2015/10/05 11:51
  • by hampe