First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.