@@ -1860,6 +1860,18 @@ def leading_item(self, *args, **kwds):
18601860 sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules
18611861 sage: f.leading_item() # needs sage.combinat sage.modules
18621862 ([3], -5)
1863+
1864+ The term ordering of polynomial rings is taken into account::
1865+
1866+ sage: R.<x,y,z> = QQ[]
1867+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).leading_item()
1868+ ((0, 4, 0), 1)
1869+ sage: R.<x,y,z> = PolynomialRing(QQ, order='lex')
1870+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).leading_item()
1871+ ((1, 2, 0), 3)
1872+ sage: R.<x,y,z> = PolynomialRing(QQ, order='invlex')
1873+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).leading_item()
1874+ ((0, 1, 3), 2)
18631875 """
18641876 k = self .leading_support (* args , ** kwds )
18651877 return k , self [k ]
@@ -1890,6 +1902,18 @@ def leading_monomial(self, *args, **kwds):
18901902 sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules
18911903 sage: f.leading_monomial() # needs sage.combinat sage.modules
18921904 s[3]
1905+
1906+ The term ordering of polynomial rings is taken into account::
1907+
1908+ sage: R.<x,y,z> = QQ[]
1909+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).leading_monomial()
1910+ y^4
1911+ sage: R.<x,y,z> = PolynomialRing(QQ, order='lex')
1912+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).leading_monomial()
1913+ x*y^2
1914+ sage: R.<x,y,z> = PolynomialRing(QQ, order='invlex')
1915+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).leading_monomial()
1916+ y*z^3
18931917 """
18941918 return self .parent ().monomial (self .leading_support (* args , ** kwds ))
18951919
@@ -1919,6 +1943,18 @@ def leading_coefficient(self, *args, **kwds):
19191943 sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules
19201944 sage: f.leading_coefficient() # needs sage.combinat sage.modules
19211945 -5
1946+
1947+ The term ordering of polynomial rings is taken into account::
1948+
1949+ sage: R.<x,y,z> = QQ[]
1950+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).leading_coefficient()
1951+ 1
1952+ sage: R.<x,y,z> = PolynomialRing(QQ, order='lex')
1953+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).leading_coefficient()
1954+ 3
1955+ sage: R.<x,y,z> = PolynomialRing(QQ, order='invlex')
1956+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).leading_coefficient()
1957+ 2
19221958 """
19231959 return self .leading_item (* args , ** kwds )[1 ]
19241960
@@ -1948,6 +1984,18 @@ def leading_term(self, *args, **kwds):
19481984 sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules
19491985 sage: f.leading_term() # needs sage.combinat sage.modules
19501986 -5*s[3]
1987+
1988+ The term ordering of polynomial rings is taken into account::
1989+
1990+ sage: R.<x,y,z> = QQ[]
1991+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).leading_term()
1992+ y^4
1993+ sage: R.<x,y,z> = PolynomialRing(QQ, order='lex')
1994+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).leading_term()
1995+ 3*x*y^2
1996+ sage: R.<x,y,z> = PolynomialRing(QQ, order='invlex')
1997+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).leading_term()
1998+ 2*y*z^3
19511999 """
19522000 return self .parent ().term (* self .leading_item (* args , ** kwds ))
19532001
@@ -2005,6 +2053,18 @@ def trailing_item(self, *args, **kwds):
20052053 sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules
20062054 sage: f.trailing_item() # needs sage.combinat sage.modules
20072055 ([1], 2)
2056+
2057+ The term ordering of polynomial rings is taken into account::
2058+
2059+ sage: R.<x,y,z> = QQ[]
2060+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).trailing_item()
2061+ ((1, 1, 1), 4)
2062+ sage: R.<x,y,z> = PolynomialRing(QQ, order='lex')
2063+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).trailing_item()
2064+ ((0, 1, 3), 2)
2065+ sage: R.<x,y,z> = PolynomialRing(QQ, order='invlex')
2066+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).trailing_item()
2067+ ((1, 2, 0), 3)
20082068 """
20092069 k = self .trailing_support (* args , ** kwds )
20102070 return k , self [k ]
@@ -2035,6 +2095,18 @@ def trailing_monomial(self, *args, **kwds):
20352095 sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules
20362096 sage: f.trailing_monomial() # needs sage.combinat sage.modules
20372097 s[1]
2098+
2099+ The term ordering of polynomial rings is taken into account::
2100+
2101+ sage: R.<x,y,z> = QQ[]
2102+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).trailing_monomial()
2103+ x*y*z
2104+ sage: R.<x,y,z> = PolynomialRing(QQ, order='lex')
2105+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).trailing_monomial()
2106+ y*z^3
2107+ sage: R.<x,y,z> = PolynomialRing(QQ, order='invlex')
2108+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).trailing_monomial()
2109+ x*y^2
20382110 """
20392111 return self .parent ().monomial (self .trailing_support (* args , ** kwds ))
20402112
@@ -2064,6 +2136,18 @@ def trailing_coefficient(self, *args, **kwds):
20642136 sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules
20652137 sage: f.trailing_coefficient() # needs sage.combinat sage.modules
20662138 2
2139+
2140+ The term ordering of polynomial rings is taken into account::
2141+
2142+ sage: R.<x,y,z> = QQ[]
2143+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).trailing_coefficient()
2144+ 4
2145+ sage: R.<x,y,z> = PolynomialRing(QQ, order='lex')
2146+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).trailing_coefficient()
2147+ 2
2148+ sage: R.<x,y,z> = PolynomialRing(QQ, order='invlex')
2149+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).trailing_coefficient()
2150+ 3
20672151 """
20682152 return self .trailing_item (* args , ** kwds )[1 ]
20692153
@@ -2093,6 +2177,18 @@ def trailing_term(self, *args, **kwds):
20932177 sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules
20942178 sage: f.trailing_term() # needs sage.combinat sage.modules
20952179 2*s[1]
2180+
2181+ The term ordering of polynomial rings is taken into account::
2182+
2183+ sage: R.<x,y,z> = QQ[]
2184+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).trailing_term()
2185+ 4*x*y*z
2186+ sage: R.<x,y,z> = PolynomialRing(QQ, order='lex')
2187+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).trailing_term()
2188+ 2*y*z^3
2189+ sage: R.<x,y,z> = PolynomialRing(QQ, order='invlex')
2190+ sage: (3*x*y^2 + 2*y*z^3 + y^4 + 4*x*y*z).trailing_term()
2191+ 3*x*y^2
20962192 """
20972193 return self .parent ().term (* self .trailing_item (* args , ** kwds ))
20982194
0 commit comments