I am trying to implement an algorithm which plots a tropical curve given a tropical polynomial $P(x,y)$. So for instance the graph of $P(x,y)=x+y+0$ should be a union of three half rays, starting at the origin, with respective directions $(-1,0),(0,-1),(1,1)$.
The method I am trying to use is as follows: Given a tropical polynomial written as a sum of monomials, $P(x,y)=m_1+\dots+ m_k$, we start by looking at two tropical monomials at a time, say $m_1$ and $m_2$, and then implicitly plotting $m_1-m_2=0$, but this graph should only show up at a point $(x,y)$ in the final picture if both $m_1$ and $m_2$ are in fact equal to $\max\{m_1,\dots,m_k\}$ at $(x,y)$. Then iterate this process for all such pairs of monomials.
To do this, I want to use Sage's implicit_plot function with an added conditional. So in (half) pseudocode for the example $P(x,y)=x+y+0$ I want to say something like
implicit_plot(x-0, if x == max(x,y,0), (x,-3,3),(y,-3,3))
implicit_plot(y-0, if y == max(x,y,0), (x,-3,3),(y,-3,3))
implicit_plot(x-y, if x == max(x,y,0), (x,-3,3),(y,-3,3)).
Does Sage have functionality which allows this type of plotting? I have looked through the documentation but could not find an example exhibiting this. If not, would there be a better way of going about this? Thanks
Not sure if you are asking for the complete solution to get the plot starting from a sum of monomials, or just for a hint on using
implicit_plot.Here is an illustration of using
implicit_plotin the way suggested in the question.Say we defined functions
f,g,hby:then we can call
implicit_ploton them to define:and assemble all these plots:
Here is what we got: