By definition, a tropical surface in $\mathbb R^3$ is the set of points $(x,y,z)$ where the maximum $f=\max(f_1,f_2,\dots,f_n)$ is attained at least twice, here $f_i$ stand for some linear functions of the type $a+ix+jy+kz, a\in \mathbb R,i,j,k\in\mathbb Z$.

The most basic example is a tropical plane, which is given by $f=\max(x,y,z,0)$. It is easy to see that the set of points which we interested in, is $\{(x,y,z)|x=y\geq \max(z,0)$ or $x=z\geq \max(y,0)$ or$ ... x=0\geq \max(y,z)...\}$, so it is a union of six hyperplanes.

One can use an equivalent definition: the tropical surface is the set of points where $f$ is not smooth (or, equivalently, not linear).

Here is the question: given $f_1,f_2,\dots$ of the above form we need to draw the set where $f=\max(f_1,f_2,\dots,f_n)$ is not smooth. In principle, one can elaborate all all the possible inequalities ($f_1=f_2\geq f_i$ for all $i$ etc), but there should be more elegant way to do that. Could you help me?

Added: the simplest way, proposed by belisarius Apr 13 at 16:12, seems to be

fns[u_, v_, w_] := {u, v, w, 0}; k = 20;
RegionPlot3D[First@Differences[Sort[fns[u, v, w]][[1 ;; 2]]] == 0,
             {u, -k, k}, {v, -k, k}, {w, -k, k}, PlotPoints -> 50]

but it draws only a part of all points (for the function $\min(x,y,z,0)$ attained twice), without the points $(0,a,b),(a,0,b),(a,b,0)$ with $a,b>0$. How could that be?

  • 1
    $\begingroup$ Please include in your question the Mathematica code you have developed so far to address your problem. $\endgroup$
    – bbgodfrey
    Apr 13, 2015 at 15:38
  • 1
    $\begingroup$ somewhat related Plot the plane so different condition has a different color? $\endgroup$
    – kglr
    Apr 13, 2015 at 15:38
  • $\begingroup$ to bbgodfrey: I produced the code illustrating the last idea: for each pair of indices $i,j$ we construct the inequalities $f_i=f_j\geq f_k$ for all $k$. The problem is not in this code. I believe that there should be a fast way for a function of type $\max(,,,)$ to find the set where it is not linear, or where the maximum is attained twice. $\endgroup$ Apr 13, 2015 at 15:42
  • $\begingroup$ to kguler: Yes, thank you, it seems it will work. I try to do like there. $\endgroup$ Apr 13, 2015 at 15:51
  • $\begingroup$ Perhaps fns[u_, v_, w_] := {u, v, w, 0}; k = 20; RegionPlot3D[ First@Differences[Sort[fns[u, v, w]][[1 ;; 2]]] == 0, {u, -k, k}, {v, -k, k}, {w, -k, k}, PlotPoints -> 50] $\endgroup$ Apr 13, 2015 at 16:12

1 Answer 1


Here's a simple way to enumerate all the conditions:

fs = {x, y, z, 0};
conds = Table[{Equal @@ fs1, 
               And @@ Table[First@fs1 >= f, {f, Complement[fs, fs1]}]}, 
              {fs1, Subsets[fs, {2}]}]
(* {{x == y, x >= 0 && x >= z}, {x == z, x >= 0 && x >= y}, 
    {x == 0, x >= y && x >= z}, {y == z, y >= 0 && y >= x}, 
    {y == 0, y >= x && y >= z}, {z == 0, z >= x && z >= y}} *)

Each item {e, i} in the list is a pair containing an equality and a conjunction of inequalities, which you can use as ContourPlot3D[e, ..., RegionFunction -> Function[{x, y, z}, i]]. Draw the whole surface by using Show to put them all together.

  ContourPlot3D[Evaluate@First@c, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
   RegionFunction -> Function[{x, y, z}, Last@c]], {c, conds}]]

enter image description here

  • 3
    $\begingroup$ This is fun! $(x^2-y^2,y^2-z^2+1,z^2-x^2-1)$: i.sstatic.net/MBoL0.png $\endgroup$
    – user484
    Apr 24, 2015 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.