Elements of Laurent polynomial rings

class sage.rings.polynomial.laurent_polynomial.LaurentPolynomial_mpair

Bases: sage.structure.element.CommutativeAlgebraElement

coefficient(mon)

Return the coefficient of mon in self, where mon must have the same parent as self. The coefficient is defined as follows. If f is this polynomial, then the coefficient is the sum T/mon where the sum is over terms T in f that are exactly divisible by mon.

A monomial m(x,y) ‘exactly divides’ f(x,y) if m(x,y)|f(x,y) and neither x*m(x,y) nor y*m(x,y) divides f(x,y).

INPUT:

  • mon – a monomial

OUTPUT:

element of the parent of self

EXAMPLES:

sage: P.<x,y> = LaurentPolynomialRing(QQ)

The coefficient returned is an element of the parent of self; in this case, P.

sage: f = 2 * x * y
sage: c = f.coefficient(x*y); c
2
sage: c.parent()
Multivariate Laurent Polynomial Ring in x, y over Rational Field

sage: P.<x,y> = LaurentPolynomialRing(QQ)
sage: f = (y^2 - x^9 - 7*x*y^2 + 5*x*y)*x^-3; f
-x^6 - 7*x^-2*y^2 + 5*x^-2*y + x^-3*y^2
sage: f.coefficient(y)
5*x^-2
sage: f.coefficient(y^2)
-7*x^-2 + x^-3
sage: f.coefficient(x*y)
0
sage: f.coefficient(x^-2)
-7*y^2 + 5*y
sage: f.coefficient(x^-2*y^2)
-7
sage: f.coefficient(1)       
-x^6 - 7*x^-2*y^2 + 5*x^-2*y + x^-3*y^2
coefficients()

Return the nonzero coefficients of this polynomial in a list. The returned list is decreasingly ordered by the term ordering of self.parent().

EXAMPLES:

sage: L.<x,y,z> = LaurentPolynomialRing(QQ,order='degrevlex')
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7        
sage: f.coefficients()                                 
[4, 3, 2, 1]
sage: L.<x,y,z> = LaurentPolynomialRing(QQ,order='lex')      
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7 
sage: f.coefficients()                                 
[4, 1, 2, 3]
degree(x=None)

Returns the degree of x in self

EXAMPLES:

sage: R.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7 
sage: f.degree(x)
7
sage: f.degree(y)
1
sage: f.degree(z)
0
dict()

EXAMPLES:

sage: L.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7 
sage: list(sorted(f.dict().iteritems()))
[((3, 1, 0), 3), ((4, 0, -2), 2), ((6, -7, 0), 1), ((7, 0, -1), 4)]
exponents()

Returns a list of the exponents of self.

EXAMPLES:

sage: L.<w,z> = LaurentPolynomialRing(QQ)
sage: a = w^2*z^-1+3; a
w^2*z^-1 + 3
sage: e = a.exponents()
sage: e.sort(); e
[(0, 0), (2, -1)]
factor()

Returns a Laurent monomial (the unit part of the factorization) and a factored multi-polynomial.

EXAMPLES:

sage: L.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7 
sage: f.factor()
(x^3*y^-7*z^-2) * (4*x^4*y^7*z + 3*y^8*z^2 + 2*x*y^7 + x^3*z^2)
has_any_inverse()

Returns True if self contains any monomials with a negative exponent, False otherwise.

EXAMPLES:

sage: L.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7 
sage: f.has_any_inverse()
True
sage: g = x^2 + y^2
sage: g.has_any_inverse()
False
has_inverse_of(i)

INPUT:

  • i – The index of a generator of self.parent()

OUTPUT:

Returns True if self contains a monomial including the inverse of self.parent().gen(i), False otherwise.

EXAMPLES:

sage: L.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7 
sage: f.has_inverse_of(0)
False
sage: f.has_inverse_of(1)
True
sage: f.has_inverse_of(2)
True
subs(in_dict, **kwds=None)

Note that this is a very unsophisticated implementation.

EXAMPLES:

sage: L.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = x + 2*y + 3*z
sage: f.subs(x=1)
2*y + 3*z + 1
sage: f.subs(y=1)
x + 3*z + 2
sage: f.subs(z=1)
x + 2*y + 3
sage: f.subs(x=1,y=1,z=1)
6

sage: f = x^-1
sage: f.subs(x=2)
1/2
sage: f.subs({x:2})
1/2

sage: f = x + 2*y + 3*z
sage: f.subs({x:1,y:1,z:1})
6
sage: f.substitute(x=1,y=1,z=1)
6

TESTS:

sage: f = x + 2*y + 3*z
sage: f(q=10)
x + 2*y + 3*z
variables(sort=True)

Return a tuple of all variables occurring in self.

INPUT:

  • sort – specifies whether the indices shall be sorted

EXAMPLES:

sage: L.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7 
sage: f.variables()
(z, y, x)
sage: f.variables(sort=False) #random
(y, z, x)

Previous topic

Ring of Laurent Polynomials

Next topic

Boolean Polynomials

This Page