Multivariate Tropical Polynomials

AUTHORS:

  • Verrel Rievaldo Wijaya (2024-06): initial version

EXAMPLES:

sage: T = TropicalSemiring(QQ, use_min=True)
sage: R.<x,y,z> = PolynomialRing(T)
sage: z.parent()
Multivariate Tropical Polynomial Semiring in x, y, z over Rational Field
sage: R(2)*x + R(-1)*x + R(5)*y + R(-3)
(-1)*x + 5*y + (-3)
sage: (x+y+z)^2
0*x^2 + 0*x*y + 0*y^2 + 0*x*z + 0*y*z + 0*z^2

REFERENCES:

class sage.rings.semirings.tropical_mpolynomial.TropicalMPolynomial(parent, x)[source]

Bases: MPolynomial_polydict

A multivariate tropical polynomial.

Let x1,x2,,xn be indeterminants. A tropical monomial is any product of these variables, possibly including repetitions: x1i1xnin where ij{0,1,}, for all j{1,,n}. A multivariate tropical polynomial is a finite linear combination of tropical monomials, p(x1,,xn)=i=1ncix1i1xnin.

In classical arithmetic, we can rewrite the general form of a tropical monomial: x1i1xnini1x1++inxn. Thus, the tropical polynomial can be viewed as the minimum (maximum) of a finite collection of linear functions.

EXAMPLES:

Construct a multivariate tropical polynomial semiring in two variables:

sage: T = TropicalSemiring(QQ, use_min=False)
sage: R.<a,b> = PolynomialRing(T); R
Multivariate Tropical Polynomial Semiring in a, b over Rational Field

Define some multivariate tropical polynomials:

sage: p1 = R(3)*a*b + a + R(-1)*b; p1
3*a*b + 0*a + (-1)*b
sage: p2 = R(1)*a + R(1)*b + R(1)*a*b; p2
1*a*b + 1*a + 1*b

Some basic arithmetic operations for multivariate tropical polynomials:

sage: p1 + p2
3*a*b + 1*a + 1*b
sage: p1 * p2
4*a^2*b^2 + 4*a^2*b + 4*a*b^2 + 1*a^2 + 1*a*b + 0*b^2
sage: T(2) * p1
5*a*b + 2*a + 1*b
sage: p1(T(1),T(2))
6

Let us look at the different result for tropical curve and 3d graph of tropical polynomial in two variables when different algebra is used. First for the min-plus algebra:

sage: T = TropicalSemiring(QQ, use_min=True)
sage: R.<a,b> = PolynomialRing(T)
sage: p1 = R(3)*a*b + a + R(-1)*b
sage: p1.tropical_variety()
Tropical curve of 3*a*b + 0*a + (-1)*b
sage: p1.tropical_variety().plot()
Graphics object consisting of 3 graphics primitives
../../../_images/tropical_mpolynomial-1.svg

Tropical polynomial in two variables will induce a function in three dimension that consists of a number of surfaces:

sage: p1.plot3d()
Graphics3d Object
../../../_images/tropical_mpolynomial-2.svg

If we use a max-plus algebra, we will get a slightly different result:

sage: T = TropicalSemiring(QQ, use_min=False)
sage: R.<a,b> = PolynomialRing(T)
sage: p1 = R(3)*a*b + a + R(-1)*b
sage: p1.tropical_variety()
Tropical curve of 3*a*b + 0*a + (-1)*b
sage: p1.tropical_variety().plot()
Graphics object consisting of 3 graphics primitives
../../../_images/tropical_mpolynomial-3.svg
sage: p1.plot3d()
Graphics3d Object
../../../_images/tropical_mpolynomial-4.svg

Another way to represent tropical curve is through dual subdivision, which is a subdivision of Newton polytope of tropical polynomial:

sage: p1.newton_polytope()
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices
sage: p1.dual_subdivision()
Polyhedral complex with 1 maximal cell
../../../_images/tropical_mpolynomial-5.svg
dual_subdivision()[source]

Return the dual subdivision of self.

Dual subdivision refers to a specific decomposition of the Newton polytope of a tropical polynomial. The term “dual” is used in the sense that the combinatorial structure of the tropical variety is reflected in the dual subdivision. Specifically, vertices of the dual subdivision correspond to the intersection of multiple components. Edges of the dual subdivision correspond to the individual components.

OUTPUT: PolyhedralComplex

EXAMPLES:

Dual subdivision of a tropical curve:

sage: T = TropicalSemiring(QQ, use_min=False)
sage: R.<x,y> = PolynomialRing(T)
sage: p1 = R(3) + R(2)*x + R(2)*y + R(3)*x*y + x^2 + y^2
sage: pc = p1.dual_subdivision(); pc
Polyhedral complex with 4 maximal cells
sage: [p.Vrepresentation() for p in pc.maximal_cells_sorted()]
[(A vertex at (0, 0), A vertex at (0, 1), A vertex at (1, 1)),
 (A vertex at (0, 0), A vertex at (1, 0), A vertex at (1, 1)),
 (A vertex at (0, 1), A vertex at (0, 2), A vertex at (1, 1)),
 (A vertex at (1, 0), A vertex at (1, 1), A vertex at (2, 0))]
../../../_images/tropical_mpolynomial-6.svg

A subdivision of a pentagonal Newton polytope:

sage: p2 = R(3) + x^2 + R(-2)*y + R(1/2)*x^2*y + R(2)*x*y^3 + R(-1)*x^3*y^4
sage: pc = p2.dual_subdivision(); pc
Polyhedral complex with 5 maximal cells
sage: [p.Vrepresentation() for p in pc.maximal_cells_sorted()]
[(A vertex at (0, 0), A vertex at (0, 1), A vertex at (1, 3)),
 (A vertex at (0, 0), A vertex at (1, 3), A vertex at (2, 1)),
 (A vertex at (0, 0), A vertex at (2, 0), A vertex at (2, 1)),
 (A vertex at (1, 3), A vertex at (2, 1), A vertex at (3, 4)),
 (A vertex at (2, 0), A vertex at (2, 1), A vertex at (3, 4))]
../../../_images/tropical_mpolynomial-7.svg

A subdivision with many faces, not all of which are triangles:

sage: # long time (:issue:`39569`)
sage: T = TropicalSemiring(QQ)
sage: R.<x,y> = PolynomialRing(T)
sage: p3 = (R(8) + R(4)*x + R(2)*y + R(1)*x^2 + x*y + R(1)*y^2
....:      + R(2)*x^3 + x^2*y + x*y^2 + R(4)*y^3 + R(8)*x^4
....:      + R(4)*x^3*y + x^2*y^2 + R(2)*x*y^3 + y^4)
sage: pc = p3.dual_subdivision(); pc
Polyhedral complex with 10 maximal cells
sage: [p.Vrepresentation() for p in pc.maximal_cells_sorted()]
[(A vertex at (0, 0), A vertex at (0, 1), A vertex at (1, 0)),
 (A vertex at (0, 1), A vertex at (0, 2), A vertex at (1, 1)),
 (A vertex at (0, 1), A vertex at (1, 0), A vertex at (2, 0)),
 (A vertex at (0, 1), A vertex at (1, 1), A vertex at (2, 0)),
 (A vertex at (0, 2), A vertex at (0, 4), A vertex at (1, 1)),
 (A vertex at (0, 4),
  A vertex at (1, 1),
  A vertex at (2, 1),
  A vertex at (2, 2)),
 (A vertex at (1, 1), A vertex at (2, 0), A vertex at (2, 1)),
 (A vertex at (2, 0), A vertex at (2, 1), A vertex at (3, 0)),
 (A vertex at (2, 1), A vertex at (2, 2), A vertex at (3, 0)),
 (A vertex at (2, 2), A vertex at (3, 0), A vertex at (4, 0))]
../../../_images/tropical_mpolynomial-8.svg

Dual subdivision of a tropical surface:

sage: # long time (:issue:`39569`)
sage: T = TropicalSemiring(QQ)
sage: R.<x,y,z> = PolynomialRing(T)
sage: p1 = x + y + z + x^2 + R(1)
sage: pc = p1.dual_subdivision(); pc
Polyhedral complex with 7 maximal cells
sage: [p.Vrepresentation() for p in pc.maximal_cells_sorted()]
[(A vertex at (0, 0, 0), A vertex at (0, 0, 1), A vertex at (0, 1, 0)),
 (A vertex at (0, 0, 0), A vertex at (0, 0, 1), A vertex at (1, 0, 0)),
 (A vertex at (0, 0, 0), A vertex at (0, 1, 0), A vertex at (1, 0, 0)),
 (A vertex at (0, 0, 1), A vertex at (0, 1, 0), A vertex at (1, 0, 0)),
 (A vertex at (0, 0, 1), A vertex at (0, 1, 0), A vertex at (2, 0, 0)),
 (A vertex at (0, 0, 1), A vertex at (1, 0, 0), A vertex at (2, 0, 0)),
 (A vertex at (0, 1, 0), A vertex at (1, 0, 0), A vertex at (2, 0, 0))]
../../../_images/tropical_mpolynomial-9.svg

Dual subdivision of a tropical hypersurface:

sage: T = TropicalSemiring(QQ)
sage: R.<a,b,c,d> = PolynomialRing(T)
sage: p1 = R(2)*a*b + R(3)*a*c + R(-1)*c^2 + R(-1/3)*a*d
sage: pc = p1.dual_subdivision(); pc
Polyhedral complex with 4 maximal cells
sage: [p.Vrepresentation() for p in pc.maximal_cells_sorted()]
[(A vertex at (0, 0, 2, 0),
 A vertex at (1, 0, 0, 1),
 A vertex at (1, 0, 1, 0)),
(A vertex at (0, 0, 2, 0),
 A vertex at (1, 0, 0, 1),
 A vertex at (1, 1, 0, 0)),
(A vertex at (0, 0, 2, 0),
 A vertex at (1, 0, 1, 0),
 A vertex at (1, 1, 0, 0)),
(A vertex at (1, 0, 0, 1),
 A vertex at (1, 0, 1, 0),
 A vertex at (1, 1, 0, 0))]
newton_polytope()[source]

Return the Newton polytope of self.

The Newton polytope is the convex hull of all the points corresponding to the exponents of the monomials of tropical polynomial.

OUTPUT: Polyhedron()

EXAMPLES:

A Newton polytope for a two-variable tropical polynomial:

sage: T = TropicalSemiring(QQ)
sage: R.<x,y> = PolynomialRing(T)
sage: p1 = x + y
sage: p1.newton_polytope()
A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
sage: p1.newton_polytope().Vrepresentation()
(A vertex at (0, 1), A vertex at (1, 0))
sage: p1.newton_polytope().Hrepresentation()
(An equation (1, 1) x - 1 == 0,
 An inequality (0, -1) x + 1 >= 0,
 An inequality (0, 1) x + 0 >= 0)
../../../_images/tropical_mpolynomial-10.svg

A Newton polytope in three dimension:

sage: T = TropicalSemiring(QQ)
sage: R.<x,y,z> = PolynomialRing(T)
sage: p1 = x^2 + x*y*z + x + y + z + R(0)
sage: p1.newton_polytope()
A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 5 vertices
sage: p1.newton_polytope().Vrepresentation()
(A vertex at (0, 0, 0),
A vertex at (0, 0, 1),
A vertex at (0, 1, 0),
A vertex at (2, 0, 0),
A vertex at (1, 1, 1))
sage: p1.newton_polytope().Hrepresentation()
(An inequality (0, 1, 0) x + 0 >= 0,
 An inequality (0, 0, 1) x + 0 >= 0,
 An inequality (1, 0, 0) x + 0 >= 0,
 An inequality (1, -1, -1) x + 1 >= 0,
 An inequality (-1, -2, 1) x + 2 >= 0,
 An inequality (-1, 1, -2) x + 2 >= 0)
../../../_images/tropical_mpolynomial-11.svg
plot3d(color='random')[source]

Return the 3d plot of self.

Only implemented for tropical polynomial in two variables. The x-y axes for this 3d plot is the same as the x-y axes of the corresponding tropical curve.

OUTPUT: Graphics3d Object

EXAMPLES:

A simple tropical polynomial that consist of only one surface:

sage: T = TropicalSemiring(QQ, use_min=False)
sage: R.<x,y> = PolynomialRing(T)
sage: p1 = x^2
sage: p1.plot3d()
Graphics3d Object
../../../_images/tropical_mpolynomial-12.svg

Tropical polynomials often have graphs that represent a combination of multiple surfaces:

sage: p2 = R(3) + R(2)*x + R(2)*y + R(3)*x*y
sage: p2.plot3d()
Graphics3d Object
../../../_images/tropical_mpolynomial-13.svg
sage: T = TropicalSemiring(QQ)
sage: R.<x,y> = PolynomialRing(T)
sage: p3 = R(2)*x^2 + x*y + R(2)*y^2 + x + R(-1)*y + R(3)
sage: p3.plot3d()
Graphics3d Object
../../../_images/tropical_mpolynomial-14.svg
subs(fixed=None, **kwds)[source]

Fix some given variables in self and return the changed tropical multivariate polynomials.

EXAMPLES:

sage: T = TropicalSemiring(QQ, use_min=False)
sage: R.<x,y> = PolynomialRing(T)
sage: p1 = x^2 + y + R(3)
sage: p1((R(4),y))
0*y + 8
sage: p1.subs({x: 4})
0*y + 8
tropical_variety()[source]

Return tropical roots of self.

In the multivariate case, the roots can be represented by a tropical variety. In two dimensions, this is known as a tropical curve. For dimensions higher than two, it is referred to as a tropical hypersurface.

OUTPUT: sage.rings.semirings.tropical_variety.TropicalVariety

EXAMPLES:

Tropical curve for tropical polynomials in two variables:

sage: T = TropicalSemiring(QQ, use_min=False)
sage: R.<x,y> = PolynomialRing(T)
sage: p1 = x + y + R(0); p1
0*x + 0*y + 0
sage: p1.tropical_variety()
Tropical curve of 0*x + 0*y + 0

Tropical hypersurface for tropical polynomials in more than two variables:

sage: T = TropicalSemiring(QQ)
sage: R.<x,y,z> = PolynomialRing(T)
sage: p1 = R(1)*x*y + R(-1/2)*x*z + R(4)*z^2; p1
1*x*y + (-1/2)*x*z + 4*z^2
sage: p1.tropical_variety()
Tropical surface of 1*x*y + (-1/2)*x*z + 4*z^2
class sage.rings.semirings.tropical_mpolynomial.TropicalMPolynomialSemiring(base_semiring, n, names, order)[source]

Bases: UniqueRepresentation, Parent

The semiring of tropical polynomials in multiple variables.

This is the commutative semiring consisting of all finite linear combinations of tropical monomials under (tropical) addition and multiplication with coefficients in a tropical semiring.

EXAMPLES:

sage: T = TropicalSemiring(QQ)
sage: R.<x,y> = PolynomialRing(T)
sage: f = T(1)*x + T(-1)*y
sage: g = T(2)*x + T(-2)*y
sage: f + g
1*x + (-2)*y
sage: f * g
3*x^2 + (-1)*x*y + (-3)*y^2
sage: f + R.zero() == f
True
sage: f * R.zero() == R.zero()
True
sage: f * R.one() == f
True
Element[source]

alias of TropicalMPolynomial

gen(n=0)[source]

Return the n-th generator of self.

EXAMPLES:

sage: T = TropicalSemiring(QQ)
sage: R.<a,b,c> = PolynomialRing(T)
sage: R.gen()
0*a
sage: R.gen(2)
0*c
gens()[source]

Return the generators of self.

EXAMPLES:

sage: T = TropicalSemiring(QQ)
sage: R = PolynomialRing(T, 5, 'x')
sage: R.gens()
(0*x0, 0*x1, 0*x2, 0*x3, 0*x4)
ngens()[source]

Return the number of generators of self.

EXAMPLES:

sage: T = TropicalSemiring(QQ)
sage: R = PolynomialRing(T, 10, 'z')
sage: R.ngens()
10
one()[source]

Return the multiplicative identity of self.

EXAMPLES:

sage: T = TropicalSemiring(QQ)
sage: R = PolynomialRing(T, 'x,y')
sage: R.one()
0
random_element(degree=2, terms=None, choose_degree=False, *args, **kwargs)[source]

Return a random multivariate tropical polynomial from self.

OUTPUT: TropicalMPolynomial

EXAMPLES:

A random polynomial of at most degree d and at most t terms:

sage: T = TropicalSemiring(QQ)
sage: R.<a,b,c> = PolynomialRing(T)
sage: f = R.random_element(2, 5)
sage: f.degree() <= 2
True
sage: f.parent() is R
True
sage: len(list(f)) <= 5
True

Choose degrees of monomials randomly first rather than monomials uniformly random:

sage: f = R.random_element(3, 6, choose_degree=True)
sage: f.degree() <= 3
True
sage: f.parent() is R
True
sage: len(list(f)) <= 6
True
term_order()[source]

Return the defined term order of self.

EXAMPLES:

sage: T = TropicalSemiring(QQ)
sage: R.<x,y,z> = PolynomialRing(T)
sage: R.term_order()
Degree reverse lexicographic term order
zero()[source]

Return the additive identity of self.

EXAMPLES:

sage: T = TropicalSemiring(QQ)
sage: R = PolynomialRing(T, 'x,y')
sage: R.zero()
+infinity