Skip to content

Commit d2e4be5

Browse files
author
Release Manager
committed
gh-40808: add Newton polytopes in one variable in order to have the same behaviour as in several variables ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #40808 Reported by: Frédéric Chapoton Reviewer(s): Martin Rubey
2 parents f911c0b + 4e5a43f commit d2e4be5

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/sage/rings/polynomial/multi_polynomial.pyx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,9 +1232,7 @@ cdef class MPolynomial(CommutativePolynomial):
12321232
((0, 2), (1, 1), (2, 0))
12331233
"""
12341234
from sage.geometry.polyhedron.constructor import Polyhedron
1235-
e = self.exponents()
1236-
P = Polyhedron(vertices=e, base_ring=ZZ)
1237-
return P
1235+
return Polyhedron(vertices=self.exponents(), base_ring=ZZ)
12381236

12391237
def __iter__(self):
12401238
r"""

src/sage/rings/polynomial/polynomial_element.pyx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,29 @@ cdef class Polynomial(CommutativePolynomial):
11881188
"""
11891189
return self[i]
11901190

1191+
def newton_polytope(self):
1192+
r"""
1193+
Return the Newton polytope of this polynomial.
1194+
1195+
EXAMPLES::
1196+
1197+
sage: R.<x> = QQ[]
1198+
sage: f = 42 + x + x^3
1199+
sage: P = f.newton_polytope(); P # needs sage.geometry.polyhedron
1200+
A 1-dimensional polyhedron in ZZ^1 defined as the convex hull of 2 vertices
1201+
1202+
TESTS::
1203+
1204+
sage: R.<x> = QQ[]
1205+
sage: R(0).newton_polytope() # needs sage.geometry.polyhedron
1206+
The empty polyhedron in ZZ^0
1207+
sage: R(1).newton_polytope() # needs sage.geometry.polyhedron
1208+
A 0-dimensional polyhedron in ZZ^1 defined as the convex hull of 1 vertex
1209+
"""
1210+
from sage.geometry.polyhedron.constructor import Polyhedron
1211+
return Polyhedron(vertices=[(e,) for e in self.exponents()],
1212+
base_ring=ZZ)
1213+
11911214
def __iter__(self):
11921215
"""
11931216
EXAMPLES::

0 commit comments

Comments
 (0)