Nathan Tiggemann

Coding

Plotting tropical curves

You can download a Python script for plotting tropical curves defined by a tropical polynomial by clicking here. The same script, but as a .exe file can be downloaded by clicking here. The script also plots the dual subdivision and can print the tikz code for the figures.
It uses the packages numpy, matplotlib and tkinter.
If you are on Windows, you can just download the exe-version and are ready to go. Here are short notes on how to use the program: For more details on how to make this script work, what the options do, which inputs are allowed and how to configure default values, see here.

An app to plot tropical curves

I wrote an android app that allows you to plot tropical curves and their dual subdivision. You can find an APK-file here. Run this file on an android device to install the app. Android will be suspicious about the file as it does not come from the app store.
The app is very simplistic and unpolished, however, it does its job. It was written and build using BeeWare. The input for the polynomial works like described above. The plotting range is adjusted automatically. There are no error messages implemented, so you should check if the plot looks weird yourself.

Plotting tropical hypersurfaces in three dimensions

You can find a Python script for plotting tropical hypersurfaces in \(\mathbb{R}^3\) here. It uses the packages matplotlib, numpy and scipy. An even easier-to-use program written by Lars Allermann can be found here.
My script, however, does plot the edges of the dual subdivision, too. There is no support for min-convention yet and you have to do the input directly in the file. Running it will immediately show you the plots. This script uses the packages numpy, matplotlib and scipy.
For more details on how to make this script work and how the input works, see here.

Disclaimer

Use all the scripts on this website at your own risk. I am confident that they work very well for reasonable input, however, I do not guarantee that all outputs are correct. If you find any bugs, please contact me after you made sure that you are using the latest version. I only learned Python to write these scripts, so don't be surprised if my codes might not be the most elegant or efficient ones ever written.

On plotting tropical curves

How to install Python and necessary packages

I use Windows, so here is how it worked for me: Download Python from the official website. Install it - AND make sure that you pick the "Add Python to PATH" during the installation.
Download pip with the command "curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py" in the command prompt (You find that by pressing the Windows key and then typing cmd. The "" are not part of the command). Install pip with the command "python get-pip.py". Use the commands "pip install numpy", "pip install matplotlib" to install the two needed packages.
If you use Linux or macOS: Ask chatGPT how to install everything. You might need to install "tkinter" explicitly, too.

The options

Input

Some remarks about the input

Change default values

If you open the file in your favorite editor, you will immediately see a comment that reads "#Default values". Change the variables underneath to the values to the default values you want.

The algorithm

The idea is the following:

Why I wrote this script

There are already existing programs to plot tropical curves. And they are probably faster, more elegant, and use only algebraic methods. My motivations for writing this script were mostly the following two: Writing it was fun and it is easy to use. This is also why I tried to keep all explanations very low level.

About old versions of the algorithm

The very first version of this script used the following logic: "If you compute the vertices of a tropical curve and connect them if their middle point is part of the curve you end up with the curve". However, this approach is not correct: For example if you consider the input "-4+y+x-1x2-1y2+1xy-1xy2-1yx2" the points (-4,-4) and (2,2) would falsely get connected.
After realizing this, I updated the code to also check if the maximum at the middle point was attained by monomials that are part of the maximal monomials at the vertices. However, this is not correct either: For "y+x+x2+y2" the points on the diagonal that intersect with the boundary of the plotting range would get connected and this edge would get a weight 2 assigned.
Since version 2.3 of the .exe/.py file and 0.4 of the app the following statement is used: "Let x,y be two points on a tropical curve with 2 common monomials that are maximal. Then all convex combinations of them are part of the curve". This follows from the convexity of the graphs of tropical polynomial functions.

On plotting tropical hypersurfaces in three dimensions

How to install Python and necessary packages

I use Windows, so here is how it worked for me: Download Python from the official website. Install it - and make sure that you pick the "Add Python to PATH" during the installation.
Download pip with the command "curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py" in the command prompt (You find that by pressing the Windows key and then typing cmd. The "" are not part of the command). Install pip with the command "python get-pip.py". Use the commands "pip install numpy", "pip install matplotlib", "pip install scipy" to install the three packages. "math", "re" and "tkinter" are pre-installed.
If you use Linux or macOS: Ask chatGPT how to install everything. You might need to install "tkinter" explicitly, too.

Input

For this script, you have to manually adjust the input in the code. If you open the file, after line 15 (''' INPUT ''') there are more explanations on how to do this.

The algorithm

The idea, similarly to the two-dimensional case, is: Obviously, there are quite a few details I skipped here.

Why I wrote this script

There are already existing programs to plot tropical hypersurfaces. And they are probably faster, more elegant, and use only algebraic methods. My motivations for writing this script were mostly the following two: Writing it was fun and it is easy to use (This is also why I tried to keep all explanations very low level.). At the time I didn't know the program by Lars Allermann. Still, plotting the dual is an advantage my script has.

About old versions of the algorithm

The old versions of this script followed the same ideas as the algorithm for the two-dimensional case to construct the one-dimensional faces.
Since version 1.3 the following statement is used: "Let x,y be two points on a tropical hypersurface with 3 common monomials that are maximal. Then for all convex combinations of these two points the max is attained by these three monomials". This follows from the convexity of the graphs of tropical polynomial functions.

How to get a website like this

Website Hosting

This website is hosted on GitHub. Here is a good reference on how to start your own website. Thanks to Thomas Brazelton for this hint!

Writing the HTML code

Here is the obvious hint: Describe to chatGPT how you want your website to look and the structure to be and ask it to give you the HTML code. This works incredibly well.