Ask Your Question
0

Best way to extract weighted homogenous parts of a polynomial lying on its Newton polytope

asked 2024-12-12 23:40:35 +0100

sarubia gravatar image

Given a polynomial in two variables $f(x,y)$, I would like to extract a list of the weighted homogeneous polynomials which lay on the Newton polytope of $f$ in SageMath.

For example, given as input a polynomial f(x,y)=x^3*y+2*x^2y^2+x*y^3+y^7+x^5, I would like to get as output the following list: (y^7+x*y^3,x^3*y+2*x^2*y^2+x*y^3,x^3*y+x^5). The function f.newton_polytope() returns a Newton polytope geometric object, but gives no way to extract the polynomials directly. I suppose that one could work with the vertices of the polytope, to compute the normals to the facets of the polytope which define the weights of each facet, and then compute homogeneous parts with respect to the monomial orders defined by each weights, but I'm not sure how to change orders "dynamically" (i.e. without changing the ring each time, ideally). Thank you!

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2024-12-13 09:17:32 +0100

FrédéricC gravatar image

Like this, maybe:

sage: x, y = polygens(QQ, 'x,y')
sage: R = x.parent()
sage: f = x^3*y+2*x^2*y^2+x*y^3+y^7+x^5
sage: P = f.newton_polytope()
sage: [R({exp:cf for exp,cf in f.dict().items() if exp in facet}) for facet in P.facets()]
[x^5 + x^3*y, y^7 + x^5, y^7 + x*y^3, x^3*y + 2*x^2*y^2 + x*y^3]
edit flag offensive delete link more

Comments

Wonderful! I should have looked closer into the polyedral geometry documentation. Thank you very much for this neat solution.

sarubia gravatar imagesarubia ( 2024-12-13 10:19:38 +0100 )edit
1

answered 2024-12-13 01:38:07 +0100

sarubia gravatar image

I ended up doing the following:

from sage.geometry.newton_polygon import NewtonPolygon
R.<x,y> = PolynomialRing(QQbar,2,order='invlex')

def facets(f):
        NP = NewtonPolygon(f.newton_polytope())
        slopes = NP.slopes(repetition=False)
        weights = [(numerator(abs(slope)),denominator(abs(slope))) for slope in slopes]
        facets = []
        for w in weights:
            S.<x,y> = PolynomialRing(QQbar,'x,y',order=TermOrder('wdeglex',w))
            f = S(f)
            jw = f.homogeneous_components()
            j = jw[sorted(jw)[0]]
            facets.append(j)
        return facets,weights

f = x*y*(x+y)^2 + y^7 + x^5 

facets,_ = facets(f)

print(facets)

which prints:

[x*y^3 + y^7, x^3*y + 2*x^2*y^2 + x*y^3, x^5 + x^3*y]

Though I am not sure if this is best practice.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2024-12-12 22:38:57 +0100

Seen: 68 times

Last updated: Dec 13 '24