Skip to content

Commit d546825

Browse files
author
Release Manager
committed
gh-40818: add Newton polytopes for Laurent polynomials as an useful tool to have see also #40808 ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. URL: #40818 Reported by: Frédéric Chapoton Reviewer(s): Martin Rubey
2 parents 3142b99 + 3a649e4 commit d546825

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/sage/rings/polynomial/laurent_polynomial.pyx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,30 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial):
913913
"""
914914
return [i + self.__n for i in self.__u.exponents()]
915915

916+
def newton_polytope(self):
917+
r"""
918+
Return the Newton polytope of this Laurent polynomial.
919+
920+
EXAMPLES::
921+
922+
sage: R.<x> = LaurentPolynomialRing(QQ)
923+
sage: f = 1 + x + 33 * x^-3
924+
sage: P = f.newton_polytope(); P # needs sage.geometry.polyhedron
925+
A 1-dimensional polyhedron in ZZ^1 defined as the convex hull of 2 vertices
926+
927+
TESTS::
928+
929+
sage: R.<x> = LaurentPolynomialRing(QQ)
930+
sage: R(0).newton_polytope() # needs sage.geometry.polyhedron
931+
The empty polyhedron in ZZ^0
932+
sage: R(1).newton_polytope() # needs sage.geometry.polyhedron
933+
A 0-dimensional polyhedron in ZZ^1 defined as the convex hull of 1 vertex
934+
"""
935+
from sage.geometry.polyhedron.constructor import Polyhedron
936+
from sage.rings.integer_ring import ZZ
937+
return Polyhedron(vertices=[(e,) for e in self.exponents()],
938+
base_ring=ZZ)
939+
916940
def __setitem__(self, n, value):
917941
"""
918942
EXAMPLES::

src/sage/rings/polynomial/laurent_polynomial_mpair.pyx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,29 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial):
13251325
# Find the minimal valuation of x by checking each term
13261326
return Integer(min(e[i] for e in self.exponents()))
13271327

1328+
def newton_polytope(self):
1329+
r"""
1330+
Return the Newton polytope of this Laurent polynomial.
1331+
1332+
EXAMPLES::
1333+
1334+
sage: R.<x, y> = LaurentPolynomialRing(QQ)
1335+
sage: f = 1 + x*y + y**2 + 33 * x^-3
1336+
sage: P = f.newton_polytope(); P # needs sage.geometry.polyhedron
1337+
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 4 vertices
1338+
1339+
TESTS::
1340+
1341+
sage: R.<x,y> = LaurentPolynomialRing(QQ)
1342+
sage: R(0).newton_polytope() # needs sage.geometry.polyhedron
1343+
The empty polyhedron in ZZ^0
1344+
sage: R(1).newton_polytope() # needs sage.geometry.polyhedron
1345+
A 0-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex
1346+
"""
1347+
from sage.geometry.polyhedron.constructor import Polyhedron
1348+
from sage.rings.integer_ring import ZZ
1349+
return Polyhedron(vertices=self.exponents(), base_ring=ZZ)
1350+
13281351
def has_inverse_of(self, i):
13291352
"""
13301353
INPUT:

0 commit comments

Comments
 (0)