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
>>> from sage.all import *
>>> T = TropicalSemiring(QQ, use_min=True)
>>> R = PolynomialRing(T, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> z.parent()
Multivariate Tropical Polynomial Semiring in x, y, z over Rational Field
>>> R(Integer(2))*x + R(-Integer(1))*x + R(Integer(5))*y + R(-Integer(3))
(-1)*x + 5*y + (-3)
>>> (x+y+z)**Integer(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 \(x_1, x_2, \ldots, x_n\) be indeterminants. A tropical monomial is any product of these variables, possibly including repetitions: \(x_1^{i_1}\cdots x_n^{i_n}\) where \(i_j \in \{0,1,\ldots\}\), for all \(j\in \{1,\ldots,n\}\). A multivariate tropical polynomial is a finite linear combination of tropical monomials, \(p(x_1, \ldots, x_n) = \sum_{i=1}^n c_i x_1^{i_1}\cdots x_n^{i_n}\).
In classical arithmetic, we can rewrite the general form of a tropical monomial: \(x_1^{i_1}\cdots x_n^{i_n} \mapsto i_1 x_1 + \cdots + i_n x_n\). 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
>>> from sage.all import * >>> T = TropicalSemiring(QQ, use_min=False) >>> R = PolynomialRing(T, names=('a', 'b',)); (a, b,) = R._first_ngens(2); 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
>>> from sage.all import * >>> p1 = R(Integer(3))*a*b + a + R(-Integer(1))*b; p1 3*a*b + 0*a + (-1)*b >>> p2 = R(Integer(1))*a + R(Integer(1))*b + R(Integer(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
>>> from sage.all import * >>> p1 + p2 3*a*b + 1*a + 1*b >>> p1 * p2 4*a^2*b^2 + 4*a^2*b + 4*a*b^2 + 1*a^2 + 1*a*b + 0*b^2 >>> T(Integer(2)) * p1 5*a*b + 2*a + 1*b >>> p1(T(Integer(1)),T(Integer(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
>>> from sage.all import * >>> T = TropicalSemiring(QQ, use_min=True) >>> R = PolynomialRing(T, names=('a', 'b',)); (a, b,) = R._first_ngens(2) >>> p1 = R(Integer(3))*a*b + a + R(-Integer(1))*b >>> p1.tropical_variety() Tropical curve of 3*a*b + 0*a + (-1)*b >>> p1.tropical_variety().plot() Graphics object consisting of 3 graphics primitives
Tropical polynomial in two variables will induce a function in three dimension that consists of a number of surfaces:
sage: p1.plot3d() Graphics3d Object
>>> from sage.all import * >>> p1.plot3d() Graphics3d Object
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
>>> from sage.all import * >>> T = TropicalSemiring(QQ, use_min=False) >>> R = PolynomialRing(T, names=('a', 'b',)); (a, b,) = R._first_ngens(2) >>> p1 = R(Integer(3))*a*b + a + R(-Integer(1))*b >>> p1.tropical_variety() Tropical curve of 3*a*b + 0*a + (-1)*b >>> p1.tropical_variety().plot() Graphics object consisting of 3 graphics primitives
sage: p1.plot3d() Graphics3d Object
>>> from sage.all import * >>> p1.plot3d() Graphics3d Object
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
>>> from sage.all import * >>> p1.newton_polytope() A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices >>> p1.dual_subdivision() Polyhedral complex with 1 maximal cell
- 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))]
>>> from sage.all import * >>> T = TropicalSemiring(QQ, use_min=False) >>> R = PolynomialRing(T, names=('x', 'y',)); (x, y,) = R._first_ngens(2) >>> p1 = R(Integer(3)) + R(Integer(2))*x + R(Integer(2))*y + R(Integer(3))*x*y + x**Integer(2) + y**Integer(2) >>> pc = p1.dual_subdivision(); pc Polyhedral complex with 4 maximal cells >>> [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))]
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))]
>>> from sage.all import * >>> p2 = R(Integer(3)) + x**Integer(2) + R(-Integer(2))*y + R(Integer(1)/Integer(2))*x**Integer(2)*y + R(Integer(2))*x*y**Integer(3) + R(-Integer(1))*x**Integer(3)*y**Integer(4) >>> pc = p2.dual_subdivision(); pc Polyhedral complex with 5 maximal cells >>> [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))]
A subdivision with many faces, not all of which are triangles:
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))]
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, names=('x', 'y',)); (x, y,) = R._first_ngens(2) >>> p3 = (R(Integer(8)) + R(Integer(4))*x + R(Integer(2))*y + R(Integer(1))*x**Integer(2) + x*y + R(Integer(1))*y**Integer(2) ... + R(Integer(2))*x**Integer(3) + x**Integer(2)*y + x*y**Integer(2) + R(Integer(4))*y**Integer(3) + R(Integer(8))*x**Integer(4) ... + R(Integer(4))*x**Integer(3)*y + x**Integer(2)*y**Integer(2) + R(Integer(2))*x*y**Integer(3) + y**Integer(4)) >>> pc = p3.dual_subdivision(); pc Polyhedral complex with 10 maximal cells >>> [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))]
Dual subdivision of a tropical surface:
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))]
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3) >>> p1 = x + y + z + x**Integer(2) + R(Integer(1)) >>> pc = p1.dual_subdivision(); pc Polyhedral complex with 7 maximal cells >>> [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))]
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))]
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, names=('a', 'b', 'c', 'd',)); (a, b, c, d,) = R._first_ngens(4) >>> p1 = R(Integer(2))*a*b + R(Integer(3))*a*c + R(-Integer(1))*c**Integer(2) + R(-Integer(1)/Integer(3))*a*d >>> pc = p1.dual_subdivision(); pc Polyhedral complex with 4 maximal cells >>> [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)
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, names=('x', 'y',)); (x, y,) = R._first_ngens(2) >>> p1 = x + y >>> p1.newton_polytope() A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices >>> p1.newton_polytope().Vrepresentation() (A vertex at (0, 1), A vertex at (1, 0)) >>> 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)
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)
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3) >>> p1 = x**Integer(2) + x*y*z + x + y + z + R(Integer(0)) >>> p1.newton_polytope() A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 5 vertices >>> 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)) >>> 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)
- 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
>>> from sage.all import * >>> T = TropicalSemiring(QQ, use_min=False) >>> R = PolynomialRing(T, names=('x', 'y',)); (x, y,) = R._first_ngens(2) >>> p1 = x**Integer(2) >>> p1.plot3d() Graphics3d Object
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
>>> from sage.all import * >>> p2 = R(Integer(3)) + R(Integer(2))*x + R(Integer(2))*y + R(Integer(3))*x*y >>> p2.plot3d() Graphics3d Object
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
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, names=('x', 'y',)); (x, y,) = R._first_ngens(2) >>> p3 = R(Integer(2))*x**Integer(2) + x*y + R(Integer(2))*y**Integer(2) + x + R(-Integer(1))*y + R(Integer(3)) >>> p3.plot3d() Graphics3d Object
- 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
>>> from sage.all import * >>> T = TropicalSemiring(QQ, use_min=False) >>> R = PolynomialRing(T, names=('x', 'y',)); (x, y,) = R._first_ngens(2) >>> p1 = x**Integer(2) + y + R(Integer(3)) >>> p1((R(Integer(4)),y)) 0*y + 8 >>> p1.subs({x: Integer(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
>>> from sage.all import * >>> T = TropicalSemiring(QQ, use_min=False) >>> R = PolynomialRing(T, names=('x', 'y',)); (x, y,) = R._first_ngens(2) >>> p1 = x + y + R(Integer(0)); p1 0*x + 0*y + 0 >>> 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
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3) >>> p1 = R(Integer(1))*x*y + R(-Integer(1)/Integer(2))*x*z + R(Integer(4))*z**Integer(2); p1 1*x*y + (-1/2)*x*z + 4*z^2 >>> 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
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, names=('x', 'y',)); (x, y,) = R._first_ngens(2) >>> f = T(Integer(1))*x + T(-Integer(1))*y >>> g = T(Integer(2))*x + T(-Integer(2))*y >>> f + g 1*x + (-2)*y >>> f * g 3*x^2 + (-1)*x*y + (-3)*y^2 >>> f + R.zero() == f True >>> f * R.zero() == R.zero() True >>> f * R.one() == f True
- Element[source]¶
alias of
TropicalMPolynomial
- gen(n=0)[source]¶
Return the
n
-th generator ofself
.EXAMPLES:
sage: T = TropicalSemiring(QQ) sage: R.<a,b,c> = PolynomialRing(T) sage: R.gen() 0*a sage: R.gen(2) 0*c
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, names=('a', 'b', 'c',)); (a, b, c,) = R._first_ngens(3) >>> R.gen() 0*a >>> R.gen(Integer(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)
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, Integer(5), 'x') >>> 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
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, Integer(10), 'z') >>> 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
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, 'x,y') >>> 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
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, names=('a', 'b', 'c',)); (a, b, c,) = R._first_ngens(3) >>> f = R.random_element(Integer(2), Integer(5)) >>> f.degree() <= Integer(2) True >>> f.parent() is R True >>> len(list(f)) <= Integer(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
>>> from sage.all import * >>> f = R.random_element(Integer(3), Integer(6), choose_degree=True) >>> f.degree() <= Integer(3) True >>> f.parent() is R True >>> len(list(f)) <= Integer(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
>>> from sage.all import * >>> T = TropicalSemiring(QQ) >>> R = PolynomialRing(T, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3) >>> R.term_order() Degree reverse lexicographic term order